@pasko70/pibo 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/apps/chat-ui/assets/{dist-CrBzZkUp.js → dist-7YaJd19a.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DfcIkFSN.js → dist-8Noo5eCN.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-B4lw9z4F.js → dist-BIvPnn_C.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DGLWQLX8.js → dist-BbNE72h8.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CGINd7XU.js → dist-CVQU42Fn.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CyyISotB.js → dist-ChSZNqKE.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-y9D6la48.js → dist-CiYeO8nN.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DFbnFNpX.js → dist-CjSI6y5z.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BcT_c1EJ.js → dist-D7TCkoFT.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-sKDHTwaT.js → dist-KXCMNKIL.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BbTaHWON.js → dist-Ubstha8t.js} +1 -1
- package/dist/apps/chat-ui/assets/{index-CUkuvI3v.js → index-CmxtUVG1.js} +3 -3
- package/dist/apps/chat-ui/index.html +1 -1
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-1.3.0.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-1.3.1.vsix +0 -0
- package/dist/cli.js +15 -1
- package/dist/config/config.js +9 -0
- package/dist/core/context-build.js +36 -2
- package/dist/core/wsl.js +100 -0
- package/dist/gateway/web.js +51 -11
- package/dist/plugins/dev-auth.js +26 -0
- package/dist/setup/cli.js +60 -8
- package/dist/web/channel.js +47 -1
- package/dist/web/http.js +6 -3
- package/docs/ops/install-user-host.md +21 -1
- package/docs/ops/vscode-extension-release.md +24 -2
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-ChSZNqKE.js","assets/dist-SVPsM5Oi.js","assets/dist-tGfufz3b.js","assets/dist-C5YJOwhH.js","assets/dist-CKM5j-iy.js","assets/rolldown-runtime-S-ySWqyJ.js","assets/dist-BIvPnn_C.js","assets/dist-7YaJd19a.js","assets/dist-CjSI6y5z.js","assets/dist--55mTWk3.js","assets/dist-KXCMNKIL.js","assets/dist-BZ39rB1W.js","assets/dist-C5oXtFSP.js","assets/dist-CiYeO8nN.js","assets/dist-CVQU42Fn.js","assets/dist-D7TCkoFT.js","assets/dist-8Noo5eCN.js","assets/dist-CUp9us2q.js","assets/dist-DSKQpPaz.js","assets/dist-CZ9T4Cly.js","assets/dist-Zqt9kNG9.js","assets/dist-BsedZGJo.js","assets/dockerfile-CUaqzcqp.js","assets/simple-mode-CL04yRVp.js","assets/factor-C2tAxNob.js","assets/nsis-SMDwKltR.js","assets/pug-Bo3wfL-f.js","assets/javascript-DSlzRUd8.js","assets/dist-BbNE72h8.js","assets/dist-Ubstha8t.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{$ as r,A as i,At as a,Ct as o,Dt as s,E as c,Et as l,G as u,J as d,K as f,L as p,Mt as m,Nt as h,O as g,Ot as _,P as v,Pt as y,Q as b,S as x,St as S,T as C,Tt as w,W as T,X as E,Y as D,Z as O,_t as k,a as A,at as j,bt as M,c as N,ct as P,dt as F,et as ee,f as te,ft as I,g as ne,gt as L,ht as re,it as ie,j as ae,jt as oe,kt as se,l as ce,lt as le,mt as ue,n as de,nt as fe,o as pe,ot as me,pt as he,q as ge,rt as _e,st as ve,t as ye,tt as be,ut as xe,v as Se,vt as Ce,w as we,wt as Te,x as Ee,xt as De,yt as Oe}from"./dist-SVPsM5Oi.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ke=n((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var ee=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},te={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=te,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ee)}catch(e){ee(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.5`})),Ae=n(((e,t)=>{t.exports=ke()})),je=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}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(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Me=n(((e,t)=>{t.exports=je()})),Ne=n((e=>{var t=Ae();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.5`})),Pe=n(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ne()})),Fe=n((e=>{var t=Me(),n=Ae(),r=Pe();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},ee=[],te=-1;function I(e){return{current:e}}function ne(e){0>te||(e.current=ee[te],ee[te]=null,te--)}function L(e,t){te++,ee[te]=e.current,e.current=t}var re=I(null),ie=I(null),ae=I(null),oe=I(null);function se(e,t){switch(L(ae,t),L(ie,e),L(re,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Qd(t),e=$d(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ne(re),L(re,e)}function ce(){ne(re),ne(ie),ne(ae)}function le(e){e.memoizedState!==null&&L(oe,e);var t=re.current,n=$d(t,e.type);t!==n&&(L(ie,e),L(re,n))}function ue(e){ie.current===e&&(ne(re),ne(ie)),oe.current===e&&(ne(oe),lp._currentValue=F)}var de,fe;function pe(e){if(de===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);de=t&&t[1]||``,fe=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+de+e+fe}var me=!1;function he(e,t){if(!e||me)return``;me=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -124,7 +124,7 @@ Error generating stack: `+e.message+`
|
|
|
124
124
|
`},sO=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},sle=function(){R.useEffect(function(){return document.body.setAttribute(oO,(sO()+1).toString()),function(){var e=sO()-1;e<=0?document.body.removeAttribute(oO):document.body.setAttribute(oO,e.toString())}},[])},cle=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;sle();var a=R.useMemo(function(){return ile(i)},[i]);return R.createElement(ale,{styles:ole(a,!t,i,n?``:`!important`)})},cO=!1;if(typeof window<`u`)try{var lO=Object.defineProperty({},`passive`,{get:function(){return cO=!0,!0}});window.addEventListener(`test`,lO,lO),window.removeEventListener(`test`,lO,lO)}catch{cO=!1}var uO=cO?{passive:!1}:!1,lle=function(e){return e.tagName===`TEXTAREA`},dO=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!lle(e)&&n[t]===`visible`)},ule=function(e){return dO(e,`overflowY`)},dle=function(e){return dO(e,`overflowX`)},fO=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),pO(e,r)){var i=mO(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fle=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},ple=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},pO=function(e,t){return e===`v`?ule(t):dle(t)},mO=function(e,t){return e===`v`?fle(t):ple(t)},mle=function(e,t){return e===`h`&&t===`rtl`?-1:1},hle=function(e,t,n,r,i){var a=mle(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=mO(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&pO(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},hO=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},gO=function(e){return[e.deltaX,e.deltaY]},_O=function(e){return e&&`current`in e?e.current:e},gle=function(e,t){return e[0]===t[0]&&e[1]===t[1]},_le=function(e){return`
|
|
125
125
|
.block-interactivity-${e} {pointer-events: none;}
|
|
126
126
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
127
|
-
`},vle=0,vO=[];function yle(e){var t=R.useRef([]),n=R.useRef([0,0]),r=R.useRef(),i=R.useState(vle++)[0],a=R.useState(iO)[0],o=R.useRef(e);R.useEffect(function(){o.current=e},[e]),R.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Bce([e.lockRef.current],(e.shards||[]).map(_O),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=R.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=hO(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=fO(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=fO(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return hle(h,t,e,h===`h`?s:c,!0)},[]),c=R.useCallback(function(e){var n=e;if(!(!vO.length||vO[vO.length-1]!==a)){var r=`deltaY`in n?gO(n):hO(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&gle(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(_O).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=R.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ble(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=R.useCallback(function(e){n.current=hO(e),r.current=void 0},[]),d=R.useCallback(function(t){l(t.type,gO(t),t.target,s(t,e.lockRef.current))},[]),f=R.useCallback(function(t){l(t.type,hO(t),t.target,s(t,e.lockRef.current))},[]);R.useEffect(function(){return vO.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,uO),document.addEventListener(`touchmove`,c,uO),document.addEventListener(`touchstart`,u,uO),function(){vO=vO.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,uO),document.removeEventListener(`touchmove`,c,uO),document.removeEventListener(`touchstart`,u,uO)}},[]);var p=e.removeScrollBar,m=e.inert;return R.createElement(R.Fragment,null,m?R.createElement(a,{styles:_le(i)}):null,p?R.createElement(cle,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ble(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var xle=Yce(eO,yle),yO=R.forwardRef(function(e,t){return R.createElement(nO,qD({},e,{ref:t,sideCar:xle}))});yO.classNames=nO.classNames;var bO=`Popover`,[xO,Sle]=zT(bO,[CD]),SO=CD(),[Cle,CO]=xO(bO),wO=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=SO(t),c=R.useRef(null),[l,u]=R.useState(!1),[d,f]=BD({prop:r,defaultProp:i??!1,onChange:a,caller:bO});return(0,z.jsx)(ND,{...s,children:(0,z.jsx)(Cle,{scope:t,contentId:lE(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:R.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:R.useCallback(()=>u(!0),[]),onCustomAnchorRemove:R.useCallback(()=>u(!1),[]),modal:o,children:n})})};wO.displayName=bO;var TO=`PopoverAnchor`,EO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(TO,n),a=SO(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return R.useEffect(()=>(o(),()=>s()),[o,s]),(0,z.jsx)(PD,{...a,...r,ref:t})});EO.displayName=TO;var DO=`PopoverTrigger`,OO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(DO,n),a=SO(n),o=RT(t,i.triggerRef),s=(0,z.jsx)(HT.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":IO(i.open),...r,ref:o,onClick:FT(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,z.jsx)(PD,{asChild:!0,...a,children:s})});OO.displayName=DO;var kO=`PopoverPortal`,[wle,Tle]=xO(kO,{forceMount:void 0}),AO=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=CO(kO,t);return(0,z.jsx)(wle,{scope:t,forceMount:n,children:(0,z.jsx)(RD,{present:n||a.open,children:(0,z.jsx)(LD,{asChild:!0,container:i,children:r})})})};AO.displayName=kO;var jO=`PopoverContent`,MO=R.forwardRef((e,t)=>{let n=Tle(jO,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=CO(jO,e.__scopePopover);return(0,z.jsx)(RD,{present:r||a.open,children:a.modal?(0,z.jsx)(Dle,{...i,ref:t}):(0,z.jsx)(Ole,{...i,ref:t})})});MO.displayName=jO;var Ele=BT(`PopoverContent.RemoveScroll`),Dle=R.forwardRef((e,t)=>{let n=CO(jO,e.__scopePopover),r=R.useRef(null),i=RT(t,r),a=R.useRef(!1);return R.useEffect(()=>{let e=r.current;if(e)return KD(e)},[]),(0,z.jsx)(yO,{as:Ele,allowPinchZoom:!0,children:(0,z.jsx)(NO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:FT(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:FT(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:FT(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ole=R.forwardRef((e,t)=>{let n=CO(jO,e.__scopePopover),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(NO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),NO=R.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=CO(jO,n),p=SO(n);return ZT(),(0,z.jsx)(nE,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(qT,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,z.jsx)(FD,{"data-state":IO(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),PO=`PopoverClose`,kle=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(PO,n);return(0,z.jsx)(HT.button,{type:`button`,...r,ref:t,onClick:FT(e.onClick,()=>i.onOpenChange(!1))})});kle.displayName=PO;var Ale=`PopoverArrow`,FO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=SO(n);return(0,z.jsx)(ID,{...i,...r,ref:t})});FO.displayName=Ale;function IO(e){return e?`open`:`closed`}var LO=wO,jle=EO,RO=AO,Mle=MO,zO=FO;function BO(e){let t=e+`CollectionProvider`,[n,r]=zT(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=R.useRef(null),a=R.useRef(new Map).current;return(0,z.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=BT(s),l=R.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,z.jsx)(c,{ref:RT(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=BT(u),p=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),s=RT(t,o),c=a(u,n);return R.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return R.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Nle=R.createContext(void 0);function VO(e){let t=R.useContext(Nle);return e||t||`ltr`}var HO=`rovingFocusGroup.onEntryFocus`,Ple={bubbles:!1,cancelable:!0},UO=`RovingFocusGroup`,[WO,GO,Fle]=BO(UO),[Ile,KO]=zT(UO,[Fle]),[Lle,Rle]=Ile(UO),qO=R.forwardRef((e,t)=>(0,z.jsx)(WO.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(WO.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(zle,{...e,ref:t})})}));qO.displayName=UO;var zle=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=R.useRef(null),p=RT(t,f),m=VO(a),[h,g]=BD({prop:o,defaultProp:s??null,onChange:c,caller:UO}),[_,v]=R.useState(!1),y=UT(l),b=GO(n),x=R.useRef(!1),[S,C]=R.useState(0);return R.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(HO,y),()=>e.removeEventListener(HO,y)},[y]),(0,z.jsx)(Lle,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:R.useCallback(e=>g(e),[g]),onItemShiftTab:R.useCallback(()=>v(!0),[]),onFocusableItemAdd:R.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:R.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(HT.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:FT(e.onMouseDown,()=>{x.current=!0}),onFocus:FT(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(HO,Ple);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);QO([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:FT(e.onBlur,()=>v(!1))})})}),JO=`RovingFocusGroupItem`,YO=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=lE(),l=a||c,u=Rle(JO,n),d=u.currentTabStopId===l,f=GO(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return R.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,z.jsx)(WO.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,z.jsx)(HT.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:FT(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:FT(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:FT(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ZO(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?$O(n,r+1):n.slice(r+1)}setTimeout(()=>QO(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});YO.displayName=JO;var Ble={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function XO(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ZO(e,t,n){let r=XO(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Ble[r]}function QO(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $O(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ek=qO,tk=YO,nk=`Separator`,rk=`horizontal`,ik=[`horizontal`,`vertical`],ak=R.forwardRef((e,t)=>{let{decorative:n,orientation:r=rk,...i}=e,a=ok(r)?r:rk,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,z.jsx)(HT.div,{"data-orientation":a,...o,...i,ref:t})});ak.displayName=nk;function ok(e){return ik.includes(e)}var sk=ak,ck=`Toggle`,lk=R.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=BD({prop:n,onChange:i,defaultProp:r??!1,caller:ck});return(0,z.jsx)(HT.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:FT(e.onClick,()=>{e.disabled||s(!o)})})});lk.displayName=ck;var uk=`ToggleGroup`,[dk,fk]=zT(uk,[KO]),pk=KO(),mk=R.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,z.jsx)(_k,{...r,ref:t});if(n===`multiple`)return(0,z.jsx)(vk,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${uk}\``)});mk.displayName=uk;var[hk,gk]=dk(uk),_k=R.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=BD({prop:n,defaultProp:r??``,onChange:i,caller:uk});return(0,z.jsx)(hk,{scope:e.__scopeToggleGroup,type:`single`,value:R.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:R.useCallback(()=>s(``),[s]),children:(0,z.jsx)(xk,{...a,ref:t})})}),vk=R.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=BD({prop:n,defaultProp:r??[],onChange:i,caller:uk}),c=R.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=R.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,z.jsx)(hk,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,z.jsx)(xk,{...a,ref:t})})});mk.displayName=uk;var[yk,bk]=dk(uk),xk=R.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=pk(n),u=VO(o),d={role:`group`,dir:u,...c};return(0,z.jsx)(yk,{scope:n,rovingFocus:i,disabled:r,children:i?(0,z.jsx)(ek,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,z.jsx)(HT.div,{...d,ref:t})}):(0,z.jsx)(HT.div,{...d,ref:t})})}),Sk=`ToggleGroupItem`,Ck=R.forwardRef((e,t)=>{let n=gk(Sk,e.__scopeToggleGroup),r=bk(Sk,e.__scopeToggleGroup),i=pk(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=R.useRef(null);return r.rovingFocus?(0,z.jsx)(tk,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,z.jsx)(wk,{...s,ref:t})}):(0,z.jsx)(wk,{...s,ref:t})});Ck.displayName=Sk;var wk=R.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=gk(Sk,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,z.jsx)(lk,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),Tk=mk,Ek=Ck,Dk=`Toolbar`,[Ok,Vle]=zT(Dk,[KO,fk]),kk=KO(),Ak=fk(),[jk,Mk]=Ok(Dk),Nk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,orientation:r=`horizontal`,dir:i,loop:a=!0,...o}=e,s=kk(n),c=VO(i);return(0,z.jsx)(jk,{scope:n,orientation:r,dir:c,children:(0,z.jsx)(ek,{asChild:!0,...s,orientation:r,dir:c,loop:a,children:(0,z.jsx)(HT.div,{role:`toolbar`,"aria-orientation":r,dir:c,...o,ref:t})})})});Nk.displayName=Dk;var Pk=`ToolbarSeparator`,Fk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Mk(Pk,n);return(0,z.jsx)(sk,{orientation:i.orientation===`horizontal`?`vertical`:`horizontal`,...r,ref:t})});Fk.displayName=Pk;var Ik=`ToolbarButton`,Lk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=kk(n);return(0,z.jsx)(tk,{asChild:!0,...i,focusable:!e.disabled,children:(0,z.jsx)(HT.button,{type:`button`,...r,ref:t})})});Lk.displayName=Ik;var Rk=`ToolbarLink`,zk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=kk(n);return(0,z.jsx)(tk,{asChild:!0,...i,focusable:!0,children:(0,z.jsx)(HT.a,{...r,ref:t,onKeyDown:FT(e.onKeyDown,e=>{e.key===` `&&e.currentTarget.click()})})})});zk.displayName=Rk;var Bk=`ToolbarToggleGroup`,Vk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Mk(Bk,n),a=Ak(n);return(0,z.jsx)(Tk,{"data-orientation":i.orientation,dir:i.dir,...a,...r,ref:t,rovingFocus:!1})});Vk.displayName=Bk;var Hk=`ToolbarToggleItem`,Uk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Ak(n);return(0,z.jsx)(Lk,{asChild:!0,__scopeToolbar:e.__scopeToolbar,children:(0,z.jsx)(Ek,{...i,...r,ref:t})})});Uk.displayName=Hk;var Wk=Nk,Gk=Fk,Kk=Lk,qk=Vk,Jk=Uk;function Yk(e,t){return e===null||e===t?!1:e.dataset.editorDialog!==void 0||e.dataset.toolbarItem!==void 0||e.dataset.editorDropdown?!0:Yk(e.parentElement,t)}function Xk(){let e=[...Array(256).keys()].map(e=>e.toString(16).padStart(2,`0`)),t=crypto.getRandomValues(new Uint8Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,[...t.entries()].map(([t,n])=>[4,6,8,10].includes(t)?`-${e[n]}`:e[n]).join(``)}var Zk=e=>e===0?`th`:`td`,Qk={center:mw.centeredCell,left:mw.leftAlignedCell,right:mw.rightAlignedCell},$k=({mdastNode:e,parentEditor:t,lexicalTable:n})=>{let[r,i]=R.useState(null),[a,o]=Hl(NC,WS),s=R.useMemo(()=>e=>(e.__cacheKey??=Xk(),e.__cacheKey),[]),c=R.useCallback(e=>{let r=n.getColCount();if(e===null){i(null);return}let[a,o]=e;if(a>r-1&&(a=0,o++),a<0&&(a=r-1,--o),o>n.getRowCount()-1){i(null),t.update(()=>{if(n.getLatest().getNextSibling())n.getLatest().selectNext();else{let e=nh();n.insertAfter(e),e.select()}});return}if(o<0){i(null),t.update(()=>{n.getLatest().selectPrevious()});return}i([a,o])},[n,t]);R.useEffect(()=>{n.focusEmitter.subscribe(c)},[n,c]);let l=R.useCallback(e=>{e.preventDefault(),t.update(()=>{n.addRowToBottom(),i([0,n.getRowCount()])})},[t,n]),u=R.useCallback(e=>{e.preventDefault(),t.update(()=>{n.addColumnToRight(),i([n.getColCount(),0])})},[t,n]),[d,f]=R.useState([-1,-1]),p=R.useCallback(e=>{let t=e.target;for(;t&&![`TH`,`TD`].includes(t.tagName);){if(t===e.currentTarget)return;t=t.parentElement}if(t===null)return;let n=t.parentElement;f([n.parentElement.tagName===`TFOOT`?-1:Array.from(n.children).indexOf(t),t.tagName===`TH`?-1:Array.from(n.parentElement.children).indexOf(n)])},[]),m=rw();return R.createElement(`table`,{className:mw.tableEditor,onMouseOver:p,onMouseLeave:()=>{f([-1,-1])}},R.createElement(`colgroup`,null,o?null:R.createElement(`col`,null),Array.from({length:e.children[0].children.length},(t,n)=>{let r=Qk[(e.align??[])[n]??`left`];return R.createElement(`col`,{key:n,className:r})}),o?null:R.createElement(`col`,null)),o||R.createElement(`thead`,null,R.createElement(`tr`,null,R.createElement(`th`,{className:mw.tableToolsColumn}),Array.from({length:e.children[0].children.length},(r,i)=>R.createElement(`th`,{key:i,"data-tool-cell":!0},R.createElement(nA,{setActiveCellWithBoundaries:c,parentEditor:t,colIndex:i,highlightedCoordinates:d,lexicalTable:n,align:(e.align??[])[i]}))),R.createElement(`th`,{className:mw.tableToolsColumn,"data-tool-cell":!0},R.createElement(`button`,{className:mw.iconButton,type:`button`,title:m(`table.deleteTable`,`Delete table`),onClick:e=>{e.preventDefault(),t.update(()=>{n.selectNext(),n.remove()})}},a(`delete_small`))))),R.createElement(`tbody`,null,e.children.map((i,l)=>{let f=Zk(l);return R.createElement(`tr`,{key:l},o||R.createElement(f,{className:mw.toolCell,"data-tool-cell":!0},R.createElement(rA,{setActiveCellWithBoundaries:c,parentEditor:t,rowIndex:l,highlightedCoordinates:d,lexicalTable:n})),i.children.map((i,a)=>R.createElement(eA,{align:e.align?.[a],key:s(i),contents:i.children,setActiveCell:c,rowIndex:l,colIndex:a,lexicalTable:n,parentEditor:t,activeCell:o?[-1,-1]:r})),o||l===0&&R.createElement(`th`,{rowSpan:n.getRowCount(),"data-tool-cell":!0},R.createElement(`button`,{type:`button`,className:mw.addColumnButton,onClick:u},a(`add_column`))))})),o||R.createElement(`tfoot`,null,R.createElement(`tr`,null,R.createElement(`th`,null),R.createElement(`th`,{colSpan:n.getColCount(),"data-tool-cell":!0},R.createElement(`button`,{type:`button`,className:mw.addRowButton,onClick:l},a(`add_row`))),R.createElement(`th`,null))))},eA=({align:e,...t})=>{let{activeCell:n,setActiveCell:r}=t,i=!!(n&&n[0]===t.colIndex&&n[1]===t.rowIndex),a=Qk[e??`left`],o=Zk(t.rowIndex);return R.createElement(o,{className:a,"data-active":i,onClick:()=>{r([t.colIndex,t.rowIndex])}},R.createElement(tA,{...t,focus:i}))},tA=({focus:e,setActiveCell:t,parentEditor:n,lexicalTable:r,contents:i,colIndex:a,rowIndex:o})=>{let[s,c,l,u,d,f,p,m,h]=Hl(iC,cC,aC,fC,pC,mC,dC,BS,GC),[g]=R.useState(()=>{let e=ah({nodes:l,theme:RS,namespace:`TableCellEditor`});return e.update(()=>{bS({root:Ih(),mdastRoot:{type:`root`,children:[{type:`paragraph`,children:i}]},visitors:s,jsxComponentDescriptors:u,directiveDescriptors:d,codeBlockEditorDescriptors:f})}),e}),_=R.useCallback(e=>{g.getEditorState().read(()=>{let e=jx({root:Ih(),jsxComponentDescriptors:u,visitors:c,jsxIsAvailable:p});n.update(()=>{r.updateCellContents(a,o,e.children[0].children)},{discrete:!0}),n.dispatchCommand(zS,void 0)}),t(e)},[a,g,c,u,p,r,n,o,t]);return R.useEffect(()=>U_(g.registerCommand(vf,e=>(e.preventDefault(),_(e.shiftKey?[a-1,o]:[a+1,o]),!0),4),g.registerCommand(Pf,()=>(t([a,o]),!1),1),g.registerCommand(pf,e=>(e?.preventDefault(),_(e?.shiftKey?[a,o-1]:[a,o+1]),!0),4),g.registerCommand(Ff,e=>{let t=e.relatedTarget;return Yk(t,m.getRootElement())?!1:(_(null),!0)},0),g.registerCommand(zS,()=>(_(null),!0),0)),[a,g,m,o,_,t]),R.useEffect(()=>{e&&g.focus()},[e,g]),R.createElement(Joe,{initialEditor:g},R.createElement(pw,{contentEditable:R.createElement(sw,null),placeholder:R.createElement(`div`,null),ErrorBoundary:uw}),h.map((e,t)=>R.createElement(e,{key:t})),R.createElement(cv,null))},nA=({parentEditor:e,highlightedCoordinates:t,align:n,lexicalTable:r,colIndex:i,setActiveCellWithBoundaries:a})=>{let[o,s]=Hl(hC,NC),c=R.useCallback(t=>{e.update(()=>{r.insertColumnAt(t)}),a([t,0])},[e,r,a]),l=R.useCallback(t=>{e.update(()=>{r.deleteColumnAt(t)})},[e,r]),u=R.useCallback((t,n)=>{e.update(()=>{r.setColumnAlign(t,n)})},[e,r]),d=rw();return R.createElement(LO,null,R.createElement(OO,{className:mw.tableColumnEditorTrigger,"data-active":t[0]===i+1,title:d(`table.columnMenu`,`Column menu`)},s(`more_horiz`)),R.createElement(RO,{container:o?.current},R.createElement(MO,{className:(0,rT.default)(mw.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>{e.preventDefault()},sideOffset:5,side:`top`},R.createElement(Wk,{className:mw.tableColumnEditorToolbar},R.createElement(qk,{className:mw.toggleGroupRoot,onValueChange:e=>{u(i,e)},value:n??`left`,type:`single`,"aria-label":d(`table.textAlignment`,`Text alignment`)},R.createElement(Jk,{value:`left`,title:d(`table.alignLeft`,`Align left`)},s(`format_align_left`)),R.createElement(Jk,{value:`center`,title:d(`table.alignCenter`,`Align center`)},s(`format_align_center`)),R.createElement(Jk,{value:`right`,title:d(`table.alignRight`,`Align right`)},s(`format_align_right`))),R.createElement(Gk,null),R.createElement(Kk,{onClick:c.bind(null,i),title:d(`table.insertColumnLeft`,`Insert a column to the left of this one`)},s(`insert_col_left`)),R.createElement(Kk,{onClick:c.bind(null,i+1),title:d(`table.insertColumnRight`,`Insert a column to the right of this one`)},s(`insert_col_right`)),R.createElement(Kk,{onClick:l.bind(null,i),title:d(`table.deleteColumn`,`Delete this column`)},s(`delete_small`))),R.createElement(zO,{className:mw.popoverArrow}))))},rA=({parentEditor:e,highlightedCoordinates:t,lexicalTable:n,rowIndex:r,setActiveCellWithBoundaries:i})=>{let[a,o]=Hl(hC,NC),s=R.useCallback(t=>{e.update(()=>{n.insertRowAt(t)}),i([0,t])},[e,n,i]),c=R.useCallback(t=>{e.update(()=>{n.deleteRowAt(t)})},[e,n]),l=rw();return R.createElement(LO,null,R.createElement(OO,{className:mw.tableColumnEditorTrigger,"data-active":t[1]===r,title:l(`table.rowMenu`,`Row menu`)},o(`more_horiz`)),R.createElement(RO,{container:a?.current},R.createElement(MO,{className:(0,rT.default)(mw.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>{e.preventDefault()},sideOffset:5,side:`bottom`},R.createElement(Wk,{className:mw.tableColumnEditorToolbar},R.createElement(Kk,{onClick:s.bind(null,r),title:l(`table.insertRowAbove`,`Insert a row above this one`)},o(`insert_row_above`)),R.createElement(Kk,{onClick:s.bind(null,r+1),title:l(`table.insertRowBelow`,`Insert a row below this one`)},o(`insert_row_below`)),R.createElement(Kk,{onClick:c.bind(null,r),title:l(`table.deleteRow`,`Delete this row`)},o(`delete_small`))),R.createElement(zO,{className:mw.popoverArrow}))))},iA=Object.defineProperty,aA=(e,t,n)=>t in e?iA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oA=(e,t,n)=>(aA(e,typeof t==`symbol`?t:t+``,n),n),sA={type:`tableCell`,children:[]};function cA(){let e=Yl;return{publish:t=>{e(t)},subscribe:t=>{e=t}}}var lA=class e extends Wm{constructor(e,t){super(t),oA(this,`__mdastNode`),oA(this,`focusEmitter`,cA()),this.__mdastNode=e??{type:`table`,children:[]}}static getType(){return`table`}static clone(t){return new e(structuredClone(t.__mdastNode),t.__key)}static importJSON(e){return dA(e.mdastNode)}static importDOM(){return{table:()=>({conversion:fA,priority:3})}}exportJSON(){return{mdastNode:structuredClone(this.__mdastNode),type:`table`,version:1}}getMdastNode(){return this.__mdastNode}getRowCount(){return this.__mdastNode.children.length}getColCount(){return this.__mdastNode.children[0]?.children.length||0}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}updateCellContents(e,t,n){let r=this.getWritable().__mdastNode,i=r.children[t],a=i.children,o=a[e],s=Array.from(a),c={...o,children:n},l={...i,children:s};s[e]=c,r.children[t]=l}insertColumnAt(e){let t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){let r=t.children[n],i=r.children,a=Array.from(i),o={...r,children:a};a.splice(e,0,structuredClone(sA)),t.children[n]=o}t.align&&t.align.length>0&&t.align.splice(e,0,`left`)}deleteColumnAt(e){let t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){let r=t.children[n],i=r.children,a=Array.from(i),o={...r,children:a};a.splice(e,1),t.children[n]=o}}insertRowAt(e){let t=this.getWritable().__mdastNode,n={type:`tableRow`,children:Array.from({length:this.getColCount()},()=>structuredClone(sA))};t.children.splice(e,0,n)}deleteRowAt(e){this.getRowCount()===1?(this.selectNext(),this.remove()):this.getWritable().__mdastNode.children.splice(e,1)}addRowToBottom(){this.insertRowAt(this.getRowCount())}addColumnToRight(){this.insertColumnAt(this.getColCount())}setColumnAlign(e,t){let n=this.getWritable().__mdastNode;n.align??=[],n.align[e]=t}decorate(e){return R.createElement($k,{lexicalTable:this,mdastNode:this.__mdastNode,parentEditor:e})}select(e){this.focusEmitter.publish(e??[0,0])}isInline(){return!1}};function uA(e){return e instanceof lA}function dA(e){return new lA(e)}function fA(e){let t=e.querySelectorAll(`tr`);return{node:new lA({type:`table`,children:Array.from(t).map(e=>({type:`tableRow`,children:Array.from(e.querySelectorAll(`td, th`)).map(e=>({type:`tableCell`,children:[{type:`text`,value:e.textContent}]}))}))})}}var pA={testLexicalNode:uA,visitLexicalNode({actions:e,mdastParent:t,lexicalNode:n}){e.appendToParent(t,n.getMdastNode())}},mA={testNode:`table`,visitNode({mdastNode:e,lexicalParent:t}){t.append(dA(e))}};function hA(e=1,t=1){let n={type:`table`,children:[]};for(let r=0;r<e;r++){let e={type:`tableRow`,children:[]};for(let n=0;n<t;n++)e.children.push({type:`tableCell`,children:[]});n.children.push(e)}return n}var gA=Ll(e=>{e.link(e.pipe(gA,Wl(({rows:e,columns:t})=>()=>dA(hA(e,t)))),XC)}),_A=Xl({init(e,t){e.pubIn({[xC]:wT(),[bC]:OT(),[yC]:mA,[vC]:lA,[SC]:pA,[CC]:DT({tableCellPadding:t?.tableCellPadding??!0,tablePipeAlign:t?.tablePipeAlign??!0})})}}),vA={testNode:`link`,visitNode({mdastNode:e,actions:t}){t.addAndStepInto(gw(e.url,{title:e.title}))}},yA={testLexicalNode:_w,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto(`link`,{url:e.getURL(),title:e.getTitle()})}};function bA({validateUrl:e,attributes:t}){let[n]=eu();return(0,R.useEffect)((()=>{if(!n.hasNodes([hw]))throw Error(`LinkPlugin: LinkNode not registered on editor`);return U_(n.registerCommand(xw,(n=>{if(n===null)return Cw(n),!0;if(typeof n==`string`)return!(e!==void 0&&!e(n))&&(Cw(n,t),!0);{let{url:e,target:r,rel:i,title:a}=n;return Cw(e,{...t,rel:i,target:r,title:a}),!0}}),1),e===void 0?()=>{}:n.registerCommand(Qd,(r=>{let i=G();if(!W(i)||i.isCollapsed()||!$_(r,ClipboardEvent)||r.clipboardData===null)return!1;let a=r.clipboardData.getData(`text`);return!!e(a)&&!i.getNodes().some((e=>K(e)))&&(n.dispatchCommand(xw,{...t,url:a}),r.preventDefault(),!0)}),1))}),[n,e,t]),null}function xA(e,t=(e=>e)){return n=>{let r=e.exec(n);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:t(r[0])}}}function SA(e,t){for(let n=0;n<t.length;n++){let r=t[n](e);if(r)return r}return null}var CA=/[.,;\s]/;function wA(e){return CA.test(e)}function TA(e){return wA(e[e.length-1])}function EA(e){return wA(e[0])}function DA(e){let t=e.getPreviousSibling();return K(t)&&(t=t.getLastDescendant()),t===null||vp(t)||U(t)&&TA(t.getTextContent())}function OA(e){let t=e.getNextSibling();return K(t)&&(t=t.getFirstDescendant()),t===null||vp(t)||U(t)&&EA(t.getTextContent())}function kA(e,t,n,r){return(e>0?wA(n[e-1]):DA(r[0]))?t<n.length?wA(n[t]):OA(r[r.length-1]):!1}function AA(e,t,n){let r=[],i=[],a=[],o=0,s=0,c=[...e];for(;c.length>0;){let e=c[0],l=e.getTextContent().length,u=s;s+l<=t?(r.push(e),o+=l):u>=n?a.push(e):i.push(e),s+=l,c.shift()}return[o,r,i,a]}function jA(e,t,n,r){let i=yw(r.url,r.attributes);if(e.length===1){let a,o=e[0];t===0?[a,o]=o.splitText(n):[,a,o]=o.splitText(t,n);let s=Fp(r.text);return s.setFormat(a.getFormat()),s.setDetail(a.getDetail()),s.setStyle(a.getStyle()),i.append(s),a.replace(i),o}if(e.length>1){let r=e[0],a,o=r.getTextContent().length;t===0?a=r:[,a]=r.splitText(t);let s=[],c;for(let t=1;t<e.length;t++){let r=e[t],i=r.getTextContent().length,a=o;if(a<n)if(o+i<=n)s.push(r);else{let[e,t]=r.splitText(n-a);s.push(e),c=t}o+=i}let l=G(),u=l?l.getNodes().find(U):void 0,d=Fp(a.getTextContent());return d.setFormat(a.getFormat()),d.setDetail(a.getDetail()),d.setStyle(a.getStyle()),i.append(d,...s),u&&u===a&&(W(l)?d.select(l.anchor.offset,l.focus.offset):Kp(l)&&d.select(0,d.getTextContent().length)),a.replace(i),c}}function MA(e,t,n){let r=e.getChildren(),i=r.length;for(let t=0;t<i;t++){let i=r[t];if(!U(i)||!i.isSimpleText())return NA(e),void n(null,e.getURL())}let a=e.getTextContent(),o=SA(a,t);if(o===null||o.text!==a||!DA(e)||!OA(e))return NA(e),void n(null,e.getURL());let s=e.getURL();if(s!==o.url&&(e.setURL(o.url),n(o.url,s)),o.attributes){let t=e.getRel();t!==o.attributes.rel&&(e.setRel(o.attributes.rel||null),n(o.attributes.rel||null,t));let r=e.getTarget();r!==o.attributes.target&&(e.setTarget(o.attributes.target||null),n(o.attributes.target||null,r))}}function NA(e){let t=e.getChildren();for(let n=t.length-1;n>=0;n--)e.insertAfter(t[n]);return e.remove(),t.map((e=>e.getLatest()))}function PA(e,t,n){(0,R.useEffect)((()=>{e.hasNodes([vw])||function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(77);let r=(e,t)=>{n&&n(e,t)};return U_(e.registerNodeTransform(Ep,(e=>{let n=e.getParentOrThrow(),i=e.getPreviousSibling();bw(n)&&!n.getIsUnlinked()?MA(n,t,r):_w(n)||(e.isSimpleText()&&(EA(e.getTextContent())||!bw(i))&&(function(e,t,n){let r=[...e],i=r.map((e=>e.getTextContent())).join(``),a,o=i,s=0;for(;(a=SA(o,t))&&a!==null;){let e=a.index,t=e+a.length;if(kA(s+e,s+t,i,r)){let[i,,o,c]=AA(r,s+e,s+t),l=jA(o,s+e-i,s+t-i,a);r=l?[l,...c]:c,n(a.url,null),s=0}else s+=t;o=o.substring(t)}})(function(e){let t=[e],n=e.getNextSibling();for(;n!==null&&U(n)&&n.isSimpleText()&&(t.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return t}(e),t,r),(function(e,t,n){let r=e.getPreviousSibling(),i=e.getNextSibling(),a=e.getTextContent();var o;!bw(r)||r.getIsUnlinked()||EA(a)&&(o=a,!(r.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(o):/^\.[a-zA-Z0-9]{1,}/.test(o)))||(r.append(e),MA(r,t,n),n(null,r.getURL())),!bw(i)||i.getIsUnlinked()||TA(a)||(NA(i),MA(i,t,n),n(null,i.getURL()))})(e,t,r))})),e.registerCommand(xw,(e=>{let t=G();return e!==null||!W(t)||t.extract().forEach((e=>{let t=e.getParent();bw(t)&&(t.setIsUnlinked(!t.getIsUnlinked()),t.markDirty())})),!1}),1))}),[e,t,n])}function FA({matchers:e,onChange:t}){let[n]=eu();return PA(n,e,t),null}var IA=[xA(/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,e=>e.startsWith(`http`)?e:`https://${e}`),xA(/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,e=>`mailto:${e}`)],LA=()=>R.createElement(FA,{matchers:IA}),RA=Il(!1),zA=Xl({init(e,t){let n=!!t?.disableAutoLink,r=t?.validateUrl?{validateUrl:t.validateUrl}:{},i=()=>R.createElement(R.Fragment,null,R.createElement(bA,{...r}),n?null:R.createElement(LA,null));e.pubIn({[ew]:`link`,[yC]:vA,[vC]:[hw,vw],[SC]:yA,[RA]:n,[WC]:i,[KC]:i,[BC]:i})}}),BA=e=>e.type===`checkbox`,VA=e=>e instanceof Date,HA=e=>e==null,UA=e=>typeof e==`object`,WA=e=>!HA(e)&&!Array.isArray(e)&&UA(e)&&!VA(e),GA=e=>WA(e)&&e.target?BA(e.target)?e.target.checked:e.target.value:e,KA=(e,t)=>t.split(`.`).some((t,n,r)=>!isNaN(Number(t))&&e.has(r.slice(0,n).join(`.`))),qA=e=>{let t=e.constructor&&e.constructor.prototype;return WA(t)&&t.hasOwnProperty(`isPrototypeOf`)},JA=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function YA(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(JA&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(WA(e)&&qA(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=YA(e[t]));return r}var XA=e=>/^\w*$/.test(e),ZA=e=>e===void 0,QA=e=>Array.isArray(e)?e.filter(Boolean):[],$A=e=>QA(e.replace(/["|']|\]/g,``).split(/\.|\[/)),ej=(e,t,n)=>{if(!t||!WA(e))return n;let r=(XA(t)?[t]:$A(t)).reduce((e,t)=>HA(e)?void 0:e[t],e);return ZA(r)||r===e?ZA(e[t])?n:e[t]:r},tj=e=>typeof e==`boolean`,nj=e=>typeof e==`function`,rj=(e,t,n)=>{let r=-1,i=XA(t)?[t]:$A(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=WA(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},ij={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},aj={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},oj={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},sj=`form`,cj=`root`,lj=R.createContext(null);lj.displayName=`HookFormControlContext`;var uj=()=>R.useContext(lj),dj=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==aj.all&&(t._proxyFormState[i]=!r||aj.all),n&&(n[i]=!0),e[i]}});return i},fj=typeof window<`u`?R.useLayoutEffect:R.useEffect;function Hle(e){let t=uj(),{control:n=t,disabled:r,name:i,exact:a}=e||{},[o,s]=R.useState(n._formState),c=R.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return fj(()=>n._subscribe({name:i,formState:c.current,exact:a,callback:e=>{!r&&s({...n._formState,...e})}}),[i,r,a]),R.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),R.useMemo(()=>dj(o,n,c.current,!1),[o,n])}var pj=e=>typeof e==`string`,mj=(e,t,n,r,i)=>pj(e)?(r&&t.watch.add(e),ej(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),ej(n,e))):(r&&(t.watchAll=!0),n),hj=e=>HA(e)||!UA(e);function gj(e,t,n=new WeakSet){if(e===t)return!0;if(hj(e)||hj(t))return Object.is(e,t);if(VA(e)&&VA(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(let i of r){let r=e[i];if(!(i in t))return!1;if(i!==`ref`){let e=t[i];if(VA(r)&&VA(e)||(WA(r)||Array.isArray(r))&&(WA(e)||Array.isArray(e))?!gj(r,e,n):!Object.is(r,e))return!1}}return!0}function Ule(e){let t=uj(),{control:n=t,name:r,defaultValue:i,disabled:a,exact:o,compute:s}=e||{},c=R.useRef(i),l=R.useRef(s),u=R.useRef(void 0),d=R.useRef(n),f=R.useRef(r);l.current=s;let[p,m]=R.useState(()=>{let e=n._getWatch(r,c.current);return l.current?l.current(e):e}),h=R.useCallback(e=>{let t=mj(r,n._names,e||n._formValues,!1,c.current);return l.current?l.current(t):t},[n._formValues,n._names,r]),g=R.useCallback(e=>{if(!a){let t=mj(r,n._names,e||n._formValues,!1,c.current);if(l.current){let e=l.current(t);gj(e,u.current)||(m(e),u.current=e)}else m(t)}},[n._formValues,n._names,a,r]);fj(()=>((d.current!==n||!gj(f.current,r))&&(d.current=n,f.current=r,g()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:e=>{g(e.values)}})),[n,o,r,g]),R.useEffect(()=>n._removeUnmounted());let _=d.current!==n,v=f.current,y=R.useMemo(()=>{if(a)return null;let e=!_&&!gj(v,r);return _||e?h():null},[a,_,r,v,h]);return y===null?p:y}function Wle(e){let t=uj(),{name:n,disabled:r,control:i=t,shouldUnregister:a,defaultValue:o,exact:s=!0}=e,c=KA(i._names.array,n),l=Ule({control:i,name:n,defaultValue:R.useMemo(()=>ej(i._formValues,n,ej(i._defaultValues,n,o)),[i,n,o]),exact:s}),u=Hle({control:i,name:n,exact:s}),d=R.useRef(e),f=R.useRef(i.register(n,{...e.rules,value:l,...tj(e.disabled)?{disabled:e.disabled}:{}}));d.current=e;let p=R.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ej(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!ej(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ej(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ej(u.validatingFields,n)},error:{enumerable:!0,get:()=>ej(u.errors,n)}}),[u,n]),m=R.useCallback(e=>f.current.onChange({target:{value:GA(e),name:n},type:ij.CHANGE}),[n]),h=R.useCallback(()=>f.current.onBlur({target:{value:ej(i._formValues,n),name:n},type:ij.BLUR}),[n,i._formValues]),g=R.useCallback(e=>{let t=ej(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>nj(e.focus)&&e.focus(),select:()=>nj(e.select)&&e.select(),setCustomValidity:t=>nj(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>nj(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),_=R.useMemo(()=>({name:n,value:l,...tj(r)||u.disabled?{disabled:u.disabled||r}:{},onChange:m,onBlur:h,ref:g}),[n,r,u.disabled,m,h,g,l]);return R.useEffect(()=>{let e=i._options.shouldUnregister||a;i.register(n,{...d.current.rules,...tj(d.current.disabled)?{disabled:d.current.disabled}:{}});let t=(e,t)=>{let n=ej(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=YA(ej(i._options.defaultValues,n,d.current.defaultValue));rj(i._defaultValues,n,e),ZA(ej(i._formValues,n))&&rj(i._formValues,n,e)}return!c&&i.register(n),()=>{(c?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,c,a]),R.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),R.useMemo(()=>({field:_,formState:u,fieldState:p}),[_,u,p])}var Gle=e=>e.render(Wle(e)),Kle=R.createContext(null);Kle.displayName=`HookFormContext`;var qle=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},_j=e=>Array.isArray(e)?e:[e],vj=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function yj(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&WA(i)&&a){let e=yj(i,a);WA(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var bj=e=>WA(e)&&!Object.keys(e).length,xj=e=>e.type===`file`,Sj=e=>{if(!JA)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Cj=e=>e.type===`select-multiple`,wj=e=>e.type===`radio`,Jle=e=>wj(e)||BA(e),Tj=e=>Sj(e)&&e.isConnected;function Yle(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;){if(HA(e)){e=void 0;break}e=e[t[r]],r++}return e}function Xle(e){for(let t in e)if(e.hasOwnProperty(t)&&!ZA(e[t]))return!1;return!0}function Ej(e,t){if(pj(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;let n=Array.isArray(t)?t:XA(t)?[t]:$A(t),r=n.length===1?e:Yle(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(WA(r)&&bj(r)||Array.isArray(r)&&Xle(r))&&Ej(e,n.slice(0,-1)),e}var Zle=e=>{for(let t in e)if(nj(e[t]))return!0;return!1};function Dj(e){return Array.isArray(e)||WA(e)&&!Zle(e)}function Oj(e,t={}){for(let n in e){let r=e[n];Dj(r)?(t[n]=Array.isArray(r)?[]:{},Oj(r,t[n])):ZA(r)||(t[n]=!0)}return t}function kj(e,t,n){n||=Oj(t);for(let r in e){let i=e[r];if(Dj(i))ZA(t)||hj(n[r])?n[r]=Oj(i,Array.isArray(i)?[]:{}):kj(i,HA(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!gj(i,e)}}return n}var Aj={value:!1,isValid:!1},jj={value:!0,isValid:!0},Mj=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ZA(e[0].attributes.value)?ZA(e[0].value)||e[0].value===``?jj:{value:e[0].value,isValid:!0}:jj:Aj}return Aj},Nj=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ZA(e)?e:t?e===``?NaN:e&&+e:n&&pj(e)?new Date(e):r?r(e):e,Pj={isValid:!1,value:null},Fj=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,Pj):Pj;function Ij(e){let t=e.ref;return xj(t)?t.files:wj(t)?Fj(e.refs).value:Cj(t)?[...t.selectedOptions].map(({value:e})=>e):BA(t)?Mj(e.refs).value:Nj(ZA(t.value)?e.ref.value:t.value,e)}var Qle=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,$le=(e,t,n,r)=>{let i={};for(let n of e){let e=ej(t,n);e&&rj(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Lj=e=>e instanceof RegExp,Rj=e=>ZA(e)?e:Lj(e)?e.source:WA(e)?Lj(e.value)?e.value.source:e.value:e,zj=e=>({isOnSubmit:!e||e===aj.onSubmit,isOnBlur:e===aj.onBlur,isOnChange:e===aj.onChange,isOnAll:e===aj.all,isOnTouch:e===aj.onTouched}),Bj=`AsyncFunction`,eue=e=>!!e&&!!e.validate&&!!(nj(e.validate)&&e.validate.constructor.name===Bj||WA(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===Bj)),tue=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Vj=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),Hj=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=ej(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(Hj(a,t))break}else if(WA(a)&&Hj(a,t))break}}};function Uj(e,t,n){let r=ej(e,n);if(r||XA(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=ej(t,r),o=ej(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var nue=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return bj(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||aj.all))},rue=(e,t,n)=>!e||!t||e===t||_j(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),iue=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,aue=(e,t)=>!QA(ej(e,t)).length&&Ej(e,t),oue=(e,t,n)=>{let r=_j(ej(e,n));return rj(r,cj,t[n]),rj(e,n,r),e};function Wj(e,t,n=`validate`){if(pj(e)||Array.isArray(e)&&e.every(pj)||tj(e)&&!e)return{type:n,message:pj(e)?e:``,ref:t}}var Gj=e=>WA(e)&&!Lj(e)?e:{value:e,message:``},Kj=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=ej(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(tj(e)?``:e||``),y.reportValidity())},x={},S=wj(o),C=BA(o),w=S||C,T=(g||xj(o))&&ZA(o.value)&&ZA(v)||Sj(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length||g&&typeof v==`number`&&isNaN(v),E=qle.bind(null,h,r,x),D=(e,t,n,r=oj.maxLength,i=oj.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||HA(v))||tj(v)&&!v||C&&!Mj(s).isValid||S&&!Fj(s).isValid)){let{value:e,message:t}=pj(c)?{value:!!c,message:c}:Gj(c);if(e&&(x[h]={type:oj.required,message:t,ref:y,...E(oj.required,t)},!r))return b(t),x}if(!T&&(!HA(d)||!HA(f))){let e,t,n=Gj(f),i=Gj(d);if(!HA(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;HA(n.value)||(e=r>n.value),HA(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;pj(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),pj(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,oj.max,oj.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(pj(v)||a&&Array.isArray(v))){let e=Gj(l),t=Gj(u),n=!HA(e.value)&&v.length>+e.value,i=!HA(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&pj(v)){let{value:e,message:t}=Gj(p);if(Lj(e)&&!v.match(e)&&(x[h]={type:oj.pattern,message:t,ref:o,...E(oj.pattern,t)},!r))return b(t),x}if(m){if(nj(m)){let e=Wj(await m(v,n),y);if(e&&(x[h]={...e,...E(oj.validate,e.message)},!r))return b(e.message),x}else if(WA(m)){let e={};for(let t in m){if(!bj(e)&&!r)break;let i=Wj(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!bj(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},sue={mode:aj.onSubmit,reValidateMode:aj.onChange,shouldFocusError:!0};function cue(e={}){let t={...sue,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:nj(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(WA(t.defaultValues)||WA(t.values))&&YA(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:YA(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={...d},p={array:vj(),state:vj()},m=t.criteriaMode===aj.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||f.isValid||e)){let e;t.resolver?(e=bj((await T()).errors),_()):e=await O({fields:r,onlyCheckValid:!0,eventType:ij.VALID}),e!==n.isValid&&p.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?rj(n.validatingFields,e,r):Ej(n.validatingFields,e))}),p.state.next({validatingFields:n.validatingFields,isValidating:!bj(n.validatingFields)}))},v=e=>{let t=kj(i,a),r=Qle(e);rj(n.dirtyFields,r,ej(t,r))},y=(e,i=[],s,c,l=!0,u=!0)=>{if(c&&s&&!t.disabled){if(o.action=!0,u&&Array.isArray(ej(r,e))){let t=s(ej(r,e),c.argA,c.argB);l&&rj(r,e,t)}if(u&&Array.isArray(ej(n.errors,e))){let t=s(ej(n.errors,e),c.argA,c.argB);l&&rj(n.errors,e,t),aue(n.errors,e)}if((d.touchedFields||f.touchedFields)&&u&&Array.isArray(ej(n.touchedFields,e))){let t=s(ej(n.touchedFields,e),c.argA,c.argB);l&&rj(n.touchedFields,e,t)}(d.dirtyFields||f.dirtyFields)&&v(e),p.state.next({name:e,isDirty:A(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else rj(a,e,i)},b=(e,t)=>{rj(n.errors,e,t),p.state.next({errors:n.errors})},x=e=>{n.errors=e,p.state.next({errors:n.errors,isValid:!1})},S=(e,t,n,s)=>{let c=ej(r,e);if(c){let r=ej(a,e,ZA(n)?ej(i,e):n);ZA(r)||s&&s.defaultChecked||t?rj(a,e,t?r:Ij(c._f)):N(e,r),o.mount&&!o.action&&g()}},C=(e,r,a,o,s)=>{let c=!1,l=!1,u={name:e};if(!t.disabled){if(!a||o){(d.isDirty||f.isDirty)&&(l=n.isDirty,n.isDirty=u.isDirty=A(),c=l!==u.isDirty);let t=gj(ej(i,e),r);l=!!ej(n.dirtyFields,e),t?Ej(n.dirtyFields,e):rj(n.dirtyFields,e,!0),u.dirtyFields=n.dirtyFields,c||=(d.dirtyFields||f.dirtyFields)&&l!==!t}if(a){let t=ej(n.touchedFields,e);t||(rj(n.touchedFields,e,a),u.touchedFields=n.touchedFields,c||=(d.touchedFields||f.touchedFields)&&t!==a)}c&&s&&p.state.next(u)}return c?u:{}},w=(e,r,i,a)=>{let o=ej(n.errors,e),s=(d.isValid||f.isValid)&&tj(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>b(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?rj(n.errors,e,i):Ej(n.errors,e)),(i?!gj(o,i):o)||!bj(a)||s){let t={...a,...s&&tj(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},p.state.next(t)}},T=async e=>(_(e,!0),await t.resolver(a,t.context,$le(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),E=async e=>{let{errors:t}=await T(e);if(_(e),e)for(let r of e){let e=ej(t,r);e?rj(n.errors,r,e):Ej(n.errors,r)}else n.errors=t;return t},D=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(WA(i))for(let e in i)i[e]&&ae(`${sj}.${e}`,{message:pj(i.message)?i.message:``,type:oj.validate});else pj(i)||!i?ae(sj,{message:i||``,type:oj.validate}):ie(sj);return i}return!0},O=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await D({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...f}=u;if(r){let o=s.array.has(r.name),c=u._f&&eue(u._f);c&&d.validatingFields&&_([r.name],!0);let f=await Kj(u,s.disabled,a,m,t.shouldUseNativeValidation&&!i,o);if(c&&d.validatingFields&&_([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(ej(f,r.name)?o?oue(n.errors,f,r.name):rj(n.errors,r.name,f[r.name]):Ej(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!bj(f)&&await O({context:l,onlyCheckValid:i,fields:f,name:o,eventType:c})}}return l.valid},k=()=>{for(let e of s.unMount){let t=ej(r,e);t&&(t._f.refs?t._f.refs.every(e=>!Tj(e)):!Tj(t._f.ref))&&le(e)}s.unMount=new Set},A=(e,n)=>!t.disabled&&(e&&n&&rj(a,e,n),!gj(L(),i)),j=(e,t,n)=>mj(e,s,{...o.mount?a:ZA(t)?i:pj(e)?{[e]:t}:t},n,t),M=e=>QA(ej(o.mount?a:i,e,t.shouldUnregister?ej(i,e,[]):[])),N=(e,t,n={})=>{let i=ej(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&rj(a,e,Nj(t,n)),o=Sj(n.ref)&&HA(t)?``:t,Cj(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?BA(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):xj(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||p.state.next({name:e,values:YA(a)})))}(n.shouldDirty||n.shouldTouch)&&C(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&ne(e)},P=(e,t,n)=>{for(let i in t){if(!t.hasOwnProperty(i))return;let a=t[i],o=e+`.`+i,c=ej(r,o);(s.array.has(e)||WA(a)||c&&!c._f)&&!VA(a)?P(o,a,n):N(o,a,n)}},F=(e,t,i={})=>{let c=ej(r,e),l=s.array.has(e),u=YA(t),d=gj(ej(a,e),u);if(rj(a,e,u),l)p.array.next({name:e,values:YA(a)}),i.shouldDirty&&(v(e),p.state.next({name:e,dirtyFields:n.dirtyFields,isDirty:A(e,u)}));else{let t=Array.isArray(u)&&!u.length||bj(u);!c||c._f||HA(u)||t?N(e,u,i):P(e,u,i)}d||(Vj(e,s)?p.state.next({...n,name:e,values:YA(a)}):p.state.next({name:o.mount?e:void 0,values:YA(a)}))},ee=e=>{let t=nj(e)?e(a):e;gj(a,t)||(a={...a,...t},p.state.next({...n,values:a}))},te=async i=>{o.mount=!0;let l=i.target,u=l.name,h=!0,v=ej(r,u),y=e=>{h=Number.isNaN(e)||VA(e)&&isNaN(e.getTime())||gj(e,ej(a,u,e))},b=zj(t.mode),x=zj(t.reValidateMode);if(v){let o,S,E=l.type?Ij(v._f):GA(i),k=i.type===ij.BLUR||i.type===ij.FOCUS_OUT,A=!tue(v._f)&&!e.validate&&!t.resolver&&!ej(n.errors,u)&&!v._f.deps||iue(k,ej(n.touchedFields,u),n.isSubmitted,x,b),j=Vj(u,s,k);rj(a,u,E),k?(!l||!l.readOnly)&&(v._f.onBlur&&v._f.onBlur(i),c&&c(0)):v._f.onChange&&v._f.onChange(i);let M=C(u,E,k),N=!bj(M)||j;if(!k&&p.state.next({name:u,type:i.type,values:YA(a)}),A)return(d.isValid||f.isValid)&&(t.mode===`onBlur`?k&&g():k||g()),N&&p.state.next({name:u,...j?{}:M});if(!t.resolver&&e.validate&&await D({name:u,eventType:i.type}),!k&&j&&p.state.next({...n}),t.resolver){let{errors:e}=await T([u]);if(_([u]),y(E),h){let t=Uj(n.errors,r,u),i=Uj(e,r,t.name||u);o=i.error,u=i.name,S=bj(e)}}else _([u],!0),o=(await Kj(v,s.disabled,a,m,t.shouldUseNativeValidation))[u],_([u]),y(E),h&&(o?S=!1:(d.isValid||f.isValid)&&(S=await O({fields:r,onlyCheckValid:!0,name:u,eventType:i.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&ne(v._f.deps),w(u,S,o,M))}},I=(e,t)=>{if(ej(n.errors,t)&&e.focus)return e.focus(),1},ne=async(e,i={})=>{let a,o,c=_j(e);if(t.resolver){let t=await E(ZA(e)?e:c);a=bj(t),o=e?!c.some(e=>ej(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=ej(r,e);return await O({fields:t&&t._f?{[e]:t}:t,eventType:ij.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await O({fields:r,name:e,eventType:ij.TRIGGER});return p.state.next({...!pj(e)||(d.isValid||f.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&Hj(r,I,e?c:s.mount),o},L=(e,t)=>{let r={...o.mount?a:i};return t&&(r=yj(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),ZA(e)?r:pj(e)?ej(r,e):e.map(e=>ej(r,e))},re=(e,t)=>({invalid:!!ej((t||n).errors,e),isDirty:!!ej((t||n).dirtyFields,e),error:ej((t||n).errors,e),isValidating:!!ej(n.validatingFields,e),isTouched:!!ej((t||n).touchedFields,e)}),ie=e=>{let t=e?_j(e):void 0;t?.forEach(e=>Ej(n.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:n.errors})}):p.state.next({errors:{}})},ae=(e,t,i)=>{let a=(ej(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=ej(n.errors,e)||{};rj(n.errors,e,{...l,...t,ref:a}),p.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},oe=(e,t)=>nj(e)?p.state.subscribe({next:n=>`values`in n&&e(n.values||j(void 0,t),n)}):j(e,t,!0),se=e=>p.state.subscribe({next:t=>{if(rue(e.name,t.name,e.exact)&&nue(t,e.formState||d,ye,e.reRenderRoot)){let r={...a};e.callback({values:r,...n,...t,defaultValues:i})}}}).unsubscribe,ce=e=>(o.mount=!0,f={...f,...e.formState},se({...e,formState:{...u,...e.formState}})),le=(e,o={})=>{for(let c of e?_j(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(Ej(r,c),Ej(a,c)),!o.keepError&&Ej(n.errors,c),!o.keepDirty&&Ej(n.dirtyFields,c),!o.keepTouched&&Ej(n.touchedFields,c),!o.keepIsValidating&&Ej(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&Ej(i,c);p.state.next({values:YA(a)}),p.state.next({...n,...o.keepDirty?{isDirty:A()}:{}}),!o.keepIsValid&&g()},ue=({disabled:e,name:t})=>{if(tj(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&g()}},de=(e,n={})=>{let a=ej(r,e),c=tj(n.disabled)||tj(t.disabled),l=!s.registerName.has(e)&&a&&a._f&&!a._f.mount;return rj(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a&&!l?ue({disabled:tj(n.disabled)?n.disabled:t.disabled,name:e}):S(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:Rj(n.min),max:Rj(n.max),minLength:Rj(n.minLength),maxLength:Rj(n.maxLength),pattern:Rj(n.pattern)}:{},name:e,onChange:te,onBlur:te,ref:c=>{if(c){s.registerName.add(e),de(e,n),s.registerName.delete(e),a=ej(r,e);let t=ZA(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=Jle(t),l=a._f.refs||[];if(o?l.find(e=>e===t):t===a._f.ref)return;rj(r,e,{_f:{...a._f,...o?{refs:[...l.filter(Tj),t,...Array.isArray(ej(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),S(e,!1,void 0,t)}else a=ej(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(KA(s.array,e)&&o.action)&&s.unMount.add(e)}}},fe=()=>t.shouldFocusError&&Hj(r,I,s.mount),pe=e=>{tj(e)&&(p.state.next({disabled:e}),Hj(r,(t,n)=>{let i=ej(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},me=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=YA(a);if(p.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await T();_(),n.errors=e,l=YA(t)}else await O({fields:r,eventType:ij.SUBMIT});if(s.disabled.size)for(let e of s.disabled)Ej(l,e);if(Ej(n.errors,cj),bj(n.errors)){p.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),fe(),setTimeout(fe);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bj(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},he=(e,t={})=>{ej(r,e)&&(ZA(t.defaultValue)?F(e,YA(ej(i,e))):(F(e,t.defaultValue),rj(i,e,YA(t.defaultValue))),t.keepTouched||Ej(n.touchedFields,e),t.keepDirty||(Ej(n.dirtyFields,e),n.isDirty=t.defaultValue?A(e,YA(ej(i,e))):A()),t.keepError||(Ej(n.errors,e),d.isValid&&g()),p.state.next({...n}))},ge=(e,c={})=>{let l=e?YA(e):i,u=YA(l),f=bj(e),m=f?i:u;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(kj(i,a))]);for(let t of Array.from(e)){let e=ej(n.dirtyFields,t),r=ej(a,t),i=ej(m,t);e&&!ZA(r)?rj(m,t,r):!e&&!ZA(i)&&F(t,i)}}else{if(JA&&ZA(e))for(let e of s.mount){let t=ej(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Sj(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)F(e,ej(m,e));else r={}}a=t.shouldUnregister?c.keepDefaultValues?YA(i):{}:YA(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!d.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!bj(m),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(n.errors={}),p.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:f?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!gj(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:f?{}:c.keepDirtyValues?c.keepDefaultValues&&a?kj(i,a):n.dirtyFields:c.keepDefaultValues&&e?kj(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},_e=(e,n)=>ge(nj(e)?e(a):e,{...t.resetOptions,...n}),ve=(e,t={})=>{let n=ej(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&nj(e.select)&&e.select()})}},ye=e=>{n={...n,...e}},be={control:{register:de,unregister:le,getFieldState:re,handleSubmit:me,setError:ae,_subscribe:se,_runSchema:T,_updateIsValidating:_,_focusError:fe,_getWatch:j,_getDirty:A,_setValid:g,_setFieldArray:y,_setDisabledField:ue,_setErrors:x,_getFieldArray:M,_reset:ge,_resetDefaultValues:()=>nj(t.defaultValues)&&t.defaultValues().then(e=>{_e(e,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:k,_disableForm:pe,_subjects:p,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:ce,trigger:ne,register:de,handleSubmit:me,watch:oe,setValue:F,setValues:ee,getValues:L,reset:_e,resetField:he,clearErrors:ie,unregister:le,setError:ae,setFocus:ve,getFieldState:re};return{...be,formControl:be}}function lue(e={}){let t=R.useRef(void 0),n=R.useRef(void 0),[r,i]=R.useState({isDirty:!1,isValidating:!1,isLoading:nj(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:nj(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!nj(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=cue(e);t.current={...i,formState:r}}let a=t.current.control;return a._options=e,fj(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),R.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),R.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),R.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),R.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),R.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),R.useEffect(()=>{e.values&&!gj(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),a._options.resetOptions?.keepIsValid||a._setValid(),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),R.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=R.useMemo(()=>dj(r,a),[a,r]),t.current}function qj(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},q.apply(null,arguments)}var uue=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),due=n(((e,t)=>{var n=uue();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),fue=n(((e,t)=>{t.exports=due()()})),pue=n((e=>{if(typeof Symbol==`function`&&Symbol.for){var t=Symbol.for;t(`react.element`),t(`react.portal`),t(`react.fragment`),t(`react.strict_mode`),t(`react.profiler`),t(`react.provider`),t(`react.context`),t(`react.forward_ref`),t(`react.suspense`),t(`react.suspense_list`),t(`react.memo`),t(`react.lazy`),t(`react.block`),t(`react.server.block`),t(`react.fundamental`),t(`react.debug_trace_mode`),t(`react.legacy_hidden`)}})),mue=n(((e,t)=>{t.exports=pue()})),Jj=e=>typeof e==`object`&&!!e&&e.nodeType===1,Yj=(e,t)=>(!t||e!==`hidden`)&&e!==`visible`&&e!==`clip`,Xj=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let n=getComputedStyle(e,null);return Yj(n.overflowY,t)||Yj(n.overflowX,t)||(e=>{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch{return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},Zj=(e,t,n,r,i,a,o,s)=>a<e&&o>t||a>e&&o<t?0:a<=e&&s<=n||o>=t&&s>=n?a-e-r:o>t&&s<n||a<e&&s>n?o-t+i:0,hue=e=>e.parentElement??(e.getRootNode().host||null),gue=(e,t)=>{if(typeof document>`u`)return[];let{scrollMode:n,block:r,inline:i,boundary:a,skipOverflowHiddenElements:o}=t,s=typeof a==`function`?a:e=>e!==a;if(!Jj(e))throw TypeError(`Invalid target`);let c=document.scrollingElement||document.documentElement,l=[],u=e;for(;Jj(u)&&s(u);){if(u=hue(u),u===c){l.push(u);break}u!=null&&u===document.body&&Xj(u)&&!Xj(document.documentElement)||u!=null&&Xj(u,o)&&l.push(u)}let d=window.visualViewport?.width??innerWidth,f=window.visualViewport?.height??innerHeight,p=window.scrollX??pageXOffset,m=window.scrollY??pageYOffset,{height:h,width:g,top:_,right:v,bottom:y,left:b}=e.getBoundingClientRect(),x=r===`start`||r===`nearest`?_:r===`end`?y:_+h/2,S=i===`center`?b+g/2:i===`end`?v:b,C=[];for(let e=0;e<l.length;e++){let t=l[e],{height:a,width:o,top:s,right:u,bottom:w,left:T}=t.getBoundingClientRect();if(n===`if-needed`&&_>=0&&b>=0&&y<=f&&v<=d&&_>=s&&y<=w&&b>=T&&v<=u)return C;let E=getComputedStyle(t),D=parseInt(E.borderLeftWidth,10),O=parseInt(E.borderTopWidth,10),k=parseInt(E.borderRightWidth,10),A=parseInt(E.borderBottomWidth,10),j=0,M=0,N=`offsetWidth`in t?t.offsetWidth-t.clientWidth-D-k:0,P=`offsetHeight`in t?t.offsetHeight-t.clientHeight-O-A:0,F=`offsetWidth`in t?t.offsetWidth===0?0:o/t.offsetWidth:0,ee=`offsetHeight`in t?t.offsetHeight===0?0:a/t.offsetHeight:0;if(c===t)j=r===`start`?x:r===`end`?x-f:r===`nearest`?Zj(m,m+f,f,O,A,m+x,m+x+h,h):x-f/2,M=i===`start`?S:i===`center`?S-d/2:i===`end`?S-d:Zj(p,p+d,d,D,k,p+S,p+S+g,g),j=Math.max(0,j+m),M=Math.max(0,M+p);else{j=r===`start`?x-s-O:r===`end`?x-w+A+P:r===`nearest`?Zj(s,w,a,O,A+P,x,x+h,h):x-(s+a/2)+P/2,M=i===`start`?S-T-D:i===`center`?S-(T+o/2)+N/2:i===`end`?S-u+k+N:Zj(T,u,o,D,k+N,S,S+g,g);let{scrollLeft:e,scrollTop:n}=t;j=Math.max(0,Math.min(n+j/ee,t.scrollHeight-a/ee+P)),M=Math.max(0,Math.min(e+M/F,t.scrollWidth-o/F+N)),x+=n-j,S+=e-M}C.push({el:t,top:j,left:M})}return C},J=t(fue());mue();var _ue=0;function Qj(){}function vue(e,t){e&&gue(e,{boundary:t,block:`nearest`,scrollMode:`if-needed`}).forEach(function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r})}function $j(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function eM(e,t){var n;function r(){n&&clearTimeout(n)}function i(){var i=[...arguments];r(),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}return i.cancel=r,i}function tM(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return e&&e.apply(void 0,[t].concat(n)),t.preventDownshiftDefault||t.hasOwnProperty(`nativeEvent`)&&t.nativeEvent.preventDownshiftDefault})}}function nM(){var e=[...arguments];return function(t){e.forEach(function(e){typeof e==`function`?e(t):e&&(e.current=t)})}}function yue(){return String(_ue++)}function bue(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n===r?``:n+` result`+(n===1?` is`:`s are`)+` available, use up and down arrow keys to navigate. Press Enter key to select.`:`No results are available.`:``}function rM(e,t){return Object.keys(e).reduce(function(n,r){return n[r]=iM(t,r)?t[r]:e[r],n},{})}function iM(e,t){return e[t]!==void 0}function aM(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf(`Arrow`)!==0?`Arrow`+t:t}function oM(e,t,n,r,i){if(i===void 0&&(i=!0),n===0)return-1;var a=n-1;(typeof t!=`number`||t<0||t>=n)&&(t=e>0?-1:a+1);var o=t+e;o<0?o=i?a:0:o>a&&(o=i?0:a);var s=sM(e,o,n,r,i);return s===-1?t>=n?-1:t:s}function sM(e,t,n,r,i){var a=r(t);if(!a||!a.hasAttribute(`disabled`))return t;if(e>0){for(var o=t+1;o<n;o++)if(!r(o).hasAttribute(`disabled`))return o}else for(var s=t-1;s>=0;s--)if(!r(s).hasAttribute(`disabled`))return s;return i?e>0?sM(1,0,n,r,!1):sM(-1,n-1,n,r,!1):-1}function cM(e,t,n,r){return r===void 0&&(r=!0),t.some(function(t){return t&&($j(t,e,n)||r&&$j(t,n.document.activeElement,n))})}var xue=eM(function(e){uM(e).textContent=``},500);function lM(e,t){var n=uM(t);e&&(n.textContent=e,xue(t))}function uM(e){e===void 0&&(e=document);var t=e.getElementById(`a11y-status-message`);return t||(t=e.createElement(`div`),t.setAttribute(`id`,`a11y-status-message`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-relevant`,`additions text`),Object.assign(t.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`}),e.body.appendChild(t),t)}var Sue=[`isInitialMount`,`highlightedIndex`,`items`,`environment`],dM={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:``};function Cue(e,t,n){var r=e.props,i=e.type,a={};Object.keys(t).forEach(function(r){wue(r,e,t,n),n[r]!==t[r]&&(a[r]=n[r])}),r.onStateChange&&Object.keys(a).length&&r.onStateChange(q({type:i},a))}function wue(e,t,n,r){var i=t.props,a=t.type,o=`on`+mM(e)+`Change`;i[o]&&r[e]!==void 0&&r[e]!==n[e]&&i[o](q({type:a},r))}function Tue(e,t){return t.changes}function Eue(e){var t=e.selectedItem,n=e.itemToString;return t?n(t)+` has been selected.`:``}var Due=eM(function(e,t){lM(e(),t)},200),Oue=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?R.useLayoutEffect:R.useEffect;function fM(e){var t=e.id,n=t===void 0?`downshift-`+yue():t,r=e.labelId,i=e.menuId,a=e.getItemId,o=e.toggleButtonId,s=e.inputId;return(0,R.useRef)({labelId:r||n+`-label`,menuId:i||n+`-menu`,getItemId:a||function(e){return n+`-item-`+e},toggleButtonId:o||n+`-toggle-button`,inputId:s||n+`-input`}).current}function pM(e,t,n,r){var i,a;if(e===void 0){if(t===void 0)throw Error(r);i=n[t],a=t}else a=t===void 0?n.indexOf(e):t,i=e;return[i,a]}function kue(e){return e?String(e):``}function Aue(e){return/^\S{1}$/.test(e)}function mM(e){return``+e.slice(0,1).toUpperCase()+e.slice(1)}function hM(e){var t=(0,R.useRef)(e);return t.current=e,t}function gM(e,t,n){var r=(0,R.useRef)(),i=(0,R.useRef)(),a=(0,R.useReducer)((0,R.useCallback)(function(t,n){i.current=n,t=rM(t,n.props);var r=e(t,n);return n.props.stateReducer(t,q({},n,{changes:r}))},[e]),t),o=a[0],s=a[1],c=hM(n),l=(0,R.useCallback)(function(e){return s(q({props:c.current},e))},[c]),u=i.current;return(0,R.useEffect)(function(){u&&r.current&&r.current!==o&&Cue(u,rM(r.current,u.props),o),r.current=o},[o,n,u]),[o,l]}function _M(e,t,n){var r=gM(e,t,n),i=r[0],a=r[1];return[rM(i,n),a]}var vM={itemToString:kue,stateReducer:Tue,getA11ySelectionMessage:Eue,scrollIntoView:vue,environment:typeof window>`u`?{}:window};function yM(e,t,n){n===void 0&&(n=dM);var r=e[`default`+mM(t)];return r===void 0?n[t]:r}function bM(e,t,n){n===void 0&&(n=dM);var r=e[t];if(r!==void 0)return r;var i=e[`initial`+mM(t)];return i===void 0?yM(e,t,n):i}function xM(e){var t=bM(e,`selectedItem`),n=bM(e,`isOpen`),r=bM(e,`highlightedIndex`),i=bM(e,`inputValue`);return{highlightedIndex:r<0&&t&&n?e.items.indexOf(t):r,isOpen:n,selectedItem:t,inputValue:i}}function SM(e,t,n){var r=e.items,i=e.initialHighlightedIndex,a=e.defaultHighlightedIndex,o=t.selectedItem,s=t.highlightedIndex;return r.length===0?-1:i!==void 0&&s===i?i:a===void 0?o?r.indexOf(o):n===0?-1:n<0?r.length-1:0:a}function CM(e,t,n,r){var i=(0,R.useRef)({isMouseDown:!1,isTouchMove:!1});return(0,R.useEffect)(function(){if(n?.addEventListener!=null){var a=function(){i.current.isMouseDown=!0},o=function(a){i.current.isMouseDown=!1,e&&!cM(a.target,t.map(function(e){return e.current}),n)&&r()},s=function(){i.current.isTouchMove=!1},c=function(){i.current.isTouchMove=!0},l=function(a){e&&!i.current.isTouchMove&&!cM(a.target,t.map(function(e){return e.current}),n,!1)&&r()};return n.addEventListener(`mousedown`,a),n.addEventListener(`mouseup`,o),n.addEventListener(`touchstart`,s),n.addEventListener(`touchmove`,c),n.addEventListener(`touchend`,l),function(){n.removeEventListener(`mousedown`,a),n.removeEventListener(`mouseup`,o),n.removeEventListener(`touchstart`,s),n.removeEventListener(`touchmove`,c),n.removeEventListener(`touchend`,l)}}},[e,n]),i}var wM=function(){return Qj};function TM(e,t,n){var r=n.isInitialMount,i=n.highlightedIndex,a=n.items,o=n.environment,s=qj(n,Sue);(0,R.useEffect)(function(){r||Due(function(){return e(q({highlightedIndex:i,highlightedItem:a[i],resultCount:a.length},s))},o.document)},t)}function EM(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,i=e.getItemNodeFromIndex,a=e.menuElement,o=e.scrollIntoView,s=(0,R.useRef)(!0);return Oue(function(){t<0||!n||!Object.keys(r.current).length||(s.current===!1?s.current=!0:o(i(t),a))},[t]),s}var DM=Qj;function OM(e,t,n){return n===void 0&&(n=!0),q({isOpen:!1,highlightedIndex:-1},e.items?.length&&t>=0&&q({selectedItem:e.items[t],isOpen:yM(e,`isOpen`),highlightedIndex:yM(e,`highlightedIndex`)},n&&{inputValue:e.itemToString(e.items[t])}))}function kM(e,t,n){var r=t.type,i=t.props,a;switch(r){case n.ItemMouseMove:a={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:a={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:a={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:SM(i,e,0)};break;case n.FunctionOpenMenu:a={isOpen:!0,highlightedIndex:SM(i,e,0)};break;case n.FunctionCloseMenu:a={isOpen:!1};break;case n.FunctionSetHighlightedIndex:a={highlightedIndex:t.highlightedIndex};break;case n.FunctionSetInputValue:a={inputValue:t.inputValue};break;case n.FunctionReset:a={highlightedIndex:yM(i,`highlightedIndex`),isOpen:yM(i,`isOpen`),selectedItem:yM(i,`selectedItem`),inputValue:yM(i,`inputValue`)};break;default:throw Error(`Reducer called without proper action type.`)}return q({},e,a)}function jue(e){for(var t=e.keysSoFar,n=e.highlightedIndex,r=e.items,i=e.itemToString,a=e.getItemNodeFromIndex,o=t.toLowerCase(),s=0;s<r.length;s++){var c=(s+n+ +(t.length<2))%r.length,l=r[c];if(l!==void 0&&i(l).toLowerCase().startsWith(o)&&!a(c)?.hasAttribute(`disabled`))return c}return n}J.default.array.isRequired,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.bool,J.default.bool,J.default.bool,J.default.any,J.default.any,J.default.any,J.default.string,J.default.string,J.default.string,J.default.func,J.default.string,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});function Mue(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n===r?``:`${n} result${n===1?` is`:`s are`} available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.`:`No results are available.`:``}var Nue=qD(qD({},vM),{getA11yStatusMessage:Mue}),Pue=Qj,AM=0,jM=1,MM=2,NM=3,PM=4,FM=5,IM=6,LM=7,RM=8,zM=9,BM=10,VM=11,HM=12,UM=13,WM=14,GM=15,KM=16,qM=17,JM=18,YM=19,XM=20,ZM=21,QM=Object.freeze({__proto__:null,ToggleButtonClick:AM,ToggleButtonKeyDownArrowDown:jM,ToggleButtonKeyDownArrowUp:MM,ToggleButtonKeyDownCharacter:NM,ToggleButtonKeyDownEscape:PM,ToggleButtonKeyDownHome:FM,ToggleButtonKeyDownEnd:IM,ToggleButtonKeyDownEnter:LM,ToggleButtonKeyDownSpaceButton:RM,ToggleButtonKeyDownPageUp:zM,ToggleButtonKeyDownPageDown:BM,ToggleButtonBlur:VM,MenuMouseLeave:HM,ItemMouseMove:UM,ItemClick:WM,FunctionToggleMenu:GM,FunctionOpenMenu:KM,FunctionCloseMenu:qM,FunctionSetHighlightedIndex:JM,FunctionSelectItem:YM,FunctionSetInputValue:XM,FunctionReset:ZM});function Fue(e,t){var n=t.type,r=t.props,i=t.altKey,a;switch(n){case WM:a={isOpen:yM(r,`isOpen`),highlightedIndex:yM(r,`highlightedIndex`),selectedItem:r.items[t.index]};break;case NM:var o=t.key,s=``+e.inputValue+o;a={inputValue:s,highlightedIndex:jue({keysSoFar:s,highlightedIndex:!e.isOpen&&e.selectedItem?r.items.indexOf(e.selectedItem):e.highlightedIndex,items:r.items,itemToString:r.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex}),isOpen:!0};break;case jM:a={highlightedIndex:e.isOpen?oM(1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1):i&&e.selectedItem==null?-1:SM(r,e,1),isOpen:!0};break;case MM:a=e.isOpen&&i?OM(r,e.highlightedIndex,!1):{highlightedIndex:e.isOpen?oM(-1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1):SM(r,e,-1),isOpen:!0};break;case LM:case RM:a=OM(r,e.highlightedIndex,!1);break;case FM:a={highlightedIndex:sM(1,0,r.items.length,t.getItemNodeFromIndex,!1),isOpen:!0};break;case IM:a={highlightedIndex:sM(-1,r.items.length-1,r.items.length,t.getItemNodeFromIndex,!1),isOpen:!0};break;case zM:a={highlightedIndex:oM(-10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case BM:a={highlightedIndex:oM(10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case PM:a={isOpen:!1,highlightedIndex:-1};break;case VM:a=q({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&r.items?.length&&{selectedItem:r.items[e.highlightedIndex]});break;case YM:a={selectedItem:t.selectedItem};break;default:return kM(e,t,QM)}return q({},e,a)}var Iue=[`onMouseLeave`,`refKey`,`onKeyDown`,`onBlur`,`ref`],Lue=[`onBlur`,`onClick`,`onPress`,`onKeyDown`,`refKey`,`ref`],Rue=[`item`,`index`,`onMouseMove`,`onClick`,`onPress`,`refKey`,`ref`,`disabled`];$M.stateChangeTypes=QM;function $M(e){e===void 0&&(e={}),Pue(e,$M);var t=q({},Nue,e),n=t.items,r=t.scrollIntoView,i=t.environment,a=t.itemToString,o=t.getA11ySelectionMessage,s=t.getA11yStatusMessage,c=_M(Fue,xM(t),t),l=c[0],u=c[1],d=l.isOpen,f=l.highlightedIndex,p=l.selectedItem,m=l.inputValue,h=(0,R.useRef)(null),g=(0,R.useRef)(null),_=(0,R.useRef)({}),v=(0,R.useRef)(null),y=fM(t),b=(0,R.useRef)(),x=(0,R.useRef)(!0),S=hM({state:l,props:t}),C=(0,R.useCallback)(function(e){return _.current[y.getItemId(e)]},[y]);TM(s,[d,f,m,n],q({isInitialMount:x.current,previousResultCount:b.current,items:n,environment:i,itemToString:a},l)),TM(o,[p],q({isInitialMount:x.current,previousResultCount:b.current,items:n,environment:i,itemToString:a},l));var w=EM({menuElement:g.current,highlightedIndex:f,isOpen:d,itemRefs:_,scrollIntoView:r,getItemNodeFromIndex:C});(0,R.useEffect)(function(){return v.current=eM(function(e){e({type:XM,inputValue:``})},500),function(){v.current.cancel()}},[]),(0,R.useEffect)(function(){m&&v.current(u)},[u,m]),DM({isInitialMount:x.current,props:t,state:l}),(0,R.useEffect)(function(){x.current||(b.current=n.length)});var T=CM(d,[g,h],i,function(){u({type:VM})}),E=wM(`getMenuProps`,`getToggleButtonProps`);(0,R.useEffect)(function(){return x.current=!1,function(){x.current=!0}},[]),(0,R.useEffect)(function(){d||(_.current={})},[d]);var D=(0,R.useMemo)(function(){return{ArrowDown:function(e){e.preventDefault(),u({type:jM,getItemNodeFromIndex:C,altKey:e.altKey})},ArrowUp:function(e){e.preventDefault(),u({type:MM,getItemNodeFromIndex:C,altKey:e.altKey})},Home:function(e){e.preventDefault(),u({type:FM,getItemNodeFromIndex:C})},End:function(e){e.preventDefault(),u({type:IM,getItemNodeFromIndex:C})},Escape:function(){S.current.state.isOpen&&u({type:PM})},Enter:function(e){e.preventDefault(),u({type:S.current.state.isOpen?LM:AM})},PageUp:function(e){S.current.state.isOpen&&(e.preventDefault(),u({type:zM,getItemNodeFromIndex:C}))},PageDown:function(e){S.current.state.isOpen&&(e.preventDefault(),u({type:BM,getItemNodeFromIndex:C}))}," ":function(e){e.preventDefault();var t=S.current.state;if(!t.isOpen){u({type:AM});return}t.inputValue?u({type:NM,key:` `,getItemNodeFromIndex:C}):u({type:RM})}}},[u,C,S]),O=(0,R.useCallback)(function(){u({type:GM})},[u]),k=(0,R.useCallback)(function(){u({type:qM})},[u]),A=(0,R.useCallback)(function(){u({type:KM})},[u]),j=(0,R.useCallback)(function(e){u({type:JM,highlightedIndex:e})},[u]),M=(0,R.useCallback)(function(e){u({type:YM,selectedItem:e})},[u]),N=(0,R.useCallback)(function(){u({type:ZM})},[u]),P=(0,R.useCallback)(function(e){u({type:XM,inputValue:e})},[u]),F=(0,R.useCallback)(function(e){return q({id:y.labelId,htmlFor:y.toggleButtonId},e)},[y]),ee=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onMouseLeave,a=r.refKey,o=a===void 0?`ref`:a;r.onKeyDown,r.onBlur;var s=r.ref,c=qj(r,Iue),l=(t===void 0?{}:t).suppressRefError;return E(`getMenuProps`,l===void 0?!1:l,o,g),q((n={},n[o]=nM(s,function(e){g.current=e}),n.id=y.menuId,n.role=`listbox`,n[`aria-labelledby`]=c&&c[`aria-label`]?void 0:``+y.labelId,n.onMouseLeave=tM(i,function(){u({type:HM})}),n),c)},[u,E,y]);return{getToggleButtonProps:(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onBlur,a=r.onClick;r.onPress;var o=r.onKeyDown,s=r.refKey,c=s===void 0?`ref`:s,l=r.ref,d=qj(r,Lue),f=(t===void 0?{}:t).suppressRefError,p=f===void 0?!1:f,m=S.current.state,g=function(){u({type:AM})},_=function(){m.isOpen&&!T.current.isMouseDown&&u({type:VM})},v=function(e){var t=aM(e);t&&D[t]?D[t](e):Aue(t)&&u({type:NM,key:t,getItemNodeFromIndex:C})},b=q((n={},n[c]=nM(l,function(e){h.current=e}),n[`aria-activedescendant`]=m.isOpen&&m.highlightedIndex>-1?y.getItemId(m.highlightedIndex):``,n[`aria-controls`]=y.menuId,n[`aria-expanded`]=S.current.state.isOpen,n[`aria-haspopup`]=`listbox`,n[`aria-labelledby`]=d&&d[`aria-label`]?void 0:``+y.labelId,n.id=y.toggleButtonId,n.role=`combobox`,n.tabIndex=0,n.onBlur=tM(i,_),n),d);return d.disabled||(b.onClick=tM(a,g),b.onKeyDown=tM(o,v)),E(`getToggleButtonProps`,p,c,h),b},[S,y,E,u,T,D,C]),getLabelProps:F,getMenuProps:ee,getItemProps:(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.item,i=n.index,a=n.onMouseMove,o=n.onClick;n.onPress;var s=n.refKey,c=s===void 0?`ref`:s,l=n.ref,d=n.disabled,f=qj(n,Rue),m=S.current,h=m.state,g=m.props,v=pM(r,i,g.items,`Pass either item or index to getItemProps!`),b=v[0],x=v[1],C=function(){x!==h.highlightedIndex&&(w.current=!1,u({type:UM,index:x,disabled:d}))},T=function(){u({type:WM,index:x})},E=q((t={disabled:d,role:`option`,"aria-selected":``+(b===p),id:y.getItemId(x)},t[c]=nM(l,function(e){e&&(_.current[y.getItemId(x)]=e)}),t),f);return d||(E.onClick=tM(o,T)),E.onMouseMove=tM(a,C),E},[S,p,y,w,u]),toggleMenu:O,openMenu:A,closeMenu:k,setHighlightedIndex:j,selectItem:M,reset:N,setInputValue:P,highlightedIndex:f,isOpen:d,selectedItem:p,inputValue:m}}var eN=0,tN=1,nN=2,rN=3,iN=4,aN=5,oN=6,sN=7,cN=8,lN=9,uN=10,dN=11,fN=12,pN=13,mN=14,hN=15,gN=16,_N=17,vN=18,yN=19,bN=20,xN=21,SN=22,CN=Object.freeze({__proto__:null,InputKeyDownArrowDown:eN,InputKeyDownArrowUp:tN,InputKeyDownEscape:nN,InputKeyDownHome:rN,InputKeyDownEnd:iN,InputKeyDownPageUp:aN,InputKeyDownPageDown:oN,InputKeyDownEnter:sN,InputChange:cN,InputBlur:lN,InputFocus:uN,MenuMouseLeave:dN,ItemMouseMove:fN,ItemClick:pN,ToggleButtonClick:mN,FunctionToggleMenu:hN,FunctionOpenMenu:gN,FunctionCloseMenu:_N,FunctionSetHighlightedIndex:vN,FunctionSelectItem:yN,FunctionSetInputValue:bN,FunctionReset:xN,ControlledPropUpdatedSelectedItem:SN});function zue(e){var t=xM(e),n=t.selectedItem,r=t.inputValue;return r===``&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(r=e.itemToString(n)),q({},t,{inputValue:r})}J.default.array.isRequired,J.default.func,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.bool,J.default.bool,J.default.bool,J.default.any,J.default.any,J.default.any,J.default.string,J.default.string,J.default.string,J.default.string,J.default.string,J.default.string,J.default.func,J.default.string,J.default.string,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});function Bue(e,t,n){var r=(0,R.useRef)(),i=gM(e,t,n),a=i[0],o=i[1];return(0,R.useEffect)(function(){iM(n,`selectedItem`)&&(n.selectedItemChanged(r.current,n.selectedItem)&&o({type:SN,inputValue:n.itemToString(n.selectedItem)}),r.current=a.selectedItem===r.current?n.selectedItem:a.selectedItem)},[a.selectedItem,n.selectedItem]),[rM(a,n),o]}var Vue=Qj,Hue=q({},vM,{selectedItemChanged:function(e,t){return e!==t},getA11yStatusMessage:bue});function Uue(e,t){var n=t.type,r=t.props,i=t.altKey,a;switch(n){case pN:a={isOpen:yM(r,`isOpen`),highlightedIndex:yM(r,`highlightedIndex`),selectedItem:r.items[t.index],inputValue:r.itemToString(r.items[t.index])};break;case eN:a=e.isOpen?{highlightedIndex:oM(1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!0)}:{highlightedIndex:i&&e.selectedItem==null?-1:SM(r,e,1,t.getItemNodeFromIndex),isOpen:r.items.length>=0};break;case tN:a=e.isOpen?i?OM(r,e.highlightedIndex):{highlightedIndex:oM(-1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!0)}:{highlightedIndex:SM(r,e,-1,t.getItemNodeFromIndex),isOpen:r.items.length>=0};break;case sN:a=OM(r,e.highlightedIndex);break;case nN:a=q({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:``});break;case aN:a={highlightedIndex:oM(-10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case oN:a={highlightedIndex:oM(10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case rN:a={highlightedIndex:sM(1,0,r.items.length,t.getItemNodeFromIndex,!1)};break;case iN:a={highlightedIndex:sM(-1,r.items.length-1,r.items.length,t.getItemNodeFromIndex,!1)};break;case lN:a=q({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&r.items?.length&&t.selectItem&&{selectedItem:r.items[e.highlightedIndex],inputValue:r.itemToString(r.items[e.highlightedIndex])});break;case cN:a={isOpen:!0,highlightedIndex:yM(r,`highlightedIndex`),inputValue:t.inputValue};break;case uN:a={isOpen:!0,highlightedIndex:SM(r,e,0)};break;case yN:a={selectedItem:t.selectedItem,inputValue:r.itemToString(t.selectedItem)};break;case SN:a={inputValue:t.inputValue};break;default:return kM(e,t,CN)}return q({},e,a)}var Wue=[`onMouseLeave`,`refKey`,`ref`],Gue=[`item`,`index`,`refKey`,`ref`,`onMouseMove`,`onMouseDown`,`onClick`,`onPress`,`disabled`],Kue=[`onClick`,`onPress`,`refKey`,`ref`],que=[`onKeyDown`,`onChange`,`onInput`,`onFocus`,`onBlur`,`onChangeText`,`refKey`,`ref`];wN.stateChangeTypes=CN;function wN(e){e===void 0&&(e={}),Vue(e,wN);var t=q({},Hue,e),n=t.initialIsOpen,r=t.defaultIsOpen,i=t.items,a=t.scrollIntoView,o=t.environment,s=t.getA11yStatusMessage,c=t.getA11ySelectionMessage,l=t.itemToString,u=Bue(Uue,zue(t),t),d=u[0],f=u[1],p=d.isOpen,m=d.highlightedIndex,h=d.selectedItem,g=d.inputValue,_=(0,R.useRef)(null),v=(0,R.useRef)({}),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(!0),S=fM(t),C=(0,R.useRef)(),w=hM({state:d,props:t}),T=(0,R.useCallback)(function(e){return v.current[S.getItemId(e)]},[S]);TM(s,[p,m,g,i],q({isInitialMount:x.current,previousResultCount:C.current,items:i,environment:o,itemToString:l},d)),TM(c,[h],q({isInitialMount:x.current,previousResultCount:C.current,items:i,environment:o,itemToString:l},d));var E=EM({menuElement:_.current,highlightedIndex:m,isOpen:p,itemRefs:v,scrollIntoView:a,getItemNodeFromIndex:T});DM({isInitialMount:x.current,props:t,state:d}),(0,R.useEffect)(function(){(n||r||p)&&y.current&&y.current.focus()},[]),(0,R.useEffect)(function(){x.current||(C.current=i.length)});var D=CM(p,[y,_,b],o,function(){f({type:lN,selectItem:!1})}),O=wM(`getInputProps`,`getMenuProps`);(0,R.useEffect)(function(){return x.current=!1,function(){x.current=!0}},[]),(0,R.useEffect)(function(){if(!p)v.current={};else if(o.document?.activeElement!==y.current){var e;y==null||(e=y.current)==null||e.focus()}},[p,o]);var k=(0,R.useMemo)(function(){return{ArrowDown:function(e){e.preventDefault(),f({type:eN,altKey:e.altKey,getItemNodeFromIndex:T})},ArrowUp:function(e){e.preventDefault(),f({type:tN,altKey:e.altKey,getItemNodeFromIndex:T})},Home:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:rN,getItemNodeFromIndex:T}))},End:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:iN,getItemNodeFromIndex:T}))},Escape:function(e){var t=w.current.state;(t.isOpen||t.inputValue||t.selectedItem||t.highlightedIndex>-1)&&(e.preventDefault(),f({type:nN}))},Enter:function(e){!w.current.state.isOpen||e.which===229||(e.preventDefault(),f({type:sN,getItemNodeFromIndex:T}))},PageUp:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:aN,getItemNodeFromIndex:T}))},PageDown:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:oN,getItemNodeFromIndex:T}))}}},[f,w,T]),A=(0,R.useCallback)(function(e){return q({id:S.labelId,htmlFor:S.inputId},e)},[S]),j=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onMouseLeave,a=r.refKey,o=a===void 0?`ref`:a,s=r.ref,c=qj(r,Wue),l=(t===void 0?{}:t).suppressRefError;return O(`getMenuProps`,l===void 0?!1:l,o,_),q((n={},n[o]=nM(s,function(e){_.current=e}),n.id=S.menuId,n.role=`listbox`,n[`aria-labelledby`]=c&&c[`aria-label`]?void 0:``+S.labelId,n.onMouseLeave=tM(i,function(){f({type:dN})}),n),c)},[f,O,S]),M=(0,R.useCallback)(function(e){var t,n,r=e===void 0?{}:e,i=r.item,a=r.index,o=r.refKey,s=o===void 0?`ref`:o,c=r.ref,l=r.onMouseMove,u=r.onMouseDown,d=r.onClick;r.onPress;var p=r.disabled,m=qj(r,Gue),h=w.current,g=h.props,_=h.state,y=pM(i,a,g.items,`Pass either item or index to getItemProps!`)[1],b=`onClick`,x=d;return q((t={},t[s]=nM(c,function(e){e&&(v.current[S.getItemId(y)]=e)}),t.disabled=p,t.role=`option`,t[`aria-selected`]=``+(y===_.highlightedIndex),t.id=S.getItemId(y),t),!p&&(n={},n[b]=tM(x,function(){f({type:pN,index:y})}),n),{onMouseMove:tM(l,function(){y!==_.highlightedIndex&&(E.current=!1,f({type:fN,index:y,disabled:p}))}),onMouseDown:tM(u,function(e){return e.preventDefault()})},m)},[f,w,E,S]),N=(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.onClick;n.onPress;var i=n.refKey,a=i===void 0?`ref`:i,o=n.ref,s=qj(n,Kue),c=w.current.state;return q((t={},t[a]=nM(o,function(e){b.current=e}),t[`aria-controls`]=S.menuId,t[`aria-expanded`]=c.isOpen,t.id=S.toggleButtonId,t.tabIndex=-1,t),!s.disabled&&q({},{onClick:tM(r,function(){f({type:mN})})}),s)},[f,w,S]),P=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onKeyDown,a=r.onChange,s=r.onInput,c=r.onFocus,l=r.onBlur;r.onChangeText;var u=r.refKey,d=u===void 0?`ref`:u,p=r.ref,m=qj(r,que),h=(t===void 0?{}:t).suppressRefError;O(`getInputProps`,h===void 0?!1:h,d,y);var g=w.current.state,_=function(e){var t=aM(e);t&&k[t]&&k[t](e)},v=function(e){f({type:cN,inputValue:e.target.value})},b=function(e){g.isOpen&&!D.current.isMouseDown&&f({type:lN,selectItem:!(e.relatedTarget===null&&o.document.activeElement!==o.document.body)})},x=function(){g.isOpen||f({type:uN})},C=`onChange`,T={};if(!m.disabled){var E;T=(E={},E[C]=tM(a,s,v),E.onKeyDown=tM(i,_),E.onBlur=tM(l,b),E.onFocus=tM(c,x),E)}return q((n={},n[d]=nM(p,function(e){y.current=e}),n[`aria-activedescendant`]=g.isOpen&&g.highlightedIndex>-1?S.getItemId(g.highlightedIndex):``,n[`aria-autocomplete`]=`list`,n[`aria-controls`]=S.menuId,n[`aria-expanded`]=g.isOpen,n[`aria-labelledby`]=m&&m[`aria-label`]?void 0:``+S.labelId,n.autoComplete=`off`,n.id=S.inputId,n.role=`combobox`,n.value=g.inputValue,n),T,m)},[O,w,S,k,f,D,o]),F=(0,R.useCallback)(function(){f({type:hN})},[f]),ee=(0,R.useCallback)(function(){f({type:_N})},[f]),te=(0,R.useCallback)(function(){f({type:gN})},[f]),I=(0,R.useCallback)(function(e){f({type:vN,highlightedIndex:e})},[f]),ne=(0,R.useCallback)(function(e){f({type:yN,selectedItem:e})},[f]);return{getItemProps:M,getLabelProps:A,getMenuProps:j,getInputProps:P,getToggleButtonProps:N,toggleMenu:F,openMenu:te,closeMenu:ee,setHighlightedIndex:I,setInputValue:(0,R.useCallback)(function(e){f({type:bN,inputValue:e})},[f]),selectItem:ne,reset:(0,R.useCallback)(function(){f({type:xN})},[f]),highlightedIndex:m,isOpen:p,selectedItem:h,inputValue:g}}var TN={activeIndex:-1,selectedItems:[]};function EN(e,t){return bM(e,t,TN)}function DN(e,t){return yM(e,t,TN)}function Jue(e){return{activeIndex:EN(e,`activeIndex`),selectedItems:EN(e,`selectedItems`)}}function ON(e){if(e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return!1;var t=e.target;return!(t instanceof HTMLInputElement&&t.value!==``&&(t.selectionStart!==0||t.selectionEnd!==0))}function Yue(e){var t=e.removedSelectedItem,n=e.itemToString;return n(t)+` has been removed.`}J.default.array,J.default.array,J.default.array,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.func,J.default.func,J.default.string,J.default.string,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});var Xue={itemToString:vM.itemToString,stateReducer:vM.stateReducer,environment:vM.environment,getA11yRemovalMessage:Yue,keyNavigationNext:`ArrowRight`,keyNavigationPrevious:`ArrowLeft`},Zue=Qj,kN=0,AN=1,jN=2,MN=3,NN=4,PN=5,FN=6,IN=7,LN=8,RN=9,zN=10,BN=11,VN=12,Que=Object.freeze({__proto__:null,SelectedItemClick:kN,SelectedItemKeyDownDelete:AN,SelectedItemKeyDownBackspace:jN,SelectedItemKeyDownNavigationNext:MN,SelectedItemKeyDownNavigationPrevious:NN,DropdownKeyDownNavigationPrevious:PN,DropdownKeyDownBackspace:FN,DropdownClick:IN,FunctionAddSelectedItem:LN,FunctionRemoveSelectedItem:RN,FunctionSetSelectedItems:zN,FunctionSetActiveIndex:BN,FunctionReset:VN});function $ue(e,t){var n=t.type,r=t.index,i=t.props,a=t.selectedItem,o=e.activeIndex,s=e.selectedItems,c;switch(n){case kN:c={activeIndex:r};break;case NN:c={activeIndex:o-1<0?0:o-1};break;case MN:c={activeIndex:o+1>=s.length?-1:o+1};break;case jN:case AN:if(o<0)break;var l=o;s.length===1?l=-1:o===s.length-1&&(l=s.length-2),c=q({selectedItems:[].concat(s.slice(0,o),s.slice(o+1))},{activeIndex:l});break;case PN:c={activeIndex:s.length-1};break;case FN:c={selectedItems:s.slice(0,s.length-1)};break;case LN:c={selectedItems:[].concat(s,[a])};break;case IN:c={activeIndex:-1};break;case RN:var u=o,d=s.indexOf(a);if(d<0)break;s.length===1?u=-1:d===s.length-1&&(u=s.length-2),c={selectedItems:[].concat(s.slice(0,d),s.slice(d+1)),activeIndex:u};break;case zN:c={selectedItems:t.selectedItems};break;case BN:c={activeIndex:t.activeIndex};break;case VN:c={activeIndex:DN(i,`activeIndex`),selectedItems:DN(i,`selectedItems`)};break;default:throw Error(`Reducer called without proper action type.`)}return q({},e,c)}var ede=[`refKey`,`ref`,`onClick`,`onKeyDown`,`selectedItem`,`index`],tde=[`refKey`,`ref`,`onKeyDown`,`onClick`,`preventKeyAction`];HN.stateChangeTypes=Que;function HN(e){e===void 0&&(e={}),Zue(e,HN);var t=q({},Xue,e),n=t.getA11yRemovalMessage,r=t.itemToString,i=t.environment,a=t.keyNavigationNext,o=t.keyNavigationPrevious,s=_M($ue,Jue(t),t),c=s[0],l=s[1],u=c.activeIndex,d=c.selectedItems,f=(0,R.useRef)(!0),p=(0,R.useRef)(null),m=(0,R.useRef)(d),h=(0,R.useRef)();h.current=[];var g=hM({state:c,props:t});(0,R.useEffect)(function(){if(!f.current){if(d.length<m.current.length){var e=m.current.find(function(e){return d.indexOf(e)<0});lM(n({itemToString:r,resultCount:d.length,removedSelectedItem:e,activeIndex:u,activeSelectedItem:d[u]}),i.document)}m.current=d}},[d.length]),(0,R.useEffect)(function(){f.current||(u===-1&&p.current?p.current.focus():h.current[u]&&h.current[u].focus())},[u]),DM({isInitialMount:f.current,props:t,state:c});var _=wM(`getDropdownProps`);(0,R.useEffect)(function(){return f.current=!1,function(){f.current=!0}},[]);var v=(0,R.useMemo)(function(){var e;return e={},e[o]=function(){l({type:NN})},e[a]=function(){l({type:MN})},e.Delete=function(){l({type:AN})},e.Backspace=function(){l({type:jN})},e},[l,a,o]),y=(0,R.useMemo)(function(){var e;return e={},e[o]=function(e){ON(e)&&l({type:PN})},e.Backspace=function(e){ON(e)&&l({type:FN})},e},[l,o]);return{getSelectedItemProps:(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.refKey,i=r===void 0?`ref`:r,a=n.ref,o=n.onClick,s=n.onKeyDown,c=n.selectedItem,u=n.index,d=qj(n,ede),f=g.current.state,p=pM(c,u,f.selectedItems,`Pass either item or index to getSelectedItemProps!`)[1],m=p>-1&&p===f.activeIndex;return q((t={},t[i]=nM(a,function(e){e&&h.current.push(e)}),t.tabIndex=m?0:-1,t.onClick=tM(o,function(){l({type:kN,index:p})}),t.onKeyDown=tM(s,function(e){var t=aM(e);t&&v[t]&&v[t](e)}),t),d)},[l,g,v]),getDropdownProps:(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.refKey,a=i===void 0?`ref`:i,o=r.ref,s=r.onKeyDown,c=r.onClick,u=r.preventKeyAction,d=u===void 0?!1:u,f=qj(r,tde),m=(t===void 0?{}:t).suppressRefError;return _(`getDropdownProps`,m===void 0?!1:m,a,p),q((n={},n[a]=nM(o,function(e){e&&(p.current=e)}),n),!d&&{onKeyDown:tM(s,function(e){var t=aM(e);t&&y[t]&&y[t](e)}),onClick:tM(c,function(){l({type:IN})})},f)},[l,y,_]),addSelectedItem:(0,R.useCallback)(function(e){l({type:LN,selectedItem:e})},[l]),removeSelectedItem:(0,R.useCallback)(function(e){l({type:RN,selectedItem:e})},[l]),setSelectedItems:(0,R.useCallback)(function(e){l({type:zN,selectedItems:e})},[l]),setActiveIndex:(0,R.useCallback)(function(e){l({type:BN,activeIndex:e})},[l]),reset:(0,R.useCallback)(function(){l({type:VN})},[l]),selectedItems:d,activeIndex:u}}var UN=20,nde=e=>e.suggestions.length>0?R.createElement(rde,{...e}):R.createElement(`input`,{className:mw.textInput,size:40,autoFocus:!0,...e.register(e.inputName)}),rde=({autofocus:e,suggestions:t,control:n,inputName:r,placeholder:i,initialInputValue:a,setValue:o})=>{let[s,c]=R.useState(t.slice(0,UN)),l=Vl(NC),u=t.length>0,{isOpen:d,getToggleButtonProps:f,getMenuProps:p,getInputProps:m,highlightedIndex:h,getItemProps:g,selectedItem:_}=wN({initialInputValue:a,onInputValueChange({inputValue:e=``}){o(r,e),e=e.toLowerCase()||``;let n=[];for(let r of t)if(r.toLowerCase().includes(e)&&(n.push(r),n.length>=UN))break;c(n)},items:s,itemToString(e){return e??``}}),v=d&&s.length>0;return R.createElement(`div`,{className:mw.downshiftAutocompleteContainer},R.createElement(`div`,{"data-visible-dropdown":v,className:mw.downshiftInputWrapper},R.createElement(Gle,{name:r,control:n,render:({field:t})=>{let n=m();return R.createElement(`input`,{...n,name:t.name,placeholder:i,className:mw.downshiftInput,size:30,"data-editor-dialog":!0,autoFocus:e})}}),u&&R.createElement(`button`,{"aria-label":`toggle menu`,type:`button`,...f()},l(`arrow_drop_down`))),R.createElement(`div`,{className:mw.downshiftAutocompleteContainer},R.createElement(`ul`,{...p(),"data-visible":v},s.map((e,t)=>R.createElement(`li`,{"data-selected":_===e,"data-highlighted":h===t,key:`${e}${t}`,...g({item:e,index:t})},e)))))};function ide(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}var ade={testNode:`blockquote`,visitNode({actions:e}){e.addAndStepInto(wv())}},ode={testLexicalNode:Tv,visitLexicalNode:({actions:e})=>{e.addAndStepInto(`blockquote`)}},sde=Xl({init(e){e.pubIn({[ew]:`quote`,[yC]:ade,[vC]:Cv,[SC]:ode})}});function WN(){let e=Yl;return{publish:()=>{e()},subscribe:t=>{e=t}}}var cde=Object.defineProperty,lde=(e,t,n)=>t in e?cde(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,GN=(e,t,n)=>(lde(e,typeof t==`symbol`?t:t+``,n),n),KN=class e extends Wm{constructor(e,t,n,r){super(r),GN(this,`__code`),GN(this,`__meta`),GN(this,`__language`),GN(this,`__focusEmitter`,WN()),GN(this,`setCode`,e=>{e!==this.__code&&(this.getWritable().__code=e)}),GN(this,`setMeta`,e=>{e!==this.__meta&&(this.getWritable().__meta=e)}),GN(this,`setLanguage`,e=>{e!==this.__language&&(this.getWritable().__language=e)}),GN(this,`select`,()=>{this.__focusEmitter.publish()}),this.__code=e,this.__meta=n,this.__language=t}static getType(){return`codeblock`}static clone(t){return new e(t.__code,t.__language,t.__meta,t.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__code=e.__code,this.__meta=e.__meta,this.__language=e.__language,this.__focusEmitter=WN()}static importJSON(e){let{code:t,meta:n,language:r}=e;return YN({code:t,language:r,meta:n})}static importDOM(){return{pre:()=>({conversion:pde,priority:3})}}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:`codeblock`,version:1}}createDOM(e,t){return document.createElement(`div`)}updateDOM(){return!1}getCode(){return this.__code}getMeta(){return this.__meta}getLanguage(){return this.__language}decorate(e){return R.createElement(dde,{parentEditor:e,code:this.getCode(),meta:this.getMeta(),language:this.getLanguage(),codeBlockNode:this,nodeKey:this.getKey(),focusEmitter:this.__focusEmitter})}isInline(){return!1}},qN=R.createContext(null),ude=({parentEditor:e,lexicalNode:t,children:n})=>{let r=R.useMemo(()=>({lexicalNode:t,parentEditor:e,setCode:n=>{e.update(()=>{t.setCode(n),setTimeout(()=>{e.dispatchCommand(zS,void 0)},0)})},setLanguage:n=>{e.update(()=>{t.setLanguage(n)})},setMeta:n=>{e.update(()=>{t.setMeta(n)})}}),[t,e]);return R.createElement(qN.Provider,{value:r},n)};function JN(){let e=R.useContext(qN);if(!e)throw Error(`useCodeBlockEditor must be used within a CodeBlockEditor`);return e}var dde=e=>{let t=Vl(mC),n=Vl(XN),r=t.sort((e,t)=>t.priority-e.priority).find(t=>t.match(e.language||``,e.meta||``));if(r??=t.find(t=>t.match(n||``,e.meta||``)),!r)throw Error(`No CodeBlockEditor registered for language=${e.language} meta=${e.meta}`);let i=r.Editor,{codeBlockNode:a,parentEditor:o,...s}=e;return R.createElement(ude,{parentEditor:e.parentEditor,lexicalNode:e.codeBlockNode},R.createElement(i,{...s}))};function YN(e){let{code:t=``,language:n=``,meta:r=``}=e;return new KN(t,n,r)}function fde(e){return e instanceof KN}function pde(e){let t=e,n=t.textContent,r=e.getAttribute(`class`)??``,i=e.getAttribute(`data-language`)??``,a=/language-(\w+)/.exec(r);return{node:YN({code:n,language:a?a[1]:i,meta:t.getAttribute(`data-meta`)??``})}}var mde={testLexicalNode:fde,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto(`code`,{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}},hde={testNode:(e,{codeBlockEditorDescriptors:t})=>e.type===`code`?t.find(t=>t.match(e.lang,e.meta))!==void 0:!1,visitNode({mdastNode:e,actions:t}){t.addAndStepInto(YN({code:e.value,language:e.lang??``,meta:e.meta??``}))}},XN=Il(``),ZN=Ll(e=>{e.link(e.pipe(ZN,Gl(XN),Wl(([e,t])=>()=>YN({language:t,...e}))),XC)}),gde=PC(mC),_de=Xl({update(e,t){e.pub(XN,t?.defaultCodeBlockLanguage??``)},init(e,t){e.pubIn({[ew]:`codeblock`,[mC]:t?.codeBlockEditorDescriptors??[],[yC]:hde,[vC]:KN,[SC]:mde})}}),vde=`modulepreload`,yde=function(e){return`/apps/chat/`+e},QN={},Y=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=yde(t,n),t in QN)return;QN[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:vde,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},$N=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ae(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(iP(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function eP(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function bde(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=eP(t)+eP(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function tP(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:bde(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function xde(e,t){return n=>{for(let t=ae(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var nP=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function rP(e){return e.selection.main.from}function iP(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var aP=he.define();function Sde(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:k.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var oP=new WeakMap;function Cde(e){if(!Array.isArray(e))return e;let t=oP.get(e);return t||oP.set(e,t=tP(e)),t}var sP=w.define(),cP=w.define(),wde=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=se(e,t),r=a(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(se(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(t.length==1){let r=se(e,0),i=a(r),o=i==e.length?0:-100;if(r!=t[0])if(r==n[0])o+=-200;else return null;return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<c;){let o=se(e,i);(o==t[l]||o==n[l])&&(r[l++]=i),i+=a(o)}if(l<c)return null}let u=0,d=0,f=!1,p=0,m=-1,h=-1,g=/[a-z]/.test(e),_=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&d<c;){let l=se(e,r);s<0&&(u<c&&l==t[u]&&(i[u++]=r),p<c&&(l==t[p]||l==n[p]?(p==0&&(m=r),h=r+1,p++):p=0));let b,x=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(b=y(l))==b.toLowerCase()?b==b.toUpperCase()?0:2:1;(!r||x==1&&g||v==0&&x!=0)&&(t[d]==l||n[d]==l&&(f=!0)?o[d++]=r:o.length&&(_=!1)),v=x,r+=a(l)}return d==c&&o[0]==0&&_?this.result(-100+(f?-200:0),o,e):p==c&&m==0?this.ret(-200-e.length+(h==e.length?0:-100),[0,h]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):p==c?this.ret(-900-e.length,[m,h]):d==c?this.result(-100+(f?-200:0)+-700+(_?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?a(se(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Tde=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},lP=Oe.define({combine(e){return oe(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ede,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>uP(e(n),t(n)),optionClass:(e,t)=>n=>uP(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function uP(e,t){return e?t?e+` `+t:e:t}function Ede(e,t,n,r,i,a){let o=e.textDirection==u.RTL,s=o,c=!1,l=`top`,d,f,p=t.left-i.left,m=i.right-t.right,h=r.right-r.left,g=r.bottom-r.top;if(s&&p<Math.min(h,m)?s=!1:!s&&m<Math.min(h,p)&&(s=!0),h<=(s?p:m))d=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,f=Math.min(400,s?p:m);else{c=!0,f=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=g||e>t.top?d=n.bottom-t.top:(l=`bottom`,d=t.bottom-n.top)}let _=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${d/_}px; max-width: ${f/v}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var dP=w.define();function Dde(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function fP(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var Ode=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(lP);this.optionContent=Dde(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fP(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:dP.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(lP).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:cP.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=fP(r.length,i,e.state.facet(lP).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fP(t.options.length,t.selected,this.view.state.facet(lP).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>me(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Ade(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(lP).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function kde(e,t){return n=>new Ode(n,e,t)}function Ade(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function pP(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function jde(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(lP);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new nP(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Tde(n):new wde(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new nP(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):pP(e.completion)>pP(c)&&(s[s.length-1]=e),c=e.completion}return s}var Mde=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,mP(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=jde(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(lP).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,mP(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:zde,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Nde=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Lde,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(lP),i=(r.override||n.languageDataAt(`autocomplete`,rP(n)).map(Cde)).map(e=>(this.active.find(t=>t.source==e)||new gP(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(vP));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Pde(i,this.active)||o?a=Mde.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new gP(e.source,0):e));for(let e of t.effects)e.is(dP)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fde:Ide}};function Pde(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var Fde={"aria-autocomplete":`list`},Ide={};function mP(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Lde=[];function hP(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(aP);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var gP=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=hP(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(sP))i=new e(i.source,1,n.value);else if(n.is(cP))i=new e(i.source,0);else if(n.is(vP))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(rP(e.state))}},_P=class e extends gP{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=rP(t.state);if(o>a||!r||n&2&&(rP(t.startState)==this.from||o<this.limit))return new gP(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Rde(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new $N(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??rP(t.state)):new gP(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new gP(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Rde(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):iP(e,!0).test(i)}var vP=w.define({map(e,t){return e.map(e=>e.map(t))}}),yP=l.define({create(){return Nde.start()},update(e,t){return e.update(t)},provide:e=>[F.from(e,e=>e.tooltip),f.contentAttributes.from(e,e=>e.attrs)]});function bP(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(yP).active.find(e=>e.source==t.source);return r instanceof _P?(typeof n==`string`?e.dispatch({...Sde(e.state,n,r.from,r.to),annotations:aP.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var zde=kde(yP,bP);function xP(e,t=`option`){return n=>{let i=n.state.field(yP,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(lP).interactionDelay)return!1;let a=1,o;t==`page`&&(o=r(n,i.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector(`li`).offsetHeight)-1));let{length:s}=i.open.options,c=i.open.selected>-1?i.open.selected+a*(e?1:-1):e?0:s-1;return c<0?c=t==`page`?0:s-1:c>=s&&(c=t==`page`?s-1:0),n.dispatch({effects:dP.of(c)}),!0}}var Bde=e=>{let t=e.state.field(yP,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(lP).interactionDelay?!1:bP(e,t.open.options[t.open.selected])},SP=e=>e.state.field(yP,!1)?(e.dispatch({effects:sP.of(!0)}),!0):!1,Vde=e=>{let t=e.state.field(yP,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:cP.of(null)}),!0)},Hde=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Ude=50,Wde=1e3,Gde=ge.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(yP).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(yP),n=e.state.facet(lP);if(!e.selectionSet&&!e.docChanged&&e.startState.field(yP)==t)return;let r=e.transactions.some(e=>{let t=hP(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>Ude&&Date.now()-n.time>Wde){for(let e of n.context.abortListeners)try{e()}catch(e){me(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(sP)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(yP);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(lP).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new $N(t,rP(t),e.explicit,this.view),r=new Hde(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:cP.of(null)}),me(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(lP).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(lP),n=this.view.state.field(yP);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=rP(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new _P(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new gP(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:vP.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(yP,!1);if(t&&t.tooltip&&this.view.state.facet(lP).closeOnBlur){let n=t.open&&r(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:cP.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:sP.of(!1)}),20),this.composing=0}}}),Kde=typeof navigator==`object`&&/Win/.test(navigator.platform),qde=De.highest(f.domEventHandlers({keydown(e,t){let n=t.state.field(yP,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Kde&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&bP(t,r),!1}})),CP=f.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Jde=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Yde=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,M.TrackDel),r=t.mapPos(this.to,1,M.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Xde=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(c);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new Yde(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Jde(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},Zde=T.widget({widget:new class extends d{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Qde=T.mark({class:`cm-snippetField`}),wP=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=T.set(e.map(e=>(e.from==e.to?Zde:Qde).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},TP=w.define({map(e,t){return e&&e.map(t)}}),$de=w.define(),EP=l.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(TP))return n.value;if(n.is($de)&&e)return new wP(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>f.decorations.from(e,e=>e?e.deco:T.none)});function DP(e,t){return k.create(e.filter(e=>e.field==t).map(e=>k.range(e.from,e.to)))}function efe(e){let t=Xde.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:c}=e.state.selection,l={changes:{from:r,to:i==c.from?c.to:i,insert:s.of(a)},scrollIntoView:!0,annotations:n?[aP.of(n),_.userEvent.of(`input.complete`)]:void 0};if(o.length&&(l.selection=DP(o,0)),o.some(e=>e.field>0)){let t=new wP(o,0),n=l.effects=[TP.of(t)];e.state.field(EP,!1)===void 0&&n.push(w.appendConfig.of([EP,nfe,ife,CP]))}e.dispatch(e.state.update(l))}}function OP(e){return({state:t,dispatch:n})=>{let r=t.field(EP,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:DP(r.ranges,i),effects:TP.of(a?null:new wP(r.ranges,i)),scrollIntoView:!0})),!0}}var tfe=[{key:`Tab`,run:OP(1),shift:OP(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(EP,!1)?(t(e.update({effects:TP.of(null)})),!0):!1}],kP=Oe.define({combine(e){return e.length?e[0]:tfe}}),nfe=De.highest(ie.compute([kP],e=>e.facet(kP)));function rfe(e,t){return{...t,apply:efe(e)}}var ife=f.domEventHandlers({mousedown(e,t){let n=t.state.field(EP,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:DP(n.ranges,i.field),effects:TP.of(n.ranges.some(e=>e.field>i.field)?new wP(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),AP={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},jP=w.define({map(e,t){return t.mapPos(e,-1,M.TrackAfter)??void 0}}),MP=new class extends Te{};MP.startSide=1,MP.endSide=-1;var NP=l.define({create(){return S.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(jP)&&(e=e.update({add:[MP.range(n.value,n.value+1)]}));return e}});function afe(){return[sfe,NP]}var PP=`()[]{}<>«»»«[]{}`;function FP(e){for(let t=0;t<16;t+=2)if(PP.charCodeAt(t)==e)return PP.charAt(t+1);return y(e<128?e:e+1)}function IP(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||AP}var ofe=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),sfe=f.inputHandler.of((e,t,n,r)=>{if((ofe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&a(se(r,0))==1||t!=i.from||n!=i.to)return!1;let o=lfe(e.state,r);return o?(e.dispatch(o),!0):!1}),cfe=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=IP(e,e.selection.main.head).brackets||AP.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=ufe(e.doc,t.head);for(let i of n)if(i==r&&RP(e.doc,t.head)==FP(se(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:k.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function lfe(e,t){let n=IP(e,e.selection.main.head),r=n.brackets||AP.brackets;for(let i of r){let a=FP(se(i,0));if(t==i)return a==i?pfe(e,i,r.indexOf(i+i+i)>-1,n):dfe(e,i,a,n.before||AP.before);if(t==a&&LP(e,e.selection.main.from))return ffe(e,i,a)}return null}function LP(e,t){let n=!1;return e.field(NP).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function RP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,a(se(n,0)))}function ufe(e,t){let n=e.sliceString(t-2,t);return a(se(n,0))==n.length?n:n.slice(1)}function dfe(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:jP.of(a.to+t.length),range:k.range(a.anchor+t.length,a.head+t.length)};let o=RP(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:jP.of(a.head+t.length),range:k.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function ffe(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&RP(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:k.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function pfe(e,t,n,r){let i=r.stringPrefixes||AP.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:jP.of(r.to+t.length),range:k.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=RP(e.doc,o),c;if(s==t){if(zP(e,o))return{changes:{insert:t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};if(LP(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:k.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=BP(e,o-2*t.length,i))>-1&&zP(e,c))return{changes:{insert:t+t+t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=L.Word&&BP(e,o,i)>-1&&!mfe(e,o,t,i))return{changes:{insert:t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function zP(e,t){let n=ae(e).resolveInner(t+1);return n.parent&&n.from==t}function mfe(e,t,n,r){let i=ae(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function BP(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=L.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=L.Word)return n}return-1}function hfe(e={}){return[qde,yP,lP.of(e),Gde,gfe,CP]}var VP=[{key:`Ctrl-Space`,run:SP},{mac:"Alt-`",run:SP},{mac:`Alt-i`,run:SP},{key:`Escape`,run:Vde},{key:`ArrowDown`,run:xP(!0)},{key:`ArrowUp`,run:xP(!1)},{key:`PageDown`,run:xP(!0,`page`)},{key:`PageUp`,run:xP(!1,`page`)},{key:`Enter`,run:Bde}],gfe=De.highest(ie.computeN([lP],e=>e.facet(lP).defaultKeymap?[VP]:[])),_fe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=UP(e.state,n.from);return r.line?vfe(e):r.block?bfe(e):!1};function HP(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var vfe=HP(Cfe,0),yfe=HP(GP,0),bfe=HP((e,t)=>GP(e,t,Sfe(t)),0);function UP(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var WP=50;function xfe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-WP,r),o=e.sliceDoc(i,i+WP),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*WP?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+WP),d=e.sliceDoc(i-WP,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Sfe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function GP(e,t,n=t.selection.ranges){let r=n.map(e=>UP(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xfe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Cfe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=UP(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var KP=he.define(),wfe=he.define(),Tfe=Oe.define(),qP=Oe.define({combine(e){return oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),JP=l.define({create(){return aF.empty},update(e,t){let n=t.state.facet(qP),r=t.annotation(KP);if(r){let i=$P.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?eF(o,o.length,n.minDepth,i):rF(o,t.startState.selection),new aF(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(wfe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(_.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=$P.fromTransaction(t),o=t.annotation(_.time),s=t.annotation(_.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new aF(e.done.map($P.fromJSON),e.undone.map($P.fromJSON))}});function YP(e={}){return[JP,qP.of(e),f.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ZP:e.inputType==`historyRedo`?QP:null;return n?(e.preventDefault(),n(t)):!1}})]}function XP(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(JP,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ZP=XP(0,!1),QP=XP(1,!1),Efe=XP(0,!0),Dfe=XP(1,!0),$P=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&re.fromJSON(t.changes),[],t.mapped&&ue.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,n){let r=nF;for(let e of t.startState.facet(Tfe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,nF)}static selection(t){return new e(void 0,nF,void 0,void 0,t)}};function eF(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Ofe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function kfe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function tF(e,t){return e.length?t.length?e.concat(t):e:t}var nF=[],Afe=200;function rF(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Afe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),eF(e,e.length-1,1e9,n.setSelAfter(r)))}else return[$P.selection([t])]}function jfe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function iF(e,t){if(!e.length)return e;let n=e.length,r=nF;for(;n;){let i=Mfe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[$P.selection(r)]:nF}function Mfe(e,t,n){let r=tF(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):nF,n);if(!e.changes)return $P.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new $P(i,w.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Nfe=/^(input\.type|delete)($|\.)/,aF=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Nfe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Ofe(s.changes,t.changes))||r==`input.type.compose`)?eF(o,o.length-1,i.minDepth,new $P(t.changes.compose(s.changes),tF(w.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,nF)):eF(o,o.length,i.minDepth,t),new e(o,nF,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:nF;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kfe(a[a.length-1],t)?this:new e(rF(this.done,t),this.undone,n,r)}addMapping(t){return new e(iF(this.done,t),iF(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:KP.of({side:e,rest:jfe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?nF:r.slice(0,r.length-1);return i.mapped&&(n=iF(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:KP.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};aF.empty=new aF(nF,nF);var oF=[{key:`Mod-z`,run:ZP,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:QP,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:QP,preventDefault:!0},{key:`Mod-u`,run:Efe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Dfe,preventDefault:!0}];function sF(e,t){return k.create(e.ranges.map(t),e.mainIndex)}function cF(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function lF({state:e,dispatch:t},n){let r=sF(e.selection,n);return r.eq(e.selection,!0)?!1:(t(cF(e,r)),!0)}function uF(e,t){return k.cursor(t?e.to:e.from)}function dF(e,t){return lF(e,n=>n.empty?e.moveByChar(n,t):uF(n,t))}function fF(e){return e.textDirectionAt(e.state.selection.main.head)==u.LTR}var pF=e=>dF(e,!fF(e)),mF=e=>dF(e,fF(e));function hF(e,t){return lF(e,n=>n.empty?e.moveByGroup(n,t):uF(n,t))}var Pfe=e=>hF(e,!fF(e)),Ffe=e=>hF(e,fF(e));typeof Intl<`u`&&Intl.Segmenter;function Ife(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function gF(e,t,n){let r=ae(e).resolveInner(t.head),i=n?p.closedBy:p.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ife(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?g(e,r.from,1):g(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,k.cursor(s,n?-1:1)}var Lfe=e=>lF(e,t=>gF(e.state,t,!fF(e))),Rfe=e=>lF(e,t=>gF(e.state,t,fF(e)));function _F(e,t){return lF(e,n=>{if(!n.empty)return uF(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var vF=e=>_F(e,!1),yF=e=>_F(e,!0);function bF(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(f.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function xF(e,t){let n=bF(e),{state:r}=e,i=sF(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):uF(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=f.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(cF(r,i),{effects:a}),!0}var SF=e=>xF(e,!1),CF=e=>xF(e,!0);function wF(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=k.cursor(r.from+n))}return i}var zfe=e=>lF(e,t=>wF(e,t,!0)),Bfe=e=>lF(e,t=>wF(e,t,!1)),Vfe=e=>lF(e,t=>wF(e,t,!fF(e))),Hfe=e=>lF(e,t=>wF(e,t,fF(e))),Ufe=e=>lF(e,t=>k.cursor(e.lineBlockAt(t.head).from,1)),Wfe=e=>lF(e,t=>k.cursor(e.lineBlockAt(t.head).to,-1));function Gfe(e,t,n){let r=!1,i=sF(e.selection,t=>{let i=g(e,t.head,-1)||g(e,t.head,1)||t.head>0&&g(e,t.head-1,1)||t.head<e.doc.length&&g(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?k.range(t.anchor,a):k.cursor(a)});return r?(t(cF(e,i)),!0):!1}var Kfe=({state:e,dispatch:t})=>Gfe(e,t,!1);function TF(e,t){let n=sF(e.state.selection,e=>{let n=t(e);return k.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(cF(e.state,n)),!0)}function EF(e,t){return TF(e,n=>e.moveByChar(n,t))}var DF=e=>EF(e,!fF(e)),OF=e=>EF(e,fF(e));function kF(e,t){return TF(e,n=>e.moveByGroup(n,t))}var qfe=e=>kF(e,!fF(e)),Jfe=e=>kF(e,fF(e)),Yfe=e=>TF(e,t=>gF(e.state,t,!fF(e))),Xfe=e=>TF(e,t=>gF(e.state,t,fF(e)));function AF(e,t){return TF(e,n=>e.moveVertically(n,t))}var jF=e=>AF(e,!1),MF=e=>AF(e,!0);function NF(e,t){return TF(e,n=>e.moveVertically(n,t,bF(e).height))}var PF=e=>NF(e,!1),FF=e=>NF(e,!0),Zfe=e=>TF(e,t=>wF(e,t,!0)),Qfe=e=>TF(e,t=>wF(e,t,!1)),$fe=e=>TF(e,t=>wF(e,t,!fF(e))),epe=e=>TF(e,t=>wF(e,t,fF(e))),tpe=e=>TF(e,t=>k.cursor(e.lineBlockAt(t.head).from)),npe=e=>TF(e,t=>k.cursor(e.lineBlockAt(t.head).to)),IF=({state:e,dispatch:t})=>(t(cF(e,{anchor:0})),!0),LF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.doc.length})),!0),RF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.selection.main.anchor,head:0})),!0),zF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),rpe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ipe=({state:e,dispatch:t})=>{let n=JF(e).map(({from:t,to:n})=>k.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:k.create(n),userEvent:`select`})),!0},ape=({state:e,dispatch:t})=>{let n=sF(e.selection,t=>{let n=ae(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return k.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(cF(e,n)),!0)};function BF(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(cF(n,k.create(i,i.length-1))),!0)}var ope=e=>BF(e,!1),spe=e=>BF(e,!0),cpe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=k.create([n.main]):n.main.empty||(r=k.create([k.cursor(n.main.head)])),r?(t(cF(e,r)),!0):!1};function VF(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=HF(e,o,!1)):o>i&&(n=`delete.forward`,o=HF(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=HF(e,i,!1),a=HF(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:k.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?f.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function HF(e,t,n){if(e instanceof f)for(let r of e.state.facet(f.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var UF=(e,t,n)=>VF(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=m(s,a.tabSize)%Ee(a)||Ee(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=h(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=h(o.text,c-o.from,!1,!1)+o.from);return c}),WF=e=>UF(e,!1,!0),GF=e=>UF(e,!0,!1),KF=(e,t)=>VF(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=h(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),qF=e=>KF(e,!1),lpe=e=>KF(e,!0),upe=e=>VF(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),dpe=e=>VF(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),fpe=e=>VF(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),ppe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:s.of([``,``])},range:k.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},mpe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:h(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:h(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:k.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function JF(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function YF(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of JF(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(k.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(k.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:k.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var hpe=({state:e,dispatch:t})=>YF(e,t,!1),gpe=({state:e,dispatch:t})=>YF(e,t,!0);function XF(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of JF(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var _pe=({state:e,dispatch:t})=>XF(e,t,!1),vpe=({state:e,dispatch:t})=>XF(e,t,!0),ype=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(JF(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=sF(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function bpe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=ae(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(p.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var ZF=QF(!1),xpe=QF(!0);function QF(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&bpe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let c=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),l=x(c,r);for(l??=m(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let u=[``,C(t,l)];return o&&u.push(C(t,c.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:s.of(u)},range:k.cursor(r+1+u[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function $F(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:k.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Spe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=$F(e,(t,i,a)=>{let o=x(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=C(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},eI=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($F(e,(t,n)=>{n.push({from:t.from,insert:e.facet(c)})}),{userEvent:`input.indent`})),!0),tI=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($F(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=m(r,e.tabSize),a=0,o=C(e,Math.max(0,i-Ee(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Cpe=e=>(e.setTabFocusMode(),!0),wpe=[{key:`Ctrl-b`,run:pF,shift:DF,preventDefault:!0},{key:`Ctrl-f`,run:mF,shift:OF},{key:`Ctrl-p`,run:vF,shift:jF},{key:`Ctrl-n`,run:yF,shift:MF},{key:`Ctrl-a`,run:Ufe,shift:tpe},{key:`Ctrl-e`,run:Wfe,shift:npe},{key:`Ctrl-d`,run:GF},{key:`Ctrl-h`,run:WF},{key:`Ctrl-k`,run:upe},{key:`Ctrl-Alt-h`,run:qF},{key:`Ctrl-o`,run:ppe},{key:`Ctrl-t`,run:mpe},{key:`Ctrl-v`,run:CF}],Tpe=[{key:`ArrowLeft`,run:pF,shift:DF,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Pfe,shift:qfe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Vfe,shift:$fe,preventDefault:!0},{key:`ArrowRight`,run:mF,shift:OF,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ffe,shift:Jfe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Hfe,shift:epe,preventDefault:!0},{key:`ArrowUp`,run:vF,shift:jF,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:IF,shift:RF},{mac:`Ctrl-ArrowUp`,run:SF,shift:PF},{key:`ArrowDown`,run:yF,shift:MF,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:LF,shift:zF},{mac:`Ctrl-ArrowDown`,run:CF,shift:FF},{key:`PageUp`,run:SF,shift:PF},{key:`PageDown`,run:CF,shift:FF},{key:`Home`,run:Bfe,shift:Qfe,preventDefault:!0},{key:`Mod-Home`,run:IF,shift:RF},{key:`End`,run:zfe,shift:Zfe,preventDefault:!0},{key:`Mod-End`,run:LF,shift:zF},{key:`Enter`,run:ZF,shift:ZF},{key:`Mod-a`,run:rpe},{key:`Backspace`,run:WF,shift:WF,preventDefault:!0},{key:`Delete`,run:GF,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:qF,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:lpe,preventDefault:!0},{mac:`Mod-Backspace`,run:dpe,preventDefault:!0},{mac:`Mod-Delete`,run:fpe,preventDefault:!0}].concat(wpe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),nI=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Lfe,shift:Yfe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Rfe,shift:Xfe},{key:`Alt-ArrowUp`,run:hpe},{key:`Shift-Alt-ArrowUp`,run:_pe},{key:`Alt-ArrowDown`,run:gpe},{key:`Shift-Alt-ArrowDown`,run:vpe},{key:`Mod-Alt-ArrowUp`,run:ope},{key:`Mod-Alt-ArrowDown`,run:spe},{key:`Escape`,run:cpe},{key:`Mod-Enter`,run:xpe},{key:`Alt-l`,mac:`Ctrl-l`,run:ipe},{key:`Mod-i`,run:ape,preventDefault:!0},{key:`Mod-[`,run:tI},{key:`Mod-]`,run:eI},{key:`Mod-Alt-\\`,run:Spe},{key:`Shift-Mod-k`,run:ype},{key:`Shift-Mod-\\`,run:Kfe},{key:`Mod-/`,run:_fe},{key:`Alt-A`,run:yfe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Cpe}].concat(Tpe),Epe={key:`Tab`,run:eI,shift:tI};function Dpe(e,t,n,r){let i=Vl(VS),a=Ul(jC),o=R.useRef(null),{lexicalNode:s}=JN(),c=R.useRef(!1),l=R.useRef(!1),u=R.useCallback(()=>{a({editorType:t,rootNode:s,editorRef:o.current})},[t,s,a]),d=R.useCallback(t=>{if(t.key===`ArrowDown`){let t=o.current?.getCodemirror()?.state;t&&t.doc.length===t.selection.ranges[0].to&&(c.current?(i?.update(()=>{var t;let n=Ah(e);n.getNextSibling()?((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectNext()):n.insertAfter(nh())}),c.current=!1):c.current=!0)}else if(t.key===`ArrowUp`){let t=o.current?.getCodemirror()?.state;t&&t.selection.ranges[0].from===0&&(l.current?(i?.update(()=>{var t;let n=Ah(e);n.getPreviousSibling()&&((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectPrevious())}),l.current=!1):l.current=!0)}else t.key===`Enter`?t.stopPropagation():(t.key===`Backspace`||t.key===`Delete`)&&(o.current?.getCodemirror()?.state)?.doc.length===0&&i?.update(()=>{Ah(e).remove()})},[i,e]);return R.useEffect(()=>{let e=o.current;return setTimeout(()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.addEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.addEventListener(`keydown`,d)},300),()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.removeEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.removeEventListener(`keydown`,d)}},[o,u,d,n]),R.useEffect(()=>{r.subscribe(()=>{var e;(e=o.current?.getCodemirror())==null||e.focus(),u()})},[r,o,e,u]),o}function X(e){return new pe(N.define(e))}function rI(e){return Y(()=>import(`./dist-CyyISotB.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Ope=[A.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return Y(()=>import(`./dist-C5YJOwhH.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),A.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return Y(()=>import(`./dist-C5YJOwhH.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),A.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return rI(`Cassandra`)}}),A.of({name:`CSS`,extensions:[`css`],load(){return Y(()=>import(`./dist-CKM5j-iy.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,5,1,2]))}}),A.of({name:`Go`,extensions:[`go`],load(){return Y(()=>import(`./dist-B4lw9z4F.js`).then(e=>e.go()),__vite__mapDeps([6,1,2]))}}),A.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return Y(()=>import(`./dist-CrBzZkUp.js`).then(e=>e.html()),__vite__mapDeps([7,4,5,1,2,8]))}}),A.of({name:`Java`,extensions:[`java`],load(){return Y(()=>import(`./dist--55mTWk3.js`).then(e=>e.java()),__vite__mapDeps([9,1,2]))}}),A.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return Y(()=>import(`./dist-DFbnFNpX.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return Y(()=>import(`./dist-sKDHTwaT.js`).then(e=>e.jinja()),__vite__mapDeps([10,7,4,5,1,2,8]))}}),A.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return Y(()=>import(`./dist-BZ39rB1W.js`).then(e=>e.json()),__vite__mapDeps([11,1,2]))}}),A.of({name:`JSX`,extensions:[`jsx`],load(){return Y(()=>import(`./dist-DFbnFNpX.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`LESS`,extensions:[`less`],load(){return Y(()=>import(`./dist-C5oXtFSP.js`).then(e=>e.less()),__vite__mapDeps([12,4,5,1,2]))}}),A.of({name:`Liquid`,extensions:[`liquid`],load(){return Y(()=>import(`./dist-y9D6la48.js`).then(e=>e.liquid()),__vite__mapDeps([13,7,4,5,1,2,8]))}}),A.of({name:`MariaDB SQL`,load(){return rI(`MariaSQL`)}}),A.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return Y(()=>import(`./dist-CGINd7XU.js`).then(e=>e.markdown()),__vite__mapDeps([14,7,4,5,1,2,8]))}}),A.of({name:`MS SQL`,load(){return rI(`MSSQL`)}}),A.of({name:`MySQL`,load(){return rI(`MySQL`)}}),A.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return Y(()=>import(`./dist-BcT_c1EJ.js`).then(e=>e.php()),__vite__mapDeps([15,7,4,5,1,2,8]))}}),A.of({name:`PLSQL`,extensions:[`pls`],load(){return rI(`PLSQL`)}}),A.of({name:`PostgreSQL`,load(){return rI(`PostgreSQL`)}}),A.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return Y(()=>import(`./dist-DfcIkFSN.js`).then(e=>e.python()),__vite__mapDeps([16,1,2]))}}),A.of({name:`Rust`,extensions:[`rs`],load(){return Y(()=>import(`./dist-CUp9us2q.js`).then(e=>e.rust()),__vite__mapDeps([17,1,2]))}}),A.of({name:`Sass`,extensions:[`sass`],load(){return Y(()=>import(`./dist-DSKQpPaz.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([18,4,5,1,2]))}}),A.of({name:`SCSS`,extensions:[`scss`],load(){return Y(()=>import(`./dist-DSKQpPaz.js`).then(e=>e.sass()),__vite__mapDeps([18,4,5,1,2]))}}),A.of({name:`SQL`,extensions:[`sql`],load(){return rI(`StandardSQL`)}}),A.of({name:`SQLite`,load(){return rI(`SQLite`)}}),A.of({name:`TSX`,extensions:[`tsx`],load(){return Y(()=>import(`./dist-DFbnFNpX.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return Y(()=>import(`./dist-DFbnFNpX.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return Y(()=>import(`./dist-CZ9T4Cly.js`).then(e=>e.wast()),__vite__mapDeps([19,1,2]))}}),A.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return Y(()=>import(`./dist-Zqt9kNG9.js`).then(e=>e.xml()),__vite__mapDeps([20,1,2]))}}),A.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return Y(()=>import(`./dist-BsedZGJo.js`).then(e=>e.yaml()),__vite__mapDeps([21,1,2]))}}),A.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return Y(()=>import(`./apl-BxEMbctQ.js`).then(e=>X(e.apl)),[])}}),A.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return Y(()=>import(`./asciiarmor-eFjeGRuZ.js`).then(e=>X(e.asciiArmor)),[])}}),A.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return Y(()=>import(`./asn1-Cfx-0pt9.js`).then(e=>X(e.asn1({}))),[])}}),A.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return Y(()=>import(`./asterisk-B5BHTsBr.js`).then(e=>X(e.asterisk)),[])}}),A.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return Y(()=>import(`./brainfuck-CAA2xofr.js`).then(e=>X(e.brainfuck)),[])}}),A.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return Y(()=>import(`./cobol-BfgHZgup.js`).then(e=>X(e.cobol)),[])}}),A.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.csharp)),[])}}),A.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`ClojureScript`,extensions:[`cljs`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return Y(()=>import(`./css-BqOeyZOV.js`).then(e=>X(e.gss)),[])}}),A.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return Y(()=>import(`./cmake-BUPAhezI.js`).then(e=>X(e.cmake)),[])}}),A.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return Y(()=>import(`./coffeescript-G1Pe_1AZ.js`).then(e=>X(e.coffeeScript)),[])}}),A.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return Y(()=>import(`./commonlisp-B3N0CjHn.js`).then(e=>X(e.commonLisp)),[])}}),A.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return Y(()=>import(`./cypher-KjIKv-wW.js`).then(e=>X(e.cypher)),[])}}),A.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return Y(()=>import(`./python-C2_X1GpX.js`).then(e=>X(e.cython)),[])}}),A.of({name:`Crystal`,extensions:[`cr`],load(){return Y(()=>import(`./crystal-C15ndaGM.js`).then(e=>X(e.crystal)),[])}}),A.of({name:`D`,extensions:[`d`],load(){return Y(()=>import(`./d-BlT5AEC-.js`).then(e=>X(e.d)),[])}}),A.of({name:`Dart`,extensions:[`dart`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.dart)),[])}}),A.of({name:`diff`,extensions:[`diff`,`patch`],load(){return Y(()=>import(`./diff-oF98tbqj.js`).then(e=>X(e.diff)),[])}}),A.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return Y(()=>import(`./dockerfile-CUaqzcqp.js`).then(e=>X(e.dockerFile)),__vite__mapDeps([22,23]))}}),A.of({name:`DTD`,extensions:[`dtd`],load(){return Y(()=>import(`./dtd-VCA9yr61.js`).then(e=>X(e.dtd)),[])}}),A.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return Y(()=>import(`./dylan-O-V5Dw5W.js`).then(e=>X(e.dylan)),[])}}),A.of({name:`EBNF`,load(){return Y(()=>import(`./ebnf-SPmdBkvT.js`).then(e=>X(e.ebnf)),[])}}),A.of({name:`ECL`,extensions:[`ecl`],load(){return Y(()=>import(`./ecl-ChfCttfI.js`).then(e=>X(e.ecl)),[])}}),A.of({name:`edn`,extensions:[`edn`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`Eiffel`,extensions:[`e`],load(){return Y(()=>import(`./eiffel-cB9EbjeN.js`).then(e=>X(e.eiffel)),[])}}),A.of({name:`Elm`,extensions:[`elm`],load(){return Y(()=>import(`./elm-BTiVflBU.js`).then(e=>X(e.elm)),[])}}),A.of({name:`Erlang`,extensions:[`erl`],load(){return Y(()=>import(`./erlang-egf0TXFm.js`).then(e=>X(e.erlang)),[])}}),A.of({name:`Esper`,load(){return Y(()=>import(`./sql-D_dieYbr.js`).then(e=>X(e.esper)),[])}}),A.of({name:`Factor`,extensions:[`factor`],load(){return Y(()=>import(`./factor-C2tAxNob.js`).then(e=>X(e.factor)),__vite__mapDeps([24,23]))}}),A.of({name:`FCL`,load(){return Y(()=>import(`./fcl-BiCjh1tj.js`).then(e=>X(e.fcl)),[])}}),A.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return Y(()=>import(`./forth-C4kDGW6u.js`).then(e=>X(e.forth)),[])}}),A.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return Y(()=>import(`./fortran-DzkLaPnd.js`).then(e=>X(e.fortran)),[])}}),A.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.fSharp)),[])}}),A.of({name:`Gas`,extensions:[`s`],load(){return Y(()=>import(`./gas-DMOxskQF.js`).then(e=>X(e.gas)),[])}}),A.of({name:`Gherkin`,extensions:[`feature`],load(){return Y(()=>import(`./gherkin-BPxBpp-k.js`).then(e=>X(e.gherkin)),[])}}),A.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return Y(()=>import(`./groovy-CkEnc0ZY.js`).then(e=>X(e.groovy)),[])}}),A.of({name:`Haskell`,extensions:[`hs`],load(){return Y(()=>import(`./haskell-Dadpo9-w.js`).then(e=>X(e.haskell)),[])}}),A.of({name:`Haxe`,extensions:[`hx`],load(){return Y(()=>import(`./haxe-CDNZL9MW.js`).then(e=>X(e.haxe)),[])}}),A.of({name:`HXML`,extensions:[`hxml`],load(){return Y(()=>import(`./haxe-CDNZL9MW.js`).then(e=>X(e.hxml)),[])}}),A.of({name:`HTTP`,load(){return Y(()=>import(`./http-jy9Zxxt3.js`).then(e=>X(e.http)),[])}}),A.of({name:`IDL`,extensions:[`pro`],load(){return Y(()=>import(`./idl-CGSB6iiy.js`).then(e=>X(e.idl)),[])}}),A.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return Y(()=>import(`./javascript-DSlzRUd8.js`).then(e=>X(e.jsonld)),[])}}),A.of({name:`Julia`,extensions:[`jl`],load(){return Y(()=>import(`./julia-DTiF9v6R.js`).then(e=>X(e.julia)),[])}}),A.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.kotlin)),[])}}),A.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return Y(()=>import(`./livescript-Ci8Xxna6.js`).then(e=>X(e.liveScript)),[])}}),A.of({name:`Lua`,extensions:[`lua`],load(){return Y(()=>import(`./lua-eVxIrt9t.js`).then(e=>X(e.lua)),[])}}),A.of({name:`mIRC`,extensions:[`mrc`],load(){return Y(()=>import(`./mirc-CtHu9S1B.js`).then(e=>X(e.mirc)),[])}}),A.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return Y(()=>import(`./mathematica-Da3grj36.js`).then(e=>X(e.mathematica)),[])}}),A.of({name:`Modelica`,extensions:[`mo`],load(){return Y(()=>import(`./modelica-cKbQ0UXu.js`).then(e=>X(e.modelica)),[])}}),A.of({name:`MUMPS`,extensions:[`mps`],load(){return Y(()=>import(`./mumps-CKBHkOQq.js`).then(e=>X(e.mumps)),[])}}),A.of({name:`Mbox`,extensions:[`mbox`],load(){return Y(()=>import(`./mbox-BWBMSafM.js`).then(e=>X(e.mbox)),[])}}),A.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return Y(()=>import(`./nginx-B00AiQel.js`).then(e=>X(e.nginx)),[])}}),A.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return Y(()=>import(`./nsis-SMDwKltR.js`).then(e=>X(e.nsis)),__vite__mapDeps([25,23]))}}),A.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return Y(()=>import(`./ntriples-B_36EBV0.js`).then(e=>X(e.ntriples)),[])}}),A.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.objectiveC)),[])}}),A.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.objectiveCpp)),[])}}),A.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.oCaml)),[])}}),A.of({name:`Octave`,extensions:[`m`],load(){return Y(()=>import(`./octave-BXPjzAif.js`).then(e=>X(e.octave)),[])}}),A.of({name:`Oz`,extensions:[`oz`],load(){return Y(()=>import(`./oz-Dedpat1M.js`).then(e=>X(e.oz)),[])}}),A.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return Y(()=>import(`./pascal-CMcUg72K.js`).then(e=>X(e.pascal)),[])}}),A.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return Y(()=>import(`./perl-DoVTbnzt.js`).then(e=>X(e.perl)),[])}}),A.of({name:`Pig`,extensions:[`pig`],load(){return Y(()=>import(`./pig-CULXT1YV.js`).then(e=>X(e.pig)),[])}}),A.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return Y(()=>import(`./powershell-Cv5Uhf6b.js`).then(e=>X(e.powerShell)),[])}}),A.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return Y(()=>import(`./properties-CQ1C2P-M.js`).then(e=>X(e.properties)),[])}}),A.of({name:`ProtoBuf`,extensions:[`proto`],load(){return Y(()=>import(`./protobuf-SRlvzrl6.js`).then(e=>X(e.protobuf)),[])}}),A.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return Y(()=>import(`./pug-Bo3wfL-f.js`).then(e=>X(e.pug)),__vite__mapDeps([26,27]))}}),A.of({name:`Puppet`,extensions:[`pp`],load(){return Y(()=>import(`./puppet-ClSqCGj6.js`).then(e=>X(e.puppet)),[])}}),A.of({name:`Q`,extensions:[`q`],load(){return Y(()=>import(`./q-B_6Gdyzl.js`).then(e=>X(e.q)),[])}}),A.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return Y(()=>import(`./r-BD07NGED.js`).then(e=>X(e.r)),[])}}),A.of({name:`RPM Changes`,load(){return Y(()=>import(`./rpm-CRu5Z2Jl.js`).then(e=>X(e.rpmChanges)),[])}}),A.of({name:`RPM Spec`,extensions:[`spec`],load(){return Y(()=>import(`./rpm-CRu5Z2Jl.js`).then(e=>X(e.rpmSpec)),[])}}),A.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return Y(()=>import(`./ruby-dZPnOz8h.js`).then(e=>X(e.ruby)),[])}}),A.of({name:`SAS`,extensions:[`sas`],load(){return Y(()=>import(`./sas-S2t8_sDI.js`).then(e=>X(e.sas)),[])}}),A.of({name:`Scala`,extensions:[`scala`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.scala)),[])}}),A.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return Y(()=>import(`./scheme-WcyFWLW2.js`).then(e=>X(e.scheme)),[])}}),A.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return Y(()=>import(`./shell-DUelnYSh.js`).then(e=>X(e.shell)),[])}}),A.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return Y(()=>import(`./sieve-jDjlVhNh.js`).then(e=>X(e.sieve)),[])}}),A.of({name:`Smalltalk`,extensions:[`st`],load(){return Y(()=>import(`./smalltalk-ddWDYy10.js`).then(e=>X(e.smalltalk)),[])}}),A.of({name:`Solr`,load(){return Y(()=>import(`./solr-C7rQhLuW.js`).then(e=>X(e.solr)),[])}}),A.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.sml)),[])}}),A.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return Y(()=>import(`./sparql--fPCCgVd.js`).then(e=>X(e.sparql)),[])}}),A.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return Y(()=>import(`./spreadsheet-DjthqD5G.js`).then(e=>X(e.spreadsheet)),[])}}),A.of({name:`Squirrel`,extensions:[`nut`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.squirrel)),[])}}),A.of({name:`Stylus`,extensions:[`styl`],load(){return Y(()=>import(`./stylus-DxF70RNr.js`).then(e=>X(e.stylus)),[])}}),A.of({name:`Swift`,extensions:[`swift`],load(){return Y(()=>import(`./swift-T0hDoOb-.js`).then(e=>X(e.swift)),[])}}),A.of({name:`sTeX`,load(){return Y(()=>import(`./stex-rHcFYcA0.js`).then(e=>X(e.stex)),[])}}),A.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return Y(()=>import(`./stex-rHcFYcA0.js`).then(e=>X(e.stex)),[])}}),A.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return Y(()=>import(`./verilog-BJOO83gk.js`).then(e=>X(e.verilog)),[])}}),A.of({name:`Tcl`,extensions:[`tcl`],load(){return Y(()=>import(`./tcl-Dlzy1mPk.js`).then(e=>X(e.tcl)),[])}}),A.of({name:`Textile`,extensions:[`textile`],load(){return Y(()=>import(`./textile-Dy5rFZe5.js`).then(e=>X(e.textile)),[])}}),A.of({name:`TiddlyWiki`,load(){return Y(()=>import(`./tiddlywiki-DQP1OymS.js`).then(e=>X(e.tiddlyWiki)),[])}}),A.of({name:`Tiki wiki`,load(){return Y(()=>import(`./tiki-0vOj3DB2.js`).then(e=>X(e.tiki)),[])}}),A.of({name:`TOML`,extensions:[`toml`],load(){return Y(()=>import(`./toml-DEltN0lI.js`).then(e=>X(e.toml)),[])}}),A.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return Y(()=>import(`./troff-CRbBpEqY.js`).then(e=>X(e.troff)),[])}}),A.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return Y(()=>import(`./ttcn-M5q1nLKg.js`).then(e=>X(e.ttcn)),[])}}),A.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return Y(()=>import(`./ttcn-cfg-Rmw9NWq9.js`).then(e=>X(e.ttcnCfg)),[])}}),A.of({name:`Turtle`,extensions:[`ttl`],load(){return Y(()=>import(`./turtle-BCDWhJK0.js`).then(e=>X(e.turtle)),[])}}),A.of({name:`Web IDL`,extensions:[`webidl`],load(){return Y(()=>import(`./webidl-Ddy6hbV6.js`).then(e=>X(e.webIDL)),[])}}),A.of({name:`VB.NET`,extensions:[`vb`],load(){return Y(()=>import(`./vb-QQ7LGlOz.js`).then(e=>X(e.vb)),[])}}),A.of({name:`VBScript`,extensions:[`vbs`],load(){return Y(()=>import(`./vbscript-BiSEdUzz.js`).then(e=>X(e.vbScript)),[])}}),A.of({name:`Velocity`,extensions:[`vtl`],load(){return Y(()=>import(`./velocity-CzMg5_6w.js`).then(e=>X(e.velocity)),[])}}),A.of({name:`Verilog`,extensions:[`v`],load(){return Y(()=>import(`./verilog-BJOO83gk.js`).then(e=>X(e.verilog)),[])}}),A.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return Y(()=>import(`./vhdl-ed4zAZAA.js`).then(e=>X(e.vhdl)),[])}}),A.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return Y(()=>import(`./xquery-Bw1zwhh6.js`).then(e=>X(e.xQuery)),[])}}),A.of({name:`Yacas`,extensions:[`ys`],load(){return Y(()=>import(`./yacas-DZdTXy3s.js`).then(e=>X(e.yacas)),[])}}),A.of({name:`Z80`,extensions:[`z80`],load(){return Y(()=>import(`./z80-DMG02_YV.js`).then(e=>X(e.z80)),[])}}),A.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.mscgen)),[])}}),A.of({name:`Xù`,extensions:[`xu`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.xu)),[])}}),A.of({name:`MsGenny`,extensions:[`msgenny`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.msgenny)),[])}}),A.of({name:`Vue`,extensions:[`vue`],load(){return Y(()=>import(`./dist-DGLWQLX8.js`).then(e=>e.vue()),__vite__mapDeps([28,7,4,5,1,2,8]))}}),A.of({name:`Angular Template`,load(){return Y(()=>import(`./dist-BbTaHWON.js`).then(e=>e.angular()),__vite__mapDeps([29,7,4,5,1,2,8]))}})],iI=`#2e3440`,aI=`#3b4252`,oI=`#434c5e`,sI=`#4c566a`,cI=`#e5e9f0`,lI=`#eceff4`,uI=`#8fbcbb`,dI=`#88c0d0`,kpe=`#81a1c1`,fI=`#5e81ac`,Ape=`#bf616a`,pI=`#d08770`,mI=`#ebcb8b`,hI=`#a3be8c`,jpe=`#b48ead`,gI=`#d30102`,_I=lI,vI=_I,Mpe=`#ffffff`,yI=aI,Npe=_I,bI=aI,Ppe=[f.theme({"&":{color:iI,backgroundColor:Mpe},".cm-content":{caretColor:bI},".cm-cursor, .cm-dropCursor":{borderLeftColor:bI},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Npe},".cm-panels":{backgroundColor:_I,color:sI},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid ${sI}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:cI},".cm-activeLine":{backgroundColor:vI},".cm-selectionMatch":{backgroundColor:cI},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${sI}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:lI},".cm-gutters":{backgroundColor:lI,color:iI,border:`none`},".cm-activeLineGutter":{backgroundColor:vI},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:yI},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:yI,borderBottomColor:yI},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:vI,color:sI}}},{dark:!1}),i(ye.define([{tag:v.keyword,color:fI},{tag:[v.name,v.deleted,v.character,v.propertyName,v.macroName],color:pI},{tag:[v.variableName],color:pI},{tag:[v.function(v.variableName)],color:fI},{tag:[v.labelName],color:kpe},{tag:[v.color,v.constant(v.name),v.standard(v.name)],color:fI},{tag:[v.definition(v.name),v.separator],color:hI},{tag:[v.brace],color:uI},{tag:[v.annotation],color:gI},{tag:[v.number,v.changed,v.annotation,v.modifier,v.self,v.namespace],color:dI},{tag:[v.typeName,v.className],color:mI},{tag:[v.operator,v.operatorKeyword],color:hI},{tag:[v.tagName],color:jpe},{tag:[v.squareBracket],color:Ape},{tag:[v.angleBracket],color:pI},{tag:[v.attributeName],color:mI},{tag:[v.regexp],color:fI},{tag:[v.quote],color:aI},{tag:[v.string],color:pI},{tag:v.link,color:uI,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[v.url,v.escape,v.special(v.string)],color:pI},{tag:[v.meta],color:dI},{tag:[v.comment],color:oI,fontStyle:`italic`},{tag:v.strong,fontWeight:`bold`,color:fI},{tag:v.emphasis,fontStyle:`italic`,color:fI},{tag:v.strikethrough,textDecoration:`line-through`},{tag:v.heading,fontWeight:`bold`,color:fI},{tag:v.special(v.heading1),fontWeight:`bold`,color:fI},{tag:v.heading1,fontWeight:`bold`,color:fI},{tag:[v.heading2,v.heading3,v.heading4],fontWeight:`bold`,color:fI},{tag:[v.heading5,v.heading6],color:fI},{tag:[v.atom,v.bool,v.special(v.variableName)],color:pI},{tag:[v.processingInstruction,v.inserted],color:uI},{tag:[v.contentSeparator],color:mI},{tag:v.invalid,color:oI,borderBottom:`1px dotted ${gI}`}]))],xI=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,SI=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(xI(e)):xI,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return se(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=y(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=a(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(SI.prototype[Symbol.iterator]=function(){return this});var CI={from:-1,to:-1,match:/.*/.exec(``),precise:!0},wI=`gm`+(/x/.unicode==null?``:`u`),TI=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=CI,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new OI(e,t,n,r,i);this.re=new RegExp(t,wI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=kI(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=kI(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},EI=new WeakMap,DI=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=EI.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return EI.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),EI.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},OI=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=CI,this.matchPos=kI(e,r),this.re=new RegExp(t,wI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=DI.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=kI(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=DI.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(TI.prototype[Symbol.iterator]=OI.prototype[Symbol.iterator]=function(){return this});function Fpe(e){try{return new RegExp(e,wI),!0}catch{return!1}}function kI(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Ipe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=le(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),m=k.cursor(p.from+Math.max(0,Math.min(u,p.length)));e.dispatch({effects:[r,f.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},Lpe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},AI=Oe.define({combine(e){return oe(e,Lpe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Rpe(e){let t=[Upe,Hpe];return e&&t.push(AI.of(e)),t}var zpe=T.mark({class:`cm-selectionMatch`}),Bpe=T.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function jI(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=L.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=L.Word)}function Vpe(e,t,n,r){return e(t.sliceDoc(n,n+1))==L.Word&&e(t.sliceDoc(r-1,r))==L.Word}var Hpe=ge.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(AI),{state:n}=e,r=n.selection;if(r.ranges.length>1)return T.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return T.none;let e=n.wordAt(i.head);if(!e)return T.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return T.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(jI(o,n,i.from,i.to)&&Vpe(o,n,i.from,i.to)))return T.none}else if(a=n.sliceDoc(i.from,i.to),!a)return T.none}let s=[];for(let r of e.visibleRanges){let e=new SI(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||jI(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Bpe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(zpe.range(r,a)),s.length>t.maxMatches))return T.none}}return T.set(s)}},{decorations:e=>e.decorations}),Upe=f.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Wpe=({state:e,dispatch:t})=>{let{selection:n}=e,r=k.create(n.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Gpe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new SI(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new SI(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Kpe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Wpe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Gpe(e,r);return i?(t(e.update({selection:e.selection.addRange(k.range(i.from,i.to),!1),effects:f.scrollIntoView(i.to)})),!0):!1},MI=Oe.define({combine(e){return oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ome(e),scrollToMatch:e=>f.scrollIntoView(e)})}}),NI=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Fpe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
127
|
+
`},vle=0,vO=[];function yle(e){var t=R.useRef([]),n=R.useRef([0,0]),r=R.useRef(),i=R.useState(vle++)[0],a=R.useState(iO)[0],o=R.useRef(e);R.useEffect(function(){o.current=e},[e]),R.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Bce([e.lockRef.current],(e.shards||[]).map(_O),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=R.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=hO(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=fO(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=fO(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return hle(h,t,e,h===`h`?s:c,!0)},[]),c=R.useCallback(function(e){var n=e;if(!(!vO.length||vO[vO.length-1]!==a)){var r=`deltaY`in n?gO(n):hO(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&gle(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(_O).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=R.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:ble(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=R.useCallback(function(e){n.current=hO(e),r.current=void 0},[]),d=R.useCallback(function(t){l(t.type,gO(t),t.target,s(t,e.lockRef.current))},[]),f=R.useCallback(function(t){l(t.type,hO(t),t.target,s(t,e.lockRef.current))},[]);R.useEffect(function(){return vO.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,uO),document.addEventListener(`touchmove`,c,uO),document.addEventListener(`touchstart`,u,uO),function(){vO=vO.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,uO),document.removeEventListener(`touchmove`,c,uO),document.removeEventListener(`touchstart`,u,uO)}},[]);var p=e.removeScrollBar,m=e.inert;return R.createElement(R.Fragment,null,m?R.createElement(a,{styles:_le(i)}):null,p?R.createElement(cle,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ble(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var xle=Yce(eO,yle),yO=R.forwardRef(function(e,t){return R.createElement(nO,qD({},e,{ref:t,sideCar:xle}))});yO.classNames=nO.classNames;var bO=`Popover`,[xO,Sle]=zT(bO,[CD]),SO=CD(),[Cle,CO]=xO(bO),wO=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=SO(t),c=R.useRef(null),[l,u]=R.useState(!1),[d,f]=BD({prop:r,defaultProp:i??!1,onChange:a,caller:bO});return(0,z.jsx)(ND,{...s,children:(0,z.jsx)(Cle,{scope:t,contentId:lE(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:R.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:R.useCallback(()=>u(!0),[]),onCustomAnchorRemove:R.useCallback(()=>u(!1),[]),modal:o,children:n})})};wO.displayName=bO;var TO=`PopoverAnchor`,EO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(TO,n),a=SO(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return R.useEffect(()=>(o(),()=>s()),[o,s]),(0,z.jsx)(PD,{...a,...r,ref:t})});EO.displayName=TO;var DO=`PopoverTrigger`,OO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(DO,n),a=SO(n),o=RT(t,i.triggerRef),s=(0,z.jsx)(HT.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":IO(i.open),...r,ref:o,onClick:FT(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,z.jsx)(PD,{asChild:!0,...a,children:s})});OO.displayName=DO;var kO=`PopoverPortal`,[wle,Tle]=xO(kO,{forceMount:void 0}),AO=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=CO(kO,t);return(0,z.jsx)(wle,{scope:t,forceMount:n,children:(0,z.jsx)(RD,{present:n||a.open,children:(0,z.jsx)(LD,{asChild:!0,container:i,children:r})})})};AO.displayName=kO;var jO=`PopoverContent`,MO=R.forwardRef((e,t)=>{let n=Tle(jO,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=CO(jO,e.__scopePopover);return(0,z.jsx)(RD,{present:r||a.open,children:a.modal?(0,z.jsx)(Dle,{...i,ref:t}):(0,z.jsx)(Ole,{...i,ref:t})})});MO.displayName=jO;var Ele=BT(`PopoverContent.RemoveScroll`),Dle=R.forwardRef((e,t)=>{let n=CO(jO,e.__scopePopover),r=R.useRef(null),i=RT(t,r),a=R.useRef(!1);return R.useEffect(()=>{let e=r.current;if(e)return KD(e)},[]),(0,z.jsx)(yO,{as:Ele,allowPinchZoom:!0,children:(0,z.jsx)(NO,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:FT(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:FT(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;a.current=t.button===2||n},{checkForDefaultPrevented:!1}),onFocusOutside:FT(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),Ole=R.forwardRef((e,t)=>{let n=CO(jO,e.__scopePopover),r=R.useRef(!1),i=R.useRef(!1);return(0,z.jsx)(NO,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),NO=R.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=CO(jO,n),p=SO(n);return ZT(),(0,z.jsx)(nE,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,z.jsx)(qT,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,z.jsx)(FD,{"data-state":IO(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),PO=`PopoverClose`,kle=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=CO(PO,n);return(0,z.jsx)(HT.button,{type:`button`,...r,ref:t,onClick:FT(e.onClick,()=>i.onOpenChange(!1))})});kle.displayName=PO;var Ale=`PopoverArrow`,FO=R.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=SO(n);return(0,z.jsx)(ID,{...i,...r,ref:t})});FO.displayName=Ale;function IO(e){return e?`open`:`closed`}var LO=wO,jle=EO,RO=AO,Mle=MO,zO=FO;function BO(e){let t=e+`CollectionProvider`,[n,r]=zT(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=R.useRef(null),a=R.useRef(new Map).current;return(0,z.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=BT(s),l=R.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,z.jsx)(c,{ref:RT(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=BT(u),p=R.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=R.useRef(null),s=RT(t,o),c=a(u,n);return R.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,z.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return R.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var Nle=R.createContext(void 0);function VO(e){let t=R.useContext(Nle);return e||t||`ltr`}var HO=`rovingFocusGroup.onEntryFocus`,Ple={bubbles:!1,cancelable:!0},UO=`RovingFocusGroup`,[WO,GO,Fle]=BO(UO),[Ile,KO]=zT(UO,[Fle]),[Lle,Rle]=Ile(UO),qO=R.forwardRef((e,t)=>(0,z.jsx)(WO.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(WO.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,z.jsx)(zle,{...e,ref:t})})}));qO.displayName=UO;var zle=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=R.useRef(null),p=RT(t,f),m=VO(a),[h,g]=BD({prop:o,defaultProp:s??null,onChange:c,caller:UO}),[_,v]=R.useState(!1),y=UT(l),b=GO(n),x=R.useRef(!1),[S,C]=R.useState(0);return R.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(HO,y),()=>e.removeEventListener(HO,y)},[y]),(0,z.jsx)(Lle,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:R.useCallback(e=>g(e),[g]),onItemShiftTab:R.useCallback(()=>v(!0),[]),onFocusableItemAdd:R.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:R.useCallback(()=>C(e=>e-1),[]),children:(0,z.jsx)(HT.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:FT(e.onMouseDown,()=>{x.current=!0}),onFocus:FT(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(HO,Ple);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);QO([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:FT(e.onBlur,()=>v(!1))})})}),JO=`RovingFocusGroupItem`,YO=R.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=lE(),l=a||c,u=Rle(JO,n),d=u.currentTabStopId===l,f=GO(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return R.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,z.jsx)(WO.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,z.jsx)(HT.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:FT(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:FT(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:FT(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ZO(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?$O(n,r+1):n.slice(r+1)}setTimeout(()=>QO(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});YO.displayName=JO;var Ble={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function XO(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ZO(e,t,n){let r=XO(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return Ble[r]}function QO(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function $O(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ek=qO,tk=YO,nk=`Separator`,rk=`horizontal`,ik=[`horizontal`,`vertical`],ak=R.forwardRef((e,t)=>{let{decorative:n,orientation:r=rk,...i}=e,a=ok(r)?r:rk,o=n?{role:`none`}:{"aria-orientation":a===`vertical`?a:void 0,role:`separator`};return(0,z.jsx)(HT.div,{"data-orientation":a,...o,...i,ref:t})});ak.displayName=nk;function ok(e){return ik.includes(e)}var sk=ak,ck=`Toggle`,lk=R.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=BD({prop:n,onChange:i,defaultProp:r??!1,caller:ck});return(0,z.jsx)(HT.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:FT(e.onClick,()=>{e.disabled||s(!o)})})});lk.displayName=ck;var uk=`ToggleGroup`,[dk,fk]=zT(uk,[KO]),pk=KO(),mk=R.forwardRef((e,t)=>{let{type:n,...r}=e;if(n===`single`)return(0,z.jsx)(_k,{...r,ref:t});if(n===`multiple`)return(0,z.jsx)(vk,{...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${uk}\``)});mk.displayName=uk;var[hk,gk]=dk(uk),_k=R.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=BD({prop:n,defaultProp:r??``,onChange:i,caller:uk});return(0,z.jsx)(hk,{scope:e.__scopeToggleGroup,type:`single`,value:R.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:R.useCallback(()=>s(``),[s]),children:(0,z.jsx)(xk,{...a,ref:t})})}),vk=R.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...a}=e,[o,s]=BD({prop:n,defaultProp:r??[],onChange:i,caller:uk}),c=R.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=R.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,z.jsx)(hk,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,z.jsx)(xk,{...a,ref:t})})});mk.displayName=uk;var[yk,bk]=dk(uk),xk=R.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=pk(n),u=VO(o),d={role:`group`,dir:u,...c};return(0,z.jsx)(yk,{scope:n,rovingFocus:i,disabled:r,children:i?(0,z.jsx)(ek,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,z.jsx)(HT.div,{...d,ref:t})}):(0,z.jsx)(HT.div,{...d,ref:t})})}),Sk=`ToggleGroupItem`,Ck=R.forwardRef((e,t)=>{let n=gk(Sk,e.__scopeToggleGroup),r=bk(Sk,e.__scopeToggleGroup),i=pk(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=R.useRef(null);return r.rovingFocus?(0,z.jsx)(tk,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,z.jsx)(wk,{...s,ref:t})}):(0,z.jsx)(wk,{...s,ref:t})});Ck.displayName=Sk;var wk=R.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,a=gk(Sk,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0};return(0,z.jsx)(lk,{...a.type===`single`?o:void 0,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})}),Tk=mk,Ek=Ck,Dk=`Toolbar`,[Ok,Vle]=zT(Dk,[KO,fk]),kk=KO(),Ak=fk(),[jk,Mk]=Ok(Dk),Nk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,orientation:r=`horizontal`,dir:i,loop:a=!0,...o}=e,s=kk(n),c=VO(i);return(0,z.jsx)(jk,{scope:n,orientation:r,dir:c,children:(0,z.jsx)(ek,{asChild:!0,...s,orientation:r,dir:c,loop:a,children:(0,z.jsx)(HT.div,{role:`toolbar`,"aria-orientation":r,dir:c,...o,ref:t})})})});Nk.displayName=Dk;var Pk=`ToolbarSeparator`,Fk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Mk(Pk,n);return(0,z.jsx)(sk,{orientation:i.orientation===`horizontal`?`vertical`:`horizontal`,...r,ref:t})});Fk.displayName=Pk;var Ik=`ToolbarButton`,Lk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=kk(n);return(0,z.jsx)(tk,{asChild:!0,...i,focusable:!e.disabled,children:(0,z.jsx)(HT.button,{type:`button`,...r,ref:t})})});Lk.displayName=Ik;var Rk=`ToolbarLink`,zk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=kk(n);return(0,z.jsx)(tk,{asChild:!0,...i,focusable:!0,children:(0,z.jsx)(HT.a,{...r,ref:t,onKeyDown:FT(e.onKeyDown,e=>{e.key===` `&&e.currentTarget.click()})})})});zk.displayName=Rk;var Bk=`ToolbarToggleGroup`,Vk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Mk(Bk,n),a=Ak(n);return(0,z.jsx)(Tk,{"data-orientation":i.orientation,dir:i.dir,...a,...r,ref:t,rovingFocus:!1})});Vk.displayName=Bk;var Hk=`ToolbarToggleItem`,Uk=R.forwardRef((e,t)=>{let{__scopeToolbar:n,...r}=e,i=Ak(n);return(0,z.jsx)(Lk,{asChild:!0,__scopeToolbar:e.__scopeToolbar,children:(0,z.jsx)(Ek,{...i,...r,ref:t})})});Uk.displayName=Hk;var Wk=Nk,Gk=Fk,Kk=Lk,qk=Vk,Jk=Uk;function Yk(e,t){return e===null||e===t?!1:e.dataset.editorDialog!==void 0||e.dataset.toolbarItem!==void 0||e.dataset.editorDropdown?!0:Yk(e.parentElement,t)}function Xk(){let e=[...Array(256).keys()].map(e=>e.toString(16).padStart(2,`0`)),t=crypto.getRandomValues(new Uint8Array(16));return t[6]=t[6]&15|64,t[8]=t[8]&63|128,[...t.entries()].map(([t,n])=>[4,6,8,10].includes(t)?`-${e[n]}`:e[n]).join(``)}var Zk=e=>e===0?`th`:`td`,Qk={center:mw.centeredCell,left:mw.leftAlignedCell,right:mw.rightAlignedCell},$k=({mdastNode:e,parentEditor:t,lexicalTable:n})=>{let[r,i]=R.useState(null),[a,o]=Hl(NC,WS),s=R.useMemo(()=>e=>(e.__cacheKey??=Xk(),e.__cacheKey),[]),c=R.useCallback(e=>{let r=n.getColCount();if(e===null){i(null);return}let[a,o]=e;if(a>r-1&&(a=0,o++),a<0&&(a=r-1,--o),o>n.getRowCount()-1){i(null),t.update(()=>{if(n.getLatest().getNextSibling())n.getLatest().selectNext();else{let e=nh();n.insertAfter(e),e.select()}});return}if(o<0){i(null),t.update(()=>{n.getLatest().selectPrevious()});return}i([a,o])},[n,t]);R.useEffect(()=>{n.focusEmitter.subscribe(c)},[n,c]);let l=R.useCallback(e=>{e.preventDefault(),t.update(()=>{n.addRowToBottom(),i([0,n.getRowCount()])})},[t,n]),u=R.useCallback(e=>{e.preventDefault(),t.update(()=>{n.addColumnToRight(),i([n.getColCount(),0])})},[t,n]),[d,f]=R.useState([-1,-1]),p=R.useCallback(e=>{let t=e.target;for(;t&&![`TH`,`TD`].includes(t.tagName);){if(t===e.currentTarget)return;t=t.parentElement}if(t===null)return;let n=t.parentElement;f([n.parentElement.tagName===`TFOOT`?-1:Array.from(n.children).indexOf(t),t.tagName===`TH`?-1:Array.from(n.parentElement.children).indexOf(n)])},[]),m=rw();return R.createElement(`table`,{className:mw.tableEditor,onMouseOver:p,onMouseLeave:()=>{f([-1,-1])}},R.createElement(`colgroup`,null,o?null:R.createElement(`col`,null),Array.from({length:e.children[0].children.length},(t,n)=>{let r=Qk[(e.align??[])[n]??`left`];return R.createElement(`col`,{key:n,className:r})}),o?null:R.createElement(`col`,null)),o||R.createElement(`thead`,null,R.createElement(`tr`,null,R.createElement(`th`,{className:mw.tableToolsColumn}),Array.from({length:e.children[0].children.length},(r,i)=>R.createElement(`th`,{key:i,"data-tool-cell":!0},R.createElement(nA,{setActiveCellWithBoundaries:c,parentEditor:t,colIndex:i,highlightedCoordinates:d,lexicalTable:n,align:(e.align??[])[i]}))),R.createElement(`th`,{className:mw.tableToolsColumn,"data-tool-cell":!0},R.createElement(`button`,{className:mw.iconButton,type:`button`,title:m(`table.deleteTable`,`Delete table`),onClick:e=>{e.preventDefault(),t.update(()=>{n.selectNext(),n.remove()})}},a(`delete_small`))))),R.createElement(`tbody`,null,e.children.map((i,l)=>{let f=Zk(l);return R.createElement(`tr`,{key:l},o||R.createElement(f,{className:mw.toolCell,"data-tool-cell":!0},R.createElement(rA,{setActiveCellWithBoundaries:c,parentEditor:t,rowIndex:l,highlightedCoordinates:d,lexicalTable:n})),i.children.map((i,a)=>R.createElement(eA,{align:e.align?.[a],key:s(i),contents:i.children,setActiveCell:c,rowIndex:l,colIndex:a,lexicalTable:n,parentEditor:t,activeCell:o?[-1,-1]:r})),o||l===0&&R.createElement(`th`,{rowSpan:n.getRowCount(),"data-tool-cell":!0},R.createElement(`button`,{type:`button`,className:mw.addColumnButton,onClick:u},a(`add_column`))))})),o||R.createElement(`tfoot`,null,R.createElement(`tr`,null,R.createElement(`th`,null),R.createElement(`th`,{colSpan:n.getColCount(),"data-tool-cell":!0},R.createElement(`button`,{type:`button`,className:mw.addRowButton,onClick:l},a(`add_row`))),R.createElement(`th`,null))))},eA=({align:e,...t})=>{let{activeCell:n,setActiveCell:r}=t,i=!!(n&&n[0]===t.colIndex&&n[1]===t.rowIndex),a=Qk[e??`left`],o=Zk(t.rowIndex);return R.createElement(o,{className:a,"data-active":i,onClick:()=>{r([t.colIndex,t.rowIndex])}},R.createElement(tA,{...t,focus:i}))},tA=({focus:e,setActiveCell:t,parentEditor:n,lexicalTable:r,contents:i,colIndex:a,rowIndex:o})=>{let[s,c,l,u,d,f,p,m,h]=Hl(iC,cC,aC,fC,pC,mC,dC,BS,GC),[g]=R.useState(()=>{let e=ah({nodes:l,theme:RS,namespace:`TableCellEditor`});return e.update(()=>{bS({root:Ih(),mdastRoot:{type:`root`,children:[{type:`paragraph`,children:i}]},visitors:s,jsxComponentDescriptors:u,directiveDescriptors:d,codeBlockEditorDescriptors:f})}),e}),_=R.useCallback(e=>{g.getEditorState().read(()=>{let e=jx({root:Ih(),jsxComponentDescriptors:u,visitors:c,jsxIsAvailable:p});n.update(()=>{r.updateCellContents(a,o,e.children[0].children)},{discrete:!0}),n.dispatchCommand(zS,void 0)}),t(e)},[a,g,c,u,p,r,n,o,t]);return R.useEffect(()=>U_(g.registerCommand(vf,e=>(e.preventDefault(),_(e.shiftKey?[a-1,o]:[a+1,o]),!0),4),g.registerCommand(Pf,()=>(t([a,o]),!1),1),g.registerCommand(pf,e=>(e?.preventDefault(),_(e?.shiftKey?[a,o-1]:[a,o+1]),!0),4),g.registerCommand(Ff,e=>{let t=e.relatedTarget;return Yk(t,m.getRootElement())?!1:(_(null),!0)},0),g.registerCommand(zS,()=>(_(null),!0),0)),[a,g,m,o,_,t]),R.useEffect(()=>{e&&g.focus()},[e,g]),R.createElement(Joe,{initialEditor:g},R.createElement(pw,{contentEditable:R.createElement(sw,null),placeholder:R.createElement(`div`,null),ErrorBoundary:uw}),h.map((e,t)=>R.createElement(e,{key:t})),R.createElement(cv,null))},nA=({parentEditor:e,highlightedCoordinates:t,align:n,lexicalTable:r,colIndex:i,setActiveCellWithBoundaries:a})=>{let[o,s]=Hl(hC,NC),c=R.useCallback(t=>{e.update(()=>{r.insertColumnAt(t)}),a([t,0])},[e,r,a]),l=R.useCallback(t=>{e.update(()=>{r.deleteColumnAt(t)})},[e,r]),u=R.useCallback((t,n)=>{e.update(()=>{r.setColumnAlign(t,n)})},[e,r]),d=rw();return R.createElement(LO,null,R.createElement(OO,{className:mw.tableColumnEditorTrigger,"data-active":t[0]===i+1,title:d(`table.columnMenu`,`Column menu`)},s(`more_horiz`)),R.createElement(RO,{container:o?.current},R.createElement(MO,{className:(0,rT.default)(mw.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>{e.preventDefault()},sideOffset:5,side:`top`},R.createElement(Wk,{className:mw.tableColumnEditorToolbar},R.createElement(qk,{className:mw.toggleGroupRoot,onValueChange:e=>{u(i,e)},value:n??`left`,type:`single`,"aria-label":d(`table.textAlignment`,`Text alignment`)},R.createElement(Jk,{value:`left`,title:d(`table.alignLeft`,`Align left`)},s(`format_align_left`)),R.createElement(Jk,{value:`center`,title:d(`table.alignCenter`,`Align center`)},s(`format_align_center`)),R.createElement(Jk,{value:`right`,title:d(`table.alignRight`,`Align right`)},s(`format_align_right`))),R.createElement(Gk,null),R.createElement(Kk,{onClick:c.bind(null,i),title:d(`table.insertColumnLeft`,`Insert a column to the left of this one`)},s(`insert_col_left`)),R.createElement(Kk,{onClick:c.bind(null,i+1),title:d(`table.insertColumnRight`,`Insert a column to the right of this one`)},s(`insert_col_right`)),R.createElement(Kk,{onClick:l.bind(null,i),title:d(`table.deleteColumn`,`Delete this column`)},s(`delete_small`))),R.createElement(zO,{className:mw.popoverArrow}))))},rA=({parentEditor:e,highlightedCoordinates:t,lexicalTable:n,rowIndex:r,setActiveCellWithBoundaries:i})=>{let[a,o]=Hl(hC,NC),s=R.useCallback(t=>{e.update(()=>{n.insertRowAt(t)}),i([0,t])},[e,n,i]),c=R.useCallback(t=>{e.update(()=>{n.deleteRowAt(t)})},[e,n]),l=rw();return R.createElement(LO,null,R.createElement(OO,{className:mw.tableColumnEditorTrigger,"data-active":t[1]===r,title:l(`table.rowMenu`,`Row menu`)},o(`more_horiz`)),R.createElement(RO,{container:a?.current},R.createElement(MO,{className:(0,rT.default)(mw.tableColumnEditorPopoverContent),onOpenAutoFocus:e=>{e.preventDefault()},sideOffset:5,side:`bottom`},R.createElement(Wk,{className:mw.tableColumnEditorToolbar},R.createElement(Kk,{onClick:s.bind(null,r),title:l(`table.insertRowAbove`,`Insert a row above this one`)},o(`insert_row_above`)),R.createElement(Kk,{onClick:s.bind(null,r+1),title:l(`table.insertRowBelow`,`Insert a row below this one`)},o(`insert_row_below`)),R.createElement(Kk,{onClick:c.bind(null,r),title:l(`table.deleteRow`,`Delete this row`)},o(`delete_small`))),R.createElement(zO,{className:mw.popoverArrow}))))},iA=Object.defineProperty,aA=(e,t,n)=>t in e?iA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oA=(e,t,n)=>(aA(e,typeof t==`symbol`?t:t+``,n),n),sA={type:`tableCell`,children:[]};function cA(){let e=Yl;return{publish:t=>{e(t)},subscribe:t=>{e=t}}}var lA=class e extends Wm{constructor(e,t){super(t),oA(this,`__mdastNode`),oA(this,`focusEmitter`,cA()),this.__mdastNode=e??{type:`table`,children:[]}}static getType(){return`table`}static clone(t){return new e(structuredClone(t.__mdastNode),t.__key)}static importJSON(e){return dA(e.mdastNode)}static importDOM(){return{table:()=>({conversion:fA,priority:3})}}exportJSON(){return{mdastNode:structuredClone(this.__mdastNode),type:`table`,version:1}}getMdastNode(){return this.__mdastNode}getRowCount(){return this.__mdastNode.children.length}getColCount(){return this.__mdastNode.children[0]?.children.length||0}createDOM(){return document.createElement(`div`)}updateDOM(){return!1}updateCellContents(e,t,n){let r=this.getWritable().__mdastNode,i=r.children[t],a=i.children,o=a[e],s=Array.from(a),c={...o,children:n},l={...i,children:s};s[e]=c,r.children[t]=l}insertColumnAt(e){let t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){let r=t.children[n],i=r.children,a=Array.from(i),o={...r,children:a};a.splice(e,0,structuredClone(sA)),t.children[n]=o}t.align&&t.align.length>0&&t.align.splice(e,0,`left`)}deleteColumnAt(e){let t=this.getWritable().__mdastNode;for(let n=0;n<t.children.length;n++){let r=t.children[n],i=r.children,a=Array.from(i),o={...r,children:a};a.splice(e,1),t.children[n]=o}}insertRowAt(e){let t=this.getWritable().__mdastNode,n={type:`tableRow`,children:Array.from({length:this.getColCount()},()=>structuredClone(sA))};t.children.splice(e,0,n)}deleteRowAt(e){this.getRowCount()===1?(this.selectNext(),this.remove()):this.getWritable().__mdastNode.children.splice(e,1)}addRowToBottom(){this.insertRowAt(this.getRowCount())}addColumnToRight(){this.insertColumnAt(this.getColCount())}setColumnAlign(e,t){let n=this.getWritable().__mdastNode;n.align??=[],n.align[e]=t}decorate(e){return R.createElement($k,{lexicalTable:this,mdastNode:this.__mdastNode,parentEditor:e})}select(e){this.focusEmitter.publish(e??[0,0])}isInline(){return!1}};function uA(e){return e instanceof lA}function dA(e){return new lA(e)}function fA(e){let t=e.querySelectorAll(`tr`);return{node:new lA({type:`table`,children:Array.from(t).map(e=>({type:`tableRow`,children:Array.from(e.querySelectorAll(`td, th`)).map(e=>({type:`tableCell`,children:[{type:`text`,value:e.textContent}]}))}))})}}var pA={testLexicalNode:uA,visitLexicalNode({actions:e,mdastParent:t,lexicalNode:n}){e.appendToParent(t,n.getMdastNode())}},mA={testNode:`table`,visitNode({mdastNode:e,lexicalParent:t}){t.append(dA(e))}};function hA(e=1,t=1){let n={type:`table`,children:[]};for(let r=0;r<e;r++){let e={type:`tableRow`,children:[]};for(let n=0;n<t;n++)e.children.push({type:`tableCell`,children:[]});n.children.push(e)}return n}var gA=Ll(e=>{e.link(e.pipe(gA,Wl(({rows:e,columns:t})=>()=>dA(hA(e,t)))),XC)}),_A=Xl({init(e,t){e.pubIn({[xC]:wT(),[bC]:OT(),[yC]:mA,[vC]:lA,[SC]:pA,[CC]:DT({tableCellPadding:t?.tableCellPadding??!0,tablePipeAlign:t?.tablePipeAlign??!0})})}}),vA={testNode:`link`,visitNode({mdastNode:e,actions:t}){t.addAndStepInto(gw(e.url,{title:e.title}))}},yA={testLexicalNode:_w,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto(`link`,{url:e.getURL(),title:e.getTitle()})}};function bA({validateUrl:e,attributes:t}){let[n]=eu();return(0,R.useEffect)((()=>{if(!n.hasNodes([hw]))throw Error(`LinkPlugin: LinkNode not registered on editor`);return U_(n.registerCommand(xw,(n=>{if(n===null)return Cw(n),!0;if(typeof n==`string`)return!(e!==void 0&&!e(n))&&(Cw(n,t),!0);{let{url:e,target:r,rel:i,title:a}=n;return Cw(e,{...t,rel:i,target:r,title:a}),!0}}),1),e===void 0?()=>{}:n.registerCommand(Qd,(r=>{let i=G();if(!W(i)||i.isCollapsed()||!$_(r,ClipboardEvent)||r.clipboardData===null)return!1;let a=r.clipboardData.getData(`text`);return!!e(a)&&!i.getNodes().some((e=>K(e)))&&(n.dispatchCommand(xw,{...t,url:a}),r.preventDefault(),!0)}),1))}),[n,e,t]),null}function xA(e,t=(e=>e)){return n=>{let r=e.exec(n);return r===null?null:{index:r.index,length:r[0].length,text:r[0],url:t(r[0])}}}function SA(e,t){for(let n=0;n<t.length;n++){let r=t[n](e);if(r)return r}return null}var CA=/[.,;\s]/;function wA(e){return CA.test(e)}function TA(e){return wA(e[e.length-1])}function EA(e){return wA(e[0])}function DA(e){let t=e.getPreviousSibling();return K(t)&&(t=t.getLastDescendant()),t===null||vp(t)||U(t)&&TA(t.getTextContent())}function OA(e){let t=e.getNextSibling();return K(t)&&(t=t.getFirstDescendant()),t===null||vp(t)||U(t)&&EA(t.getTextContent())}function kA(e,t,n,r){return(e>0?wA(n[e-1]):DA(r[0]))?t<n.length?wA(n[t]):OA(r[r.length-1]):!1}function AA(e,t,n){let r=[],i=[],a=[],o=0,s=0,c=[...e];for(;c.length>0;){let e=c[0],l=e.getTextContent().length,u=s;s+l<=t?(r.push(e),o+=l):u>=n?a.push(e):i.push(e),s+=l,c.shift()}return[o,r,i,a]}function jA(e,t,n,r){let i=yw(r.url,r.attributes);if(e.length===1){let a,o=e[0];t===0?[a,o]=o.splitText(n):[,a,o]=o.splitText(t,n);let s=Fp(r.text);return s.setFormat(a.getFormat()),s.setDetail(a.getDetail()),s.setStyle(a.getStyle()),i.append(s),a.replace(i),o}if(e.length>1){let r=e[0],a,o=r.getTextContent().length;t===0?a=r:[,a]=r.splitText(t);let s=[],c;for(let t=1;t<e.length;t++){let r=e[t],i=r.getTextContent().length,a=o;if(a<n)if(o+i<=n)s.push(r);else{let[e,t]=r.splitText(n-a);s.push(e),c=t}o+=i}let l=G(),u=l?l.getNodes().find(U):void 0,d=Fp(a.getTextContent());return d.setFormat(a.getFormat()),d.setDetail(a.getDetail()),d.setStyle(a.getStyle()),i.append(d,...s),u&&u===a&&(W(l)?d.select(l.anchor.offset,l.focus.offset):Kp(l)&&d.select(0,d.getTextContent().length)),a.replace(i),c}}function MA(e,t,n){let r=e.getChildren(),i=r.length;for(let t=0;t<i;t++){let i=r[t];if(!U(i)||!i.isSimpleText())return NA(e),void n(null,e.getURL())}let a=e.getTextContent(),o=SA(a,t);if(o===null||o.text!==a||!DA(e)||!OA(e))return NA(e),void n(null,e.getURL());let s=e.getURL();if(s!==o.url&&(e.setURL(o.url),n(o.url,s)),o.attributes){let t=e.getRel();t!==o.attributes.rel&&(e.setRel(o.attributes.rel||null),n(o.attributes.rel||null,t));let r=e.getTarget();r!==o.attributes.target&&(e.setTarget(o.attributes.target||null),n(o.attributes.target||null,r))}}function NA(e){let t=e.getChildren();for(let n=t.length-1;n>=0;n--)e.insertAfter(t[n]);return e.remove(),t.map((e=>e.getLatest()))}function PA(e,t,n){(0,R.useEffect)((()=>{e.hasNodes([vw])||function(e,...t){let n=new URL(`https://lexical.dev/docs/error`),r=new URLSearchParams;r.append(`code`,e);for(let e of t)r.append(`v`,e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(77);let r=(e,t)=>{n&&n(e,t)};return U_(e.registerNodeTransform(Ep,(e=>{let n=e.getParentOrThrow(),i=e.getPreviousSibling();bw(n)&&!n.getIsUnlinked()?MA(n,t,r):_w(n)||(e.isSimpleText()&&(EA(e.getTextContent())||!bw(i))&&(function(e,t,n){let r=[...e],i=r.map((e=>e.getTextContent())).join(``),a,o=i,s=0;for(;(a=SA(o,t))&&a!==null;){let e=a.index,t=e+a.length;if(kA(s+e,s+t,i,r)){let[i,,o,c]=AA(r,s+e,s+t),l=jA(o,s+e-i,s+t-i,a);r=l?[l,...c]:c,n(a.url,null),s=0}else s+=t;o=o.substring(t)}})(function(e){let t=[e],n=e.getNextSibling();for(;n!==null&&U(n)&&n.isSimpleText()&&(t.push(n),!/[\s]/.test(n.getTextContent()));)n=n.getNextSibling();return t}(e),t,r),(function(e,t,n){let r=e.getPreviousSibling(),i=e.getNextSibling(),a=e.getTextContent();var o;!bw(r)||r.getIsUnlinked()||EA(a)&&(o=a,!(r.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(o):/^\.[a-zA-Z0-9]{1,}/.test(o)))||(r.append(e),MA(r,t,n),n(null,r.getURL())),!bw(i)||i.getIsUnlinked()||TA(a)||(NA(i),MA(i,t,n),n(null,i.getURL()))})(e,t,r))})),e.registerCommand(xw,(e=>{let t=G();return e!==null||!W(t)||t.extract().forEach((e=>{let t=e.getParent();bw(t)&&(t.setIsUnlinked(!t.getIsUnlinked()),t.markDirty())})),!1}),1))}),[e,t,n])}function FA({matchers:e,onChange:t}){let[n]=eu();return PA(n,e,t),null}var IA=[xA(/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,e=>e.startsWith(`http`)?e:`https://${e}`),xA(/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,e=>`mailto:${e}`)],LA=()=>R.createElement(FA,{matchers:IA}),RA=Il(!1),zA=Xl({init(e,t){let n=!!t?.disableAutoLink,r=t?.validateUrl?{validateUrl:t.validateUrl}:{},i=()=>R.createElement(R.Fragment,null,R.createElement(bA,{...r}),n?null:R.createElement(LA,null));e.pubIn({[ew]:`link`,[yC]:vA,[vC]:[hw,vw],[SC]:yA,[RA]:n,[WC]:i,[KC]:i,[BC]:i})}}),BA=e=>e.type===`checkbox`,VA=e=>e instanceof Date,HA=e=>e==null,UA=e=>typeof e==`object`,WA=e=>!HA(e)&&!Array.isArray(e)&&UA(e)&&!VA(e),GA=e=>WA(e)&&e.target?BA(e.target)?e.target.checked:e.target.value:e,KA=(e,t)=>t.split(`.`).some((t,n,r)=>!isNaN(Number(t))&&e.has(r.slice(0,n).join(`.`))),qA=e=>{let t=e.constructor&&e.constructor.prototype;return WA(t)&&t.hasOwnProperty(`isPrototypeOf`)},JA=typeof window<`u`&&window.HTMLElement!==void 0&&typeof document<`u`;function YA(e){if(e instanceof Date)return new Date(e);let t=typeof FileList<`u`&&e instanceof FileList;if(JA&&(e instanceof Blob||t))return e;let n=Array.isArray(e);if(!n&&!(WA(e)&&qA(e)))return e;let r=n?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=YA(e[t]));return r}var XA=e=>/^\w*$/.test(e),ZA=e=>e===void 0,QA=e=>Array.isArray(e)?e.filter(Boolean):[],$A=e=>QA(e.replace(/["|']|\]/g,``).split(/\.|\[/)),ej=(e,t,n)=>{if(!t||!WA(e))return n;let r=(XA(t)?[t]:$A(t)).reduce((e,t)=>HA(e)?void 0:e[t],e);return ZA(r)||r===e?ZA(e[t])?n:e[t]:r},tj=e=>typeof e==`boolean`,nj=e=>typeof e==`function`,rj=(e,t,n)=>{let r=-1,i=XA(t)?[t]:$A(t),a=i.length,o=a-1;for(;++r<a;){let t=i[r],a=n;if(r!==o){let n=e[t];a=WA(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if(t===`__proto__`||t===`constructor`||t===`prototype`)return;e[t]=a,e=e[t]}},ij={BLUR:`blur`,FOCUS_OUT:`focusout`,CHANGE:`change`,SUBMIT:`submit`,TRIGGER:`trigger`,VALID:`valid`},aj={onBlur:`onBlur`,onChange:`onChange`,onSubmit:`onSubmit`,onTouched:`onTouched`,all:`all`},oj={max:`max`,min:`min`,maxLength:`maxLength`,minLength:`minLength`,pattern:`pattern`,required:`required`,validate:`validate`},sj=`form`,cj=`root`,lj=R.createContext(null);lj.displayName=`HookFormControlContext`;var uj=()=>R.useContext(lj),dj=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let a in e)Object.defineProperty(i,a,{get:()=>{let i=a;return t._proxyFormState[i]!==aj.all&&(t._proxyFormState[i]=!r||aj.all),n&&(n[i]=!0),e[i]}});return i},fj=typeof window<`u`?R.useLayoutEffect:R.useEffect;function Hle(e){let t=uj(),{control:n=t,disabled:r,name:i,exact:a}=e||{},[o,s]=R.useState(n._formState),c=R.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return fj(()=>n._subscribe({name:i,formState:c.current,exact:a,callback:e=>{!r&&s({...n._formState,...e})}}),[i,r,a]),R.useEffect(()=>{c.current.isValid&&n._setValid(!0)},[n]),R.useMemo(()=>dj(o,n,c.current,!1),[o,n])}var pj=e=>typeof e==`string`,mj=(e,t,n,r,i)=>pj(e)?(r&&t.watch.add(e),ej(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),ej(n,e))):(r&&(t.watchAll=!0),n),hj=e=>HA(e)||!UA(e);function gj(e,t,n=new WeakSet){if(e===t)return!0;if(hj(e)||hj(t))return Object.is(e,t);if(VA(e)&&VA(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;n.add(e),n.add(t);for(let i of r){let r=e[i];if(!(i in t))return!1;if(i!==`ref`){let e=t[i];if(VA(r)&&VA(e)||(WA(r)||Array.isArray(r))&&(WA(e)||Array.isArray(e))?!gj(r,e,n):!Object.is(r,e))return!1}}return!0}function Ule(e){let t=uj(),{control:n=t,name:r,defaultValue:i,disabled:a,exact:o,compute:s}=e||{},c=R.useRef(i),l=R.useRef(s),u=R.useRef(void 0),d=R.useRef(n),f=R.useRef(r);l.current=s;let[p,m]=R.useState(()=>{let e=n._getWatch(r,c.current);return l.current?l.current(e):e}),h=R.useCallback(e=>{let t=mj(r,n._names,e||n._formValues,!1,c.current);return l.current?l.current(t):t},[n._formValues,n._names,r]),g=R.useCallback(e=>{if(!a){let t=mj(r,n._names,e||n._formValues,!1,c.current);if(l.current){let e=l.current(t);gj(e,u.current)||(m(e),u.current=e)}else m(t)}},[n._formValues,n._names,a,r]);fj(()=>((d.current!==n||!gj(f.current,r))&&(d.current=n,f.current=r,g()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:e=>{g(e.values)}})),[n,o,r,g]),R.useEffect(()=>n._removeUnmounted());let _=d.current!==n,v=f.current,y=R.useMemo(()=>{if(a)return null;let e=!_&&!gj(v,r);return _||e?h():null},[a,_,r,v,h]);return y===null?p:y}function Wle(e){let t=uj(),{name:n,disabled:r,control:i=t,shouldUnregister:a,defaultValue:o,exact:s=!0}=e,c=KA(i._names.array,n),l=Ule({control:i,name:n,defaultValue:R.useMemo(()=>ej(i._formValues,n,ej(i._defaultValues,n,o)),[i,n,o]),exact:s}),u=Hle({control:i,name:n,exact:s}),d=R.useRef(e),f=R.useRef(i.register(n,{...e.rules,value:l,...tj(e.disabled)?{disabled:e.disabled}:{}}));d.current=e;let p=R.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ej(u.errors,n)},isDirty:{enumerable:!0,get:()=>!!ej(u.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ej(u.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ej(u.validatingFields,n)},error:{enumerable:!0,get:()=>ej(u.errors,n)}}),[u,n]),m=R.useCallback(e=>f.current.onChange({target:{value:GA(e),name:n},type:ij.CHANGE}),[n]),h=R.useCallback(()=>f.current.onBlur({target:{value:ej(i._formValues,n),name:n},type:ij.BLUR}),[n,i._formValues]),g=R.useCallback(e=>{let t=ej(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>nj(e.focus)&&e.focus(),select:()=>nj(e.select)&&e.select(),setCustomValidity:t=>nj(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>nj(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),_=R.useMemo(()=>({name:n,value:l,...tj(r)||u.disabled?{disabled:u.disabled||r}:{},onChange:m,onBlur:h,ref:g}),[n,r,u.disabled,m,h,g,l]);return R.useEffect(()=>{let e=i._options.shouldUnregister||a;i.register(n,{...d.current.rules,...tj(d.current.disabled)?{disabled:d.current.disabled}:{}});let t=(e,t)=>{let n=ej(i._fields,e);n&&n._f&&(n._f.mount=t)};if(t(n,!0),e){let e=YA(ej(i._options.defaultValues,n,d.current.defaultValue));rj(i._defaultValues,n,e),ZA(ej(i._formValues,n))&&rj(i._formValues,n,e)}return!c&&i.register(n),()=>{(c?e&&!i._state.action:e)?i.unregister(n):t(n,!1)}},[n,i,c,a]),R.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),R.useMemo(()=>({field:_,formState:u,fieldState:p}),[_,u,p])}var Gle=e=>e.render(Wle(e)),Kle=R.createContext(null);Kle.displayName=`HookFormContext`;var qle=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},_j=e=>Array.isArray(e)?e:[e],vj=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}};function yj(e,t){let n={};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r],a=t[r];if(i&&WA(i)&&a){let e=yj(i,a);WA(e)&&(n[r]=e)}else e[r]&&(n[r]=a)}return n}var bj=e=>WA(e)&&!Object.keys(e).length,xj=e=>e.type===`file`,Sj=e=>{if(!JA)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Cj=e=>e.type===`select-multiple`,wj=e=>e.type===`radio`,Jle=e=>wj(e)||BA(e),Tj=e=>Sj(e)&&e.isConnected;function Yle(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;){if(HA(e)){e=void 0;break}e=e[t[r]],r++}return e}function Xle(e){for(let t in e)if(e.hasOwnProperty(t)&&!ZA(e[t]))return!1;return!0}function Ej(e,t){if(pj(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;let n=Array.isArray(t)?t:XA(t)?[t]:$A(t),r=n.length===1?e:Yle(e,n),i=n.length-1,a=n[i];return r&&delete r[a],i!==0&&(WA(r)&&bj(r)||Array.isArray(r)&&Xle(r))&&Ej(e,n.slice(0,-1)),e}var Zle=e=>{for(let t in e)if(nj(e[t]))return!0;return!1};function Dj(e){return Array.isArray(e)||WA(e)&&!Zle(e)}function Oj(e,t={}){for(let n in e){let r=e[n];Dj(r)?(t[n]=Array.isArray(r)?[]:{},Oj(r,t[n])):ZA(r)||(t[n]=!0)}return t}function kj(e,t,n){n||=Oj(t);for(let r in e){let i=e[r];if(Dj(i))ZA(t)||hj(n[r])?n[r]=Oj(i,Array.isArray(i)?[]:{}):kj(i,HA(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!gj(i,e)}}return n}var Aj={value:!1,isValid:!1},jj={value:!0,isValid:!0},Mj=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!ZA(e[0].attributes.value)?ZA(e[0].value)||e[0].value===``?jj:{value:e[0].value,isValid:!0}:jj:Aj}return Aj},Nj=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>ZA(e)?e:t?e===``?NaN:e&&+e:n&&pj(e)?new Date(e):r?r(e):e,Pj={isValid:!1,value:null},Fj=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,Pj):Pj;function Ij(e){let t=e.ref;return xj(t)?t.files:wj(t)?Fj(e.refs).value:Cj(t)?[...t.selectedOptions].map(({value:e})=>e):BA(t)?Mj(e.refs).value:Nj(ZA(t.value)?e.ref.value:t.value,e)}var Qle=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,$le=(e,t,n,r)=>{let i={};for(let n of e){let e=ej(t,n);e&&rj(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}},Lj=e=>e instanceof RegExp,Rj=e=>ZA(e)?e:Lj(e)?e.source:WA(e)?Lj(e.value)?e.value.source:e.value:e,zj=e=>({isOnSubmit:!e||e===aj.onSubmit,isOnBlur:e===aj.onBlur,isOnChange:e===aj.onChange,isOnAll:e===aj.all,isOnTouch:e===aj.onTouched}),Bj=`AsyncFunction`,eue=e=>!!e&&!!e.validate&&!!(nj(e.validate)&&e.validate.constructor.name===Bj||WA(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===Bj)),tue=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),Vj=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length)))),Hj=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=ej(e,i);if(n){let{_f:e,...a}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r||e.ref&&t(e.ref,e.name)&&!r)return!0;if(Hj(a,t))break}else if(WA(a)&&Hj(a,t))break}}};function Uj(e,t,n){let r=ej(e,n);if(r||XA(n))return{error:r,name:n};let i=n.split(`.`);for(;i.length;){let r=i.join(`.`),a=ej(t,r),o=ej(e,r);if(a&&!Array.isArray(a)&&n!==r)return{name:n};if(o&&o.type)return{name:r,error:o};if(o&&o.root&&o.root.type)return{name:`${r}.root`,error:o.root};i.pop()}return{name:n}}var nue=(e,t,n,r)=>{n(e);let{name:i,...a}=e;return bj(a)||Object.keys(a).length>=Object.keys(t).length||Object.keys(a).find(e=>t[e]===(!r||aj.all))},rue=(e,t,n)=>!e||!t||e===t||_j(e).some(e=>e&&(n?e===t:e.startsWith(t)||t.startsWith(e))),iue=(e,t,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(t||e):(n?r.isOnBlur:i.isOnBlur)?!e:(n?r.isOnChange:i.isOnChange)?e:!0,aue=(e,t)=>!QA(ej(e,t)).length&&Ej(e,t),oue=(e,t,n)=>{let r=_j(ej(e,n));return rj(r,cj,t[n]),rj(e,n,r),e};function Wj(e,t,n=`validate`){if(pj(e)||Array.isArray(e)&&e.every(pj)||tj(e)&&!e)return{type:n,message:pj(e)?e:``,ref:t}}var Gj=e=>WA(e)&&!Lj(e)?e:{value:e,message:``},Kj=async(e,t,n,r,i,a)=>{let{ref:o,refs:s,required:c,maxLength:l,minLength:u,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:_}=e._f,v=ej(n,h);if(!_||t.has(h))return{};let y=s?s[0]:o,b=e=>{i&&y.reportValidity&&(y.setCustomValidity(tj(e)?``:e||``),y.reportValidity())},x={},S=wj(o),C=BA(o),w=S||C,T=(g||xj(o))&&ZA(o.value)&&ZA(v)||Sj(o)&&o.value===``||v===``||Array.isArray(v)&&!v.length||g&&typeof v==`number`&&isNaN(v),E=qle.bind(null,h,r,x),D=(e,t,n,r=oj.maxLength,i=oj.minLength)=>{let a=e?t:n;x[h]={type:e?r:i,message:a,ref:o,...E(e?r:i,a)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(T||HA(v))||tj(v)&&!v||C&&!Mj(s).isValid||S&&!Fj(s).isValid)){let{value:e,message:t}=pj(c)?{value:!!c,message:c}:Gj(c);if(e&&(x[h]={type:oj.required,message:t,ref:y,...E(oj.required,t)},!r))return b(t),x}if(!T&&(!HA(d)||!HA(f))){let e,t,n=Gj(f),i=Gj(d);if(!HA(v)&&!isNaN(v)){let r=o.valueAsNumber||v&&+v;HA(n.value)||(e=r>n.value),HA(i.value)||(t=r<i.value)}else{let r=o.valueAsDate||new Date(v),a=e=>new Date(new Date().toDateString()+` `+e),s=o.type==`time`,c=o.type==`week`;pj(n.value)&&v&&(e=s?a(v)>a(n.value):c?v>n.value:r>new Date(n.value)),pj(i.value)&&v&&(t=s?a(v)<a(i.value):c?v<i.value:r<new Date(i.value))}if((e||t)&&(D(!!e,n.message,i.message,oj.max,oj.min),!r))return b(x[h].message),x}if((l||u)&&!T&&(pj(v)||a&&Array.isArray(v))){let e=Gj(l),t=Gj(u),n=!HA(e.value)&&v.length>+e.value,i=!HA(t.value)&&v.length<+t.value;if((n||i)&&(D(n,e.message,t.message),!r))return b(x[h].message),x}if(p&&!T&&pj(v)){let{value:e,message:t}=Gj(p);if(Lj(e)&&!v.match(e)&&(x[h]={type:oj.pattern,message:t,ref:o,...E(oj.pattern,t)},!r))return b(t),x}if(m){if(nj(m)){let e=Wj(await m(v,n),y);if(e&&(x[h]={...e,...E(oj.validate,e.message)},!r))return b(e.message),x}else if(WA(m)){let e={};for(let t in m){if(!bj(e)&&!r)break;let i=Wj(await m[t](v,n),y,t);i&&(e={...i,...E(t,i.message)},b(i.message),r&&(x[h]=e))}if(!bj(e)&&(x[h]={ref:y,...e},!r))return x}}return b(!0),x},sue={mode:aj.onSubmit,reValidateMode:aj.onChange,shouldFocusError:!0};function cue(e={}){let t={...sue,...e},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:nj(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},i=(WA(t.defaultValues)||WA(t.values))&&YA(t.defaultValues||t.values)||{},a=t.shouldUnregister?{}:YA(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,l=0,u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...u},f={...d},p={array:vj(),state:vj()},m=t.criteriaMode===aj.all,h=e=>t=>{clearTimeout(l),l=setTimeout(e,t)},g=async e=>{if(!o.keepIsValid&&!t.disabled&&(d.isValid||f.isValid||e)){let e;t.resolver?(e=bj((await T()).errors),_()):e=await O({fields:r,onlyCheckValid:!0,eventType:ij.VALID}),e!==n.isValid&&p.state.next({isValid:e})}},_=(e,r)=>{!t.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(r?rj(n.validatingFields,e,r):Ej(n.validatingFields,e))}),p.state.next({validatingFields:n.validatingFields,isValidating:!bj(n.validatingFields)}))},v=e=>{let t=kj(i,a),r=Qle(e);rj(n.dirtyFields,r,ej(t,r))},y=(e,i=[],s,c,l=!0,u=!0)=>{if(c&&s&&!t.disabled){if(o.action=!0,u&&Array.isArray(ej(r,e))){let t=s(ej(r,e),c.argA,c.argB);l&&rj(r,e,t)}if(u&&Array.isArray(ej(n.errors,e))){let t=s(ej(n.errors,e),c.argA,c.argB);l&&rj(n.errors,e,t),aue(n.errors,e)}if((d.touchedFields||f.touchedFields)&&u&&Array.isArray(ej(n.touchedFields,e))){let t=s(ej(n.touchedFields,e),c.argA,c.argB);l&&rj(n.touchedFields,e,t)}(d.dirtyFields||f.dirtyFields)&&v(e),p.state.next({name:e,isDirty:A(e,i),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else rj(a,e,i)},b=(e,t)=>{rj(n.errors,e,t),p.state.next({errors:n.errors})},x=e=>{n.errors=e,p.state.next({errors:n.errors,isValid:!1})},S=(e,t,n,s)=>{let c=ej(r,e);if(c){let r=ej(a,e,ZA(n)?ej(i,e):n);ZA(r)||s&&s.defaultChecked||t?rj(a,e,t?r:Ij(c._f)):N(e,r),o.mount&&!o.action&&g()}},C=(e,r,a,o,s)=>{let c=!1,l=!1,u={name:e};if(!t.disabled){if(!a||o){(d.isDirty||f.isDirty)&&(l=n.isDirty,n.isDirty=u.isDirty=A(),c=l!==u.isDirty);let t=gj(ej(i,e),r);l=!!ej(n.dirtyFields,e),t?Ej(n.dirtyFields,e):rj(n.dirtyFields,e,!0),u.dirtyFields=n.dirtyFields,c||=(d.dirtyFields||f.dirtyFields)&&l!==!t}if(a){let t=ej(n.touchedFields,e);t||(rj(n.touchedFields,e,a),u.touchedFields=n.touchedFields,c||=(d.touchedFields||f.touchedFields)&&t!==a)}c&&s&&p.state.next(u)}return c?u:{}},w=(e,r,i,a)=>{let o=ej(n.errors,e),s=(d.isValid||f.isValid)&&tj(r)&&n.isValid!==r;if(t.delayError&&i?(c=h(()=>b(e,i)),c(t.delayError)):(clearTimeout(l),c=null,i?rj(n.errors,e,i):Ej(n.errors,e)),(i?!gj(o,i):o)||!bj(a)||s){let t={...a,...s&&tj(r)?{isValid:r}:{},errors:n.errors,name:e};n={...n,...t},p.state.next(t)}},T=async e=>(_(e,!0),await t.resolver(a,t.context,$le(e||s.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),E=async e=>{let{errors:t}=await T(e);if(_(e),e)for(let r of e){let e=ej(t,r);e?rj(n.errors,r,e):Ej(n.errors,r)}else n.errors=t;return t},D=async({name:t,eventType:r})=>{if(e.validate){let i=await e.validate({formValues:a,formState:n,name:t,eventType:r});if(WA(i))for(let e in i)i[e]&&ae(`${sj}.${e}`,{message:pj(i.message)?i.message:``,type:oj.validate});else pj(i)||!i?ae(sj,{message:i||``,type:oj.validate}):ie(sj);return i}return!0},O=async({fields:r,onlyCheckValid:i,name:o,eventType:c,context:l={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(l.runRootValidation=!0,!await D({name:o,eventType:c})&&(l.valid=!1,i)))return l.valid;for(let o in r){let u=r[o];if(u){let{_f:r,...f}=u;if(r){let o=s.array.has(r.name),c=u._f&&eue(u._f);c&&d.validatingFields&&_([r.name],!0);let f=await Kj(u,s.disabled,a,m,t.shouldUseNativeValidation&&!i,o);if(c&&d.validatingFields&&_([r.name]),f[r.name]&&(l.valid=!1,i)||(!i&&(ej(f,r.name)?o?oue(n.errors,f,r.name):rj(n.errors,r.name,f[r.name]):Ej(n.errors,r.name)),e.shouldUseNativeValidation&&f[r.name]))break}!bj(f)&&await O({context:l,onlyCheckValid:i,fields:f,name:o,eventType:c})}}return l.valid},k=()=>{for(let e of s.unMount){let t=ej(r,e);t&&(t._f.refs?t._f.refs.every(e=>!Tj(e)):!Tj(t._f.ref))&&le(e)}s.unMount=new Set},A=(e,n)=>!t.disabled&&(e&&n&&rj(a,e,n),!gj(L(),i)),j=(e,t,n)=>mj(e,s,{...o.mount?a:ZA(t)?i:pj(e)?{[e]:t}:t},n,t),M=e=>QA(ej(o.mount?a:i,e,t.shouldUnregister?ej(i,e,[]):[])),N=(e,t,n={})=>{let i=ej(r,e),o=t;if(i){let n=i._f;n&&(!n.disabled&&rj(a,e,Nj(t,n)),o=Sj(n.ref)&&HA(t)?``:t,Cj(n.ref)?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?BA(n.ref)?n.refs.forEach(e=>{(!e.defaultChecked||!e.disabled)&&(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):xj(n.ref)?n.ref.value=``:(n.ref.value=o,n.ref.type||p.state.next({name:e,values:YA(a)})))}(n.shouldDirty||n.shouldTouch)&&C(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&ne(e)},P=(e,t,n)=>{for(let i in t){if(!t.hasOwnProperty(i))return;let a=t[i],o=e+`.`+i,c=ej(r,o);(s.array.has(e)||WA(a)||c&&!c._f)&&!VA(a)?P(o,a,n):N(o,a,n)}},F=(e,t,i={})=>{let c=ej(r,e),l=s.array.has(e),u=YA(t),d=gj(ej(a,e),u);if(rj(a,e,u),l)p.array.next({name:e,values:YA(a)}),i.shouldDirty&&(v(e),p.state.next({name:e,dirtyFields:n.dirtyFields,isDirty:A(e,u)}));else{let t=Array.isArray(u)&&!u.length||bj(u);!c||c._f||HA(u)||t?N(e,u,i):P(e,u,i)}d||(Vj(e,s)?p.state.next({...n,name:e,values:YA(a)}):p.state.next({name:o.mount?e:void 0,values:YA(a)}))},ee=e=>{let t=nj(e)?e(a):e;gj(a,t)||(a={...a,...t},p.state.next({...n,values:a}))},te=async i=>{o.mount=!0;let l=i.target,u=l.name,h=!0,v=ej(r,u),y=e=>{h=Number.isNaN(e)||VA(e)&&isNaN(e.getTime())||gj(e,ej(a,u,e))},b=zj(t.mode),x=zj(t.reValidateMode);if(v){let o,S,E=l.type?Ij(v._f):GA(i),k=i.type===ij.BLUR||i.type===ij.FOCUS_OUT,A=!tue(v._f)&&!e.validate&&!t.resolver&&!ej(n.errors,u)&&!v._f.deps||iue(k,ej(n.touchedFields,u),n.isSubmitted,x,b),j=Vj(u,s,k);rj(a,u,E),k?(!l||!l.readOnly)&&(v._f.onBlur&&v._f.onBlur(i),c&&c(0)):v._f.onChange&&v._f.onChange(i);let M=C(u,E,k),N=!bj(M)||j;if(!k&&p.state.next({name:u,type:i.type,values:YA(a)}),A)return(d.isValid||f.isValid)&&(t.mode===`onBlur`?k&&g():k||g()),N&&p.state.next({name:u,...j?{}:M});if(!t.resolver&&e.validate&&await D({name:u,eventType:i.type}),!k&&j&&p.state.next({...n}),t.resolver){let{errors:e}=await T([u]);if(_([u]),y(E),h){let t=Uj(n.errors,r,u),i=Uj(e,r,t.name||u);o=i.error,u=i.name,S=bj(e)}}else _([u],!0),o=(await Kj(v,s.disabled,a,m,t.shouldUseNativeValidation))[u],_([u]),y(E),h&&(o?S=!1:(d.isValid||f.isValid)&&(S=await O({fields:r,onlyCheckValid:!0,name:u,eventType:i.type})));h&&(v._f.deps&&(!Array.isArray(v._f.deps)||v._f.deps.length>0)&&ne(v._f.deps),w(u,S,o,M))}},I=(e,t)=>{if(ej(n.errors,t)&&e.focus)return e.focus(),1},ne=async(e,i={})=>{let a,o,c=_j(e);if(t.resolver){let t=await E(ZA(e)?e:c);a=bj(t),o=e?!c.some(e=>ej(t,e)):a}else e?(o=(await Promise.all(c.map(async e=>{let t=ej(r,e);return await O({fields:t&&t._f?{[e]:t}:t,eventType:ij.TRIGGER})}))).every(Boolean),!(!o&&!n.isValid)&&g()):o=a=await O({fields:r,name:e,eventType:ij.TRIGGER});return p.state.next({...!pj(e)||(d.isValid||f.isValid)&&a!==n.isValid?{}:{name:e},...t.resolver||!e?{isValid:a}:{},errors:n.errors}),i.shouldFocus&&!o&&Hj(r,I,e?c:s.mount),o},L=(e,t)=>{let r={...o.mount?a:i};return t&&(r=yj(t.dirtyFields?n.dirtyFields:n.touchedFields,r)),ZA(e)?r:pj(e)?ej(r,e):e.map(e=>ej(r,e))},re=(e,t)=>({invalid:!!ej((t||n).errors,e),isDirty:!!ej((t||n).dirtyFields,e),error:ej((t||n).errors,e),isValidating:!!ej(n.validatingFields,e),isTouched:!!ej((t||n).touchedFields,e)}),ie=e=>{let t=e?_j(e):void 0;t?.forEach(e=>Ej(n.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:n.errors})}):p.state.next({errors:{}})},ae=(e,t,i)=>{let a=(ej(r,e,{_f:{}})._f||{}).ref,{ref:o,message:s,type:c,...l}=ej(n.errors,e)||{};rj(n.errors,e,{...l,...t,ref:a}),p.state.next({name:e,errors:n.errors,isValid:!1}),i&&i.shouldFocus&&a&&a.focus&&a.focus()},oe=(e,t)=>nj(e)?p.state.subscribe({next:n=>`values`in n&&e(n.values||j(void 0,t),n)}):j(e,t,!0),se=e=>p.state.subscribe({next:t=>{if(rue(e.name,t.name,e.exact)&&nue(t,e.formState||d,ye,e.reRenderRoot)){let r={...a};e.callback({values:r,...n,...t,defaultValues:i})}}}).unsubscribe,ce=e=>(o.mount=!0,f={...f,...e.formState},se({...e,formState:{...u,...e.formState}})),le=(e,o={})=>{for(let c of e?_j(e):s.mount)s.mount.delete(c),s.array.delete(c),o.keepValue||(Ej(r,c),Ej(a,c)),!o.keepError&&Ej(n.errors,c),!o.keepDirty&&Ej(n.dirtyFields,c),!o.keepTouched&&Ej(n.touchedFields,c),!o.keepIsValidating&&Ej(n.validatingFields,c),!t.shouldUnregister&&!o.keepDefaultValue&&Ej(i,c);p.state.next({values:YA(a)}),p.state.next({...n,...o.keepDirty?{isDirty:A()}:{}}),!o.keepIsValid&&g()},ue=({disabled:e,name:t})=>{if(tj(e)&&o.mount||e||s.disabled.has(t)){let n=s.disabled.has(t)!==!!e;e?s.disabled.add(t):s.disabled.delete(t),n&&o.mount&&!o.action&&g()}},de=(e,n={})=>{let a=ej(r,e),c=tj(n.disabled)||tj(t.disabled),l=!s.registerName.has(e)&&a&&a._f&&!a._f.mount;return rj(r,e,{...a||{},_f:{...a&&a._f?a._f:{ref:{name:e}},name:e,mount:!0,...n}}),s.mount.add(e),a&&!l?ue({disabled:tj(n.disabled)?n.disabled:t.disabled,name:e}):S(e,!0,n.value),{...c?{disabled:n.disabled||t.disabled}:{},...t.progressive?{required:!!n.required,min:Rj(n.min),max:Rj(n.max),minLength:Rj(n.minLength),maxLength:Rj(n.maxLength),pattern:Rj(n.pattern)}:{},name:e,onChange:te,onBlur:te,ref:c=>{if(c){s.registerName.add(e),de(e,n),s.registerName.delete(e),a=ej(r,e);let t=ZA(c.value)&&c.querySelectorAll&&c.querySelectorAll(`input,select,textarea`)[0]||c,o=Jle(t),l=a._f.refs||[];if(o?l.find(e=>e===t):t===a._f.ref)return;rj(r,e,{_f:{...a._f,...o?{refs:[...l.filter(Tj),t,...Array.isArray(ej(i,e))?[{}]:[]],ref:{type:t.type,name:e}}:{ref:t}}}),S(e,!1,void 0,t)}else a=ej(r,e,{}),a._f&&(a._f.mount=!1),(t.shouldUnregister||n.shouldUnregister)&&!(KA(s.array,e)&&o.action)&&s.unMount.add(e)}}},fe=()=>t.shouldFocusError&&Hj(r,I,s.mount),pe=e=>{tj(e)&&(p.state.next({disabled:e}),Hj(r,(t,n)=>{let i=ej(r,n);i&&(t.disabled=i._f.disabled||e,Array.isArray(i._f.refs)&&i._f.refs.forEach(t=>{t.disabled=i._f.disabled||e}))},0,!1))},me=(e,i)=>async o=>{let c;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let l=YA(a);if(p.state.next({isSubmitting:!0}),t.resolver){let{errors:e,values:t}=await T();_(),n.errors=e,l=YA(t)}else await O({fields:r,eventType:ij.SUBMIT});if(s.disabled.size)for(let e of s.disabled)Ej(l,e);if(Ej(n.errors,cj),bj(n.errors)){p.state.next({errors:{}});try{await e(l,o)}catch(e){c=e}}else i&&await i({...n.errors},o),fe(),setTimeout(fe);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:bj(n.errors)&&!c,submitCount:n.submitCount+1,errors:n.errors}),c)throw c},he=(e,t={})=>{ej(r,e)&&(ZA(t.defaultValue)?F(e,YA(ej(i,e))):(F(e,t.defaultValue),rj(i,e,YA(t.defaultValue))),t.keepTouched||Ej(n.touchedFields,e),t.keepDirty||(Ej(n.dirtyFields,e),n.isDirty=t.defaultValue?A(e,YA(ej(i,e))):A()),t.keepError||(Ej(n.errors,e),d.isValid&&g()),p.state.next({...n}))},ge=(e,c={})=>{let l=e?YA(e):i,u=YA(l),f=bj(e),m=f?i:u;if(c.keepDefaultValues||(i=l),!c.keepValues){if(c.keepDirtyValues){let e=new Set([...s.mount,...Object.keys(kj(i,a))]);for(let t of Array.from(e)){let e=ej(n.dirtyFields,t),r=ej(a,t),i=ej(m,t);e&&!ZA(r)?rj(m,t,r):!e&&!ZA(i)&&F(t,i)}}else{if(JA&&ZA(e))for(let e of s.mount){let t=ej(r,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(Sj(e)){let t=e.closest(`form`);if(t){t.reset();break}}}}if(c.keepFieldsRef)for(let e of s.mount)F(e,ej(m,e));else r={}}a=t.shouldUnregister?c.keepDefaultValues?YA(i):{}:YA(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:c.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:``},o.mount=!d.isValid||!!c.keepIsValid||!!c.keepDirtyValues||!t.shouldUnregister&&!bj(m),o.watch=!!t.shouldUnregister,o.keepIsValid=!!c.keepIsValid,o.action=!1,c.keepErrors||(n.errors={}),p.state.next({submitCount:c.keepSubmitCount?n.submitCount:0,isDirty:f?!1:c.keepDirty?n.isDirty:!!(c.keepDefaultValues&&!gj(e,i)),isSubmitted:c.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:f?{}:c.keepDirtyValues?c.keepDefaultValues&&a?kj(i,a):n.dirtyFields:c.keepDefaultValues&&e?kj(i,e):c.keepDirty?n.dirtyFields:{},touchedFields:c.keepTouched?n.touchedFields:{},errors:c.keepErrors?n.errors:{},isSubmitSuccessful:c.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},_e=(e,n)=>ge(nj(e)?e(a):e,{...t.resetOptions,...n}),ve=(e,t={})=>{let n=ej(r,e),i=n&&n._f;if(i){let e=i.refs?i.refs[0]:i.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&nj(e.select)&&e.select()})}},ye=e=>{n={...n,...e}},be={control:{register:de,unregister:le,getFieldState:re,handleSubmit:me,setError:ae,_subscribe:se,_runSchema:T,_updateIsValidating:_,_focusError:fe,_getWatch:j,_getDirty:A,_setValid:g,_setFieldArray:y,_setDisabledField:ue,_setErrors:x,_getFieldArray:M,_reset:ge,_resetDefaultValues:()=>nj(t.defaultValues)&&t.defaultValues().then(e=>{_e(e,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:k,_disableForm:pe,_subjects:p,_proxyFormState:d,get _fields(){return r},get _formValues(){return a},get _state(){return o},set _state(e){o=e},get _defaultValues(){return i},get _names(){return s},set _names(e){s=e},get _formState(){return n},get _options(){return t},set _options(e){t={...t,...e}}},subscribe:ce,trigger:ne,register:de,handleSubmit:me,watch:oe,setValue:F,setValues:ee,getValues:L,reset:_e,resetField:he,clearErrors:ie,unregister:le,setError:ae,setFocus:ve,getFieldState:re};return{...be,formControl:be}}function lue(e={}){let t=R.useRef(void 0),n=R.useRef(void 0),[r,i]=R.useState({isDirty:!1,isValidating:!1,isLoading:nj(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:nj(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!nj(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=cue(e);t.current={...i,formState:r}}let a=t.current.control;return a._options=e,fj(()=>{let e=a._subscribe({formState:a._proxyFormState,callback:()=>i({...a._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),a._formState.isReady=!0,e},[a]),R.useEffect(()=>a._disableForm(e.disabled),[a,e.disabled]),R.useEffect(()=>{e.mode&&(a._options.mode=e.mode),e.reValidateMode&&(a._options.reValidateMode=e.reValidateMode)},[a,e.mode,e.reValidateMode]),R.useEffect(()=>{e.errors&&(a._setErrors(e.errors),a._focusError())},[a,e.errors]),R.useEffect(()=>{e.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,e.shouldUnregister]),R.useEffect(()=>{if(a._proxyFormState.isDirty){let e=a._getDirty();e!==r.isDirty&&a._subjects.state.next({isDirty:e})}},[a,r.isDirty]),R.useEffect(()=>{e.values&&!gj(e.values,n.current)?(a._reset(e.values,{keepFieldsRef:!0,...a._options.resetOptions}),a._options.resetOptions?.keepIsValid||a._setValid(),n.current=e.values,i(e=>({...e}))):a._resetDefaultValues()},[a,e.values]),R.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),t.current.formState=R.useMemo(()=>dj(r,a),[a,r]),t.current}function qj(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},q.apply(null,arguments)}var uue=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),due=n(((e,t)=>{var n=uue();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),fue=n(((e,t)=>{t.exports=due()()})),pue=n((e=>{if(typeof Symbol==`function`&&Symbol.for){var t=Symbol.for;t(`react.element`),t(`react.portal`),t(`react.fragment`),t(`react.strict_mode`),t(`react.profiler`),t(`react.provider`),t(`react.context`),t(`react.forward_ref`),t(`react.suspense`),t(`react.suspense_list`),t(`react.memo`),t(`react.lazy`),t(`react.block`),t(`react.server.block`),t(`react.fundamental`),t(`react.debug_trace_mode`),t(`react.legacy_hidden`)}})),mue=n(((e,t)=>{t.exports=pue()})),Jj=e=>typeof e==`object`&&!!e&&e.nodeType===1,Yj=(e,t)=>(!t||e!==`hidden`)&&e!==`visible`&&e!==`clip`,Xj=(e,t)=>{if(e.clientHeight<e.scrollHeight||e.clientWidth<e.scrollWidth){let n=getComputedStyle(e,null);return Yj(n.overflowY,t)||Yj(n.overflowX,t)||(e=>{let t=(e=>{if(!e.ownerDocument||!e.ownerDocument.defaultView)return null;try{return e.ownerDocument.defaultView.frameElement}catch{return null}})(e);return!!t&&(t.clientHeight<e.scrollHeight||t.clientWidth<e.scrollWidth)})(e)}return!1},Zj=(e,t,n,r,i,a,o,s)=>a<e&&o>t||a>e&&o<t?0:a<=e&&s<=n||o>=t&&s>=n?a-e-r:o>t&&s<n||a<e&&s>n?o-t+i:0,hue=e=>e.parentElement??(e.getRootNode().host||null),gue=(e,t)=>{if(typeof document>`u`)return[];let{scrollMode:n,block:r,inline:i,boundary:a,skipOverflowHiddenElements:o}=t,s=typeof a==`function`?a:e=>e!==a;if(!Jj(e))throw TypeError(`Invalid target`);let c=document.scrollingElement||document.documentElement,l=[],u=e;for(;Jj(u)&&s(u);){if(u=hue(u),u===c){l.push(u);break}u!=null&&u===document.body&&Xj(u)&&!Xj(document.documentElement)||u!=null&&Xj(u,o)&&l.push(u)}let d=window.visualViewport?.width??innerWidth,f=window.visualViewport?.height??innerHeight,p=window.scrollX??pageXOffset,m=window.scrollY??pageYOffset,{height:h,width:g,top:_,right:v,bottom:y,left:b}=e.getBoundingClientRect(),x=r===`start`||r===`nearest`?_:r===`end`?y:_+h/2,S=i===`center`?b+g/2:i===`end`?v:b,C=[];for(let e=0;e<l.length;e++){let t=l[e],{height:a,width:o,top:s,right:u,bottom:w,left:T}=t.getBoundingClientRect();if(n===`if-needed`&&_>=0&&b>=0&&y<=f&&v<=d&&_>=s&&y<=w&&b>=T&&v<=u)return C;let E=getComputedStyle(t),D=parseInt(E.borderLeftWidth,10),O=parseInt(E.borderTopWidth,10),k=parseInt(E.borderRightWidth,10),A=parseInt(E.borderBottomWidth,10),j=0,M=0,N=`offsetWidth`in t?t.offsetWidth-t.clientWidth-D-k:0,P=`offsetHeight`in t?t.offsetHeight-t.clientHeight-O-A:0,F=`offsetWidth`in t?t.offsetWidth===0?0:o/t.offsetWidth:0,ee=`offsetHeight`in t?t.offsetHeight===0?0:a/t.offsetHeight:0;if(c===t)j=r===`start`?x:r===`end`?x-f:r===`nearest`?Zj(m,m+f,f,O,A,m+x,m+x+h,h):x-f/2,M=i===`start`?S:i===`center`?S-d/2:i===`end`?S-d:Zj(p,p+d,d,D,k,p+S,p+S+g,g),j=Math.max(0,j+m),M=Math.max(0,M+p);else{j=r===`start`?x-s-O:r===`end`?x-w+A+P:r===`nearest`?Zj(s,w,a,O,A+P,x,x+h,h):x-(s+a/2)+P/2,M=i===`start`?S-T-D:i===`center`?S-(T+o/2)+N/2:i===`end`?S-u+k+N:Zj(T,u,o,D,k+N,S,S+g,g);let{scrollLeft:e,scrollTop:n}=t;j=Math.max(0,Math.min(n+j/ee,t.scrollHeight-a/ee+P)),M=Math.max(0,Math.min(e+M/F,t.scrollWidth-o/F+N)),x+=n-j,S+=e-M}C.push({el:t,top:j,left:M})}return C},J=t(fue());mue();var _ue=0;function Qj(){}function vue(e,t){e&&gue(e,{boundary:t,block:`nearest`,scrollMode:`if-needed`}).forEach(function(e){var t=e.el,n=e.top,r=e.left;t.scrollTop=n,t.scrollLeft=r})}function $j(e,t,n){return e===t||t instanceof n.Node&&e.contains&&e.contains(t)}function eM(e,t){var n;function r(){n&&clearTimeout(n)}function i(){var i=[...arguments];r(),n=setTimeout(function(){n=null,e.apply(void 0,i)},t)}return i.cancel=r,i}function tM(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return e&&e.apply(void 0,[t].concat(n)),t.preventDownshiftDefault||t.hasOwnProperty(`nativeEvent`)&&t.nativeEvent.preventDownshiftDefault})}}function nM(){var e=[...arguments];return function(t){e.forEach(function(e){typeof e==`function`?e(t):e&&(e.current=t)})}}function yue(){return String(_ue++)}function bue(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n===r?``:n+` result`+(n===1?` is`:`s are`)+` available, use up and down arrow keys to navigate. Press Enter key to select.`:`No results are available.`:``}function rM(e,t){return Object.keys(e).reduce(function(n,r){return n[r]=iM(t,r)?t[r]:e[r],n},{})}function iM(e,t){return e[t]!==void 0}function aM(e){var t=e.key,n=e.keyCode;return n>=37&&n<=40&&t.indexOf(`Arrow`)!==0?`Arrow`+t:t}function oM(e,t,n,r,i){if(i===void 0&&(i=!0),n===0)return-1;var a=n-1;(typeof t!=`number`||t<0||t>=n)&&(t=e>0?-1:a+1);var o=t+e;o<0?o=i?a:0:o>a&&(o=i?0:a);var s=sM(e,o,n,r,i);return s===-1?t>=n?-1:t:s}function sM(e,t,n,r,i){var a=r(t);if(!a||!a.hasAttribute(`disabled`))return t;if(e>0){for(var o=t+1;o<n;o++)if(!r(o).hasAttribute(`disabled`))return o}else for(var s=t-1;s>=0;s--)if(!r(s).hasAttribute(`disabled`))return s;return i?e>0?sM(1,0,n,r,!1):sM(-1,n-1,n,r,!1):-1}function cM(e,t,n,r){return r===void 0&&(r=!0),t.some(function(t){return t&&($j(t,e,n)||r&&$j(t,n.document.activeElement,n))})}var xue=eM(function(e){uM(e).textContent=``},500);function lM(e,t){var n=uM(t);e&&(n.textContent=e,xue(t))}function uM(e){e===void 0&&(e=document);var t=e.getElementById(`a11y-status-message`);return t||(t=e.createElement(`div`),t.setAttribute(`id`,`a11y-status-message`),t.setAttribute(`role`,`status`),t.setAttribute(`aria-live`,`polite`),t.setAttribute(`aria-relevant`,`additions text`),Object.assign(t.style,{border:`0`,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:`0`,position:`absolute`,width:`1px`}),e.body.appendChild(t),t)}var Sue=[`isInitialMount`,`highlightedIndex`,`items`,`environment`],dM={highlightedIndex:-1,isOpen:!1,selectedItem:null,inputValue:``};function Cue(e,t,n){var r=e.props,i=e.type,a={};Object.keys(t).forEach(function(r){wue(r,e,t,n),n[r]!==t[r]&&(a[r]=n[r])}),r.onStateChange&&Object.keys(a).length&&r.onStateChange(q({type:i},a))}function wue(e,t,n,r){var i=t.props,a=t.type,o=`on`+mM(e)+`Change`;i[o]&&r[e]!==void 0&&r[e]!==n[e]&&i[o](q({type:a},r))}function Tue(e,t){return t.changes}function Eue(e){var t=e.selectedItem,n=e.itemToString;return t?n(t)+` has been selected.`:``}var Due=eM(function(e,t){lM(e(),t)},200),Oue=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?R.useLayoutEffect:R.useEffect;function fM(e){var t=e.id,n=t===void 0?`downshift-`+yue():t,r=e.labelId,i=e.menuId,a=e.getItemId,o=e.toggleButtonId,s=e.inputId;return(0,R.useRef)({labelId:r||n+`-label`,menuId:i||n+`-menu`,getItemId:a||function(e){return n+`-item-`+e},toggleButtonId:o||n+`-toggle-button`,inputId:s||n+`-input`}).current}function pM(e,t,n,r){var i,a;if(e===void 0){if(t===void 0)throw Error(r);i=n[t],a=t}else a=t===void 0?n.indexOf(e):t,i=e;return[i,a]}function kue(e){return e?String(e):``}function Aue(e){return/^\S{1}$/.test(e)}function mM(e){return``+e.slice(0,1).toUpperCase()+e.slice(1)}function hM(e){var t=(0,R.useRef)(e);return t.current=e,t}function gM(e,t,n){var r=(0,R.useRef)(),i=(0,R.useRef)(),a=(0,R.useReducer)((0,R.useCallback)(function(t,n){i.current=n,t=rM(t,n.props);var r=e(t,n);return n.props.stateReducer(t,q({},n,{changes:r}))},[e]),t),o=a[0],s=a[1],c=hM(n),l=(0,R.useCallback)(function(e){return s(q({props:c.current},e))},[c]),u=i.current;return(0,R.useEffect)(function(){u&&r.current&&r.current!==o&&Cue(u,rM(r.current,u.props),o),r.current=o},[o,n,u]),[o,l]}function _M(e,t,n){var r=gM(e,t,n),i=r[0],a=r[1];return[rM(i,n),a]}var vM={itemToString:kue,stateReducer:Tue,getA11ySelectionMessage:Eue,scrollIntoView:vue,environment:typeof window>`u`?{}:window};function yM(e,t,n){n===void 0&&(n=dM);var r=e[`default`+mM(t)];return r===void 0?n[t]:r}function bM(e,t,n){n===void 0&&(n=dM);var r=e[t];if(r!==void 0)return r;var i=e[`initial`+mM(t)];return i===void 0?yM(e,t,n):i}function xM(e){var t=bM(e,`selectedItem`),n=bM(e,`isOpen`),r=bM(e,`highlightedIndex`),i=bM(e,`inputValue`);return{highlightedIndex:r<0&&t&&n?e.items.indexOf(t):r,isOpen:n,selectedItem:t,inputValue:i}}function SM(e,t,n){var r=e.items,i=e.initialHighlightedIndex,a=e.defaultHighlightedIndex,o=t.selectedItem,s=t.highlightedIndex;return r.length===0?-1:i!==void 0&&s===i?i:a===void 0?o?r.indexOf(o):n===0?-1:n<0?r.length-1:0:a}function CM(e,t,n,r){var i=(0,R.useRef)({isMouseDown:!1,isTouchMove:!1});return(0,R.useEffect)(function(){if(n?.addEventListener!=null){var a=function(){i.current.isMouseDown=!0},o=function(a){i.current.isMouseDown=!1,e&&!cM(a.target,t.map(function(e){return e.current}),n)&&r()},s=function(){i.current.isTouchMove=!1},c=function(){i.current.isTouchMove=!0},l=function(a){e&&!i.current.isTouchMove&&!cM(a.target,t.map(function(e){return e.current}),n,!1)&&r()};return n.addEventListener(`mousedown`,a),n.addEventListener(`mouseup`,o),n.addEventListener(`touchstart`,s),n.addEventListener(`touchmove`,c),n.addEventListener(`touchend`,l),function(){n.removeEventListener(`mousedown`,a),n.removeEventListener(`mouseup`,o),n.removeEventListener(`touchstart`,s),n.removeEventListener(`touchmove`,c),n.removeEventListener(`touchend`,l)}}},[e,n]),i}var wM=function(){return Qj};function TM(e,t,n){var r=n.isInitialMount,i=n.highlightedIndex,a=n.items,o=n.environment,s=qj(n,Sue);(0,R.useEffect)(function(){r||Due(function(){return e(q({highlightedIndex:i,highlightedItem:a[i],resultCount:a.length},s))},o.document)},t)}function EM(e){var t=e.highlightedIndex,n=e.isOpen,r=e.itemRefs,i=e.getItemNodeFromIndex,a=e.menuElement,o=e.scrollIntoView,s=(0,R.useRef)(!0);return Oue(function(){t<0||!n||!Object.keys(r.current).length||(s.current===!1?s.current=!0:o(i(t),a))},[t]),s}var DM=Qj;function OM(e,t,n){return n===void 0&&(n=!0),q({isOpen:!1,highlightedIndex:-1},e.items?.length&&t>=0&&q({selectedItem:e.items[t],isOpen:yM(e,`isOpen`),highlightedIndex:yM(e,`highlightedIndex`)},n&&{inputValue:e.itemToString(e.items[t])}))}function kM(e,t,n){var r=t.type,i=t.props,a;switch(r){case n.ItemMouseMove:a={highlightedIndex:t.disabled?-1:t.index};break;case n.MenuMouseLeave:a={highlightedIndex:-1};break;case n.ToggleButtonClick:case n.FunctionToggleMenu:a={isOpen:!e.isOpen,highlightedIndex:e.isOpen?-1:SM(i,e,0)};break;case n.FunctionOpenMenu:a={isOpen:!0,highlightedIndex:SM(i,e,0)};break;case n.FunctionCloseMenu:a={isOpen:!1};break;case n.FunctionSetHighlightedIndex:a={highlightedIndex:t.highlightedIndex};break;case n.FunctionSetInputValue:a={inputValue:t.inputValue};break;case n.FunctionReset:a={highlightedIndex:yM(i,`highlightedIndex`),isOpen:yM(i,`isOpen`),selectedItem:yM(i,`selectedItem`),inputValue:yM(i,`inputValue`)};break;default:throw Error(`Reducer called without proper action type.`)}return q({},e,a)}function jue(e){for(var t=e.keysSoFar,n=e.highlightedIndex,r=e.items,i=e.itemToString,a=e.getItemNodeFromIndex,o=t.toLowerCase(),s=0;s<r.length;s++){var c=(s+n+ +(t.length<2))%r.length,l=r[c];if(l!==void 0&&i(l).toLowerCase().startsWith(o)&&!a(c)?.hasAttribute(`disabled`))return c}return n}J.default.array.isRequired,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.bool,J.default.bool,J.default.bool,J.default.any,J.default.any,J.default.any,J.default.string,J.default.string,J.default.string,J.default.func,J.default.string,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});function Mue(e){var t=e.isOpen,n=e.resultCount,r=e.previousResultCount;return t?n?n===r?``:`${n} result${n===1?` is`:`s are`} available, use up and down arrow keys to navigate. Press Enter or Space Bar keys to select.`:`No results are available.`:``}var Nue=qD(qD({},vM),{getA11yStatusMessage:Mue}),Pue=Qj,AM=0,jM=1,MM=2,NM=3,PM=4,FM=5,IM=6,LM=7,RM=8,zM=9,BM=10,VM=11,HM=12,UM=13,WM=14,GM=15,KM=16,qM=17,JM=18,YM=19,XM=20,ZM=21,QM=Object.freeze({__proto__:null,ToggleButtonClick:AM,ToggleButtonKeyDownArrowDown:jM,ToggleButtonKeyDownArrowUp:MM,ToggleButtonKeyDownCharacter:NM,ToggleButtonKeyDownEscape:PM,ToggleButtonKeyDownHome:FM,ToggleButtonKeyDownEnd:IM,ToggleButtonKeyDownEnter:LM,ToggleButtonKeyDownSpaceButton:RM,ToggleButtonKeyDownPageUp:zM,ToggleButtonKeyDownPageDown:BM,ToggleButtonBlur:VM,MenuMouseLeave:HM,ItemMouseMove:UM,ItemClick:WM,FunctionToggleMenu:GM,FunctionOpenMenu:KM,FunctionCloseMenu:qM,FunctionSetHighlightedIndex:JM,FunctionSelectItem:YM,FunctionSetInputValue:XM,FunctionReset:ZM});function Fue(e,t){var n=t.type,r=t.props,i=t.altKey,a;switch(n){case WM:a={isOpen:yM(r,`isOpen`),highlightedIndex:yM(r,`highlightedIndex`),selectedItem:r.items[t.index]};break;case NM:var o=t.key,s=``+e.inputValue+o;a={inputValue:s,highlightedIndex:jue({keysSoFar:s,highlightedIndex:!e.isOpen&&e.selectedItem?r.items.indexOf(e.selectedItem):e.highlightedIndex,items:r.items,itemToString:r.itemToString,getItemNodeFromIndex:t.getItemNodeFromIndex}),isOpen:!0};break;case jM:a={highlightedIndex:e.isOpen?oM(1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1):i&&e.selectedItem==null?-1:SM(r,e,1),isOpen:!0};break;case MM:a=e.isOpen&&i?OM(r,e.highlightedIndex,!1):{highlightedIndex:e.isOpen?oM(-1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1):SM(r,e,-1),isOpen:!0};break;case LM:case RM:a=OM(r,e.highlightedIndex,!1);break;case FM:a={highlightedIndex:sM(1,0,r.items.length,t.getItemNodeFromIndex,!1),isOpen:!0};break;case IM:a={highlightedIndex:sM(-1,r.items.length-1,r.items.length,t.getItemNodeFromIndex,!1),isOpen:!0};break;case zM:a={highlightedIndex:oM(-10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case BM:a={highlightedIndex:oM(10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case PM:a={isOpen:!1,highlightedIndex:-1};break;case VM:a=q({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&r.items?.length&&{selectedItem:r.items[e.highlightedIndex]});break;case YM:a={selectedItem:t.selectedItem};break;default:return kM(e,t,QM)}return q({},e,a)}var Iue=[`onMouseLeave`,`refKey`,`onKeyDown`,`onBlur`,`ref`],Lue=[`onBlur`,`onClick`,`onPress`,`onKeyDown`,`refKey`,`ref`],Rue=[`item`,`index`,`onMouseMove`,`onClick`,`onPress`,`refKey`,`ref`,`disabled`];$M.stateChangeTypes=QM;function $M(e){e===void 0&&(e={}),Pue(e,$M);var t=q({},Nue,e),n=t.items,r=t.scrollIntoView,i=t.environment,a=t.itemToString,o=t.getA11ySelectionMessage,s=t.getA11yStatusMessage,c=_M(Fue,xM(t),t),l=c[0],u=c[1],d=l.isOpen,f=l.highlightedIndex,p=l.selectedItem,m=l.inputValue,h=(0,R.useRef)(null),g=(0,R.useRef)(null),_=(0,R.useRef)({}),v=(0,R.useRef)(null),y=fM(t),b=(0,R.useRef)(),x=(0,R.useRef)(!0),S=hM({state:l,props:t}),C=(0,R.useCallback)(function(e){return _.current[y.getItemId(e)]},[y]);TM(s,[d,f,m,n],q({isInitialMount:x.current,previousResultCount:b.current,items:n,environment:i,itemToString:a},l)),TM(o,[p],q({isInitialMount:x.current,previousResultCount:b.current,items:n,environment:i,itemToString:a},l));var w=EM({menuElement:g.current,highlightedIndex:f,isOpen:d,itemRefs:_,scrollIntoView:r,getItemNodeFromIndex:C});(0,R.useEffect)(function(){return v.current=eM(function(e){e({type:XM,inputValue:``})},500),function(){v.current.cancel()}},[]),(0,R.useEffect)(function(){m&&v.current(u)},[u,m]),DM({isInitialMount:x.current,props:t,state:l}),(0,R.useEffect)(function(){x.current||(b.current=n.length)});var T=CM(d,[g,h],i,function(){u({type:VM})}),E=wM(`getMenuProps`,`getToggleButtonProps`);(0,R.useEffect)(function(){return x.current=!1,function(){x.current=!0}},[]),(0,R.useEffect)(function(){d||(_.current={})},[d]);var D=(0,R.useMemo)(function(){return{ArrowDown:function(e){e.preventDefault(),u({type:jM,getItemNodeFromIndex:C,altKey:e.altKey})},ArrowUp:function(e){e.preventDefault(),u({type:MM,getItemNodeFromIndex:C,altKey:e.altKey})},Home:function(e){e.preventDefault(),u({type:FM,getItemNodeFromIndex:C})},End:function(e){e.preventDefault(),u({type:IM,getItemNodeFromIndex:C})},Escape:function(){S.current.state.isOpen&&u({type:PM})},Enter:function(e){e.preventDefault(),u({type:S.current.state.isOpen?LM:AM})},PageUp:function(e){S.current.state.isOpen&&(e.preventDefault(),u({type:zM,getItemNodeFromIndex:C}))},PageDown:function(e){S.current.state.isOpen&&(e.preventDefault(),u({type:BM,getItemNodeFromIndex:C}))}," ":function(e){e.preventDefault();var t=S.current.state;if(!t.isOpen){u({type:AM});return}t.inputValue?u({type:NM,key:` `,getItemNodeFromIndex:C}):u({type:RM})}}},[u,C,S]),O=(0,R.useCallback)(function(){u({type:GM})},[u]),k=(0,R.useCallback)(function(){u({type:qM})},[u]),A=(0,R.useCallback)(function(){u({type:KM})},[u]),j=(0,R.useCallback)(function(e){u({type:JM,highlightedIndex:e})},[u]),M=(0,R.useCallback)(function(e){u({type:YM,selectedItem:e})},[u]),N=(0,R.useCallback)(function(){u({type:ZM})},[u]),P=(0,R.useCallback)(function(e){u({type:XM,inputValue:e})},[u]),F=(0,R.useCallback)(function(e){return q({id:y.labelId,htmlFor:y.toggleButtonId},e)},[y]),ee=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onMouseLeave,a=r.refKey,o=a===void 0?`ref`:a;r.onKeyDown,r.onBlur;var s=r.ref,c=qj(r,Iue),l=(t===void 0?{}:t).suppressRefError;return E(`getMenuProps`,l===void 0?!1:l,o,g),q((n={},n[o]=nM(s,function(e){g.current=e}),n.id=y.menuId,n.role=`listbox`,n[`aria-labelledby`]=c&&c[`aria-label`]?void 0:``+y.labelId,n.onMouseLeave=tM(i,function(){u({type:HM})}),n),c)},[u,E,y]);return{getToggleButtonProps:(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onBlur,a=r.onClick;r.onPress;var o=r.onKeyDown,s=r.refKey,c=s===void 0?`ref`:s,l=r.ref,d=qj(r,Lue),f=(t===void 0?{}:t).suppressRefError,p=f===void 0?!1:f,m=S.current.state,g=function(){u({type:AM})},_=function(){m.isOpen&&!T.current.isMouseDown&&u({type:VM})},v=function(e){var t=aM(e);t&&D[t]?D[t](e):Aue(t)&&u({type:NM,key:t,getItemNodeFromIndex:C})},b=q((n={},n[c]=nM(l,function(e){h.current=e}),n[`aria-activedescendant`]=m.isOpen&&m.highlightedIndex>-1?y.getItemId(m.highlightedIndex):``,n[`aria-controls`]=y.menuId,n[`aria-expanded`]=S.current.state.isOpen,n[`aria-haspopup`]=`listbox`,n[`aria-labelledby`]=d&&d[`aria-label`]?void 0:``+y.labelId,n.id=y.toggleButtonId,n.role=`combobox`,n.tabIndex=0,n.onBlur=tM(i,_),n),d);return d.disabled||(b.onClick=tM(a,g),b.onKeyDown=tM(o,v)),E(`getToggleButtonProps`,p,c,h),b},[S,y,E,u,T,D,C]),getLabelProps:F,getMenuProps:ee,getItemProps:(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.item,i=n.index,a=n.onMouseMove,o=n.onClick;n.onPress;var s=n.refKey,c=s===void 0?`ref`:s,l=n.ref,d=n.disabled,f=qj(n,Rue),m=S.current,h=m.state,g=m.props,v=pM(r,i,g.items,`Pass either item or index to getItemProps!`),b=v[0],x=v[1],C=function(){x!==h.highlightedIndex&&(w.current=!1,u({type:UM,index:x,disabled:d}))},T=function(){u({type:WM,index:x})},E=q((t={disabled:d,role:`option`,"aria-selected":``+(b===p),id:y.getItemId(x)},t[c]=nM(l,function(e){e&&(_.current[y.getItemId(x)]=e)}),t),f);return d||(E.onClick=tM(o,T)),E.onMouseMove=tM(a,C),E},[S,p,y,w,u]),toggleMenu:O,openMenu:A,closeMenu:k,setHighlightedIndex:j,selectItem:M,reset:N,setInputValue:P,highlightedIndex:f,isOpen:d,selectedItem:p,inputValue:m}}var eN=0,tN=1,nN=2,rN=3,iN=4,aN=5,oN=6,sN=7,cN=8,lN=9,uN=10,dN=11,fN=12,pN=13,mN=14,hN=15,gN=16,_N=17,vN=18,yN=19,bN=20,xN=21,SN=22,CN=Object.freeze({__proto__:null,InputKeyDownArrowDown:eN,InputKeyDownArrowUp:tN,InputKeyDownEscape:nN,InputKeyDownHome:rN,InputKeyDownEnd:iN,InputKeyDownPageUp:aN,InputKeyDownPageDown:oN,InputKeyDownEnter:sN,InputChange:cN,InputBlur:lN,InputFocus:uN,MenuMouseLeave:dN,ItemMouseMove:fN,ItemClick:pN,ToggleButtonClick:mN,FunctionToggleMenu:hN,FunctionOpenMenu:gN,FunctionCloseMenu:_N,FunctionSetHighlightedIndex:vN,FunctionSelectItem:yN,FunctionSetInputValue:bN,FunctionReset:xN,ControlledPropUpdatedSelectedItem:SN});function zue(e){var t=xM(e),n=t.selectedItem,r=t.inputValue;return r===``&&n&&e.defaultInputValue===void 0&&e.initialInputValue===void 0&&e.inputValue===void 0&&(r=e.itemToString(n)),q({},t,{inputValue:r})}J.default.array.isRequired,J.default.func,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.bool,J.default.bool,J.default.bool,J.default.any,J.default.any,J.default.any,J.default.string,J.default.string,J.default.string,J.default.string,J.default.string,J.default.string,J.default.func,J.default.string,J.default.string,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.func,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});function Bue(e,t,n){var r=(0,R.useRef)(),i=gM(e,t,n),a=i[0],o=i[1];return(0,R.useEffect)(function(){iM(n,`selectedItem`)&&(n.selectedItemChanged(r.current,n.selectedItem)&&o({type:SN,inputValue:n.itemToString(n.selectedItem)}),r.current=a.selectedItem===r.current?n.selectedItem:a.selectedItem)},[a.selectedItem,n.selectedItem]),[rM(a,n),o]}var Vue=Qj,Hue=q({},vM,{selectedItemChanged:function(e,t){return e!==t},getA11yStatusMessage:bue});function Uue(e,t){var n=t.type,r=t.props,i=t.altKey,a;switch(n){case pN:a={isOpen:yM(r,`isOpen`),highlightedIndex:yM(r,`highlightedIndex`),selectedItem:r.items[t.index],inputValue:r.itemToString(r.items[t.index])};break;case eN:a=e.isOpen?{highlightedIndex:oM(1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!0)}:{highlightedIndex:i&&e.selectedItem==null?-1:SM(r,e,1,t.getItemNodeFromIndex),isOpen:r.items.length>=0};break;case tN:a=e.isOpen?i?OM(r,e.highlightedIndex):{highlightedIndex:oM(-1,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!0)}:{highlightedIndex:SM(r,e,-1,t.getItemNodeFromIndex),isOpen:r.items.length>=0};break;case sN:a=OM(r,e.highlightedIndex);break;case nN:a=q({isOpen:!1,highlightedIndex:-1},!e.isOpen&&{selectedItem:null,inputValue:``});break;case aN:a={highlightedIndex:oM(-10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case oN:a={highlightedIndex:oM(10,e.highlightedIndex,r.items.length,t.getItemNodeFromIndex,!1)};break;case rN:a={highlightedIndex:sM(1,0,r.items.length,t.getItemNodeFromIndex,!1)};break;case iN:a={highlightedIndex:sM(-1,r.items.length-1,r.items.length,t.getItemNodeFromIndex,!1)};break;case lN:a=q({isOpen:!1,highlightedIndex:-1},e.highlightedIndex>=0&&r.items?.length&&t.selectItem&&{selectedItem:r.items[e.highlightedIndex],inputValue:r.itemToString(r.items[e.highlightedIndex])});break;case cN:a={isOpen:!0,highlightedIndex:yM(r,`highlightedIndex`),inputValue:t.inputValue};break;case uN:a={isOpen:!0,highlightedIndex:SM(r,e,0)};break;case yN:a={selectedItem:t.selectedItem,inputValue:r.itemToString(t.selectedItem)};break;case SN:a={inputValue:t.inputValue};break;default:return kM(e,t,CN)}return q({},e,a)}var Wue=[`onMouseLeave`,`refKey`,`ref`],Gue=[`item`,`index`,`refKey`,`ref`,`onMouseMove`,`onMouseDown`,`onClick`,`onPress`,`disabled`],Kue=[`onClick`,`onPress`,`refKey`,`ref`],que=[`onKeyDown`,`onChange`,`onInput`,`onFocus`,`onBlur`,`onChangeText`,`refKey`,`ref`];wN.stateChangeTypes=CN;function wN(e){e===void 0&&(e={}),Vue(e,wN);var t=q({},Hue,e),n=t.initialIsOpen,r=t.defaultIsOpen,i=t.items,a=t.scrollIntoView,o=t.environment,s=t.getA11yStatusMessage,c=t.getA11ySelectionMessage,l=t.itemToString,u=Bue(Uue,zue(t),t),d=u[0],f=u[1],p=d.isOpen,m=d.highlightedIndex,h=d.selectedItem,g=d.inputValue,_=(0,R.useRef)(null),v=(0,R.useRef)({}),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(!0),S=fM(t),C=(0,R.useRef)(),w=hM({state:d,props:t}),T=(0,R.useCallback)(function(e){return v.current[S.getItemId(e)]},[S]);TM(s,[p,m,g,i],q({isInitialMount:x.current,previousResultCount:C.current,items:i,environment:o,itemToString:l},d)),TM(c,[h],q({isInitialMount:x.current,previousResultCount:C.current,items:i,environment:o,itemToString:l},d));var E=EM({menuElement:_.current,highlightedIndex:m,isOpen:p,itemRefs:v,scrollIntoView:a,getItemNodeFromIndex:T});DM({isInitialMount:x.current,props:t,state:d}),(0,R.useEffect)(function(){(n||r||p)&&y.current&&y.current.focus()},[]),(0,R.useEffect)(function(){x.current||(C.current=i.length)});var D=CM(p,[y,_,b],o,function(){f({type:lN,selectItem:!1})}),O=wM(`getInputProps`,`getMenuProps`);(0,R.useEffect)(function(){return x.current=!1,function(){x.current=!0}},[]),(0,R.useEffect)(function(){if(!p)v.current={};else if(o.document?.activeElement!==y.current){var e;y==null||(e=y.current)==null||e.focus()}},[p,o]);var k=(0,R.useMemo)(function(){return{ArrowDown:function(e){e.preventDefault(),f({type:eN,altKey:e.altKey,getItemNodeFromIndex:T})},ArrowUp:function(e){e.preventDefault(),f({type:tN,altKey:e.altKey,getItemNodeFromIndex:T})},Home:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:rN,getItemNodeFromIndex:T}))},End:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:iN,getItemNodeFromIndex:T}))},Escape:function(e){var t=w.current.state;(t.isOpen||t.inputValue||t.selectedItem||t.highlightedIndex>-1)&&(e.preventDefault(),f({type:nN}))},Enter:function(e){!w.current.state.isOpen||e.which===229||(e.preventDefault(),f({type:sN,getItemNodeFromIndex:T}))},PageUp:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:aN,getItemNodeFromIndex:T}))},PageDown:function(e){w.current.state.isOpen&&(e.preventDefault(),f({type:oN,getItemNodeFromIndex:T}))}}},[f,w,T]),A=(0,R.useCallback)(function(e){return q({id:S.labelId,htmlFor:S.inputId},e)},[S]),j=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onMouseLeave,a=r.refKey,o=a===void 0?`ref`:a,s=r.ref,c=qj(r,Wue),l=(t===void 0?{}:t).suppressRefError;return O(`getMenuProps`,l===void 0?!1:l,o,_),q((n={},n[o]=nM(s,function(e){_.current=e}),n.id=S.menuId,n.role=`listbox`,n[`aria-labelledby`]=c&&c[`aria-label`]?void 0:``+S.labelId,n.onMouseLeave=tM(i,function(){f({type:dN})}),n),c)},[f,O,S]),M=(0,R.useCallback)(function(e){var t,n,r=e===void 0?{}:e,i=r.item,a=r.index,o=r.refKey,s=o===void 0?`ref`:o,c=r.ref,l=r.onMouseMove,u=r.onMouseDown,d=r.onClick;r.onPress;var p=r.disabled,m=qj(r,Gue),h=w.current,g=h.props,_=h.state,y=pM(i,a,g.items,`Pass either item or index to getItemProps!`)[1],b=`onClick`,x=d;return q((t={},t[s]=nM(c,function(e){e&&(v.current[S.getItemId(y)]=e)}),t.disabled=p,t.role=`option`,t[`aria-selected`]=``+(y===_.highlightedIndex),t.id=S.getItemId(y),t),!p&&(n={},n[b]=tM(x,function(){f({type:pN,index:y})}),n),{onMouseMove:tM(l,function(){y!==_.highlightedIndex&&(E.current=!1,f({type:fN,index:y,disabled:p}))}),onMouseDown:tM(u,function(e){return e.preventDefault()})},m)},[f,w,E,S]),N=(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.onClick;n.onPress;var i=n.refKey,a=i===void 0?`ref`:i,o=n.ref,s=qj(n,Kue),c=w.current.state;return q((t={},t[a]=nM(o,function(e){b.current=e}),t[`aria-controls`]=S.menuId,t[`aria-expanded`]=c.isOpen,t.id=S.toggleButtonId,t.tabIndex=-1,t),!s.disabled&&q({},{onClick:tM(r,function(){f({type:mN})})}),s)},[f,w,S]),P=(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.onKeyDown,a=r.onChange,s=r.onInput,c=r.onFocus,l=r.onBlur;r.onChangeText;var u=r.refKey,d=u===void 0?`ref`:u,p=r.ref,m=qj(r,que),h=(t===void 0?{}:t).suppressRefError;O(`getInputProps`,h===void 0?!1:h,d,y);var g=w.current.state,_=function(e){var t=aM(e);t&&k[t]&&k[t](e)},v=function(e){f({type:cN,inputValue:e.target.value})},b=function(e){g.isOpen&&!D.current.isMouseDown&&f({type:lN,selectItem:!(e.relatedTarget===null&&o.document.activeElement!==o.document.body)})},x=function(){g.isOpen||f({type:uN})},C=`onChange`,T={};if(!m.disabled){var E;T=(E={},E[C]=tM(a,s,v),E.onKeyDown=tM(i,_),E.onBlur=tM(l,b),E.onFocus=tM(c,x),E)}return q((n={},n[d]=nM(p,function(e){y.current=e}),n[`aria-activedescendant`]=g.isOpen&&g.highlightedIndex>-1?S.getItemId(g.highlightedIndex):``,n[`aria-autocomplete`]=`list`,n[`aria-controls`]=S.menuId,n[`aria-expanded`]=g.isOpen,n[`aria-labelledby`]=m&&m[`aria-label`]?void 0:``+S.labelId,n.autoComplete=`off`,n.id=S.inputId,n.role=`combobox`,n.value=g.inputValue,n),T,m)},[O,w,S,k,f,D,o]),F=(0,R.useCallback)(function(){f({type:hN})},[f]),ee=(0,R.useCallback)(function(){f({type:_N})},[f]),te=(0,R.useCallback)(function(){f({type:gN})},[f]),I=(0,R.useCallback)(function(e){f({type:vN,highlightedIndex:e})},[f]),ne=(0,R.useCallback)(function(e){f({type:yN,selectedItem:e})},[f]);return{getItemProps:M,getLabelProps:A,getMenuProps:j,getInputProps:P,getToggleButtonProps:N,toggleMenu:F,openMenu:te,closeMenu:ee,setHighlightedIndex:I,setInputValue:(0,R.useCallback)(function(e){f({type:bN,inputValue:e})},[f]),selectItem:ne,reset:(0,R.useCallback)(function(){f({type:xN})},[f]),highlightedIndex:m,isOpen:p,selectedItem:h,inputValue:g}}var TN={activeIndex:-1,selectedItems:[]};function EN(e,t){return bM(e,t,TN)}function DN(e,t){return yM(e,t,TN)}function Jue(e){return{activeIndex:EN(e,`activeIndex`),selectedItems:EN(e,`selectedItems`)}}function ON(e){if(e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return!1;var t=e.target;return!(t instanceof HTMLInputElement&&t.value!==``&&(t.selectionStart!==0||t.selectionEnd!==0))}function Yue(e){var t=e.removedSelectedItem,n=e.itemToString;return n(t)+` has been removed.`}J.default.array,J.default.array,J.default.array,J.default.func,J.default.func,J.default.func,J.default.number,J.default.number,J.default.number,J.default.func,J.default.func,J.default.string,J.default.string,J.default.shape({addEventListener:J.default.func,removeEventListener:J.default.func,document:J.default.shape({getElementById:J.default.func,activeElement:J.default.any,body:J.default.any})});var Xue={itemToString:vM.itemToString,stateReducer:vM.stateReducer,environment:vM.environment,getA11yRemovalMessage:Yue,keyNavigationNext:`ArrowRight`,keyNavigationPrevious:`ArrowLeft`},Zue=Qj,kN=0,AN=1,jN=2,MN=3,NN=4,PN=5,FN=6,IN=7,LN=8,RN=9,zN=10,BN=11,VN=12,Que=Object.freeze({__proto__:null,SelectedItemClick:kN,SelectedItemKeyDownDelete:AN,SelectedItemKeyDownBackspace:jN,SelectedItemKeyDownNavigationNext:MN,SelectedItemKeyDownNavigationPrevious:NN,DropdownKeyDownNavigationPrevious:PN,DropdownKeyDownBackspace:FN,DropdownClick:IN,FunctionAddSelectedItem:LN,FunctionRemoveSelectedItem:RN,FunctionSetSelectedItems:zN,FunctionSetActiveIndex:BN,FunctionReset:VN});function $ue(e,t){var n=t.type,r=t.index,i=t.props,a=t.selectedItem,o=e.activeIndex,s=e.selectedItems,c;switch(n){case kN:c={activeIndex:r};break;case NN:c={activeIndex:o-1<0?0:o-1};break;case MN:c={activeIndex:o+1>=s.length?-1:o+1};break;case jN:case AN:if(o<0)break;var l=o;s.length===1?l=-1:o===s.length-1&&(l=s.length-2),c=q({selectedItems:[].concat(s.slice(0,o),s.slice(o+1))},{activeIndex:l});break;case PN:c={activeIndex:s.length-1};break;case FN:c={selectedItems:s.slice(0,s.length-1)};break;case LN:c={selectedItems:[].concat(s,[a])};break;case IN:c={activeIndex:-1};break;case RN:var u=o,d=s.indexOf(a);if(d<0)break;s.length===1?u=-1:d===s.length-1&&(u=s.length-2),c={selectedItems:[].concat(s.slice(0,d),s.slice(d+1)),activeIndex:u};break;case zN:c={selectedItems:t.selectedItems};break;case BN:c={activeIndex:t.activeIndex};break;case VN:c={activeIndex:DN(i,`activeIndex`),selectedItems:DN(i,`selectedItems`)};break;default:throw Error(`Reducer called without proper action type.`)}return q({},e,c)}var ede=[`refKey`,`ref`,`onClick`,`onKeyDown`,`selectedItem`,`index`],tde=[`refKey`,`ref`,`onKeyDown`,`onClick`,`preventKeyAction`];HN.stateChangeTypes=Que;function HN(e){e===void 0&&(e={}),Zue(e,HN);var t=q({},Xue,e),n=t.getA11yRemovalMessage,r=t.itemToString,i=t.environment,a=t.keyNavigationNext,o=t.keyNavigationPrevious,s=_M($ue,Jue(t),t),c=s[0],l=s[1],u=c.activeIndex,d=c.selectedItems,f=(0,R.useRef)(!0),p=(0,R.useRef)(null),m=(0,R.useRef)(d),h=(0,R.useRef)();h.current=[];var g=hM({state:c,props:t});(0,R.useEffect)(function(){if(!f.current){if(d.length<m.current.length){var e=m.current.find(function(e){return d.indexOf(e)<0});lM(n({itemToString:r,resultCount:d.length,removedSelectedItem:e,activeIndex:u,activeSelectedItem:d[u]}),i.document)}m.current=d}},[d.length]),(0,R.useEffect)(function(){f.current||(u===-1&&p.current?p.current.focus():h.current[u]&&h.current[u].focus())},[u]),DM({isInitialMount:f.current,props:t,state:c});var _=wM(`getDropdownProps`);(0,R.useEffect)(function(){return f.current=!1,function(){f.current=!0}},[]);var v=(0,R.useMemo)(function(){var e;return e={},e[o]=function(){l({type:NN})},e[a]=function(){l({type:MN})},e.Delete=function(){l({type:AN})},e.Backspace=function(){l({type:jN})},e},[l,a,o]),y=(0,R.useMemo)(function(){var e;return e={},e[o]=function(e){ON(e)&&l({type:PN})},e.Backspace=function(e){ON(e)&&l({type:FN})},e},[l,o]);return{getSelectedItemProps:(0,R.useCallback)(function(e){var t,n=e===void 0?{}:e,r=n.refKey,i=r===void 0?`ref`:r,a=n.ref,o=n.onClick,s=n.onKeyDown,c=n.selectedItem,u=n.index,d=qj(n,ede),f=g.current.state,p=pM(c,u,f.selectedItems,`Pass either item or index to getSelectedItemProps!`)[1],m=p>-1&&p===f.activeIndex;return q((t={},t[i]=nM(a,function(e){e&&h.current.push(e)}),t.tabIndex=m?0:-1,t.onClick=tM(o,function(){l({type:kN,index:p})}),t.onKeyDown=tM(s,function(e){var t=aM(e);t&&v[t]&&v[t](e)}),t),d)},[l,g,v]),getDropdownProps:(0,R.useCallback)(function(e,t){var n,r=e===void 0?{}:e,i=r.refKey,a=i===void 0?`ref`:i,o=r.ref,s=r.onKeyDown,c=r.onClick,u=r.preventKeyAction,d=u===void 0?!1:u,f=qj(r,tde),m=(t===void 0?{}:t).suppressRefError;return _(`getDropdownProps`,m===void 0?!1:m,a,p),q((n={},n[a]=nM(o,function(e){e&&(p.current=e)}),n),!d&&{onKeyDown:tM(s,function(e){var t=aM(e);t&&y[t]&&y[t](e)}),onClick:tM(c,function(){l({type:IN})})},f)},[l,y,_]),addSelectedItem:(0,R.useCallback)(function(e){l({type:LN,selectedItem:e})},[l]),removeSelectedItem:(0,R.useCallback)(function(e){l({type:RN,selectedItem:e})},[l]),setSelectedItems:(0,R.useCallback)(function(e){l({type:zN,selectedItems:e})},[l]),setActiveIndex:(0,R.useCallback)(function(e){l({type:BN,activeIndex:e})},[l]),reset:(0,R.useCallback)(function(){l({type:VN})},[l]),selectedItems:d,activeIndex:u}}var UN=20,nde=e=>e.suggestions.length>0?R.createElement(rde,{...e}):R.createElement(`input`,{className:mw.textInput,size:40,autoFocus:!0,...e.register(e.inputName)}),rde=({autofocus:e,suggestions:t,control:n,inputName:r,placeholder:i,initialInputValue:a,setValue:o})=>{let[s,c]=R.useState(t.slice(0,UN)),l=Vl(NC),u=t.length>0,{isOpen:d,getToggleButtonProps:f,getMenuProps:p,getInputProps:m,highlightedIndex:h,getItemProps:g,selectedItem:_}=wN({initialInputValue:a,onInputValueChange({inputValue:e=``}){o(r,e),e=e.toLowerCase()||``;let n=[];for(let r of t)if(r.toLowerCase().includes(e)&&(n.push(r),n.length>=UN))break;c(n)},items:s,itemToString(e){return e??``}}),v=d&&s.length>0;return R.createElement(`div`,{className:mw.downshiftAutocompleteContainer},R.createElement(`div`,{"data-visible-dropdown":v,className:mw.downshiftInputWrapper},R.createElement(Gle,{name:r,control:n,render:({field:t})=>{let n=m();return R.createElement(`input`,{...n,name:t.name,placeholder:i,className:mw.downshiftInput,size:30,"data-editor-dialog":!0,autoFocus:e})}}),u&&R.createElement(`button`,{"aria-label":`toggle menu`,type:`button`,...f()},l(`arrow_drop_down`))),R.createElement(`div`,{className:mw.downshiftAutocompleteContainer},R.createElement(`ul`,{...p(),"data-visible":v},s.map((e,t)=>R.createElement(`li`,{"data-selected":_===e,"data-highlighted":h===t,key:`${e}${t}`,...g({item:e,index:t})},e)))))};function ide(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}var ade={testNode:`blockquote`,visitNode({actions:e}){e.addAndStepInto(wv())}},ode={testLexicalNode:Tv,visitLexicalNode:({actions:e})=>{e.addAndStepInto(`blockquote`)}},sde=Xl({init(e){e.pubIn({[ew]:`quote`,[yC]:ade,[vC]:Cv,[SC]:ode})}});function WN(){let e=Yl;return{publish:()=>{e()},subscribe:t=>{e=t}}}var cde=Object.defineProperty,lde=(e,t,n)=>t in e?cde(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,GN=(e,t,n)=>(lde(e,typeof t==`symbol`?t:t+``,n),n),KN=class e extends Wm{constructor(e,t,n,r){super(r),GN(this,`__code`),GN(this,`__meta`),GN(this,`__language`),GN(this,`__focusEmitter`,WN()),GN(this,`setCode`,e=>{e!==this.__code&&(this.getWritable().__code=e)}),GN(this,`setMeta`,e=>{e!==this.__meta&&(this.getWritable().__meta=e)}),GN(this,`setLanguage`,e=>{e!==this.__language&&(this.getWritable().__language=e)}),GN(this,`select`,()=>{this.__focusEmitter.publish()}),this.__code=e,this.__meta=n,this.__language=t}static getType(){return`codeblock`}static clone(t){return new e(t.__code,t.__language,t.__meta,t.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__code=e.__code,this.__meta=e.__meta,this.__language=e.__language,this.__focusEmitter=WN()}static importJSON(e){let{code:t,meta:n,language:r}=e;return YN({code:t,language:r,meta:n})}static importDOM(){return{pre:()=>({conversion:pde,priority:3})}}exportJSON(){return{code:this.getCode(),language:this.getLanguage(),meta:this.getMeta(),type:`codeblock`,version:1}}createDOM(e,t){return document.createElement(`div`)}updateDOM(){return!1}getCode(){return this.__code}getMeta(){return this.__meta}getLanguage(){return this.__language}decorate(e){return R.createElement(dde,{parentEditor:e,code:this.getCode(),meta:this.getMeta(),language:this.getLanguage(),codeBlockNode:this,nodeKey:this.getKey(),focusEmitter:this.__focusEmitter})}isInline(){return!1}},qN=R.createContext(null),ude=({parentEditor:e,lexicalNode:t,children:n})=>{let r=R.useMemo(()=>({lexicalNode:t,parentEditor:e,setCode:n=>{e.update(()=>{t.setCode(n),setTimeout(()=>{e.dispatchCommand(zS,void 0)},0)})},setLanguage:n=>{e.update(()=>{t.setLanguage(n)})},setMeta:n=>{e.update(()=>{t.setMeta(n)})}}),[t,e]);return R.createElement(qN.Provider,{value:r},n)};function JN(){let e=R.useContext(qN);if(!e)throw Error(`useCodeBlockEditor must be used within a CodeBlockEditor`);return e}var dde=e=>{let t=Vl(mC),n=Vl(XN),r=t.sort((e,t)=>t.priority-e.priority).find(t=>t.match(e.language||``,e.meta||``));if(r??=t.find(t=>t.match(n||``,e.meta||``)),!r)throw Error(`No CodeBlockEditor registered for language=${e.language} meta=${e.meta}`);let i=r.Editor,{codeBlockNode:a,parentEditor:o,...s}=e;return R.createElement(ude,{parentEditor:e.parentEditor,lexicalNode:e.codeBlockNode},R.createElement(i,{...s}))};function YN(e){let{code:t=``,language:n=``,meta:r=``}=e;return new KN(t,n,r)}function fde(e){return e instanceof KN}function pde(e){let t=e,n=t.textContent,r=e.getAttribute(`class`)??``,i=e.getAttribute(`data-language`)??``,a=/language-(\w+)/.exec(r);return{node:YN({code:n,language:a?a[1]:i,meta:t.getAttribute(`data-meta`)??``})}}var mde={testLexicalNode:fde,visitLexicalNode:({lexicalNode:e,actions:t})=>{t.addAndStepInto(`code`,{value:e.getCode(),lang:e.getLanguage(),meta:e.getMeta()})}},hde={testNode:(e,{codeBlockEditorDescriptors:t})=>e.type===`code`?t.find(t=>t.match(e.lang,e.meta))!==void 0:!1,visitNode({mdastNode:e,actions:t}){t.addAndStepInto(YN({code:e.value,language:e.lang??``,meta:e.meta??``}))}},XN=Il(``),ZN=Ll(e=>{e.link(e.pipe(ZN,Gl(XN),Wl(([e,t])=>()=>YN({language:t,...e}))),XC)}),gde=PC(mC),_de=Xl({update(e,t){e.pub(XN,t?.defaultCodeBlockLanguage??``)},init(e,t){e.pubIn({[ew]:`codeblock`,[mC]:t?.codeBlockEditorDescriptors??[],[yC]:hde,[vC]:KN,[SC]:mde})}}),vde=`modulepreload`,yde=function(e){return`/apps/chat/`+e},QN={},Y=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=yde(t,n),t in QN)return;QN[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:vde,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},$N=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=ae(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(iP(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function eP(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function bde(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=eP(t)+eP(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function tP(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:bde(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function xde(e,t){return n=>{for(let t=ae(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var nP=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function rP(e){return e.selection.main.from}function iP(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var aP=he.define();function Sde(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:k.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var oP=new WeakMap;function Cde(e){if(!Array.isArray(e))return e;let t=oP.get(e);return t||oP.set(e,t=tP(e)),t}var sP=w.define(),cP=w.define(),wde=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=se(e,t),r=a(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(se(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(t.length==1){let r=se(e,0),i=a(r),o=i==e.length?0:-100;if(r!=t[0])if(r==n[0])o+=-200;else return null;return this.ret(o,[0,i])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=t.length,l=0;if(s<0){for(let i=0,o=Math.min(e.length,200);i<o&&l<c;){let o=se(e,i);(o==t[l]||o==n[l])&&(r[l++]=i),i+=a(o)}if(l<c)return null}let u=0,d=0,f=!1,p=0,m=-1,h=-1,g=/[a-z]/.test(e),_=!0;for(let r=0,l=Math.min(e.length,200),v=0;r<l&&d<c;){let l=se(e,r);s<0&&(u<c&&l==t[u]&&(i[u++]=r),p<c&&(l==t[p]||l==n[p]?(p==0&&(m=r),h=r+1,p++):p=0));let b,x=l<255?l>=48&&l<=57||l>=97&&l<=122?2:+(l>=65&&l<=90):(b=y(l))==b.toLowerCase()?b==b.toUpperCase()?0:2:1;(!r||x==1&&g||v==0&&x!=0)&&(t[d]==l||n[d]==l&&(f=!0)?o[d++]=r:o.length&&(_=!1)),v=x,r+=a(l)}return d==c&&o[0]==0&&_?this.result(-100+(f?-200:0),o,e):p==c&&m==0?this.ret(-200-e.length+(h==e.length?0:-100),[0,h]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):p==c?this.ret(-900-e.length,[m,h]):d==c?this.result(-100+(f?-200:0)+-700+(_?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?a(se(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},Tde=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},lP=Oe.define({combine(e){return oe(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Ede,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>uP(e(n),t(n)),optionClass:(e,t)=>n=>uP(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function uP(e,t){return e?t?e+` `+t:e:t}function Ede(e,t,n,r,i,a){let o=e.textDirection==u.RTL,s=o,c=!1,l=`top`,d,f,p=t.left-i.left,m=i.right-t.right,h=r.right-r.left,g=r.bottom-r.top;if(s&&p<Math.min(h,m)?s=!1:!s&&m<Math.min(h,p)&&(s=!0),h<=(s?p:m))d=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,f=Math.min(400,s?p:m);else{c=!0,f=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=g||e>t.top?d=n.bottom-t.top:(l=`bottom`,d=t.bottom-n.top)}let _=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${d/_}px; max-width: ${f/v}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var dP=w.define();function Dde(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function fP(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var Ode=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(lP);this.optionContent=Dde(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fP(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:dP.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(lP).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:cP.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=fP(r.length,i,e.state.facet(lP).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fP(t.options.length,t.selected,this.view.state.facet(lP).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>me(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&Ade(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(lP).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function kde(e,t){return n=>new Ode(n,e,t)}function Ade(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function pP(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function jde(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(lP);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new nP(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new Tde(n):new wde(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new nP(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):pP(e.completion)>pP(c)&&(s[s.length-1]=e),c=e.completion}return s}var Mde=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,mP(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=jde(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(lP).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,mP(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:zde,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},Nde=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(Lde,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(lP),i=(r.override||n.languageDataAt(`autocomplete`,rP(n)).map(Cde)).map(e=>(this.active.find(t=>t.source==e)||new gP(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(vP));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!Pde(i,this.active)||o?a=Mde.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new gP(e.source,0):e));for(let e of t.effects)e.is(dP)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Fde:Ide}};function Pde(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var Fde={"aria-autocomplete":`list`},Ide={};function mP(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var Lde=[];function hP(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(aP);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var gP=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=hP(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(sP))i=new e(i.source,1,n.value);else if(n.is(cP))i=new e(i.source,0);else if(n.is(vP))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(rP(e.state))}},_P=class e extends gP{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=rP(t.state);if(o>a||!r||n&2&&(rP(t.startState)==this.from||o<this.limit))return new gP(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Rde(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new $N(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??rP(t.state)):new gP(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new gP(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Rde(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):iP(e,!0).test(i)}var vP=w.define({map(e,t){return e.map(e=>e.map(t))}}),yP=l.define({create(){return Nde.start()},update(e,t){return e.update(t)},provide:e=>[F.from(e,e=>e.tooltip),f.contentAttributes.from(e,e=>e.attrs)]});function bP(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(yP).active.find(e=>e.source==t.source);return r instanceof _P?(typeof n==`string`?e.dispatch({...Sde(e.state,n,r.from,r.to),annotations:aP.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var zde=kde(yP,bP);function xP(e,t=`option`){return n=>{let i=n.state.field(yP,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(lP).interactionDelay)return!1;let a=1,o;t==`page`&&(o=r(n,i.open.tooltip))&&(a=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector(`li`).offsetHeight)-1));let{length:s}=i.open.options,c=i.open.selected>-1?i.open.selected+a*(e?1:-1):e?0:s-1;return c<0?c=t==`page`?0:s-1:c>=s&&(c=t==`page`?s-1:0),n.dispatch({effects:dP.of(c)}),!0}}var Bde=e=>{let t=e.state.field(yP,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(lP).interactionDelay?!1:bP(e,t.open.options[t.open.selected])},SP=e=>e.state.field(yP,!1)?(e.dispatch({effects:sP.of(!0)}),!0):!1,Vde=e=>{let t=e.state.field(yP,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:cP.of(null)}),!0)},Hde=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Ude=50,Wde=1e3,Gde=ge.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(yP).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(yP),n=e.state.facet(lP);if(!e.selectionSet&&!e.docChanged&&e.startState.field(yP)==t)return;let r=e.transactions.some(e=>{let t=hP(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>Ude&&Date.now()-n.time>Wde){for(let e of n.context.abortListeners)try{e()}catch(e){me(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(sP)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(yP);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(lP).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new $N(t,rP(t),e.explicit,this.view),r=new Hde(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:cP.of(null)}),me(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(lP).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(lP),n=this.view.state.field(yP);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=rP(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new _P(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new gP(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:vP.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(yP,!1);if(t&&t.tooltip&&this.view.state.facet(lP).closeOnBlur){let n=t.open&&r(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:cP.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:sP.of(!1)}),20),this.composing=0}}}),Kde=typeof navigator==`object`&&/Win/.test(navigator.platform),qde=De.highest(f.domEventHandlers({keydown(e,t){let n=t.state.field(yP,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Kde&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&bP(t,r),!1}})),CP=f.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Jde=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},Yde=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,M.TrackDel),r=t.mapPos(this.to,1,M.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Xde=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(c);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new Yde(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1,c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Jde(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},Zde=T.widget({widget:new class extends d{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Qde=T.mark({class:`cm-snippetField`}),wP=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=T.set(e.map(e=>(e.from==e.to?Zde:Qde).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},TP=w.define({map(e,t){return e&&e.map(t)}}),$de=w.define(),EP=l.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(TP))return n.value;if(n.is($de)&&e)return new wP(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>f.decorations.from(e,e=>e?e.deco:T.none)});function DP(e,t){return k.create(e.filter(e=>e.field==t).map(e=>k.range(e.from,e.to)))}function efe(e){let t=Xde.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:c}=e.state.selection,l={changes:{from:r,to:i==c.from?c.to:i,insert:s.of(a)},scrollIntoView:!0,annotations:n?[aP.of(n),_.userEvent.of(`input.complete`)]:void 0};if(o.length&&(l.selection=DP(o,0)),o.some(e=>e.field>0)){let t=new wP(o,0),n=l.effects=[TP.of(t)];e.state.field(EP,!1)===void 0&&n.push(w.appendConfig.of([EP,nfe,ife,CP]))}e.dispatch(e.state.update(l))}}function OP(e){return({state:t,dispatch:n})=>{let r=t.field(EP,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:DP(r.ranges,i),effects:TP.of(a?null:new wP(r.ranges,i)),scrollIntoView:!0})),!0}}var tfe=[{key:`Tab`,run:OP(1),shift:OP(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(EP,!1)?(t(e.update({effects:TP.of(null)})),!0):!1}],kP=Oe.define({combine(e){return e.length?e[0]:tfe}}),nfe=De.highest(ie.compute([kP],e=>e.facet(kP)));function rfe(e,t){return{...t,apply:efe(e)}}var ife=f.domEventHandlers({mousedown(e,t){let n=t.state.field(EP,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:DP(n.ranges,i.field),effects:TP.of(n.ranges.some(e=>e.field>i.field)?new wP(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),AP={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},jP=w.define({map(e,t){return t.mapPos(e,-1,M.TrackAfter)??void 0}}),MP=new class extends Te{};MP.startSide=1,MP.endSide=-1;var NP=l.define({create(){return S.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(jP)&&(e=e.update({add:[MP.range(n.value,n.value+1)]}));return e}});function afe(){return[sfe,NP]}var PP=`()[]{}<>«»»«[]{}`;function FP(e){for(let t=0;t<16;t+=2)if(PP.charCodeAt(t)==e)return PP.charAt(t+1);return y(e<128?e:e+1)}function IP(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||AP}var ofe=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),sfe=f.inputHandler.of((e,t,n,r)=>{if((ofe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&a(se(r,0))==1||t!=i.from||n!=i.to)return!1;let o=lfe(e.state,r);return o?(e.dispatch(o),!0):!1}),cfe=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=IP(e,e.selection.main.head).brackets||AP.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=ufe(e.doc,t.head);for(let i of n)if(i==r&&RP(e.doc,t.head)==FP(se(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:k.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function lfe(e,t){let n=IP(e,e.selection.main.head),r=n.brackets||AP.brackets;for(let i of r){let a=FP(se(i,0));if(t==i)return a==i?pfe(e,i,r.indexOf(i+i+i)>-1,n):dfe(e,i,a,n.before||AP.before);if(t==a&&LP(e,e.selection.main.from))return ffe(e,i,a)}return null}function LP(e,t){let n=!1;return e.field(NP).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function RP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,a(se(n,0)))}function ufe(e,t){let n=e.sliceString(t-2,t);return a(se(n,0))==n.length?n:n.slice(1)}function dfe(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:jP.of(a.to+t.length),range:k.range(a.anchor+t.length,a.head+t.length)};let o=RP(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:jP.of(a.head+t.length),range:k.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function ffe(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&RP(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:k.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function pfe(e,t,n,r){let i=r.stringPrefixes||AP.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:jP.of(r.to+t.length),range:k.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=RP(e.doc,o),c;if(s==t){if(zP(e,o))return{changes:{insert:t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};if(LP(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:k.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=BP(e,o-2*t.length,i))>-1&&zP(e,c))return{changes:{insert:t+t+t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=L.Word&&BP(e,o,i)>-1&&!mfe(e,o,t,i))return{changes:{insert:t+t,from:o},effects:jP.of(o+t.length),range:k.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function zP(e,t){let n=ae(e).resolveInner(t+1);return n.parent&&n.from==t}function mfe(e,t,n,r){let i=ae(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function BP(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=L.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=L.Word)return n}return-1}function hfe(e={}){return[qde,yP,lP.of(e),Gde,gfe,CP]}var VP=[{key:`Ctrl-Space`,run:SP},{mac:"Alt-`",run:SP},{mac:`Alt-i`,run:SP},{key:`Escape`,run:Vde},{key:`ArrowDown`,run:xP(!0)},{key:`ArrowUp`,run:xP(!1)},{key:`PageDown`,run:xP(!0,`page`)},{key:`PageUp`,run:xP(!1,`page`)},{key:`Enter`,run:Bde}],gfe=De.highest(ie.computeN([lP],e=>e.facet(lP).defaultKeymap?[VP]:[])),_fe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=UP(e.state,n.from);return r.line?vfe(e):r.block?bfe(e):!1};function HP(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var vfe=HP(Cfe,0),yfe=HP(GP,0),bfe=HP((e,t)=>GP(e,t,Sfe(t)),0);function UP(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var WP=50;function xfe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-WP,r),o=e.sliceDoc(i,i+WP),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*WP?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+WP),d=e.sliceDoc(i-WP,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Sfe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function GP(e,t,n=t.selection.ranges){let r=n.map(e=>UP(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>xfe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Cfe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=UP(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var KP=he.define(),wfe=he.define(),Tfe=Oe.define(),qP=Oe.define({combine(e){return oe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),JP=l.define({create(){return aF.empty},update(e,t){let n=t.state.facet(qP),r=t.annotation(KP);if(r){let i=$P.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?eF(o,o.length,n.minDepth,i):rF(o,t.startState.selection),new aF(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(wfe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(_.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=$P.fromTransaction(t),o=t.annotation(_.time),s=t.annotation(_.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new aF(e.done.map($P.fromJSON),e.undone.map($P.fromJSON))}});function YP(e={}){return[JP,qP.of(e),f.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ZP:e.inputType==`historyRedo`?QP:null;return n?(e.preventDefault(),n(t)):!1}})]}function XP(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(JP,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ZP=XP(0,!1),QP=XP(1,!1),Efe=XP(0,!0),Dfe=XP(1,!0),$P=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&re.fromJSON(t.changes),[],t.mapped&&ue.fromJSON(t.mapped),t.startSelection&&k.fromJSON(t.startSelection),t.selectionsAfter.map(k.fromJSON))}static fromTransaction(t,n){let r=nF;for(let e of t.startState.facet(Tfe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,nF)}static selection(t){return new e(void 0,nF,void 0,void 0,t)}};function eF(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Ofe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function kfe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function tF(e,t){return e.length?t.length?e.concat(t):e:t}var nF=[],Afe=200;function rF(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Afe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),eF(e,e.length-1,1e9,n.setSelAfter(r)))}else return[$P.selection([t])]}function jfe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function iF(e,t){if(!e.length)return e;let n=e.length,r=nF;for(;n;){let i=Mfe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[$P.selection(r)]:nF}function Mfe(e,t,n){let r=tF(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):nF,n);if(!e.changes)return $P.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new $P(i,w.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Nfe=/^(input\.type|delete)($|\.)/,aF=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Nfe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Ofe(s.changes,t.changes))||r==`input.type.compose`)?eF(o,o.length-1,i.minDepth,new $P(t.changes.compose(s.changes),tF(w.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,nF)):eF(o,o.length,i.minDepth,t),new e(o,nF,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:nF;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&kfe(a[a.length-1],t)?this:new e(rF(this.done,t),this.undone,n,r)}addMapping(t){return new e(iF(this.done,t),iF(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:KP.of({side:e,rest:jfe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?nF:r.slice(0,r.length-1);return i.mapped&&(n=iF(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:KP.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};aF.empty=new aF(nF,nF);var oF=[{key:`Mod-z`,run:ZP,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:QP,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:QP,preventDefault:!0},{key:`Mod-u`,run:Efe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Dfe,preventDefault:!0}];function sF(e,t){return k.create(e.ranges.map(t),e.mainIndex)}function cF(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function lF({state:e,dispatch:t},n){let r=sF(e.selection,n);return r.eq(e.selection,!0)?!1:(t(cF(e,r)),!0)}function uF(e,t){return k.cursor(t?e.to:e.from)}function dF(e,t){return lF(e,n=>n.empty?e.moveByChar(n,t):uF(n,t))}function fF(e){return e.textDirectionAt(e.state.selection.main.head)==u.LTR}var pF=e=>dF(e,!fF(e)),mF=e=>dF(e,fF(e));function hF(e,t){return lF(e,n=>n.empty?e.moveByGroup(n,t):uF(n,t))}var Pfe=e=>hF(e,!fF(e)),Ffe=e=>hF(e,fF(e));typeof Intl<`u`&&Intl.Segmenter;function Ife(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function gF(e,t,n){let r=ae(e).resolveInner(t.head),i=n?p.closedBy:p.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ife(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?g(e,r.from,1):g(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,k.cursor(s,n?-1:1)}var Lfe=e=>lF(e,t=>gF(e.state,t,!fF(e))),Rfe=e=>lF(e,t=>gF(e.state,t,fF(e)));function _F(e,t){return lF(e,n=>{if(!n.empty)return uF(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var vF=e=>_F(e,!1),yF=e=>_F(e,!0);function bF(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(f.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function xF(e,t){let n=bF(e),{state:r}=e,i=sF(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):uF(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=f.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(cF(r,i),{effects:a}),!0}var SF=e=>xF(e,!1),CF=e=>xF(e,!0);function wF(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=k.cursor(r.from+n))}return i}var zfe=e=>lF(e,t=>wF(e,t,!0)),Bfe=e=>lF(e,t=>wF(e,t,!1)),Vfe=e=>lF(e,t=>wF(e,t,!fF(e))),Hfe=e=>lF(e,t=>wF(e,t,fF(e))),Ufe=e=>lF(e,t=>k.cursor(e.lineBlockAt(t.head).from,1)),Wfe=e=>lF(e,t=>k.cursor(e.lineBlockAt(t.head).to,-1));function Gfe(e,t,n){let r=!1,i=sF(e.selection,t=>{let i=g(e,t.head,-1)||g(e,t.head,1)||t.head>0&&g(e,t.head-1,1)||t.head<e.doc.length&&g(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?k.range(t.anchor,a):k.cursor(a)});return r?(t(cF(e,i)),!0):!1}var Kfe=({state:e,dispatch:t})=>Gfe(e,t,!1);function TF(e,t){let n=sF(e.state.selection,e=>{let n=t(e);return k.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(cF(e.state,n)),!0)}function EF(e,t){return TF(e,n=>e.moveByChar(n,t))}var DF=e=>EF(e,!fF(e)),OF=e=>EF(e,fF(e));function kF(e,t){return TF(e,n=>e.moveByGroup(n,t))}var qfe=e=>kF(e,!fF(e)),Jfe=e=>kF(e,fF(e)),Yfe=e=>TF(e,t=>gF(e.state,t,!fF(e))),Xfe=e=>TF(e,t=>gF(e.state,t,fF(e)));function AF(e,t){return TF(e,n=>e.moveVertically(n,t))}var jF=e=>AF(e,!1),MF=e=>AF(e,!0);function NF(e,t){return TF(e,n=>e.moveVertically(n,t,bF(e).height))}var PF=e=>NF(e,!1),FF=e=>NF(e,!0),Zfe=e=>TF(e,t=>wF(e,t,!0)),Qfe=e=>TF(e,t=>wF(e,t,!1)),$fe=e=>TF(e,t=>wF(e,t,!fF(e))),epe=e=>TF(e,t=>wF(e,t,fF(e))),tpe=e=>TF(e,t=>k.cursor(e.lineBlockAt(t.head).from)),npe=e=>TF(e,t=>k.cursor(e.lineBlockAt(t.head).to)),IF=({state:e,dispatch:t})=>(t(cF(e,{anchor:0})),!0),LF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.doc.length})),!0),RF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.selection.main.anchor,head:0})),!0),zF=({state:e,dispatch:t})=>(t(cF(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),rpe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ipe=({state:e,dispatch:t})=>{let n=JF(e).map(({from:t,to:n})=>k.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:k.create(n),userEvent:`select`})),!0},ape=({state:e,dispatch:t})=>{let n=sF(e.selection,t=>{let n=ae(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return k.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(cF(e,n)),!0)};function BF(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(cF(n,k.create(i,i.length-1))),!0)}var ope=e=>BF(e,!1),spe=e=>BF(e,!0),cpe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=k.create([n.main]):n.main.empty||(r=k.create([k.cursor(n.main.head)])),r?(t(cF(e,r)),!0):!1};function VF(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=HF(e,o,!1)):o>i&&(n=`delete.forward`,o=HF(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=HF(e,i,!1),a=HF(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:k.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?f.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function HF(e,t,n){if(e instanceof f)for(let r of e.state.facet(f.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var UF=(e,t,n)=>VF(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=m(s,a.tabSize)%Ee(a)||Ee(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=h(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=h(o.text,c-o.from,!1,!1)+o.from);return c}),WF=e=>UF(e,!1,!0),GF=e=>UF(e,!0,!1),KF=(e,t)=>VF(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=h(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),qF=e=>KF(e,!1),lpe=e=>KF(e,!0),upe=e=>VF(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),dpe=e=>VF(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),fpe=e=>VF(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),ppe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:s.of([``,``])},range:k.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},mpe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:h(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:h(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:k.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function JF(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function YF(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of JF(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(k.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(k.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:k.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var hpe=({state:e,dispatch:t})=>YF(e,t,!1),gpe=({state:e,dispatch:t})=>YF(e,t,!0);function XF(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of JF(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var _pe=({state:e,dispatch:t})=>XF(e,t,!1),vpe=({state:e,dispatch:t})=>XF(e,t,!0),ype=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(JF(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=sF(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function bpe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=ae(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(p.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var ZF=QF(!1),xpe=QF(!0);function QF(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&bpe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let c=new de(t,{simulateBreak:r,simulateDoubleBreak:!!o}),l=x(c,r);for(l??=m(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let u=[``,C(t,l)];return o&&u.push(C(t,c.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:s.of(u)},range:k.cursor(r+1+u[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function $F(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:k.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Spe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new de(e,{overrideIndentation:e=>n[e]??-1}),i=$F(e,(t,i,a)=>{let o=x(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=C(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},eI=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($F(e,(t,n)=>{n.push({from:t.from,insert:e.facet(c)})}),{userEvent:`input.indent`})),!0),tI=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update($F(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=m(r,e.tabSize),a=0,o=C(e,Math.max(0,i-Ee(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Cpe=e=>(e.setTabFocusMode(),!0),wpe=[{key:`Ctrl-b`,run:pF,shift:DF,preventDefault:!0},{key:`Ctrl-f`,run:mF,shift:OF},{key:`Ctrl-p`,run:vF,shift:jF},{key:`Ctrl-n`,run:yF,shift:MF},{key:`Ctrl-a`,run:Ufe,shift:tpe},{key:`Ctrl-e`,run:Wfe,shift:npe},{key:`Ctrl-d`,run:GF},{key:`Ctrl-h`,run:WF},{key:`Ctrl-k`,run:upe},{key:`Ctrl-Alt-h`,run:qF},{key:`Ctrl-o`,run:ppe},{key:`Ctrl-t`,run:mpe},{key:`Ctrl-v`,run:CF}],Tpe=[{key:`ArrowLeft`,run:pF,shift:DF,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Pfe,shift:qfe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Vfe,shift:$fe,preventDefault:!0},{key:`ArrowRight`,run:mF,shift:OF,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Ffe,shift:Jfe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Hfe,shift:epe,preventDefault:!0},{key:`ArrowUp`,run:vF,shift:jF,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:IF,shift:RF},{mac:`Ctrl-ArrowUp`,run:SF,shift:PF},{key:`ArrowDown`,run:yF,shift:MF,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:LF,shift:zF},{mac:`Ctrl-ArrowDown`,run:CF,shift:FF},{key:`PageUp`,run:SF,shift:PF},{key:`PageDown`,run:CF,shift:FF},{key:`Home`,run:Bfe,shift:Qfe,preventDefault:!0},{key:`Mod-Home`,run:IF,shift:RF},{key:`End`,run:zfe,shift:Zfe,preventDefault:!0},{key:`Mod-End`,run:LF,shift:zF},{key:`Enter`,run:ZF,shift:ZF},{key:`Mod-a`,run:rpe},{key:`Backspace`,run:WF,shift:WF,preventDefault:!0},{key:`Delete`,run:GF,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:qF,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:lpe,preventDefault:!0},{mac:`Mod-Backspace`,run:dpe,preventDefault:!0},{mac:`Mod-Delete`,run:fpe,preventDefault:!0}].concat(wpe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),nI=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Lfe,shift:Yfe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Rfe,shift:Xfe},{key:`Alt-ArrowUp`,run:hpe},{key:`Shift-Alt-ArrowUp`,run:_pe},{key:`Alt-ArrowDown`,run:gpe},{key:`Shift-Alt-ArrowDown`,run:vpe},{key:`Mod-Alt-ArrowUp`,run:ope},{key:`Mod-Alt-ArrowDown`,run:spe},{key:`Escape`,run:cpe},{key:`Mod-Enter`,run:xpe},{key:`Alt-l`,mac:`Ctrl-l`,run:ipe},{key:`Mod-i`,run:ape,preventDefault:!0},{key:`Mod-[`,run:tI},{key:`Mod-]`,run:eI},{key:`Mod-Alt-\\`,run:Spe},{key:`Shift-Mod-k`,run:ype},{key:`Shift-Mod-\\`,run:Kfe},{key:`Mod-/`,run:_fe},{key:`Alt-A`,run:yfe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Cpe}].concat(Tpe),Epe={key:`Tab`,run:eI,shift:tI};function Dpe(e,t,n,r){let i=Vl(VS),a=Ul(jC),o=R.useRef(null),{lexicalNode:s}=JN(),c=R.useRef(!1),l=R.useRef(!1),u=R.useCallback(()=>{a({editorType:t,rootNode:s,editorRef:o.current})},[t,s,a]),d=R.useCallback(t=>{if(t.key===`ArrowDown`){let t=o.current?.getCodemirror()?.state;t&&t.doc.length===t.selection.ranges[0].to&&(c.current?(i?.update(()=>{var t;let n=Ah(e);n.getNextSibling()?((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectNext()):n.insertAfter(nh())}),c.current=!1):c.current=!0)}else if(t.key===`ArrowUp`){let t=o.current?.getCodemirror()?.state;t&&t.selection.ranges[0].from===0&&(l.current?(i?.update(()=>{var t;let n=Ah(e);n.getPreviousSibling()&&((t=o.current?.getCodemirror())==null||t.contentDOM.blur(),n.selectPrevious())}),l.current=!1):l.current=!0)}else t.key===`Enter`?t.stopPropagation():(t.key===`Backspace`||t.key===`Delete`)&&(o.current?.getCodemirror()?.state)?.doc.length===0&&i?.update(()=>{Ah(e).remove()})},[i,e]);return R.useEffect(()=>{let e=o.current;return setTimeout(()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.addEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.addEventListener(`keydown`,d)},300),()=>{var t,n;(t=e?.getCodemirror())==null||t.contentDOM.removeEventListener(`focus`,u),(n=e?.getCodemirror())==null||n.contentDOM.removeEventListener(`keydown`,d)}},[o,u,d,n]),R.useEffect(()=>{r.subscribe(()=>{var e;(e=o.current?.getCodemirror())==null||e.focus(),u()})},[r,o,e,u]),o}function X(e){return new pe(N.define(e))}function rI(e){return Y(()=>import(`./dist-ChSZNqKE.js`).then(t=>t.sql({dialect:t[e]})),__vite__mapDeps([0,1,2]))}var Ope=[A.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return Y(()=>import(`./dist-C5YJOwhH.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),A.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return Y(()=>import(`./dist-C5YJOwhH.js`).then(e=>e.cpp()),__vite__mapDeps([3,1,2]))}}),A.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return rI(`Cassandra`)}}),A.of({name:`CSS`,extensions:[`css`],load(){return Y(()=>import(`./dist-CKM5j-iy.js`).then(e=>e.i).then(e=>e.css()),__vite__mapDeps([4,5,1,2]))}}),A.of({name:`Go`,extensions:[`go`],load(){return Y(()=>import(`./dist-BIvPnn_C.js`).then(e=>e.go()),__vite__mapDeps([6,1,2]))}}),A.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return Y(()=>import(`./dist-7YaJd19a.js`).then(e=>e.html()),__vite__mapDeps([7,4,5,1,2,8]))}}),A.of({name:`Java`,extensions:[`java`],load(){return Y(()=>import(`./dist--55mTWk3.js`).then(e=>e.java()),__vite__mapDeps([9,1,2]))}}),A.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return Y(()=>import(`./dist-CjSI6y5z.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return Y(()=>import(`./dist-KXCMNKIL.js`).then(e=>e.jinja()),__vite__mapDeps([10,7,4,5,1,2,8]))}}),A.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return Y(()=>import(`./dist-BZ39rB1W.js`).then(e=>e.json()),__vite__mapDeps([11,1,2]))}}),A.of({name:`JSX`,extensions:[`jsx`],load(){return Y(()=>import(`./dist-CjSI6y5z.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`LESS`,extensions:[`less`],load(){return Y(()=>import(`./dist-C5oXtFSP.js`).then(e=>e.less()),__vite__mapDeps([12,4,5,1,2]))}}),A.of({name:`Liquid`,extensions:[`liquid`],load(){return Y(()=>import(`./dist-CiYeO8nN.js`).then(e=>e.liquid()),__vite__mapDeps([13,7,4,5,1,2,8]))}}),A.of({name:`MariaDB SQL`,load(){return rI(`MariaSQL`)}}),A.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return Y(()=>import(`./dist-CVQU42Fn.js`).then(e=>e.markdown()),__vite__mapDeps([14,7,4,5,1,2,8]))}}),A.of({name:`MS SQL`,load(){return rI(`MSSQL`)}}),A.of({name:`MySQL`,load(){return rI(`MySQL`)}}),A.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return Y(()=>import(`./dist-D7TCkoFT.js`).then(e=>e.php()),__vite__mapDeps([15,7,4,5,1,2,8]))}}),A.of({name:`PLSQL`,extensions:[`pls`],load(){return rI(`PLSQL`)}}),A.of({name:`PostgreSQL`,load(){return rI(`PostgreSQL`)}}),A.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return Y(()=>import(`./dist-8Noo5eCN.js`).then(e=>e.python()),__vite__mapDeps([16,1,2]))}}),A.of({name:`Rust`,extensions:[`rs`],load(){return Y(()=>import(`./dist-CUp9us2q.js`).then(e=>e.rust()),__vite__mapDeps([17,1,2]))}}),A.of({name:`Sass`,extensions:[`sass`],load(){return Y(()=>import(`./dist-DSKQpPaz.js`).then(e=>e.sass({indented:!0})),__vite__mapDeps([18,4,5,1,2]))}}),A.of({name:`SCSS`,extensions:[`scss`],load(){return Y(()=>import(`./dist-DSKQpPaz.js`).then(e=>e.sass()),__vite__mapDeps([18,4,5,1,2]))}}),A.of({name:`SQL`,extensions:[`sql`],load(){return rI(`StandardSQL`)}}),A.of({name:`SQLite`,load(){return rI(`SQLite`)}}),A.of({name:`TSX`,extensions:[`tsx`],load(){return Y(()=>import(`./dist-CjSI6y5z.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return Y(()=>import(`./dist-CjSI6y5z.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,5,1,2]))}}),A.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return Y(()=>import(`./dist-CZ9T4Cly.js`).then(e=>e.wast()),__vite__mapDeps([19,1,2]))}}),A.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return Y(()=>import(`./dist-Zqt9kNG9.js`).then(e=>e.xml()),__vite__mapDeps([20,1,2]))}}),A.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return Y(()=>import(`./dist-BsedZGJo.js`).then(e=>e.yaml()),__vite__mapDeps([21,1,2]))}}),A.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return Y(()=>import(`./apl-BxEMbctQ.js`).then(e=>X(e.apl)),[])}}),A.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return Y(()=>import(`./asciiarmor-eFjeGRuZ.js`).then(e=>X(e.asciiArmor)),[])}}),A.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return Y(()=>import(`./asn1-Cfx-0pt9.js`).then(e=>X(e.asn1({}))),[])}}),A.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return Y(()=>import(`./asterisk-B5BHTsBr.js`).then(e=>X(e.asterisk)),[])}}),A.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return Y(()=>import(`./brainfuck-CAA2xofr.js`).then(e=>X(e.brainfuck)),[])}}),A.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return Y(()=>import(`./cobol-BfgHZgup.js`).then(e=>X(e.cobol)),[])}}),A.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.csharp)),[])}}),A.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`ClojureScript`,extensions:[`cljs`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return Y(()=>import(`./css-BqOeyZOV.js`).then(e=>X(e.gss)),[])}}),A.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return Y(()=>import(`./cmake-BUPAhezI.js`).then(e=>X(e.cmake)),[])}}),A.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return Y(()=>import(`./coffeescript-G1Pe_1AZ.js`).then(e=>X(e.coffeeScript)),[])}}),A.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return Y(()=>import(`./commonlisp-B3N0CjHn.js`).then(e=>X(e.commonLisp)),[])}}),A.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return Y(()=>import(`./cypher-KjIKv-wW.js`).then(e=>X(e.cypher)),[])}}),A.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return Y(()=>import(`./python-C2_X1GpX.js`).then(e=>X(e.cython)),[])}}),A.of({name:`Crystal`,extensions:[`cr`],load(){return Y(()=>import(`./crystal-C15ndaGM.js`).then(e=>X(e.crystal)),[])}}),A.of({name:`D`,extensions:[`d`],load(){return Y(()=>import(`./d-BlT5AEC-.js`).then(e=>X(e.d)),[])}}),A.of({name:`Dart`,extensions:[`dart`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.dart)),[])}}),A.of({name:`diff`,extensions:[`diff`,`patch`],load(){return Y(()=>import(`./diff-oF98tbqj.js`).then(e=>X(e.diff)),[])}}),A.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return Y(()=>import(`./dockerfile-CUaqzcqp.js`).then(e=>X(e.dockerFile)),__vite__mapDeps([22,23]))}}),A.of({name:`DTD`,extensions:[`dtd`],load(){return Y(()=>import(`./dtd-VCA9yr61.js`).then(e=>X(e.dtd)),[])}}),A.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return Y(()=>import(`./dylan-O-V5Dw5W.js`).then(e=>X(e.dylan)),[])}}),A.of({name:`EBNF`,load(){return Y(()=>import(`./ebnf-SPmdBkvT.js`).then(e=>X(e.ebnf)),[])}}),A.of({name:`ECL`,extensions:[`ecl`],load(){return Y(()=>import(`./ecl-ChfCttfI.js`).then(e=>X(e.ecl)),[])}}),A.of({name:`edn`,extensions:[`edn`],load(){return Y(()=>import(`./clojure-kVFSWX0o.js`).then(e=>X(e.clojure)),[])}}),A.of({name:`Eiffel`,extensions:[`e`],load(){return Y(()=>import(`./eiffel-cB9EbjeN.js`).then(e=>X(e.eiffel)),[])}}),A.of({name:`Elm`,extensions:[`elm`],load(){return Y(()=>import(`./elm-BTiVflBU.js`).then(e=>X(e.elm)),[])}}),A.of({name:`Erlang`,extensions:[`erl`],load(){return Y(()=>import(`./erlang-egf0TXFm.js`).then(e=>X(e.erlang)),[])}}),A.of({name:`Esper`,load(){return Y(()=>import(`./sql-D_dieYbr.js`).then(e=>X(e.esper)),[])}}),A.of({name:`Factor`,extensions:[`factor`],load(){return Y(()=>import(`./factor-C2tAxNob.js`).then(e=>X(e.factor)),__vite__mapDeps([24,23]))}}),A.of({name:`FCL`,load(){return Y(()=>import(`./fcl-BiCjh1tj.js`).then(e=>X(e.fcl)),[])}}),A.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return Y(()=>import(`./forth-C4kDGW6u.js`).then(e=>X(e.forth)),[])}}),A.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return Y(()=>import(`./fortran-DzkLaPnd.js`).then(e=>X(e.fortran)),[])}}),A.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.fSharp)),[])}}),A.of({name:`Gas`,extensions:[`s`],load(){return Y(()=>import(`./gas-DMOxskQF.js`).then(e=>X(e.gas)),[])}}),A.of({name:`Gherkin`,extensions:[`feature`],load(){return Y(()=>import(`./gherkin-BPxBpp-k.js`).then(e=>X(e.gherkin)),[])}}),A.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return Y(()=>import(`./groovy-CkEnc0ZY.js`).then(e=>X(e.groovy)),[])}}),A.of({name:`Haskell`,extensions:[`hs`],load(){return Y(()=>import(`./haskell-Dadpo9-w.js`).then(e=>X(e.haskell)),[])}}),A.of({name:`Haxe`,extensions:[`hx`],load(){return Y(()=>import(`./haxe-CDNZL9MW.js`).then(e=>X(e.haxe)),[])}}),A.of({name:`HXML`,extensions:[`hxml`],load(){return Y(()=>import(`./haxe-CDNZL9MW.js`).then(e=>X(e.hxml)),[])}}),A.of({name:`HTTP`,load(){return Y(()=>import(`./http-jy9Zxxt3.js`).then(e=>X(e.http)),[])}}),A.of({name:`IDL`,extensions:[`pro`],load(){return Y(()=>import(`./idl-CGSB6iiy.js`).then(e=>X(e.idl)),[])}}),A.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return Y(()=>import(`./javascript-DSlzRUd8.js`).then(e=>X(e.jsonld)),[])}}),A.of({name:`Julia`,extensions:[`jl`],load(){return Y(()=>import(`./julia-DTiF9v6R.js`).then(e=>X(e.julia)),[])}}),A.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.kotlin)),[])}}),A.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return Y(()=>import(`./livescript-Ci8Xxna6.js`).then(e=>X(e.liveScript)),[])}}),A.of({name:`Lua`,extensions:[`lua`],load(){return Y(()=>import(`./lua-eVxIrt9t.js`).then(e=>X(e.lua)),[])}}),A.of({name:`mIRC`,extensions:[`mrc`],load(){return Y(()=>import(`./mirc-CtHu9S1B.js`).then(e=>X(e.mirc)),[])}}),A.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return Y(()=>import(`./mathematica-Da3grj36.js`).then(e=>X(e.mathematica)),[])}}),A.of({name:`Modelica`,extensions:[`mo`],load(){return Y(()=>import(`./modelica-cKbQ0UXu.js`).then(e=>X(e.modelica)),[])}}),A.of({name:`MUMPS`,extensions:[`mps`],load(){return Y(()=>import(`./mumps-CKBHkOQq.js`).then(e=>X(e.mumps)),[])}}),A.of({name:`Mbox`,extensions:[`mbox`],load(){return Y(()=>import(`./mbox-BWBMSafM.js`).then(e=>X(e.mbox)),[])}}),A.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return Y(()=>import(`./nginx-B00AiQel.js`).then(e=>X(e.nginx)),[])}}),A.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return Y(()=>import(`./nsis-SMDwKltR.js`).then(e=>X(e.nsis)),__vite__mapDeps([25,23]))}}),A.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return Y(()=>import(`./ntriples-B_36EBV0.js`).then(e=>X(e.ntriples)),[])}}),A.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.objectiveC)),[])}}),A.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.objectiveCpp)),[])}}),A.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.oCaml)),[])}}),A.of({name:`Octave`,extensions:[`m`],load(){return Y(()=>import(`./octave-BXPjzAif.js`).then(e=>X(e.octave)),[])}}),A.of({name:`Oz`,extensions:[`oz`],load(){return Y(()=>import(`./oz-Dedpat1M.js`).then(e=>X(e.oz)),[])}}),A.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return Y(()=>import(`./pascal-CMcUg72K.js`).then(e=>X(e.pascal)),[])}}),A.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return Y(()=>import(`./perl-DoVTbnzt.js`).then(e=>X(e.perl)),[])}}),A.of({name:`Pig`,extensions:[`pig`],load(){return Y(()=>import(`./pig-CULXT1YV.js`).then(e=>X(e.pig)),[])}}),A.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return Y(()=>import(`./powershell-Cv5Uhf6b.js`).then(e=>X(e.powerShell)),[])}}),A.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return Y(()=>import(`./properties-CQ1C2P-M.js`).then(e=>X(e.properties)),[])}}),A.of({name:`ProtoBuf`,extensions:[`proto`],load(){return Y(()=>import(`./protobuf-SRlvzrl6.js`).then(e=>X(e.protobuf)),[])}}),A.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return Y(()=>import(`./pug-Bo3wfL-f.js`).then(e=>X(e.pug)),__vite__mapDeps([26,27]))}}),A.of({name:`Puppet`,extensions:[`pp`],load(){return Y(()=>import(`./puppet-ClSqCGj6.js`).then(e=>X(e.puppet)),[])}}),A.of({name:`Q`,extensions:[`q`],load(){return Y(()=>import(`./q-B_6Gdyzl.js`).then(e=>X(e.q)),[])}}),A.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return Y(()=>import(`./r-BD07NGED.js`).then(e=>X(e.r)),[])}}),A.of({name:`RPM Changes`,load(){return Y(()=>import(`./rpm-CRu5Z2Jl.js`).then(e=>X(e.rpmChanges)),[])}}),A.of({name:`RPM Spec`,extensions:[`spec`],load(){return Y(()=>import(`./rpm-CRu5Z2Jl.js`).then(e=>X(e.rpmSpec)),[])}}),A.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return Y(()=>import(`./ruby-dZPnOz8h.js`).then(e=>X(e.ruby)),[])}}),A.of({name:`SAS`,extensions:[`sas`],load(){return Y(()=>import(`./sas-S2t8_sDI.js`).then(e=>X(e.sas)),[])}}),A.of({name:`Scala`,extensions:[`scala`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.scala)),[])}}),A.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return Y(()=>import(`./scheme-WcyFWLW2.js`).then(e=>X(e.scheme)),[])}}),A.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return Y(()=>import(`./shell-DUelnYSh.js`).then(e=>X(e.shell)),[])}}),A.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return Y(()=>import(`./sieve-jDjlVhNh.js`).then(e=>X(e.sieve)),[])}}),A.of({name:`Smalltalk`,extensions:[`st`],load(){return Y(()=>import(`./smalltalk-ddWDYy10.js`).then(e=>X(e.smalltalk)),[])}}),A.of({name:`Solr`,load(){return Y(()=>import(`./solr-C7rQhLuW.js`).then(e=>X(e.solr)),[])}}),A.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return Y(()=>import(`./mllike-wTFlPWXS.js`).then(e=>X(e.sml)),[])}}),A.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return Y(()=>import(`./sparql--fPCCgVd.js`).then(e=>X(e.sparql)),[])}}),A.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return Y(()=>import(`./spreadsheet-DjthqD5G.js`).then(e=>X(e.spreadsheet)),[])}}),A.of({name:`Squirrel`,extensions:[`nut`],load(){return Y(()=>import(`./clike-BoDCOLzN.js`).then(e=>X(e.squirrel)),[])}}),A.of({name:`Stylus`,extensions:[`styl`],load(){return Y(()=>import(`./stylus-DxF70RNr.js`).then(e=>X(e.stylus)),[])}}),A.of({name:`Swift`,extensions:[`swift`],load(){return Y(()=>import(`./swift-T0hDoOb-.js`).then(e=>X(e.swift)),[])}}),A.of({name:`sTeX`,load(){return Y(()=>import(`./stex-rHcFYcA0.js`).then(e=>X(e.stex)),[])}}),A.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return Y(()=>import(`./stex-rHcFYcA0.js`).then(e=>X(e.stex)),[])}}),A.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return Y(()=>import(`./verilog-BJOO83gk.js`).then(e=>X(e.verilog)),[])}}),A.of({name:`Tcl`,extensions:[`tcl`],load(){return Y(()=>import(`./tcl-Dlzy1mPk.js`).then(e=>X(e.tcl)),[])}}),A.of({name:`Textile`,extensions:[`textile`],load(){return Y(()=>import(`./textile-Dy5rFZe5.js`).then(e=>X(e.textile)),[])}}),A.of({name:`TiddlyWiki`,load(){return Y(()=>import(`./tiddlywiki-DQP1OymS.js`).then(e=>X(e.tiddlyWiki)),[])}}),A.of({name:`Tiki wiki`,load(){return Y(()=>import(`./tiki-0vOj3DB2.js`).then(e=>X(e.tiki)),[])}}),A.of({name:`TOML`,extensions:[`toml`],load(){return Y(()=>import(`./toml-DEltN0lI.js`).then(e=>X(e.toml)),[])}}),A.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return Y(()=>import(`./troff-CRbBpEqY.js`).then(e=>X(e.troff)),[])}}),A.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return Y(()=>import(`./ttcn-M5q1nLKg.js`).then(e=>X(e.ttcn)),[])}}),A.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return Y(()=>import(`./ttcn-cfg-Rmw9NWq9.js`).then(e=>X(e.ttcnCfg)),[])}}),A.of({name:`Turtle`,extensions:[`ttl`],load(){return Y(()=>import(`./turtle-BCDWhJK0.js`).then(e=>X(e.turtle)),[])}}),A.of({name:`Web IDL`,extensions:[`webidl`],load(){return Y(()=>import(`./webidl-Ddy6hbV6.js`).then(e=>X(e.webIDL)),[])}}),A.of({name:`VB.NET`,extensions:[`vb`],load(){return Y(()=>import(`./vb-QQ7LGlOz.js`).then(e=>X(e.vb)),[])}}),A.of({name:`VBScript`,extensions:[`vbs`],load(){return Y(()=>import(`./vbscript-BiSEdUzz.js`).then(e=>X(e.vbScript)),[])}}),A.of({name:`Velocity`,extensions:[`vtl`],load(){return Y(()=>import(`./velocity-CzMg5_6w.js`).then(e=>X(e.velocity)),[])}}),A.of({name:`Verilog`,extensions:[`v`],load(){return Y(()=>import(`./verilog-BJOO83gk.js`).then(e=>X(e.verilog)),[])}}),A.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return Y(()=>import(`./vhdl-ed4zAZAA.js`).then(e=>X(e.vhdl)),[])}}),A.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return Y(()=>import(`./xquery-Bw1zwhh6.js`).then(e=>X(e.xQuery)),[])}}),A.of({name:`Yacas`,extensions:[`ys`],load(){return Y(()=>import(`./yacas-DZdTXy3s.js`).then(e=>X(e.yacas)),[])}}),A.of({name:`Z80`,extensions:[`z80`],load(){return Y(()=>import(`./z80-DMG02_YV.js`).then(e=>X(e.z80)),[])}}),A.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.mscgen)),[])}}),A.of({name:`Xù`,extensions:[`xu`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.xu)),[])}}),A.of({name:`MsGenny`,extensions:[`msgenny`],load(){return Y(()=>import(`./mscgen-C5pXQCMK.js`).then(e=>X(e.msgenny)),[])}}),A.of({name:`Vue`,extensions:[`vue`],load(){return Y(()=>import(`./dist-BbNE72h8.js`).then(e=>e.vue()),__vite__mapDeps([28,7,4,5,1,2,8]))}}),A.of({name:`Angular Template`,load(){return Y(()=>import(`./dist-Ubstha8t.js`).then(e=>e.angular()),__vite__mapDeps([29,7,4,5,1,2,8]))}})],iI=`#2e3440`,aI=`#3b4252`,oI=`#434c5e`,sI=`#4c566a`,cI=`#e5e9f0`,lI=`#eceff4`,uI=`#8fbcbb`,dI=`#88c0d0`,kpe=`#81a1c1`,fI=`#5e81ac`,Ape=`#bf616a`,pI=`#d08770`,mI=`#ebcb8b`,hI=`#a3be8c`,jpe=`#b48ead`,gI=`#d30102`,_I=lI,vI=_I,Mpe=`#ffffff`,yI=aI,Npe=_I,bI=aI,Ppe=[f.theme({"&":{color:iI,backgroundColor:Mpe},".cm-content":{caretColor:bI},".cm-cursor, .cm-dropCursor":{borderLeftColor:bI},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Npe},".cm-panels":{backgroundColor:_I,color:sI},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid ${sI}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:cI},".cm-activeLine":{backgroundColor:vI},".cm-selectionMatch":{backgroundColor:cI},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${sI}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:lI},".cm-gutters":{backgroundColor:lI,color:iI,border:`none`},".cm-activeLineGutter":{backgroundColor:vI},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:yI},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:yI,borderBottomColor:yI},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:vI,color:sI}}},{dark:!1}),i(ye.define([{tag:v.keyword,color:fI},{tag:[v.name,v.deleted,v.character,v.propertyName,v.macroName],color:pI},{tag:[v.variableName],color:pI},{tag:[v.function(v.variableName)],color:fI},{tag:[v.labelName],color:kpe},{tag:[v.color,v.constant(v.name),v.standard(v.name)],color:fI},{tag:[v.definition(v.name),v.separator],color:hI},{tag:[v.brace],color:uI},{tag:[v.annotation],color:gI},{tag:[v.number,v.changed,v.annotation,v.modifier,v.self,v.namespace],color:dI},{tag:[v.typeName,v.className],color:mI},{tag:[v.operator,v.operatorKeyword],color:hI},{tag:[v.tagName],color:jpe},{tag:[v.squareBracket],color:Ape},{tag:[v.angleBracket],color:pI},{tag:[v.attributeName],color:mI},{tag:[v.regexp],color:fI},{tag:[v.quote],color:aI},{tag:[v.string],color:pI},{tag:v.link,color:uI,textDecoration:`underline`,textUnderlinePosition:`under`},{tag:[v.url,v.escape,v.special(v.string)],color:pI},{tag:[v.meta],color:dI},{tag:[v.comment],color:oI,fontStyle:`italic`},{tag:v.strong,fontWeight:`bold`,color:fI},{tag:v.emphasis,fontStyle:`italic`,color:fI},{tag:v.strikethrough,textDecoration:`line-through`},{tag:v.heading,fontWeight:`bold`,color:fI},{tag:v.special(v.heading1),fontWeight:`bold`,color:fI},{tag:v.heading1,fontWeight:`bold`,color:fI},{tag:[v.heading2,v.heading3,v.heading4],fontWeight:`bold`,color:fI},{tag:[v.heading5,v.heading6],color:fI},{tag:[v.atom,v.bool,v.special(v.variableName)],color:pI},{tag:[v.processingInstruction,v.inserted],color:uI},{tag:[v.contentSeparator],color:mI},{tag:v.invalid,color:oI,borderBottom:`1px dotted ${gI}`}]))],xI=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,SI=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(xI(e)):xI,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return se(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=y(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=a(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(SI.prototype[Symbol.iterator]=function(){return this});var CI={from:-1,to:-1,match:/.*/.exec(``),precise:!0},wI=`gm`+(/x/.unicode==null?``:`u`),TI=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=CI,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new OI(e,t,n,r,i);this.re=new RegExp(t,wI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=kI(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=kI(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},EI=new WeakMap,DI=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=EI.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return EI.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),EI.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},OI=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=CI,this.matchPos=kI(e,r),this.re=new RegExp(t,wI+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=DI.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=kI(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=DI.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(TI.prototype[Symbol.iterator]=OI.prototype[Symbol.iterator]=function(){return this});function Fpe(e){try{return new RegExp(e,wI),!0}catch{return!1}}function kI(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Ipe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=le(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),m=k.cursor(p.from+Math.max(0,Math.min(u,p.length)));e.dispatch({effects:[r,f.scrollIntoView(m.from,{y:`center`})],selection:m})}),!0},Lpe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},AI=Oe.define({combine(e){return oe(e,Lpe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Rpe(e){let t=[Upe,Hpe];return e&&t.push(AI.of(e)),t}var zpe=T.mark({class:`cm-selectionMatch`}),Bpe=T.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function jI(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=L.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=L.Word)}function Vpe(e,t,n,r){return e(t.sliceDoc(n,n+1))==L.Word&&e(t.sliceDoc(r-1,r))==L.Word}var Hpe=ge.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(AI),{state:n}=e,r=n.selection;if(r.ranges.length>1)return T.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return T.none;let e=n.wordAt(i.head);if(!e)return T.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return T.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(jI(o,n,i.from,i.to)&&Vpe(o,n,i.from,i.to)))return T.none}else if(a=n.sliceDoc(i.from,i.to),!a)return T.none}let s=[];for(let r of e.visibleRanges){let e=new SI(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||jI(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Bpe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(zpe.range(r,a)),s.length>t.maxMatches))return T.none}}return T.set(s)}},{decorations:e=>e.decorations}),Upe=f.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Wpe=({state:e,dispatch:t})=>{let{selection:n}=e,r=k.create(n.ranges.map(t=>e.wordAt(t.head)||k.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function Gpe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new SI(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new SI(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Kpe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Wpe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Gpe(e,r);return i?(t(e.update({selection:e.selection.addRange(k.range(i.from,i.to),!1),effects:f.scrollIntoView(i.to)})),!0):!1},MI=Oe.define({combine(e){return oe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new ome(e),scrollToMatch:e=>f.scrollIntoView(e)})}}),NI=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Fpe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
|
|
128
128
|
`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Qpe(this):new Ype(this)}getCursor(e,t=0,n){let r=e.doc?e:Ce.create({doc:e});return n??=r.doc.length,this.regexp?II(this,r,t,n):FI(this,r,t,n)}},PI=class{constructor(e){this.spec=e}};function qpe(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function FI(e,t,n,r){let i;return e.wholeWord&&(i=Jpe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=qpe(e.test,t,i)),new SI(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Jpe(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(LI(i,n-a))!=L.Word||t(RI(i,n-a))!=L.Word)&&(t(RI(i,r-a))!=L.Word||t(LI(i,r-a))!=L.Word))}var Ype=class extends PI{constructor(e){super(e)}nextMatch(e,t,n){let r=FI(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=FI(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=FI(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=FI(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=FI(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Xpe(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function II(e,t,n,r){let i;return e.wholeWord&&(i=Zpe(t.charCategorizer(t.selection.main.head))),e.test&&(i=Xpe(e.test,t,i)),new TI(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function LI(e,t){return e.slice(h(e,t,!1),t)}function RI(e,t){return e.slice(t,h(e,t))}function Zpe(e){return(t,n,r)=>!r[0].length||(e(LI(r.input,r.index))!=L.Word||e(RI(r.input,r.index))!=L.Word)&&(e(RI(r.input,r.index+r[0].length))!=L.Word||e(LI(r.input,r.index+r[0].length))!=L.Word)}var Qpe=class extends PI{nextMatch(e,t,n){let r=II(this.spec,e,n,e.doc.length).next();return r.done&&(r=II(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=II(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=II(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=II(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},zI=w.define(),BI=w.define(),VI=l.define({create(e){return new HI(JI(e).create(),null)},update(e,t){for(let n of t.effects)n.is(zI)?e=new HI(n.value.create(),e.panel):n.is(BI)&&(e=new HI(e.query,n.value?qI:null));return e},provide:e=>xe.from(e,e=>e.panel)}),HI=class{constructor(e,t){this.query=e,this.panel=t}},$pe=T.mark({class:`cm-searchMatch`}),eme=T.mark({class:`cm-searchMatch cm-searchMatch-selected`}),tme=ge.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(VI))}update(e){let t=e.state.field(VI);(t!=e.startState.field(VI)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return T.none;let{view:n}=this,r=new o;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?eme:$pe)})}return r.finish()}},{decorations:e=>e.decorations});function UI(e){return t=>{let n=t.state.field(VI,!1);return n&&n.query.spec.valid?e(t,n):ZI(t)}}var WI=UI((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=k.single(r.from,r.to),a=e.state.facet(MI);return e.dispatch({selection:i,effects:[nL(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),XI(e),!0}),GI=UI((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=k.single(i.from,i.to),o=e.state.facet(MI);return e.dispatch({selection:a,effects:[nL(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),XI(e),!0}),nme=UI((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:k.create(n.map(e=>k.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),rme=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new SI(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(k.range(t.value.from,t.value.to))}return t(e.update({selection:k.create(a,o),userEvent:`select.search.matches`})),!0},KI=UI((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(f.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=k.single(o.from,o.to).map(d),u.push(nL(e,o)),u.push(n.facet(MI).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),ime=UI((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:f.announce.of(r),userEvent:`input.replace.all`}),!0});function qI(e){return e.state.facet(MI).createPanel(e)}function JI(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(MI);return new NI({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function YI(e){let t=b(e,qI);return t&&t.dom.querySelector(`[main-field]`)}function XI(e){let t=YI(e);t&&t==e.root.activeElement&&t.select()}var ZI=e=>{let t=e.state.field(VI,!1);if(t&&t.panel){let n=YI(e);if(n&&n!=e.root.activeElement){let r=JI(e.state,t.query.spec);r.valid&&e.dispatch({effects:zI.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[BI.of(!0),t?zI.of(JI(e.state,t.query.spec)):w.appendConfig.of(cme)]});return!0},QI=e=>{let t=e.state.field(VI,!1);if(!t||!t.panel)return!1;let n=b(e,qI);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:BI.of(!1)}),!0},ame=[{key:`Mod-f`,run:ZI,scope:`editor search-panel`},{key:`F3`,run:WI,shift:GI,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:WI,shift:GI,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:QI,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:rme},{key:`Mod-Alt-g`,run:Ipe},{key:`Mod-d`,run:Kpe,preventDefault:!0}],ome=class{constructor(e){this.view=e;let t=this.query=e.state.field(VI).query.spec;this.commit=this.commit.bind(this),this.searchField=I(`input`,{value:t.search,placeholder:$I(e,`Find`),"aria-label":$I(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=I(`input`,{value:t.replace,placeholder:$I(e,`Replace`),"aria-label":$I(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=I(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=I(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=I(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return I(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=I(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>WI(e),[$I(e,`next`)]),n(`prev`,()=>GI(e),[$I(e,`previous`)]),n(`select`,()=>nme(e),[$I(e,`all`)]),I(`label`,null,[this.caseField,$I(e,`match case`)]),I(`label`,null,[this.reField,$I(e,`regexp`)]),I(`label`,null,[this.wordField,$I(e,`by word`)]),...e.state.readOnly?[]:[I(`br`),this.replaceField,n(`replace`,()=>KI(e),[$I(e,`replace`)]),n(`replaceAll`,()=>ime(e),[$I(e,`replace all`)])],I(`button`,{name:`close`,onclick:()=>QI(e),"aria-label":$I(e,`close`),type:`button`},[`×`])])}commit(){let e=new NI({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:zI.of(e)}))}keydown(e){P(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?GI:WI)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),KI(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(zI)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(MI).top}};function $I(e,t){return e.state.phrase(t)}var eL=30,tL=/[\s\.,:;?!]/;function nL(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-eL),o=Math.min(i,n+eL),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<eL;e++)if(!tL.test(s[e+1])&&tL.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-eL;e--)if(!tL.test(s[e-1])&&tL.test(s[e])){s=s.slice(0,e);break}}return f.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var sme=f.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),cme=[VI,De.low(tme),sme],rL=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},iL=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(dL).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),s=new o,c=[],l=0,u=r.doc.iter(),d=0,f=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!c.length)break;let n,r;if(c.length)n=l,r=c.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>f)break;r=t.to,c.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))c.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,f);let i=!1;if(c.some(e=>e.from==n&&(e.to==r||r==f))&&(i=n==r,!i&&r-n<10)){let e=n-(d+u.value.length);e>0&&(u.next(e),d=n);for(let e=n;;){if(e>=r){i=!0;break}if(!u.lineBreak&&d+u.value.length>e)break;e=d+u.value.length,d+=u.value.length,u.next()}}let o=bme(c);if(i)s.add(n,n,T.widget({widget:new gme(o),diagnostics:c.slice()}));else{let e=c.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);s.add(n,r,T.mark({class:`cm-lintRange cm-lintRange-`+o+e,diagnostics:c.slice(),inclusiveEnd:c.some(e=>e.to>r)}))}if(l=r,l==f)break;for(let e=0;e<c.length;e++)c[e].to<=l&&c.splice(e--,1)}let p=s.finish();return new e(p,n,aL(p))}};function aL(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new rL(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new rL(r.from,n,r.diagnostic)}),r}function lme(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(dL).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(oL))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function ume(e,t){return e.field(lL,!1)?t:t.concat(w.appendConfig.of(xme))}var oL=w.define(),sL=w.define(),cL=w.define(),lL=l.define({create(){return new iL(T.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=aL(n,e.selected.diagnostic,i)||aL(n,null,i)}!n.size&&i&&t.state.facet(dL).autoPanel&&(i=null),e=new iL(n,i,r)}for(let n of t.effects)if(n.is(oL)){let r=t.state.facet(dL).autoPanel?n.value.length?gL.open:null:e.panel;e=iL.init(n.value,r,t.state)}else n.is(sL)?e=new iL(e.diagnostics,n.value?gL.open:null,e.selected):n.is(cL)&&(e=new iL(e.diagnostics,e.panel,n.value));return e},provide:e=>[xe.from(e,e=>e.panel),f.decorations.from(e,e=>e.diagnostics)]}),dme=T.mark({class:`cm-lintRange cm-lintRange-active`});function fme(e,t,n){let{diagnostics:r}=e.state.field(lL),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(dL).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:pme(e,i)}}}:null}function pme(e,t){return I(`ul`,{class:`cm-tooltip-lint`},t.map(t=>mL(e,t,!1)))}var mme=e=>{let t=e.state.field(lL,!1);(!t||!t.panel)&&e.dispatch({effects:ume(e.state,[sL.of(!0)])});let n=b(e,gL.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},uL=e=>{let t=e.state.field(lL,!1);return!t||!t.panel?!1:(e.dispatch({effects:sL.of(!1)}),!0)},hme=[{key:`Mod-Shift-m`,run:mme,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(lL,!1);if(!t)return!1;let n=e.state.selection.main,r=aL(t.diagnostics,null,n.to+1);return!r&&(r=aL(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],dL=Oe.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...oe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:fL,tooltipFilter:fL,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function fL(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function pL(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function mL(e,t,n){let r=n?pL(t.actions):[];return I(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},I(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=aL(e.state.field(lL).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),I(`u`,s.slice(c,c+1)),s.slice(c+1)];return I(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&I(`div`,{class:`cm-diagnosticSource`},t.source))}var gme=class extends d{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return I(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},hL=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=mL(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},gL=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)uL(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=pL(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=aL(this.view.state.field(lL).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=I(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=I(`div`,{class:`cm-panel-lint`},this.list,I(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>uL(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(lL).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(lL),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new hL(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new hL(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=aL(this.view.state.field(lL).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:cL.of(t)})}static open(t){return new e(t)}};function _me(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function _L(e){return _me(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var vme=f.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:_L(`#d11`)},".cm-lintRange-warning":{backgroundImage:_L(`orange`)},".cm-lintRange-info":{backgroundImage:_L(`#999`)},".cm-lintRange-hint":{backgroundImage:_L(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function yme(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function bme(e){let t=`hint`,n=1;for(let r of e){let e=yme(r.severity);e>n&&(n=e,t=r.severity)}return t}var xme=[lL,f.decorations.compute([lL],e=>{let{selected:t,panel:n}=e.field(lL);return!t||!n||t.from==t.to?T.none:T.set([dme.range(t.from,t.to)])}),_e(fme,{hideOn:lme}),vme],Sme=[j(),be(),fe(),YP(),ne(),E(),O(),Ce.allowMultipleSelections.of(!0),we(),i(te,{fallback:!0}),ce(),afe(),hfe(),ve(),D(),ee(),Rpe(),ie.of([...cfe,...nI,...ame,...oF,...Se,...VP,...hme])];fe(),YP(),E(),i(te,{fallback:!0}),ie.of([...nI,...oF]);function vL(e,[t,n]){return Math.min(n,Math.max(t,e))}function Cme(e){let t=R.useRef({value:e,previous:e});return R.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var yL=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),wme=`VisuallyHidden`,bL=R.forwardRef((e,t)=>(0,z.jsx)(HT.span,{...e,ref:t,style:{...yL,...e.style}}));bL.displayName=wme;var Tme=bL,Eme=[` `,`Enter`,`ArrowUp`,`ArrowDown`],Dme=[` `,`Enter`],xL=`Select`,[SL,CL,Ome]=BO(xL),[wL,kme]=zT(xL,[Ome,CD]),TL=CD(),[Ame,EL]=wL(xL),[jme,Mme]=wL(xL),DL=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m}=e,h=TL(t),[g,_]=R.useState(null),[v,y]=R.useState(null),[b,x]=R.useState(!1),S=VO(l),[C,w]=BD({prop:r,defaultProp:i??!1,onChange:a,caller:xL}),[T,E]=BD({prop:o,defaultProp:s,onChange:c,caller:xL}),D=R.useRef(null),O=g?m||!!g.closest(`form`):!0,[k,A]=R.useState(new Set),j=Array.from(k).map(e=>e.props.value).join(`;`);return(0,z.jsx)(ND,{...h,children:(0,z.jsxs)(Ame,{required:p,scope:t,trigger:g,onTriggerChange:_,valueNode:v,onValueNodeChange:y,valueNodeHasChildren:b,onValueNodeHasChildrenChange:x,contentId:lE(),value:T,onValueChange:E,open:C,onOpenChange:w,dir:S,triggerPointerDownPosRef:D,disabled:f,children:[(0,z.jsx)(SL.Provider,{scope:t,children:(0,z.jsx)(jme,{scope:e.__scopeSelect,onNativeOptionAdd:R.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:R.useCallback(e=>{A(t=>{let n=new Set(t);return n.delete(e),n})},[]),children:n})}),O?(0,z.jsxs)(iR,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:e=>E(e.target.value),disabled:f,form:m,children:[T===void 0?(0,z.jsx)(`option`,{value:``}):null,Array.from(k)]},j):null]})})};DL.displayName=xL;var OL=`SelectTrigger`,kL=R.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,a=TL(n),o=EL(OL,n),s=o.disabled||r,c=RT(t,o.onTriggerChange),l=CL(n),u=R.useRef(`touch`),[d,f,p]=oR(e=>{let t=l().filter(e=>!e.disabled),n=sR(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),m=e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return(0,z.jsx)(PD,{asChild:!0,...a,children:(0,z.jsx)(HT.button,{type:`button`,role:`combobox`,"aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":aR(o.value)?``:void 0,...i,ref:c,onClick:FT(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:FT(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:FT(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&f(e.key),!(t&&e.key===` `)&&Eme.includes(e.key)&&(m(),e.preventDefault())})})})});kL.displayName=OL;var AL=`SelectValue`,jL=R.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=EL(AL,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=RT(t,c.onValueNodeChange);return cE(()=>{l(u)},[l,u]),(0,z.jsx)(HT.span,{...s,ref:d,style:{pointerEvents:`none`},children:aR(c.value)?(0,z.jsx)(z.Fragment,{children:o}):a})});jL.displayName=AL;var Nme=`SelectIcon`,ML=R.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,z.jsx)(HT.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})});ML.displayName=Nme;var Pme=`SelectPortal`,NL=e=>(0,z.jsx)(LD,{asChild:!0,...e});NL.displayName=Pme;var PL=`SelectContent`,FL=R.forwardRef((e,t)=>{let n=EL(PL,e.__scopeSelect),[r,i]=R.useState();if(cE(()=>{i(new DocumentFragment)},[]),!n.open){let t=r;return t?Na.createPortal((0,z.jsx)(LL,{scope:e.__scopeSelect,children:(0,z.jsx)(SL.Slot,{scope:e.__scopeSelect,children:(0,z.jsx)(`div`,{children:e.children})})}),t):null}return(0,z.jsx)(zL,{...e,ref:t})});FL.displayName=PL;var IL=10,[LL,RL]=wL(PL),Fme=`SelectContentImpl`,Ime=BT(`SelectContent.RemoveScroll`),zL=R.forwardRef((e,t)=>{let{__scopeSelect:n,position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=EL(PL,n),[y,b]=R.useState(null),[x,S]=R.useState(null),C=RT(t,e=>b(e)),[w,T]=R.useState(null),[E,D]=R.useState(null),O=CL(n),[k,A]=R.useState(!1),j=R.useRef(!1);R.useEffect(()=>{if(y)return KD(y)},[y]),ZT();let M=R.useCallback(e=>{let[t,...n]=O().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[O,x]),N=R.useCallback(()=>M([w,y]),[M,w,y]);R.useEffect(()=>{k&&N()},[k,N]);let{onOpenChange:P,triggerPointerDownPosRef:F}=v;R.useEffect(()=>{if(y){let e={x:0,y:0},t=t=>{e={x:Math.abs(Math.round(t.pageX)-(F.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(F.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():y.contains(n.target)||P(!1),document.removeEventListener(`pointermove`,t),F.current=null};return F.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,P,F]),R.useEffect(()=>{let e=()=>P(!1);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[P]);let[ee,te]=oR(e=>{let t=O().filter(e=>!e.disabled),n=sR(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current.focus())}),I=R.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&(T(e),r&&(j.current=!0))},[v.value]),ne=R.useCallback(()=>y?.focus(),[y]),L=R.useCallback((e,t,n)=>{let r=!j.current&&!n;(v.value!==void 0&&v.value===t||r)&&D(e)},[v.value]),re=r===`popper`?VL:BL,ie=re===VL?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,z.jsx)(LL,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:I,selectedItem:w,onItemLeave:ne,itemTextRefCallback:L,focusSelectedItem:N,selectedItemText:E,position:r,isPositioned:k,searchRef:ee,children:(0,z.jsx)(yO,{as:Ime,allowPinchZoom:!0,children:(0,z.jsx)(nE,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:FT(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,z.jsx)(qT,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,z.jsx)(re,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...ie,onPlaced:()=>A(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:FT(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&te(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=O().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>M(t)),e.preventDefault()}})})})})})})});zL.displayName=Fme;var Lme=`SelectItemAlignedPosition`,BL=R.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,a=EL(PL,n),o=RL(PL,n),[s,c]=R.useState(null),[l,u]=R.useState(null),d=RT(t,e=>u(e)),f=CL(n),p=R.useRef(!1),m=R.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=R.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-IL,d=vL(a,[IL,Math.max(IL,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-IL,d=vL(a,[IL,Math.max(IL,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-IL*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-IL,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${IL}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);cE(()=>y(),[y]);let[b,x]=R.useState();return cE(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]),(0,z.jsx)(zme,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:R.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]),children:(0,z.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,z.jsx)(HT.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})});BL.displayName=Lme;var Rme=`SelectPopperPosition`,VL=R.forwardRef((e,t)=>{let{__scopeSelect:n,align:r=`start`,collisionPadding:i=IL,...a}=e,o=TL(n);return(0,z.jsx)(FD,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})});VL.displayName=Rme;var[zme,HL]=wL(PL,{}),UL=`SelectViewport`,WL=R.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,a=RL(UL,n),o=HL(UL,n),s=RT(t,a.onViewportChange),c=R.useRef(0);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,z.jsx)(SL.Slot,{scope:n,children:(0,z.jsx)(HT.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:FT(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-IL*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})});WL.displayName=UL;var GL=`SelectGroup`,[Bme,Vme]=wL(GL),Hme=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=lE();return(0,z.jsx)(Bme,{scope:n,id:i,children:(0,z.jsx)(HT.div,{role:`group`,"aria-labelledby":i,...r,ref:t})})});Hme.displayName=GL;var KL=`SelectLabel`,Ume=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=Vme(KL,n);return(0,z.jsx)(HT.div,{id:i.id,...r,ref:t})});Ume.displayName=KL;var qL=`SelectItem`,[Wme,JL]=wL(qL),YL=R.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=EL(qL,n),c=RL(qL,n),l=s.value===r,[u,d]=R.useState(a??``),[f,p]=R.useState(!1),m=RT(t,e=>c.itemRefCallback?.(e,r,i)),h=lE(),g=R.useRef(`touch`),_=()=>{i||(s.onValueChange(r),s.onOpenChange(!1))};if(r===``)throw Error(`A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.`);return(0,z.jsx)(Wme,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:R.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,z.jsx)(SL.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,z.jsx)(HT.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:FT(o.onFocus,()=>p(!0)),onBlur:FT(o.onBlur,()=>p(!1)),onClick:FT(o.onClick,()=>{g.current!==`mouse`&&_()}),onPointerUp:FT(o.onPointerUp,()=>{g.current===`mouse`&&_()}),onPointerDown:FT(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:FT(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:FT(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:FT(o.onKeyDown,e=>{c.searchRef?.current!==``&&e.key===` `||(Dme.includes(e.key)&&_(),e.key===` `&&e.preventDefault())})})})})});YL.displayName=qL;var XL=`SelectItemText`,ZL=R.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...a}=e,o=EL(XL,n),s=RL(XL,n),c=JL(XL,n),l=Mme(XL,n),[u,d]=R.useState(null),f=RT(t,e=>d(e),c.onItemTextChange,e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=u?.textContent,m=R.useMemo(()=>(0,z.jsx)(`option`,{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:h,onNativeOptionRemove:g}=l;return cE(()=>(h(m),()=>g(m)),[h,g,m]),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(HT.span,{id:c.textId,...a,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Na.createPortal(a.children,o.valueNode):null]})});ZL.displayName=XL;var QL=`SelectItemIndicator`,Gme=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return JL(QL,n).isSelected?(0,z.jsx)(HT.span,{"aria-hidden":!0,...r,ref:t}):null});Gme.displayName=QL;var $L=`SelectScrollUpButton`,Kme=R.forwardRef((e,t)=>{let n=RL($L,e.__scopeSelect),r=HL($L,e.__scopeSelect),[i,a]=R.useState(!1),o=RT(t,r.onScrollButtonChange);return cE(()=>{if(n.viewport&&n.isPositioned){let e=function(){a(t.scrollTop>0)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,z.jsx)(tR,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null});Kme.displayName=$L;var eR=`SelectScrollDownButton`,qme=R.forwardRef((e,t)=>{let n=RL(eR,e.__scopeSelect),r=HL(eR,e.__scopeSelect),[i,a]=R.useState(!1),o=RT(t,r.onScrollButtonChange);return cE(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight;a(Math.ceil(t.scrollTop)<e)},t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,z.jsx)(tR,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null});qme.displayName=eR;var tR=R.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=RL(`SelectScrollButton`,n),o=R.useRef(null),s=CL(n),c=R.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return R.useEffect(()=>()=>c(),[c]),cE(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,z.jsx)(HT.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:FT(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:FT(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:FT(i.onPointerLeave,()=>{c()})})}),Jme=`SelectSeparator`,nR=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,z.jsx)(HT.div,{"aria-hidden":!0,...r,ref:t})});nR.displayName=Jme;var rR=`SelectArrow`,Yme=R.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=TL(n),a=EL(rR,n),o=RL(rR,n);return a.open&&o.position===`popper`?(0,z.jsx)(ID,{...i,...r,ref:t}):null});Yme.displayName=rR;var Xme=`SelectBubbleInput`,iR=R.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=R.useRef(null),a=RT(r,i),o=Cme(t);return R.useEffect(()=>{let e=i.current;if(!e)return;let n=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`).set;if(o!==t&&r){let n=new Event(`change`,{bubbles:!0});r.call(e,t),e.dispatchEvent(n)}},[o,t]),(0,z.jsx)(HT.select,{...n,style:{...yL,...n.style},ref:a,defaultValue:t})});iR.displayName=Xme;function aR(e){return e===``||e===void 0}function oR(e){let t=UT(e),n=R.useRef(``),r=R.useRef(0),i=R.useCallback(e=>{let i=n.current+e;t(i),(function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))})(i)},[t]),a=R.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return R.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function sR(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Zme(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Zme(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Qme=DL,$me=kL,ehe=jL,the=ML,nhe=NL,rhe=FL,ihe=WL,ahe=YL,ohe=ZL,she=nR,[cR,che]=zT(`Tooltip`,[CD]),lR=CD(),uR=`TooltipProvider`,lhe=700,dR=`tooltip.open`,[uhe,fR]=cR(uR),pR=e=>{let{__scopeTooltip:t,delayDuration:n=lhe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=R.useRef(!0),s=R.useRef(!1),c=R.useRef(0);return R.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,z.jsx)(uhe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:R.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:R.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:R.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};pR.displayName=uR;var mR=`Tooltip`,[dhe,hR]=cR(mR),gR=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=fR(mR,e.__scopeTooltip),l=lR(t),[u,d]=R.useState(null),f=lE(),p=R.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=R.useRef(!1),[_,v]=BD({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(dR))):c.onClose(),a?.(e)},caller:mR}),y=R.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=R.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=R.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=R.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return R.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,z.jsx)(ND,{...l,children:(0,z.jsx)(dhe,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:R.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:R.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};gR.displayName=mR;var _R=`TooltipTrigger`,vR=R.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=hR(_R,n),a=fR(_R,n),o=lR(n),s=RT(t,R.useRef(null),i.onTriggerChange),c=R.useRef(!1),l=R.useRef(!1),u=R.useCallback(()=>c.current=!1,[]);return R.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,z.jsx)(PD,{asChild:!0,...o,children:(0,z.jsx)(HT.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:FT(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:FT(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:FT(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:FT(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:FT(e.onBlur,i.onClose),onClick:FT(e.onClick,i.onClose)})})});vR.displayName=_R;var yR=`TooltipPortal`,[fhe,phe]=cR(yR,{forceMount:void 0}),bR=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=hR(yR,t);return(0,z.jsx)(fhe,{scope:t,forceMount:n,children:(0,z.jsx)(RD,{present:n||a.open,children:(0,z.jsx)(LD,{asChild:!0,container:i,children:r})})})};bR.displayName=yR;var xR=`TooltipContent`,SR=R.forwardRef((e,t)=>{let n=phe(xR,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=hR(xR,e.__scopeTooltip);return(0,z.jsx)(RD,{present:r||o.open,children:o.disableHoverableContent?(0,z.jsx)(CR,{side:i,...a,ref:t}):(0,z.jsx)(mhe,{side:i,...a,ref:t})})}),mhe=R.forwardRef((e,t)=>{let n=hR(xR,e.__scopeTooltip),r=fR(xR,e.__scopeTooltip),i=R.useRef(null),a=RT(t,i),[o,s]=R.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=R.useCallback(()=>{s(null),d(!1)},[d]),p=R.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=yhe(r,vhe(r,n.getBoundingClientRect())),a=bhe(t.getBoundingClientRect());s(She([...i,...a])),d(!0)},[d]);return R.useEffect(()=>()=>f(),[f]),R.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),R.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!xhe(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,z.jsx)(CR,{...e,ref:a})}),[hhe,ghe]=cR(mR,{isInside:!1}),_he=Zoe(`TooltipContent`),CR=R.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=hR(xR,n),l=lR(n),{onClose:u}=c;return R.useEffect(()=>(document.addEventListener(dR,u),()=>document.removeEventListener(dR,u)),[u]),R.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,z.jsx)(qT,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,z.jsxs)(FD,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,z.jsx)(_he,{children:r}),(0,z.jsx)(hhe,{scope:n,isInside:!0,children:(0,z.jsx)(Tme,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});SR.displayName=xR;var wR=`TooltipArrow`,TR=R.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=lR(n);return ghe(wR,n).isInside?null:(0,z.jsx)(ID,{...i,...r,ref:t})});TR.displayName=wR;function vhe(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function yhe(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function bhe(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function xhe(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function She(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Che(t)}function Che(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var ER=pR,DR=gR,OR=vR,kR=bR,AR=SR,whe=TR,jR=R.forwardRef(({title:e,children:t},n)=>{let r=Vl(hC);return R.createElement(ER,{delayDuration:100},R.createElement(DR,null,R.createElement(OR,{ref:n,asChild:!0},R.createElement(`span`,{className:mw.tooltipTrigger},t)),R.createElement(kR,{container:r?.current},R.createElement(AR,{className:(0,rT.default)(mw.tooltipContent),sideOffset:10},e))))}),The=R.forwardRef(({children:e,className:t,...n},r)=>R.createElement(ahe,{...n,ref:r,className:(0,rT.default)(t,mw.selectItem)},R.createElement(ohe,null,e))),Ehe=({title:e,placeholder:t,className:n})=>{let[r,i]=Hl(WS,NC);return R.createElement(jR,{title:e},R.createElement($me,{"aria-label":t,className:(0,rT.default)(mw.selectTrigger,n),"data-toolbar-item":!0,disabled:r},R.createElement(ehe,{placeholder:t}),R.createElement(the,{className:mw.selectDropdownArrow},i(`arrow_drop_down`))))},Dhe=({children:e,className:t=mw.selectContainer})=>{let n=Vl(hC);return R.createElement(nhe,{container:n?.current},R.createElement(rhe,{className:(0,rT.default)(t,`mdxeditor-select-content`),onCloseAutoFocus:e=>{e.preventDefault()},position:`popper`},R.createElement(ihe,{"data-editor-dropdown":!0,style:{maxHeight:`var(--radix-select-content-available-height)`}},e)))},MR=e=>R.createElement(Qme,{value:e.value||``,onValueChange:e.onChange,disabled:e.disabled},R.createElement(Ehe,{title:e.triggerTitle,placeholder:e.placeholder}),R.createElement(Dhe,null,e.items.map((e,t)=>e===`separator`?R.createElement(she,{key:t}):R.createElement(The,{key:t,value:e.value},e.label)))),NR=({language:e,nodeKey:t,code:n,focusEmitter:r})=>{let i=rw(),{parentEditor:a,lexicalNode:o}=JN(),[s,c,l,u,d]=Hl(WS,LR,RR,NC,IR),p=Dpe(t,`codeblock`,e,r),{setCode:m}=JN(),h=R.useRef(null),g=R.useRef(null),{value:_,items:v}=R.useMemo(()=>Ohe(d,e),[d,e]),y=R.useRef(m);return y.current=m,p.current={getCodemirror:()=>h.current},R.useEffect(()=>{let t=g.current;return(async()=>{let r=[...c,Sme,Ppe,j(),ie.of([Epe]),f.lineWrapping,f.updateListener.of(({state:e})=>{y.current(e.doc.toString())}),f.domEventHandlers({focus:()=>{a.update(()=>{Rh(null)})}})];if(s&&r.push(Ce.readOnly.of(!0)),e!==``){let t=d.keyMap[e]??e,n=d.supportMap[t];if(n)r.push(n.extension);else if(l){let t=Ope.find(t=>t.name===e||t.alias.includes(e)||t.extensions.includes(e));if(t)try{let e=await t.load();r.push(e.extension)}catch{console.warn(`failed to load language support for`,e)}}}t.innerHTML=``,h.current=new f({parent:t,state:Ce.create({doc:n,extensions:r})}),t.addEventListener(`keydown`,PR)})(),()=>{var e;(e=h.current)==null||e.destroy(),h.current=null,t.removeEventListener(`keydown`,PR)}},[s,e,...c]),R.createElement(`div`,{className:mw.codeMirrorWrapper},R.createElement(`div`,{className:mw.codeMirrorToolbar},R.createElement(MR,{disabled:s,value:_,onChange:e=>{a.update(()=>{o.setLanguage(e===`__EMPTY_VALUE__`?``:e),setTimeout(()=>{a.update(()=>{o.getLatest().select()})})})},triggerTitle:i(`codeBlock.selectLanguage`,`Select code block language`),placeholder:i(`codeBlock.inlineLanguage`,`Language`),items:v}),R.createElement(`button`,{className:mw.iconButton,type:`button`,disabled:s,title:i(`codeblock.delete`,`Delete code block`),onClick:e=>{e.preventDefault(),a.update(()=>{o.remove()})}},u(`delete_small`))),R.createElement(`div`,{ref:g}))};function PR(e){e.stopPropagation()}function FR(e){let t=[],n={},r={};if(Array.isArray(e))for(let i of e){let e=i.alias?.[0]??i.name.toLowerCase(),a=e||`__EMPTY_VALUE__`;if(t.push({value:a,label:i.name}),n[e]=a,i.alias)for(let e of i.alias)n[e]=a;if(i.extensions)for(let e of i.extensions)n[e]=a;n[i.name.toLowerCase()]=a,i.support&&(r[a]=i.support)}else{let r={};for(let[i,a]of Object.entries(e))a in r||(r[a]=i,t.push({value:i||`__EMPTY_VALUE__`,label:a})),n[i]=r[a]||`__EMPTY_VALUE__`}return{items:t,keyMap:n,supportMap:r}}function Ohe(e,t){let n=e.keyMap[t]??t;return!n||e.items.some(e=>e.value===n)?{value:n,items:e.items}:{value:n,items:[...e.items,{value:n,label:t}]}}var IR=Il(FR({js:`JavaScript`,ts:`TypeScript`,tsx:`TypeScript (React)`,jsx:`JavaScript (React)`,css:`CSS`})),khe=Ll(e=>{e.link(e.pipe(khe,Wl(({language:e,code:t})=>({code:t,language:e,meta:``}))),ZN)}),LR=Il([]),RR=Il(!0),Ahe=Xl({update(e,t){e.pubIn({[IR]:FR(t?.codeBlockLanguages??{}),[LR]:t?.codeMirrorExtensions??[],[RR]:t?.autoLoadLanguageSupport??!0})},init(e,t){let n=FR(t?.codeBlockLanguages??{});e.pubIn({[IR]:n,[LR]:t?.codeMirrorExtensions??[],[gde]:jhe(),[RR]:t?.autoLoadLanguageSupport??!0})}});function jhe(e){return{match(e,t){return!t},priority:1,Editor:NR}}function Mhe({url:e,title:t,text:n,onSubmit:r,onCancel:i,linkAutocompleteSuggestions:a,showLinkTitleField:o,showAnchorTextField:s}){let{register:c,handleSubmit:l,control:u,setValue:d,reset:f}=lue({values:{url:e,title:t,text:n}}),p=rw();return R.createElement(`form`,{onSubmit:e=>{l(r)(e),e.stopPropagation(),e.preventDefault()},onReset:e=>{e.stopPropagation(),i()},onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),i())},className:(0,rT.default)(mw.multiFieldForm,mw.linkDialogEditForm)},R.createElement(`div`,{className:mw.formField},R.createElement(`label`,{htmlFor:`link-url`},p(`createLink.url`,`URL`)),R.createElement(nde,{register:c,initialInputValue:e,inputName:`url`,suggestions:a,setValue:d,control:u,placeholder:p(`createLink.urlPlaceholder`,`Select or paste an URL`),autofocus:!0})),s?R.createElement(`div`,{className:mw.formField},R.createElement(`label`,{htmlFor:`link-text`,title:p(`createLink.textTooltip`,`The text to be displayed for the link`)},p(`createLink.text`,`Anchor text`)),R.createElement(`input`,{id:`link-text`,className:mw.textInput,size:40,...c(`text`)})):null,o?R.createElement(`div`,{className:mw.formField},R.createElement(`label`,{htmlFor:`link-title`,title:p(`createLink.titleTooltip`,`The link's title attribute, shown on hover`)},p(`createLink.title`,`Link title`)),R.createElement(`input`,{id:`link-title`,className:mw.textInput,size:40,...c(`title`)})):null,R.createElement(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:`var(--spacing-2)`}},R.createElement(`button`,{type:`submit`,title:p(`createLink.saveTooltip`,`Set URL`),"aria-label":p(`createLink.saveTooltip`,`Set URL`),className:(0,rT.default)(mw.primaryButton)},p(`dialogControls.save`,`Save`)),R.createElement(`button`,{type:`reset`,title:p(`createLink.cancelTooltip`,`Cancel change`),"aria-label":p(`createLink.cancelTooltip`,`Cancel change`),className:(0,rT.default)(mw.secondaryButton)},p(`dialogControls.cancel`,`Cancel`))))}var Nhe=()=>{let[e,t,n,r,i,a,o]=Hl(hC,VS,NC,HR,JR,YR,QR),s=Ul(VR),c=Ul(UR),l=Ul(WR),u=Ul(GR),d=Ul(KR);R.useEffect(()=>{let e=()=>{t?.getEditorState().read(()=>{s(!0)})};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e)}},[t,s]);let[f,p]=R.useState(!1),m=rw();if(r.type===`inactive`)return null;let h=r.rectangle,g=r.type===`preview`&&r.url.startsWith(`http`);return R.createElement(LO,{open:!0},R.createElement(jle,{"data-visible":r.type===`edit`,className:mw.linkDialogAnchor,style:{top:`${h.top}px`,left:`${h.left}px`,width:`${h.width}px`,height:`${h.height}px`}}),R.createElement(RO,{container:e?.current},R.createElement(Mle,{className:(0,rT.default)(mw.linkDialogPopoverContent),sideOffset:5,onOpenAutoFocus:e=>{e.preventDefault()},key:r.linkNodeKey},r.type===`edit`&&R.createElement(Mhe,{url:r.url,title:r.title,text:r.text,onSubmit:c,onCancel:l.bind(null),linkAutocompleteSuggestions:i,showLinkTitleField:o,showAnchorTextField:r.withAnchorText}),r.type===`preview`&&R.createElement(R.Fragment,null,R.createElement(`a`,{className:mw.linkDialogPreviewAnchor,href:r.url,...g?{target:`_blank`,rel:`noreferrer`}:{},onClick:e=>{a!==null&&(e.preventDefault(),a(r.url))},title:g?m(`linkPreview.open`,`Open {{url}} in new window`,{url:r.url}):r.url},R.createElement(`span`,null,r.url),g&&n(`open_in_new`)),R.createElement(zR,{onClick:()=>{u()},title:m(`linkPreview.edit`,`Edit link URL`),"aria-label":m(`linkPreview.edit`,`Edit link URL`)},n(`edit`)),R.createElement(ER,null,R.createElement(DR,{open:f},R.createElement(OR,{asChild:!0},R.createElement(zR,{title:m(`linkPreview.copyToClipboard`,`Copy to clipboard`),"aria-label":m(`linkPreview.copyToClipboard`,`Copy to clipboard`),onClick:()=>{window.navigator.clipboard.writeText(r.url).then(()=>{p(!0),setTimeout(()=>{p(!1)},1e3)})}},n(f?`check`:`content_copy`))),R.createElement(kR,{container:e?.current},R.createElement(AR,{className:(0,rT.default)(mw.tooltipContent),sideOffset:5},m(`linkPreview.copied`,`Copied!`),R.createElement(whe,null))))),R.createElement(zR,{title:m(`linkPreview.remove`,`Remove link`),"aria-label":m(`linkPreview.remove`,`Remove link`),onClick:()=>{d()}},n(`link_off`))),R.createElement(zO,{className:mw.popoverArrow}))))},zR=R.forwardRef(({className:e,...t},n)=>R.createElement(`button`,{className:(0,rT.default)(mw.actionButton,e),ref:n,...t}));function BR(e){if(!e)return null;let t=qae(e);if(t===null)return null;let n=t.getParent();return _w(n)?n:_w(t)?t:null}var VR=Ll(),HR=Il({type:`inactive`},e=>{e.pub(LC,t=>t.registerCommand(gf,()=>e.getValue(HR).type===`preview`?(e.pub(HR,{type:`inactive`}),!0):!1,1)),e.sub(e.pipe(ZC),t=>{t!==`rich-text`&&e.pub(HR,{type:`inactive`})}),e.pub(LC,t=>t.registerCommand(of,t=>t.key===`k`&&(aT?t.metaKey:t.ctrlKey)&&!e.getValue(WS)&&W(G())?(e.pub(qR),t.stopPropagation(),t.preventDefault(),!0):!1,3)),e.sub(e.pipe(GR,Gl(HR,VS)),([,t,n])=>{if(t.type===`preview`)setTimeout(()=>{n?.getEditorState().read(()=>{let n=Ah(t.linkNodeKey),r=_w(n)?n.getTextContent().length>0&&n.getChildrenSize()<=1:!1,i=r&&n?n.getTextContent():``;e.pub(HR,{type:`edit`,initialUrl:t.url,url:t.url,title:t.title,text:i,withAnchorText:r,linkNodeKey:t.linkNodeKey,rectangle:t.rectangle})})});else throw Error(`Cannot switch to edit mode when not in preview mode`)}),e.sub(e.pipe(UR,Gl(VS,HR,QS)),([t,n,r,i])=>{let a=t.text?.trim()??``,o=t.url?.trim()??``,s=t.title?.trim()??``;if(o!==``){if(i?.isCollapsed()){let e=a||s||o;n?.update(()=>{let t=BR(i);if(!t){let t=gw(o,{title:s});t.append(Fp(e)),pm([t]),t.select()}else if(bw(t)){let e=gw(o,{title:s});e.append(Fp(a)),t.replace(e),e.select()}else t.setURL(o),t.setTitle(s),ZR(t.getFirstChild(),a)},{discrete:!0})}else n?.update(()=>{ZR(i?.anchor.getNode(),a)}),n?.dispatchCommand(xw,{url:o,title:s});e.pub(HR,{type:`preview`,linkNodeKey:r.linkNodeKey,rectangle:r.rectangle,title:s,url:o})}else r.type===`edit`&&r.initialUrl!==``&&n?.dispatchCommand(xw,null),e.pub(HR,{type:`inactive`})}),e.link(e.pipe(WR,Gl(HR,VS),Wl(([,e,t])=>{if(e.type===`edit`)return t?.focus(),e.initialUrl===``?{type:`inactive`}:{type:`preview`,url:e.initialUrl,linkNodeKey:e.linkNodeKey,rectangle:e.rectangle};throw Error(`Cannot cancel edit when not in edit mode`)})),HR),e.link(e.pipe(e.combine(QS,VR),Gl(VS,HR,WS),Wl(([[e],t,n,r])=>{if(W(e)&&t&&!r){let n=BR(e);if(!e.isCollapsed())return{type:`inactive`};if(n){let e=nT(t);return e?{type:`preview`,url:n.getURL(),linkNodeKey:n.getKey(),title:n.getTitle(),rectangle:e}:{type:`inactive`}}else return{type:`inactive`}}else return{type:`inactive`}})),HR)}),UR=Ll(),WR=Rl();Rl();var GR=Rl(),KR=Rl(e=>{e.sub(e.pipe(KR,Gl(VS)),([,e])=>{e?.dispatchCommand(xw,null)})}),qR=Rl(e=>{e.sub(e.pipe(qR,Gl(QS,VS),Kl(([,e])=>W(e))),([,t,n])=>{n?.focus(()=>{setTimeout(()=>{n.getEditorState().read(()=>{let r=BR(t),i=nT(n),a=r?.getURL()??``,o=r?.getURL()??``,s=r?.getTitle()??``,c=r?.getKey()??``,l=r?r.getTextContent().length>0&&r.getChildrenSize()<=1:!!t?.isCollapsed(),u=l&&r?r.getTextContent():``;e.pub(HR,{type:`edit`,initialUrl:a,url:o,title:s,text:u,withAnchorText:l,linkNodeKey:c,rectangle:i})})})})})}),JR=Il([]),YR=Il(null),XR=Il(null,e=>{e.pub(LC,t=>{function n(n){let[r,i]=e.getValues([WS,XR]);!r||i===null||t.update(()=>{let e=Nh(n.target);if(e!==null){let t=Z_(e,e=>e instanceof hw);t!==null&&i(n,t,t.getURL())}})}return t.registerRootListener((e,t)=>{e&&e.addEventListener(`click`,n),t&&t.removeEventListener(`click`,n)})})});function ZR(e,t){U(e)&&t&&(e.setTextContent(t),e.selectStart())}var QR=Il(!0),Phe=Xl({init(e,t){e.pub(BC,t?.LinkDialog??Nhe),e.pub(YR,t?.onClickLinkCallback??null),e.pub(XR,t?.onReadOnlyClickLinkCallback??null),e.pub(QR,t?.showLinkTitleField??!0)},update(e,t={}){e.pub(JR,t.linkAutocompleteSuggestions??[])}});function $R(e,t){return R.forwardRef((n,r)=>{let i=(0,rT.default)(t.className,n.className);return R.createElement(e,{...t,...n,className:i,ref:r})})}function Fhe(e){return({title:t,children:n,...r})=>R.createElement(e,{"aria-label":t,...r},R.createElement(jR,{title:t},n))}var Ihe=({readOnly:e,children:t,className:n})=>R.createElement(Wk,{className:(0,rT.default)(`mdxeditor-toolbar`,mw.toolbarRoot,{[mw.readOnlyToolbarRoot]:e},n),...e?{tabIndex:-1}:{}},t),ez=Fhe($R(Kk,{className:mw.toolbarButton,"data-toolbar-item":!0})),tz=$R(Jk,{className:mw.toolbarToggleItem,"data-toolbar-item":!0});$R(qk,{type:`single`,className:mw.toolbarToggleSingleGroup});var nz=R.forwardRef(({on:e,title:t,children:n,disabled:r,...i},a)=>R.createElement(qk,{type:`single`,className:mw.toolbarToggleSingleGroup,...i,value:e?`on`:`off`,ref:a},R.createElement(tz,{"aria-label":t,value:`on`,disabled:r},R.createElement(jR,{title:t},n)))),rz=({items:e})=>R.createElement(`div`,{className:mw.toolbarGroupOfGroups},e.map((e,t)=>R.createElement(nz,{key:t,title:e.title,on:e.active,onValueChange:t=>{e.onChange(t===`on`)},disabled:e.disabled},e.contents))),Lhe=({value:e,onChange:t,className:n,ggClassName:r,items:i,disabled:a})=>{let o=rw();return R.createElement(`div`,{className:(0,rT.default)(mw.toolbarGroupOfGroups,r)},R.createElement(qk,{"aria-label":o(`toolbar.toggleGroup`,`toggle group`),type:`single`,className:(0,rT.default)(mw.toolbarToggleSingleGroup,n),onValueChange:t,value:e||``,disabled:a,onFocus:e=>{e.preventDefault()}},i.map((e,t)=>R.createElement(tz,{key:t,"aria-label":e.title,value:e.value},R.createElement(jR,{title:e.title},e.contents)))))},iz=Il(()=>null),az=Il(``),oz=()=>"This is an empty toolbar. Pass `{toolbarContents: () => { return <>toolbar components</> }}` to the toolbarPlugin to customize it.",Rhe=Xl({init(e,t){let n=t?.toolbarPosition===`bottom`?mae:pae;e.pubIn({[iz]:t?.toolbarContents??oz,[az]:t?.toolbarClassName??``,[n]:()=>{let[e,t,n]=Hl(iz,WS,az);return R.createElement(Ihe,{className:n,readOnly:t},e())}})},update(e,t){e.pub(iz,t?.toolbarContents??oz),e.pub(az,t?.toolbarClassName??``)}});Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.javascript=Prism.languages.extend(`clike`,{"class-name":[Prism.languages.clike[`class-name`],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(`(^|[^\\w$])(?:NaN|Infinity|0[bB][01]+(?:_[01]+)*n?|0[oO][0-7]+(?:_[0-7]+)*n?|0[xX][\\dA-Fa-f]+(?:_[\\dA-Fa-f]+)*n?|\\d+(?:_\\d+)*n|(?:\\d+(?:_\\d+)*(?:\\.(?:\\d+(?:_\\d+)*)?)?|\\.\\d+(?:_\\d+)*)(?:[Ee][+-]?\\d+(?:_\\d+)*)?)(?![\\w$])`),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript[`class-name`][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore(`javascript`,`keyword`,{regex:{pattern:RegExp(`((?:^|[^$\\w\\xA0-\\uFFFF."'\\])\\s]|\\b(?:return|yield))\\s*)\\/(?:(?:\\[(?:[^\\]\\\\\\r\\n]|\\\\.)*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}|(?:\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.|\\[(?:[^[\\]\\\\\\r\\n]|\\\\.)*\\])*\\])*\\]|\\\\.|[^/\\\\\\[\\r\\n])+\\/[dgimyus]{0,7}v[dgimyus]{0,7})(?=(?:\\s|\\/\\*(?:[^*]|\\*(?!\\/))*\\*\\/)*(?:$|[\\r\\n,.;:})\\]]|\\/\\/))`),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:`language-regex`,inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:`function`},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore(`javascript`,`string`,{hashbang:{pattern:/^#!.*/,greedy:!0,alias:`comment`},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:`string`},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:`punctuation`},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:`property`}}),Prism.languages.insertBefore(`javascript`,`operator`,{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:`property`}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined(`script`,`javascript`),Prism.languages.markup.tag.addAttribute(`on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)`,`javascript`)),Prism.languages.js=Prism.languages.javascript,Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:`attr-equals`},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:`named-entity`},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside[`attr-value`].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside[`internal-subset`].inside=Prism.languages.markup,Prism.hooks.add(`wrap`,function(e){e.type===`entity`&&(e.attributes.title=e.content.replace(/&/,`&`))}),Object.defineProperty(Prism.languages.markup.tag,`addInlined`,{value:function(e,t){var n={};n[`language-`+t]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[t]},n.cdata=/^<!\[CDATA\[|\]\]>$/i;var r={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:n}};r[`language-`+t]={pattern:/[\s\S]+/,inside:Prism.languages[t]};var i={};i[e]={pattern:RegExp(`(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[\\s\\S])*?(?=<\\/__>)`.replace(/__/g,function(){return e}),`i`),lookbehind:!0,greedy:!0,inside:r},Prism.languages.insertBefore(`markup`,`cdata`,i)}}),Object.defineProperty(Prism.languages.markup.tag,`addAttribute`,{value:function(e,t){Prism.languages.markup.tag.inside[`special-attr`].push({pattern:RegExp(`(^|["'\\s])(?:`+e+`)\\s*=\\s*(?:"[^"]*"|'[^']*'|[^\\s'">=]+(?=[\\s>]))`,`i`),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,`language-`+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:`attr-equals`},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend(`markup`,{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml,(function(e){var t=`(?:\\\\.|[^\\\\\\n\\r]|(?:\\n|\\r\\n?)(?![\\r\\n]))`;function n(e){return e=e.replace(/<inner>/g,function(){return t}),RegExp(`((?:^|[^\\\\])(?:\\\\{2})*)(?:`+e+`)`)}var r="(?:\\\\.|``(?:[^`\\r\\n]|`(?!`))+``|`[^`\\r\\n]+`|[^\\\\|\\r\\n`])+",i=`\\|?__(?:\\|__)+\\|?(?:(?:\\n|\\r\\n?)|(?![\\s\\S]))`.replace(/__/g,function(){return r}),a=`\\|?[ \\t]*:?-{3,}:?[ \\t]*(?:\\|[ \\t]*:?-{3,}:?[ \\t]*)+\\|?(?:\\n|\\r\\n?)`;e.languages.markdown=e.languages.extend(`markup`,{}),e.languages.insertBefore(`markdown`,`prolog`,{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:[`yaml`,`language-yaml`],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:`punctuation`},table:{pattern:RegExp(`^`+i+a+`(?:`+i+`)*`,`m`),inside:{"table-data-rows":{pattern:RegExp(`^(`+i+a+`)(?:`+i+`)*$`),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp(`^(`+i+`)`+a+`$`),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp(`^`+i+`$`),inside:{"table-header":{pattern:RegExp(r),alias:`important`,inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:`keyword`},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:`important`,inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:`important`,inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:`punctuation`},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:`punctuation`},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:`url`},bold:{pattern:n(`\\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\\b|\\*\\*(?:(?!\\*)<inner>|\\*(?:(?!\\*)<inner>)+\\*)+\\*\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(`\\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\\b|\\*(?:(?!\\*)<inner>|\\*\\*(?:(?!\\*)<inner>)+\\*\\*)+\\*`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(`(~~?)(?:(?!~)<inner>)+\\2`),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:[`code`,`keyword`]},url:{pattern:n(`!?\\[(?:(?!\\])<inner>)+\\](?:\\([^\\s)]+(?:[\\t ]+"(?:\\\\.|[^"\\\\])*")?\\)|[ \\t]?\\[(?:(?!\\])<inner>)+\\])`),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),[`url`,`bold`,`italic`,`strike`].forEach(function(t){[`url`,`bold`,`italic`,`strike`,`code-snippet`].forEach(function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])})}),e.hooks.add(`after-tokenize`,function(e){if(e.language!==`markdown`&&e.language!==`md`)return;function t(e){if(!(!e||typeof e==`string`))for(var n=0,r=e.length;n<r;n++){var i=e[n];if(i.type!==`code`){t(i.content);continue}var a=i.content[1],o=i.content[3];if(a&&o&&a.type===`code-language`&&o.type===`code-block`&&typeof a.content==`string`){var s=a.content.replace(/\b#/g,`sharp`).replace(/\b\+\+/g,`pp`);s=(/[a-z][\w-]*/i.exec(s)||[``])[0].toLowerCase();var c=`language-`+s;o.alias?typeof o.alias==`string`?o.alias=[o.alias,c]:o.alias.push(c):o.alias=[c]}}}t(e.tokens)}),e.hooks.add(`wrap`,function(t){if(t.type===`code-block`){for(var n=``,r=0,i=t.classes.length;r<i;r++){var a=t.classes[r],o=/language-(.+)/.exec(a);if(o){n=o[1];break}}var s=e.languages[n];if(s)t.content=e.highlight(l(t.content),s,n);else if(n&&n!==`none`&&e.plugins.autoloader){var c=`md-`+new Date().valueOf()+`-`+Math.floor(Math.random()*0x2386f26fc10000);t.attributes.id=c,e.plugins.autoloader.loadLanguages(n,function(){var t=document.getElementById(c);t&&(t.innerHTML=e.highlight(t.textContent,e.languages[n],n))})}}});var o=RegExp(e.languages.markup.tag.pattern.source,`gi`),s={amp:`&`,lt:`<`,gt:`>`,quot:`"`},c=String.fromCodePoint||String.fromCharCode;function l(e){var t=e.replace(o,``);return t=t.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(e,t){return t=t.toLowerCase(),t[0]===`#`?c(t[1]===`x`?parseInt(t.slice(2),16):Number(t.slice(1))):s[t]||e}),t}e.languages.md=e.languages.markdown})(Prism),Prism.languages.c=Prism.languages.extend(`clike`,{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),Prism.languages.insertBefore(`c`,`string`,{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),Prism.languages.insertBefore(`c`,`string`,{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:`property`,inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],char:Prism.languages.c.char,comment:Prism.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:`function`}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:`keyword`},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}}}),Prism.languages.insertBefore(`c`,`function`,{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete Prism.languages.c.boolean,(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp(`@[\\w-](?:[^;{\\s"']|\\s+(?!\\s)|`+t.source+`)*?(?:;|(?=\\s*\\{))`),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:`selector`},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp(`\\burl\\((?:`+t.source+`|(?:[^\\\\\\r\\n()"']|\\\\[\\s\\S])*)\\)`,`i`),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp(`^`+t.source+`$`),alias:`url`}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+`)*(?=\\s*\\{)`),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined(`style`,`css`),n.tag.addAttribute(`style`,`css`))})(Prism),Prism.languages.objectivec=Prism.languages.extend(`c`,{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete Prism.languages.objectivec[`class-name`],Prism.languages.objc=Prism.languages.objectivec,Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},(function(e){var t=e.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/};t.string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:t},boolean:t.boolean,variable:t.variable}})(Prism),Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern://,alias:`punctuation`},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:`string`},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:[`annotation`,`punctuation`],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python[`string-interpolation`].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python,(function(e){for(var t=`\\/\\*(?:[^*/]|\\*(?!\\/)|\\/(?!\\*)|<self>)*\\*\\/`,n=0;n<2;n++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return`[^\\s\\S]`}),e.languages.rust={comment:[{pattern:RegExp(`(^|[^\\\\])`+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:`attr-name`,inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:`punctuation`},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:`symbol`},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:`punctuation`},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:`function`},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:`class-name`},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:`namespace`},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:`namespace`,inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:`property`},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},e.languages.rust[`closure-params`].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string})(Prism),Prism.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(`(^|[^"#])(?:"(?:\\\\(?:\\((?:[^()]|\\([^()]*\\))*\\)|\\r\\n|[^(])|[^\\\\\\r\\n"])*"|"""(?:\\\\(?:\\((?:[^()]|\\([^()]*\\))*\\)|[^(])|[^\\\\"]|"(?!""))*""")(?!["#])`),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:`punctuation`},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(`(^|[^"#])(#+)(?:"(?:\\\\(?:#+\\((?:[^()]|\\([^()]*\\))*\\)|\\r\\n|[^#])|[^\\\\\\r\\n])*?"|"""(?:\\\\(?:#+\\((?:[^()]|\\([^()]*\\))*\\)|[^#])|[^\\\\])*?""")\\2`),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:`punctuation`},string:/[\s\S]+/}}],directive:{pattern:RegExp(`#(?:(?:elseif|if)\\b(?:[ ]*(?:![ \\t]*)?(?:\\b\\w+\\b(?:[ \\t]*\\((?:[^()]|\\([^()]*\\))*\\))?|\\((?:[^()]|\\([^()]*\\))*\\))(?:[ \\t]*(?:&&|\\|\\|))?)+|(?:else|endif)\\b)`),alias:`property`,inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:`constant`},"other-directive":{pattern:/#\w+\b/,alias:`property`},attribute:{pattern:/@\w+/,alias:`atrule`},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:`function`},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:`important`},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:`constant`},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:`keyword`},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},Prism.languages.swift[`string-literal`].forEach(function(e){e.inside.interpolation.inside=Prism.languages.swift}),(function(e){e.languages.typescript=e.languages.extend(`javascript`,{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript[`literal-property`];var t=e.languages.extend(`typescript`,{});delete t[`class-name`],e.languages.typescript[`class-name`].inside=t,e.languages.insertBefore(`typescript`,`function`,{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:`operator`},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:t}}}}),e.languages.ts=e.languages.typescript})(Prism),(function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=`(?:[a-z]\\w*\\s*\\.\\s*)*(?:[A-Z]\\w*\\s*\\.\\s*)*`,r={pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z](?:[\\d_A-Z]*[a-z]\\w*)?\\b`),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend(`clike`,{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(`(^|[^\\w.])`+n+`[A-Z]\\w*(?=\\s+\\w+\\s*[;,=()]|\\s*(?:\\[[\\s,]*\\]\\s*)?::\\s*new\\b)`),lookbehind:!0,inside:r.inside},{pattern:RegExp(`(\\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\\s+)`+n+`[A-Z]\\w*\\b`),lookbehind:!0,inside:r.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),e.languages.insertBefore(`java`,`string`,{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:`string`},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore(`java`,`class-name`,{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:`punctuation`},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(`(\\bimport\\s+)`+n+`(?:[A-Z]\\w*|\\*)(?=\\s*;)`),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(`(\\bimport\\s+static\\s+)`+n+`(?:\\w+|\\*)(?=\\s*;)`),lookbehind:!0,alias:`static`,inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(`(\\b(?:exports|import(?:\\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\\s+)(?!<keyword>)[a-z]\\w*(?:\\.[a-z]\\w*)*\\.?`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism),(function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=`\\b(?!<keyword>)\\w+(?:\\s*\\.\\s*\\w+)*\\b`.replace(/<keyword>/g,function(){return t.source});e.languages.cpp=e.languages.extend(`c`,{"class-name":[{pattern:RegExp(`(\\b(?:class|concept|enum|struct|typename)\\s+)(?!<keyword>)\\w+`.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore(`cpp`,`string`,{module:{pattern:RegExp(`(\\b(?:import|module)\\s+)(?:"(?:\\\\(?:\\r\\n|[\\s\\S])|[^"\\\\\\r\\n])*"|<[^<>\\r\\n]*>|`+`<mod-name>(?:\\s*:\\s*<mod-name>)?|:\\s*<mod-name>`.replace(/<mod-name>/g,function(){return n})+`)`),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:`string`,greedy:!0}}),e.languages.insertBefore(`cpp`,`keyword`,{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:`class-name`,inside:e.languages.cpp}}}}),e.languages.insertBefore(`cpp`,`operator`,{"double-colon":{pattern:/::/,alias:`punctuation`}}),e.languages.insertBefore(`cpp`,`class-name`,{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend(`cpp`,{})}}),e.languages.insertBefore(`inside`,`double-colon`,{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp[`base-clause`])})(Prism);function sz(e,t){for(let n of e.childNodes){if(Cg(n)&&n.tagName===t)return!0;sz(n,t)}return!1}var cz=`data-language`,lz=`data-highlight-language`,uz=`data-theme`,dz=class e extends Hm{static getType(){return`code`}static clone(t){return new e(t.__language,t.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){let t=document.createElement(`code`);K_(t,e.theme.code),t.setAttribute(`spellcheck`,`false`);let n=this.getLanguage();n&&(t.setAttribute(cz,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(lz,n));let r=this.getTheme();r&&t.setAttribute(uz,r);let i=this.getStyle();return i&&t.setAttribute(`style`,i),t}updateDOM(e,t,n){let r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(cz,r):i&&t.removeAttribute(cz);let a=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?a&&r?r!==i&&t.setAttribute(lz,r):t.removeAttribute(lz):a&&r&&t.setAttribute(lz,r);let o=this.__theme,s=e.__theme;o?o!==s&&t.setAttribute(uz,o):s&&t.removeAttribute(uz);let c=this.__style,l=e.__style;return c?c!==l&&t.setAttribute(`style`,c):l&&t.removeAttribute(`style`),!1}exportDOM(e){let t=document.createElement(`pre`);K_(t,e._config.theme.code),t.setAttribute(`spellcheck`,`false`);let n=this.getLanguage();n&&(t.setAttribute(cz,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(lz,n));let r=this.getTheme();r&&t.setAttribute(uz,r);let i=this.getStyle();return i&&t.setAttribute(`style`,i),{element:t}}static importDOM(){return{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||sz(e,`BR`))?{conversion:mz,priority:1}:null,div:()=>({conversion:zhe,priority:1}),pre:()=>({conversion:mz,priority:0}),table:e=>_z(e)?{conversion:Bhe,priority:3}:null,td:e=>{let t=e,n=t.closest(`table`);return t.classList.contains(`js-file-line`)||n&&_z(n)?{conversion:hz,priority:3}:null},tr:e=>{let t=e.closest(`table`);return t&&_z(t)?{conversion:hz,priority:3}:null}}}static importJSON(e){return fz().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){let n=this.getChildren(),r=n.length;if(r>=2&&n[r-1].getTextContent()===`
|
|
129
129
|
`&&n[r-2].getTextContent()===`
|
|
130
130
|
`&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){n[r-1].remove(),n[r-2].remove();let e=nh();return this.insertAfter(e,t),e}let{anchor:i,focus:a}=e,o=(i.isBefore(a)?i:a).getNode();if(U(o)){let e=Hhe(o),t=[];for(;;)if(zp(e))t.push(Rp()),e=e.getNextSibling();else{if(!xz(e))break;{let n=0,r=e.getTextContent(),i=e.getTextContentSize();for(;n<i&&r[n]===` `;)n++;if(n!==0&&t.push(bz(` `.repeat(n))),n!==i)break;e=e.getNextSibling()}}let n=o.splitText(i.offset)[0],r=i.offset===0?0:1,a=n.getIndexWithinParent()+r,s=o.getParentOrThrow(),c=[_p(),...t];s.splice(a,0,c);let l=t[t.length-1];l?l.select():i.offset===0?n.selectPrevious():n.getNextSibling().selectNext(0,0)}if(pz(o)){let{offset:t}=e.anchor;o.splice(t,0,[_p()]),o.select(t+1,t+1)}return null}canIndent(){return!1}collapseAtStart(){let e=nh();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}setLanguage(e){let t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){let t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){let t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}};function fz(e,t){return Rg(dz).setLanguage(e).setTheme(t)}function pz(e){return e instanceof dz}function mz(e){return{node:fz(e.getAttribute(cz))}}function zhe(e){let t=e,n=gz(t);return n||function(e){let t=e.parentElement;for(;t!==null;){if(gz(t))return!0;t=t.parentElement}return!1}(t)?{node:n?fz():null}:{node:null}}function Bhe(){return{node:fz()}}function hz(){return{node:null}}function gz(e){return e.style.fontFamily.match(`monospace`)!==null}function _z(e){return e.classList.contains(`js-file-line-container`)}var vz=class e extends Ep{constructor(e=``,t,n){super(e,n),this.__highlightType=t}static getType(){return`code-highlight`}static clone(t){return new e(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){let t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){let t=super.createDOM(e);return K_(t,yz(e.theme,this.__highlightType)),t}updateDOM(e,t,n){let r=super.updateDOM(e,t,n),i=yz(n.theme,e.__highlightType),a=yz(n.theme,this.__highlightType);return i!==a&&(i&&q_(t,i),a&&K_(t,a)),r}static importJSON(e){return bz().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return fz()}};function yz(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function bz(e=``,t){return hg(new vz(e,t))}function xz(e){return e instanceof vz}function Vhe(e,t){let n=e;for(let r=Xg(e,t);r&&(xz(r.origin)||zp(r.origin));r=J_(r))n=r.origin;return n}function Hhe(e){return Vhe(e,`previous`)}(function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":`-`,"deleted-arrow":`<`,"inserted-sign":`+`,"inserted-arrow":`>`,unchanged:` `,diff:`!`};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),n===`diff`&&i.push(`bold`),e.languages.diff[n]={pattern:RegExp(`^(?:[`+r+`].*(?:\r
|
|
@@ -159,7 +159,7 @@ Error generating stack: `+e.message+`
|
|
|
159
159
|
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}j$.displayName=`MiniMap`;var jEe=(0,R.memo)(j$),MEe=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,NEe={[QZ.Line]:`right`,[QZ.Handle]:`bottom-right`};function PEe({nodeId:e,position:t,variant:n=QZ.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=KQ(),y=typeof e==`string`?e:v,b=fQ(),x=(0,R.useRef)(null),S=n===QZ.Handle,C=dQ((0,R.useCallback)(MEe(S&&p),[S,p]),cQ),w=(0,R.useRef)(null),T=t??NEe[n];return(0,R.useEffect)(()=>{if(!(!x.current||!y))return w.current||=_we({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=FZ([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...iZ({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,z.jsx)(`div`,{className:fJ([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,R.memo)(PEe);var M$={x:80,y:80},N$=260,P$=150;function F$(e,t){let n=L$(e),r=Object.entries(n),i=H$(e),a=new Set(r.map(([e])=>e)),o=0;return{nodes:r.map(([n,a],s)=>{let c=i[n]??LEe(a),l=c??REe(s,r.length);return c||(o+=1),{id:n,type:`workflowNode`,position:l,data:{nodeId:n,label:V$(n,a),kind:B$(a),validationCount:WEe(t,n),isInitial:J$(e).includes(n)}}}),edges:Object.entries(R$(e)).flatMap(([e,t])=>{let n=Y$(t.from),r=Y$(t.to);if(!n||!r||!a.has(n)||!a.has(r))return[];let i=typeof t.kind==`string`?t.kind:`data`;return[{id:e,source:n,target:r,type:`smoothstep`,label:i,data:{edgeId:e,kind:i},markerEnd:{type:TX.ArrowClosed,color:`#38bdf8`},style:{stroke:`#38bdf8`,strokeWidth:1.5}}]}),usedAutoLayout:o>0,missingPositionCount:o}}function FEe(e,t){return t.type===`node`?e.nodes.some(e=>e.id===t.id):e.edges.some(e=>e.id===t.id)}function I$(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function L$(e){return z$(e.nodes)}function R$(e){return z$(e.edges)}function z$(e){if(!I$(e))return{};let t={};for(let[n,r]of Object.entries(e))I$(r)&&(t[n]=r);return t}function B$(e){return typeof e.kind==`string`?e.kind:`node`}function V$(e,t){return typeof t.label==`string`&&t.label.trim()?t.label.trim():`${IEe(B$(t))} ${e}`}function IEe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function H$(e){let t=I$(e.ui)?e.ui:void 0,n=t&&I$(t.positions)?t.positions:void 0;if(!n)return{};let r={};for(let[e,t]of Object.entries(n)){let n=U$(t);n&&(r[e]=n)}return r}function LEe(e){let t=I$(e.ui)?e.ui:void 0;return t?U$(t.position):void 0}function U$(e){if(!I$(e))return;let{x:t,y:n}=e;return typeof t==`number`&&Number.isFinite(t)&&typeof n==`number`&&Number.isFinite(n)?{x:t,y:n}:void 0}function REe(e,t){if(t<=0)return M$;let n=Math.max(1,Math.ceil(Math.sqrt(t)));return{x:M$.x+e%n*N$,y:M$.y+Math.floor(e/n)*P$}}function W$(e){return e.length?{x:M$.x+e.length%3*N$,y:M$.y+Math.floor(e.length/3)*P$}:M$}function G$(e,t){let n=L$(e);if(!Object.hasOwn(n,t))return t;let r=2;for(;Object.hasOwn(n,`${t}_${r}`);)r+=1;return`${t}_${r}`}function zEe(e,t,n){let r=R$(e),i=`edge_${t}_to_${n}`.replace(/[^a-zA-Z0-9_-]/g,`-`);if(!Object.hasOwn(r,i))return i;let a=2;for(;Object.hasOwn(r,`${i}_${a}`);)a+=1;return`${i}_${a}`}function K$(e,t,n,r){let i=L$(e),a={...e,nodes:{...i,[t]:r},edges:I$(e.edges)?e.edges:{}};return J$(a).length||(a.initial=t),q$(a,{...H$(e),[t]:n})}function BEe(e,t,n,r){return{...e,edges:{...R$(e),[t]:{id:t,from:{nodeId:n},to:{nodeId:r},kind:`data`}}}}function VEe(e,t){let n=L$(e);delete n[t];let r=Object.fromEntries(Object.entries(R$(e)).filter(([,e])=>Y$(e.from)!==t&&Y$(e.to)!==t)),i=H$(e);return delete i[t],UEe(q$({...e,nodes:n,edges:r},i),t,Object.keys(n))}function HEe(e,t){let n=R$(e);return delete n[t],{...e,edges:n}}function UEe(e,t,n){let r={...e};if(typeof r.initial==`string`)return r.initial===t&&(n[0]?r.initial=n[0]:delete r.initial),r;if(Array.isArray(r.initial)){let e=r.initial.filter(e=>e!==t);e.length?r.initial=e:n[0]?r.initial=n[0]:delete r.initial}return r}function q$(e,t){let n=I$(e.ui)?e.ui:{};return{...e,ui:{...n,layout:`manual`,positions:t}}}function J$(e){return typeof e.initial==`string`?[e.initial]:Array.isArray(e.initial)?e.initial.filter(e=>typeof e==`string`):[]}function WEe(e,t){return e.filter(e=>e.nodeId===t||e.path?.startsWith(`$.nodes.${t}`)).length}function Y$(e){return I$(e)&&typeof e.nodeId==`string`&&e.nodeId.trim()?e.nodeId.trim():void 0}var X$={type:`object`,properties:{},required:[],additionalProperties:!1},Z$=[`global`,`local`,`edge`],GEe=[`draft`,`notes`,`result`],KEe=[`payload`,`previous`,`resume`],qEe=[`global`,`local`];function JEe(e,t){return Q$(e.state,t.stateAccess)}function Q$(e,t){let n=$$(e);return JSON.stringify({reads:n.reads,writes:n.writes})!==JSON.stringify({reads:t.reads,writes:t.writes})}function $$(e){let t=I$(e)?e:{},n=e1(t.reads),r=e1(t.writes),i=i1(n[0]),a=i1(r[0]);return{reads:n,writes:r,readScope:i?.scope??`global`,readPath:i?.path??``,writeScope:a?.scope===`edge`?`global`:a?.scope??`global`,writePath:a?.scope===`edge`?``:a?.path??``}}function e1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!i1(e)):[]}function t1(e,t){let n=I$(e.state)?{...e.state}:{};t.reads.length?n.reads=[...t.reads]:delete n.reads,t.writes.length?n.writes=[...t.writes]:delete n.writes,Object.keys(n).length?e.state=n:delete e.state}function n1(e,t,n){let r=n.flatMap(e=>{let n=i1(e);return n?.scope===t?[n.path]:[]}),i=t===`global`?r1(e):t===`local`?GEe:KEe;return[...new Set([...i,...r])].sort()}function r1(e){let t=I$(e.state)?e.state:void 0,n=t&&I$(t.global)?t.global:void 0;return n?Object.keys(n).sort():[]}function YEe(e){return e.trim().replace(/\s+/g,``).replace(/^\.+/,``).replace(/\.+$/,``).replace(/\.{2,}/g,`.`)}function i1(e){if(!e)return;let t=e.indexOf(`.`);if(t<=0||t===e.length-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(Z$.includes(n)&&!r.split(`.`).some(e=>!e))return{scope:n,path:r}}function a1(e){let t=typeof e.workflowId==`string`?e.workflowId:``,n=typeof e.workflowVersion==`string`?e.workflowVersion:``;return{label:typeof e.label==`string`?e.label:``,description:typeof e.description==`string`?e.description:``,inputKind:l1(e.input),inputDescription:u1(e.input),inputSchemaText:d1(e.input),outputKind:l1(e.output),outputDescription:u1(e.output),outputSchemaText:d1(e.output),stateAccess:$$(e.state),profileId:QEe(e.profile),promptTemplate:typeof e.promptTemplate==`string`?e.promptTemplate:``,handlerId:typeof e.handler==`string`?e.handler:``,adapterRef:$Ee(e.handler),adapterParamsText:b1(eDe(e.handler)),workflowVersionKey:t&&n?sDe(t,n):``,humanPrompt:typeof e.prompt==`string`?e.prompt:``,humanSchemaText:e.schema===void 0?``:f1(e.schema),humanActionRefs:tDe(e.actions),humanTimeoutKind:iDe(e.timeout),humanTimeoutValue:aDe(e.timeout)}}function XEe(e,t,n){let r=L$(e),i=r[t];if(!i)return e;let a=B$(i),o={...i};if(S1(o,`label`,n.label),S1(o,`description`,n.description),h1(o,`input`,n.inputKind,n.inputDescription,i.input,n.inputSchemaText),h1(o,`output`,n.outputKind,n.outputDescription,i.output,n.outputSchemaText),t1(o,n.stateAccess),a===`agent`&&(o.runtime=`pibo`,n.profileId.trim()&&(o.profile={kind:`fixed`,id:n.profileId.trim()}),S1(o,`promptTemplate`,n.promptTemplate),n.promptTemplate.trim()&&delete o.promptBuilder),a===`code`&&(o.language=`typescript`,n.handlerId.trim()&&(o.handler=n.handlerId.trim())),a===`adapter`&&(o.mode=`deterministic`,n.adapterRef.trim())){let e=_1(n.adapterRef.trim());x1(e,n.adapterParamsText),o.handler=e}if(a===`workflow`){let e=cDe(n.workflowVersionKey);e&&(o.workflowId=e.workflowId,o.workflowVersion=e.workflowVersion)}return a===`human`&&(S1(o,`prompt`,n.humanPrompt),n.humanSchemaText.trim()?o.schema=p1(n.humanSchemaText):delete o.schema,rDe(o,n.humanActionRefs),oDe(o,n.humanTimeoutKind,n.humanTimeoutValue)),{...e,nodes:{...r,[t]:o}}}function o1(e,t){let n=I$(e.from)?e.from:{},r=I$(e.to)?e.to:{},i=I$(e.guard)?e.guard:void 0,a=I$(e.adapter)?e.adapter:void 0,o=a&&I$(a.transform)?a.transform:void 0,s=typeof e.kind==`string`&&[`data`,`control`,`error`,`resume`].includes(e.kind)?e.kind:`data`;return{sourceNodeId:typeof n.nodeId==`string`?n.nodeId:t[0]??``,sourcePortId:typeof n.portId==`string`?n.portId:``,targetNodeId:typeof r.nodeId==`string`?r.nodeId:t.find(e=>e!==(n.nodeId??t[0]))??``,targetPortId:typeof r.portId==`string`?r.portId:``,kind:s,guardHandler:i&&typeof i.handler==`string`?i.handler:``,guardPriority:i&&typeof i.priority==`number`?String(i.priority):``,guardParamsText:b1(i?.params),adapterRef:o&&typeof o.id==`string`?o.id:``,adapterParamsText:b1(o?.params),stateAccess:$$(e.state)}}function ZEe(e,t,n){let r=R$(e),i=r[t];if(!i)return e;let a={...i,id:t,from:g1(n.sourceNodeId,n.sourcePortId),to:g1(n.targetNodeId,n.targetPortId),kind:n.kind},o=n.guardHandler.trim();if(o){let e=Number.parseInt(n.guardPriority,10),t={handler:o,...Number.isInteger(e)&&e>=0?{priority:e}:{}};x1(t,n.guardParamsText),a.guard=t}else delete a.guard;t1(a,n.stateAccess);let s=n.adapterRef.trim();if(s){let e=I$(i.adapter)?i.adapter:{},t=_1(s);x1(t,n.adapterParamsText),a.adapter={...e,kind:`edgeAdapter`,output:I$(e.output)?e.output:m1(`text`,``,void 0),transform:t}}else delete a.adapter;return{...e,edges:{...r,[t]:a}}}function s1(e){return JSON.parse(JSON.stringify(e))}function c1(e,t){return I$(e)?e.kind===`json`?`json`:`text`:t}function l1(e){return I$(e)?c1(e,`text`):`none`}function u1(e){return I$(e)&&typeof e.description==`string`?e.description:``}function d1(e){return f1(I$(e)&&e.schema!==void 0?e.schema:X$)}function f1(e){try{return JSON.stringify(e??X$,null,2)??JSON.stringify(X$,null,2)}catch{return JSON.stringify(X$,null,2)}}function p1(e){let t=e.trim();if(!t)return s1(X$);try{return JSON.parse(t)}catch{return e}}function m1(e,t,n,r){let i={kind:e};return S1(i,`description`,t),e===`json`&&(i.schema=p1(r??d1(n))),i}function h1(e,t,n,r,i,a){if(n===`none`){delete e[t];return}e[t]=m1(n,r,i,a)}function g1(e,t){let n={nodeId:e};return S1(n,`portId`,t),n}function QEe(e){return I$(e)&&e.kind===`fixed`&&typeof e.id==`string`?e.id:``}function $Ee(e){return I$(e)&&e.kind===`adapter`&&e.language===`typescript`&&typeof e.id==`string`?e.id:``}function eDe(e){return I$(e)&&e.kind===`adapter`&&e.language===`typescript`?e.params:void 0}function _1(e){return{kind:`adapter`,language:`typescript`,id:e}}function tDe(e){return Array.isArray(e)?e.flatMap(e=>!I$(e)||typeof e.id!=`string`||!e.id.trim()?[]:[v1(e.id,typeof e.kind==`string`?e.kind:void 0)]):[]}function v1(e,t){return t?{id:e,kind:t}:{id:e}}function y1(e){return e.kind?{id:e.id,kind:e.kind}:{id:e.id}}function nDe(e,t,n){return n?e.some(e=>e.id===t.id)?e:[...e,v1(t.id,t.kind)]:e.filter(e=>e.id!==t.id)}function rDe(e,t){if(!t.length){delete e.actions;return}e.actions=t.map(y1)}function iDe(e){return!I$(e)||typeof e.kind!=`string`?`none`:[`milliseconds`,`seconds`,`minutes`,`iso8601`].includes(e.kind)?e.kind:`none`}function aDe(e){return I$(e)&&(typeof e.value==`number`||typeof e.value==`string`)?String(e.value):``}function oDe(e,t,n){let r=n.trim();if(t===`none`||!r){delete e.timeout;return}if(t===`iso8601`){e.timeout={kind:t,value:r};return}let i=Number(r);Number.isFinite(i)&&i>0?e.timeout={kind:t,value:i}:delete e.timeout}function b1(e){if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return``}}function x1(e,t){let n=t.trim();if(!n){delete e.params;return}try{e.params=JSON.parse(n)}catch{e.params=n}}function S1(e,t,n){let r=n.trim();r?e[t]=r:delete e[t]}function sDe(e,t){return`${e}@${t}`}function cDe(e){let t=e.indexOf(`@`);if(!(t<=0||t===e.length-1))return{workflowId:e.slice(0,t),workflowVersion:e.slice(t+1)}}var C1=`Use the workflow input to produce a concise answer.
|
|
160
160
|
|
|
161
161
|
{{input}}`;function lDe(e,t,n,r){return K$(e,t,n,pDe(t,r))}function uDe(e,t,n,r){return K$(e,t,n,mDe(t,r))}function dDe(e,t,n,r){return K$(e,t,n,w1(t,r))}function fDe(e,t,n,r){return K$(e,t,n,hDe(t,r))}function pDe(e,t){return{kind:`agent`,runtime:`pibo`,label:`Agent ${e}`,profile:{kind:`fixed`,id:t||`base`},promptTemplate:C1,metadata:{sessionOverrides:{prompt:!0}}}}function mDe(e,t){return{kind:`workflow`,label:`Workflow ${e}`,workflowId:t.id,workflowVersion:t.version}}function w1(e,t,n,r){return{kind:`adapter`,label:`Adapter ${e}`,mode:`deterministic`,handler:_1(t),input:s1(n??m1(`text`,``,void 0)),output:s1(r??m1(`text`,``,void 0))}}function hDe(e,t){return{kind:`human`,label:`Human ${e}`,prompt:`Review the workflow context and choose an available action.`,input:m1(`text`,`Context for human review.`,void 0),output:m1(`json`,`Human action result.`,void 0,f1(X$)),schema:s1(X$),actions:[y1(t)],timeout:{kind:`minutes`,value:60}}}var gDe=`v2-starter-draft`;function T1(e,t){return`${e}@${t}`}function E1(e){let t=e.lastIndexOf(`@`);if(!(t<=0||t===e.length-1))return{workflowId:e.slice(0,t),workflowVersion:e.slice(t+1)}}function D1(e,t){return`/apps/chat/workflows/view/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function _De(e){return`/apps/chat/workflows/drafts/${encodeURIComponent(e)}`}function O1(e){typeof window>`u`||window.location.assign(e)}function k1(e){return e.source===`custom`?`${e.displayName} (custom)`:`${e.displayName} (global)`}function A1(e){return`${e.displayName} (${e.id})`}function j1(e){return`${e.displayName} (${e.id})`}function vDe(e){return`${e.displayName}${e.kind?` · ${e.kind}`:``} (${e.id})`}function M1(e){return T1(e.id,e.version)}function N1(e){return`${e.title} (${M1(e)})`}function P1({diagnostics:e,emptyLabel:t}){return e.length?(0,z.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Inspector diagnostics`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-2 text-[11px] leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:12}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),e.path?(0,z.jsx)(`div`,{className:`mt-1 font-mono text-amber-200/80`,children:e.path}):null,e.hint?(0,z.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint}):null]},`${e.code}:${e.path??e.nodeId??e.edgeId??e.registryRef??e.message}`))}):(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2 text-[11px] text-slate-500`,children:t})}function F1({label:e}){return(0,z.jsx)(`span`,{className:`rounded-full border border-slate-700 bg-[#101d22] px-2 py-0.5 text-slate-400`,children:e})}function I1({diagnostics:e}){return e.length?(0,z.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Inspector picker diagnostics`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-2 text-[11px] leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:12}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-amber-200/80`,children:e.path}),(0,z.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function L1({option:e,badge:t}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold text-slate-200`,children:e.displayName}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.id})]}),(0,z.jsx)(F1,{label:t})]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,e.paramsSchema?(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(R1,{label:`paramsSchema`,schema:e.paramsSchema})}):null]})}function R1({label:e,schema:t}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,z.jsx)(`pre`,{className:`mt-1 max-h-24 overflow-auto whitespace-pre-wrap font-mono text-[11px] leading-5 text-slate-300`,children:yDe(t)})]})}function yDe(e){return e?JSON.stringify(e,null,2):`null`}function bDe({workflowId:e,workflowVersion:t}){let[n,r]=(0,R.useState)(),[i,a]=(0,R.useState)(`loading`),[o,s]=(0,R.useState)();(0,R.useEffect)(()=>{let n=!1;return a(`loading`),s(void 0),uJ({selectedWorkflowId:e,selectedWorkflowVersion:t}).then(e=>{n||(r(e),a(`loaded`))}).catch(e=>{n||(s(e instanceof Error?e.message:`Failed to load workflow viewer`),a(`error`))}),()=>{n=!0}},[e,t]);let c=(0,R.useMemo)(()=>n?.options.find(e=>e.id===n.selectedWorkflowId&&e.version===n.selectedWorkflowVersion),[n]);return i===`loading`?(0,z.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-sm text-slate-300`,"aria-live":`polite`,children:[(0,z.jsx)(Cs,{size:16,className:`animate-spin text-[#11a4d4]`}),`Loading workflow viewer `,e,`@`,t,`…`]}):i===`error`?(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-4 text-sm leading-6 text-red-200`,role:`alert`,children:[(0,z.jsx)(`div`,{className:`font-bold`,children:`Could not load workflow viewer`}),(0,z.jsx)(`div`,{className:`mt-1 text-xs`,children:o??`Failed to load workflow metadata.`})]}):(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(rs,{size:13}),`Workflow version viewer`]}),(0,z.jsx)(`h3`,{className:`mt-1 text-lg font-bold text-slate-100`,children:c?.title??`${e}@${t}`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:`This separate viewer is the nested workflow navigation target. Parent graphs do not inline-expand nested workflow internals in V2.`})]}),(0,z.jsx)(`a`,{className:`shrink-0 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,href:`/apps/chat/workflows`,children:`Back to Workflows`})]}),c?(0,z.jsx)(z1,{option:c}):null,(0,z.jsx)(B1,{diagnostics:n?.diagnostics??[],ariaLabel:`Workflow viewer diagnostics`}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Viewer mode shows registry metadata and navigation context only. To change a child workflow, open its own UI draft or duplicate/edit a published workflow from the Workflow Library.`})]})}function z1({option:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`font-semibold text-slate-200`,children:[`Selected workflow: `,e.title]}),(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:[e.id,`@`,e.version]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${e.source} source`}),(0,z.jsx)(F1,{label:e.status}),e.tags.map(e=>(0,z.jsx)(F1,{label:e},e))]})]})}function xDe({option:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold text-slate-200`,children:e.title}),(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:[e.id,`@`,e.version]})]}),(0,z.jsx)(F1,{label:`published workflow`})]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${e.source} source`}),e.tags.map(e=>(0,z.jsx)(F1,{label:e},e))]})]})}function B1({diagnostics:e,ariaLabel:t}){return e.length?(0,z.jsx)(`div`,{className:`grid gap-2`,"aria-label":t,children:e.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:13}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-amber-200/80`,children:e.path}),(0,z.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null}function SDe(){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(CDe,{}),(0,z.jsx)(wDe,{}),(0,z.jsx)(TDe,{}),(0,z.jsx)(EDe,{})]})}function CDe(){let[e,t]=(0,R.useState)(DDe),[n,r]=(0,R.useState)(C1),[i,a]=(0,R.useState)(),[o,s]=(0,R.useState)(`loading`),[c,l]=(0,R.useState)();(0,R.useEffect)(()=>{let t=!1;return s(`loading`),l(void 0),aJ(e||void 0).then(e=>{t||(a(e),s(`loaded`))}).catch(e=>{t||(l(e instanceof Error?e.message:`Failed to load workflow profile picker`),s(`error`))}),()=>{t=!0}},[e]);let u=(0,R.useMemo)(()=>i?.options.find(e=>e.id===i.selectedProfileId),[i]),d=i?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(Po,{size:13}),`Agent node editor`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`Select a non-archived Agent Designer profile and edit the direct prompt template stored on the Pibo Workflow IR node.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void jDe(e,a,s,l),disabled:o===`loading`,children:[o===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),(0,z.jsxs)(`label`,{className:`grid gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Agent Designer profile`}),(0,z.jsxs)(`select`,{"aria-label":`Agent Designer profile`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-3 py-2 text-sm text-slate-100 outline-none transition focus:border-[#11a4d4] disabled:opacity-60`,value:i?.selectedProfileId??``,onChange:e=>t(e.target.value),disabled:o===`loading`||o===`error`,children:[(0,z.jsx)(`option`,{value:``,children:`Select a non-archived profile`}),i?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:k1(e)},e.id))]})]}),o===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:c??`Failed to load workflow profile picker.`}):null,u?(0,z.jsx)(FDe,{option:u}):null,d.length?(0,z.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Agent profile diagnostics`,children:d.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:13}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null,(0,z.jsxs)(`label`,{className:`grid gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Prompt template`}),(0,z.jsx)(`textarea`,{"aria-label":`Agent prompt template`,className:`min-h-28 resize-y rounded-sm border border-slate-700 bg-[#151f24] px-3 py-2 font-mono text-xs leading-5 text-slate-100 outline-none transition focus:border-[#11a4d4]`,value:n,onChange:e=>r(e.target.value)}),(0,z.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`This editor is enabled for Agent nodes with a direct `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`promptTemplate`}),`. Nodes backed by registered prompt builders remain registry-controlled.`]})]}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Archived profiles are intentionally omitted from the picker. If a loaded draft already references one, the API returns a structured diagnostic and keeps the selection empty.`})]})}function wDe(){let[e,t]=(0,R.useState)(ODe),[n,r]=(0,R.useState)(),[i,a]=(0,R.useState)(`loading`),[o,s]=(0,R.useState)();(0,R.useEffect)(()=>{let t=!1;return a(`loading`),s(void 0),oJ(e||void 0).then(e=>{t||(r(e),a(`loaded`))}).catch(e=>{t||(s(e instanceof Error?e.message:`Failed to load workflow handler picker`),a(`error`))}),()=>{t=!0}},[e]);let c=(0,R.useMemo)(()=>n?.options.find(e=>e.id===n.selectedHandlerId),[n]),l=n?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(Zo,{size:13}),`Code node editor`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`Select a registered Workflow Registry handler ref. The UI stores only the handler id on the Pibo Workflow IR node and never opens inline TypeScript, JavaScript, shell, or eval code.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void MDe(e,r,a,s),disabled:i===`loading`,children:[i===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),(0,z.jsxs)(`label`,{className:`grid gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered code handler`}),(0,z.jsxs)(`select`,{"aria-label":`Registered code handler`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-3 py-2 text-sm text-slate-100 outline-none transition focus:border-[#11a4d4] disabled:opacity-60`,value:n?.selectedHandlerId??``,onChange:e=>t(e.target.value),disabled:i===`loading`||i===`error`,children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered handler ref`}),n?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:A1(e)},e.id))]})]}),i===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:o??`Failed to load workflow handler picker.`}):null,c?(0,z.jsx)(IDe,{option:c}):null,l.length?(0,z.jsx)(`div`,{className:`grid gap-2`,"aria-label":`Code handler diagnostics`,children:l.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:13}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsx)(`div`,{className:`mt-1 text-amber-200/80`,children:e.hint})]},`${e.code}:${e.registryRef}`))}):null,(0,z.jsxs)(`div`,{className:`grid gap-3`,"aria-label":`Registered handler picker options`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered handler refs`}),n?.options.map(e=>(0,z.jsx)(LDe,{option:e},e.id))]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Missing handler refs return structured `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`WorkflowGraphError.unknownHandlerRef`}),` diagnostics and block publish/run paths once executable validation is invoked.`]})]})}function TDe(){let[e,t]=(0,R.useState)(kDe),[n,r]=(0,R.useState)(),[i,a]=(0,R.useState)(`loading`),[o,s]=(0,R.useState)();(0,R.useEffect)(()=>{let t=!1;return a(`loading`),s(void 0),sJ(e||void 0).then(e=>{t||(r(e),a(`loaded`))}).catch(e=>{t||(s(e instanceof Error?e.message:`Failed to load workflow adapter picker`),a(`error`))}),()=>{t=!0}},[e]);let c=(0,R.useMemo)(()=>n?.options.find(e=>e.id===n.selectedRefId),[n]),l=n?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(bs,{size:13}),`Adapter node editor`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`Select a registered deterministic adapter ref for visible adapter nodes. The UI stores only the registry ref and never opens inline transformation code.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void NDe(e,r,a,s),disabled:i===`loading`,children:[i===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),(0,z.jsxs)(`label`,{className:`grid gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered adapter`}),(0,z.jsxs)(`select`,{"aria-label":`Registered adapter`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-3 py-2 text-sm text-slate-100 outline-none transition focus:border-[#11a4d4] disabled:opacity-60`,value:n?.selectedRefId??``,onChange:e=>t(e.target.value),disabled:i===`loading`||i===`error`,children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),n?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),i===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:o??`Failed to load workflow adapter picker.`}):null,c?(0,z.jsx)(L1,{option:c,badge:`registered adapter`}):null,(0,z.jsx)(I1,{diagnostics:l}),(0,z.jsxs)(`div`,{className:`grid gap-3`,"aria-label":`Registered adapter picker options`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered adapter refs`}),n?.options.map(e=>(0,z.jsx)(L1,{option:e,badge:`registered adapter`},e.id))]}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Adapter nodes are visible graph nodes for schema transformation. Incompatible edges can alternatively use the compatible edge adapter dialog to keep the adapter on the edge.`})]})}function EDe(){let[e,t]=(0,R.useState)(ADe),[n,r]=(0,R.useState)(),[i,a]=(0,R.useState)(`loading`),[o,s]=(0,R.useState)();(0,R.useEffect)(()=>{let t=!1;return a(`loading`),s(void 0),lJ({selectedWorkflowId:e.workflowId||void 0,selectedWorkflowVersion:e.workflowVersion||void 0}).then(e=>{t||(r(e),a(`loaded`))}).catch(e=>{t||(s(e instanceof Error?e.message:`Failed to load workflow version picker`),a(`error`))}),()=>{t=!0}},[e.workflowId,e.workflowVersion]);let c=(0,R.useMemo)(()=>n?.options.find(e=>e.id===n.selectedWorkflowId&&e.version===n.selectedWorkflowVersion),[n]),l=c?M1(c):``,u=n?.diagnostics??[];return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(vs,{size:13}),`Workflow node editor`]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`Select a published workflow id/version from registry metadata. The parent graph stores only this reference and opens the child workflow separately.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void PDe(e,r,a,s),disabled:i===`loading`,children:[i===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),(0,z.jsxs)(`label`,{className:`grid gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Nested workflow version`}),(0,z.jsxs)(`select`,{"aria-label":`Nested workflow picker`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-3 py-2 text-sm text-slate-100 outline-none transition focus:border-[#11a4d4] disabled:opacity-60`,value:l,onChange:e=>t(E1(e.target.value)??{workflowId:``,workflowVersion:``}),disabled:i===`loading`||i===`error`,children:[(0,z.jsx)(`option`,{value:``,children:`Select a published workflow version`}),n?.options.map(e=>(0,z.jsx)(`option`,{value:M1(e),children:N1(e)},M1(e)))]})]}),i===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:o??`Failed to load workflow version picker.`}):null,c?(0,z.jsx)(z1,{option:c}):null,(0,z.jsx)(B1,{diagnostics:u,ariaLabel:`Nested workflow diagnostics`}),(0,z.jsxs)(`a`,{className:`inline-flex items-center justify-center gap-2 rounded-sm border px-3 py-2 text-xs font-semibold transition ${c?`border-[#11a4d4]/50 text-[#8bdcf4] hover:border-[#11a4d4] hover:text-slate-100`:`pointer-events-none border-slate-800 text-slate-600`}`,href:c?D1(c.id,c.version):`#`,"aria-disabled":!c,children:[(0,z.jsx)(rs,{size:13}),`Open workflow`]}),(0,z.jsxs)(`div`,{className:`grid gap-3`,"aria-label":`Nested workflow picker options`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Published workflow refs`}),n?.options.map(e=>(0,z.jsx)(xDe,{option:e},M1(e)))]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Nested workflow internals stay collapsed in the parent graph for V2. Use `,(0,z.jsx)(`span`,{className:`font-semibold text-slate-300`,children:`Open workflow`}),` to navigate to the child workflow viewer instead of inline-expanding its graph.`]})]})}function DDe(){return typeof window>`u`?``:new URL(window.location.href).searchParams.get(`profileRef`)??``}function ODe(){return typeof window>`u`?``:new URL(window.location.href).searchParams.get(`handlerRef`)??``}function kDe(){return typeof window>`u`?``:new URL(window.location.href).searchParams.get(`adapterRef`)??``}function ADe(){if(typeof window>`u`)return{workflowId:``,workflowVersion:``};let e=new URL(window.location.href).searchParams,t=e.get(`workflowRef`);return t?E1(t)??{workflowId:t,workflowVersion:``}:{workflowId:e.get(`workflowId`)??``,workflowVersion:e.get(`workflowVersion`)??``}}async function jDe(e,t,n,r){n(`loading`),r(void 0);try{t(await aJ(e||void 0)),n(`loaded`)}catch(e){r(e instanceof Error?e.message:`Failed to load workflow profile picker`),n(`error`)}}async function MDe(e,t,n,r){n(`loading`),r(void 0);try{t(await oJ(e||void 0)),n(`loaded`)}catch(e){r(e instanceof Error?e.message:`Failed to load workflow handler picker`),n(`error`)}}async function NDe(e,t,n,r){n(`loading`),r(void 0);try{t(await sJ(e||void 0)),n(`loaded`)}catch(e){r(e instanceof Error?e.message:`Failed to load workflow adapter picker`),n(`error`)}}async function PDe(e,t,n,r){n(`loading`),r(void 0);try{t(await lJ({selectedWorkflowId:e.workflowId||void 0,selectedWorkflowVersion:e.workflowVersion||void 0})),n(`loaded`)}catch(e){r(e instanceof Error?e.message:`Failed to load workflow version picker`),n(`error`)}}function FDe({option:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`font-semibold text-slate-200`,children:[`Selected profile: `,e.displayName]}),e.description?(0,z.jsx)(`div`,{className:`mt-1 text-slate-500`,children:e.description}):null,(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:e.source===`custom`?`Custom Agent`:`Global profile`}),(0,z.jsx)(F1,{label:`${e.nativeTools.length} native tools`}),(0,z.jsx)(F1,{label:`${e.skills.length} skills`}),(0,z.jsx)(F1,{label:`${e.contextFiles.length} context files`})]})]})}function IDe({option:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`font-semibold text-slate-200`,children:[`Selected handler: `,e.displayName]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.id}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsxs)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(R1,{label:`inputSchema`,schema:e.inputSchema}),(0,z.jsx)(R1,{label:`outputSchema`,schema:e.outputSchema})]})]})}function LDe({option:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`font-semibold text-slate-200`,children:e.displayName}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.id})]}),(0,z.jsx)(F1,{label:`registered handler`})]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsxs)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(R1,{label:`inputSchema`,schema:e.inputSchema}),(0,z.jsx)(R1,{label:`outputSchema`,schema:e.outputSchema})]})]})}function RDe({draft:e,onDraftChange:t,renderInspectors:n}){let r=(0,R.useMemo)(()=>F$(e.definition,e.diagnostics),[e.definition,e.diagnostics]),[i,a]=(0,R.useState)(r.nodes),[o,s]=(0,R.useState)(r.edges),[c,l]=(0,R.useState)(),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``),[m,h]=(0,R.useState)(!1),[g,_]=(0,R.useState)(`idle`),[v,y]=(0,R.useState)(),[b,x]=(0,R.useState)(`base`),[S,C]=(0,R.useState)([]),[w,T]=(0,R.useState)(``),[E,D]=(0,R.useState)([]),[O,k]=(0,R.useState)(``),[A,j]=(0,R.useState)([]),[M,N]=(0,R.useState)(``);(0,R.useEffect)(()=>{let e=!1;return aJ().then(t=>{!e&&t.options[0]?.id&&x(t.options[0].id)}).catch(()=>void 0),()=>{e=!0}},[]),(0,R.useEffect)(()=>{let e=!1;return lJ().then(t=>{e||(C(t.options),T(e=>e||(t.options[0]?M1(t.options[0]):``)))}).catch(()=>void 0),()=>{e=!0}},[]),(0,R.useEffect)(()=>{let e=!1;return sJ().then(t=>{e||(D(t.options),k(e=>e||(t.options[0]?.id??``)))}).catch(()=>void 0),()=>{e=!0}},[]),(0,R.useEffect)(()=>{let e=!1;return cJ().then(t=>{e||(j(t.options),N(e=>e||(t.options[0]?.id??``)))}).catch(()=>void 0),()=>{e=!0}},[]),(0,R.useEffect)(()=>{a(r.nodes),s(r.edges),h(!1),l(e=>e&&FEe(r,e)?e:void 0)},[r]);let P=(0,R.useMemo)(()=>i.map(e=>e.id),[i]);(0,R.useEffect)(()=>{d(e=>e&&P.includes(e)?e:P[0]??``),p(e=>e&&P.includes(e)&&e!==u?e:P.find(e=>e!==(u||P[0]))??``)},[P,u]);let F=(0,R.useCallback)(async(n,r,i={})=>{_(`saving`),y(void 0);try{t((await dJ(e.draftId,{definition:n,editTrigger:i.editTrigger??`graph_edit`})).draft),_(`saved`),y(r),i.clearLayoutDirty&&h(!1)}catch(e){_(`error`),y(e instanceof Error?e.message:`Failed to save graph edit`)}},[e.draftId,t]),ee=(0,R.useCallback)(e=>{a(t=>OQ(e,t)),e.some(e=>e.type===`position`)&&h(!0)},[]),te=(0,R.useCallback)(e=>{s(t=>kQ(e,t))},[]),I=()=>{let t=G$(e.definition,`agent`),n=W$(i),r=lDe(e.definition,t,n,b);l({type:`node`,id:t}),F(r,`Added node ${t}.`)},ne=(0,R.useMemo)(()=>S.find(e=>M1(e)===w),[S,w]),L=()=>{if(!ne)return;let t=G$(e.definition,`workflow`),n=W$(i),r=uDe(e.definition,t,n,ne);l({type:`node`,id:t}),F(r,`Added nested workflow node ${t} for ${ne.id}@${ne.version}.`)},re=()=>{if(!O)return;let t=G$(e.definition,`adapter`),n=W$(i),r=dDe(e.definition,t,n,O);l({type:`node`,id:t}),F(r,`Added adapter node ${t} for ${O}.`)},ie=()=>{if(!M)return;let t=G$(e.definition,`human`),n=W$(i),r=A.find(e=>e.id===M),a=fDe(e.definition,t,n,v1(M,r?.kind));l({type:`node`,id:t}),F(a,`Added human node ${t} with action ${M}.`)},ae=(0,R.useCallback)((t=u,n=f)=>{if(!t||!n||t===n)return;let r=zEe(e.definition,t,n),i=BEe(e.definition,r,t,n);s(e=>vZ({id:r,source:t,target:n,type:`smoothstep`},e)),l({type:`edge`,id:r}),F(i,`Connected ${t} to ${n}.`)},[e.definition,F,u,f]),oe=()=>{if(!c)return;let t=c.type===`node`?VEe(e.definition,c.id):HEe(e.definition,c.id);l(void 0),F(t,`Deleted ${c.type} ${c.id}.`)},se=(e,t)=>{c?.type===`node`&&(a(n=>n.map(n=>n.id===c.id?{...n,position:{x:n.position.x+e,y:n.position.y+t},selected:!0}:n)),h(!0),y(`Moved node ${c.id}; save layout to persist UI positions.`))},ce=()=>{F(q$(e.definition,Object.fromEntries(i.map(e=>[e.id,e.position]))),`Layout saved to workflow.ui.positions without changing runtime semantics.`,{clearLayoutDirty:!0})},le=(0,R.useCallback)(e=>{!e.source||!e.target||ae(e.source,e.target)},[ae]),ue=VDe(e.definition,c),de=g===`saving`,fe=P.length>1;return(0,z.jsxs)(`section`,{className:`grid gap-4 rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-labelledby":`workflow-graph-canvas-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(ks,{size:13}),`Workflow graph canvas`]}),(0,z.jsx)(`h4`,{id:`workflow-graph-canvas-title`,className:`mt-1 text-sm font-bold text-slate-100`,children:`Visual graph editor`}),(0,z.jsxs)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:[`React Flow projects Pibo Workflow IR nodes and edges. Graph edits save IR changes; layout saves only `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`workflow.ui.positions`}),` metadata.`]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${i.length} nodes`}),(0,z.jsx)(F1,{label:`${o.length} edges`}),(0,z.jsx)(F1,{label:r.usedAutoLayout?`auto layout (${r.missingPositionCount} missing)`:`manual positions`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 text-xs xl:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,z.jsx)(`div`,{className:`h-[420px] min-w-0 overflow-hidden rounded-sm border border-slate-800 bg-[#0c171c]`,"aria-label":`Workflow graph canvas`,children:(0,z.jsxs)(oEe,{nodes:i,edges:o,nodeTypes:BDe,onNodesChange:ee,onEdgesChange:te,onConnect:le,onNodeClick:(e,t)=>l({type:`node`,id:t.id}),onEdgeClick:(e,t)=>l({type:`edge`,id:t.id}),onPaneClick:()=>l(void 0),fitView:!0,minZoom:.35,maxZoom:1.6,colorMode:`dark`,defaultEdgeOptions:{type:`smoothstep`,markerEnd:{type:TX.ArrowClosed,color:`#38bdf8`}},children:[(0,z.jsx)(dEe,{color:`#1f3a44`,gap:18}),(0,z.jsx)(jEe,{pannable:!0,zoomable:!0,nodeColor:e=>e.selected?`#38bdf8`:`#1e293b`}),(0,z.jsx)(vEe,{showInteractive:!1})]})}),(0,z.jsxs)(`div`,{className:`grid content-start gap-3`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Graph edit controls`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:I,disabled:de,children:[(0,z.jsx)(Ps,{size:13}),`Add Agent node`]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Nested workflow version`}),(0,z.jsx)(`select`,{"aria-label":`Nested workflow version`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:w,onChange:e=>T(e.target.value),disabled:de||!S.length,children:S.length?S.map(e=>(0,z.jsx)(`option`,{value:M1(e),children:N1(e)},M1(e))):(0,z.jsx)(`option`,{value:``,children:`No published workflow versions`})})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:L,disabled:de||!ne,children:[(0,z.jsx)(vs,{size:13}),`Add Workflow node`]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Adapter ref`}),(0,z.jsx)(`select`,{"aria-label":`Adapter node ref`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:O,onChange:e=>k(e.target.value),disabled:de||!E.length,children:E.length?E.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id)):(0,z.jsx)(`option`,{value:``,children:`No registered adapters`})})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:re,disabled:de||!O,children:[(0,z.jsx)(bs,{size:13}),`Add Adapter node`]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Human action ref`}),(0,z.jsx)(`select`,{"aria-label":`Human node action ref`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:M,onChange:e=>N(e.target.value),disabled:de||!A.length,children:A.length?A.map(e=>(0,z.jsx)(`option`,{value:e.id,children:vDe(e)},e.id)):(0,z.jsx)(`option`,{value:``,children:`No registered human actions`})})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:ie,disabled:de||!M,children:[(0,z.jsx)(ks,{size:13}),`Add Human node`]}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-500`,children:`Workflow nodes store only a workflow id/version reference. Adapter and human nodes store only registered deterministic adapter or human action refs. V2 does not inline-expand nested workflow internals or create inline transform code.`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`From`}),(0,z.jsx)(`select`,{"aria-label":`Connect from node`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:u,onChange:e=>d(e.target.value),disabled:de||!fe,children:P.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`To`}),(0,z.jsx)(`select`,{"aria-label":`Connect to node`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:f,onChange:e=>p(e.target.value),disabled:de||!fe,children:P.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>ae(),disabled:de||!u||!f||u===f,children:[(0,z.jsx)(bs,{size:13}),`Connect nodes`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>se(40,0),disabled:de||c?.type!==`node`,children:[(0,z.jsx)(As,{size:13}),`Nudge selected node`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-red-500/70 hover:text-red-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:oe,disabled:de||!c,children:[(0,z.jsx)(qs,{size:13}),`Delete selected`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-emerald-700/70 px-3 py-2 text-xs font-semibold text-emerald-200 transition hover:border-emerald-400 hover:text-emerald-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:ce,disabled:de||!i.length||!m,children:[de?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save layout`]})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Selected graph element`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Selected graph element`}),(0,z.jsx)(`div`,{className:`mt-2 text-xs leading-5 text-slate-300`,children:ue})]}),n({draft:e,selectedElement:c,nodeIds:P,isSaving:de,onSaveDefinition:F}),v?(0,z.jsx)(`div`,{className:`rounded-sm border p-3 text-xs leading-5 ${g===`error`?`border-red-900/70 bg-red-950/40 text-red-200`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,role:`status`,children:v}):null]})]}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Automatic layout is a canvas projection for workflows without saved positions. Saving layout writes only display metadata and does not change nodes, edges, ports, guards, adapters, runtime routing, or validation semantics.`})]})}function zDe({data:e,selected:t}){return(0,z.jsxs)(`div`,{className:`min-w-44 rounded-sm border bg-[#15242b] px-3 py-2 shadow-lg shadow-black/20 ${t?`border-[#38bdf8]`:`border-slate-700`}`,children:[(0,z.jsx)(qQ,{type:`target`,position:EX.Left,className:`!h-2.5 !w-2.5 !border-[#0f172a] !bg-[#38bdf8]`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`truncate text-xs font-bold text-slate-100`,children:e.label}),(0,z.jsx)(`span`,{className:`rounded-full border border-slate-700 px-2 py-0.5 text-[10px] uppercase tracking-[0.12em] text-slate-400`,children:e.kind})]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[10px] text-slate-500`,children:e.nodeId}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1 text-[10px]`,children:[e.isInitial?(0,z.jsx)(`span`,{className:`rounded-full border border-[#11a4d4]/40 bg-[#11a4d4]/10 px-2 py-0.5 text-[#8bdcf4]`,children:`initial`}):null,e.validationCount?(0,z.jsxs)(`span`,{className:`rounded-full border border-amber-600/60 bg-amber-950/30 px-2 py-0.5 text-amber-200`,children:[e.validationCount,` diagnostics`]}):null]}),(0,z.jsx)(qQ,{type:`source`,position:EX.Right,className:`!h-2.5 !w-2.5 !border-[#0f172a] !bg-[#38bdf8]`})]})}var BDe={workflowNode:zDe};function VDe(e,t){if(!t)return`Select a node or edge in the canvas to inspect or delete it.`;if(t.type===`node`){let n=L$(e)[t.id];return n?`Node ${t.id}: ${B$(n)} — ${V$(t.id,n)}`:`Node ${t.id}`}let n=R$(e)[t.id],r=n?Y$(n.from):void 0,i=n?Y$(n.to):void 0;return n&&r&&i?`Edge ${t.id}: ${r} → ${i}`:`Edge ${t.id}`}function HDe(e,t){let n=Y$(t.from),r=Y$(t.to),i=V1(e,t),a=H1(e,t);return{...n?{sourceNodeId:n}:{},...r?{targetNodeId:r}:{},...i?{sourcePort:i}:{},...a?{targetPort:a}:{},directlyCompatible:!!(i&&a&&KDe(i,a))}}function UDe(e){let t=I$(e.adapter)?e.adapter:void 0;return JDe(t&&I$(t.transform)?t.transform:void 0)}function WDe(e,t,n){let r=R$(e),i=r[t];if(!i)return e;let a=H1(e,i)??W1();return{...e,edges:{...r,[t]:{...i,id:t,adapter:{kind:`edgeAdapter`,transform:qDe(n),output:K1(a)}}}}}function GDe(e,t,n){let r=R$(e),i=r[t];if(!i)return e;let a=Y$(i.from),o=Y$(i.to);if(!a||!o)return e;let s=L$(e),c=G$(e,`adapter`),l=V1(e,i)??W1(),u=H1(e,i)??W1(),d=H$(e),f=YDe(d[a],d[o])??W$(F$(e,[]).nodes),p={...r};delete p[t];let m=G1(p,`${t}_to_${c}`),h=G1({...p,[m]:{}},`${c}_to_${o}`),g={id:m,from:K1(I$(i.from)?i.from:{nodeId:a}),to:{nodeId:c},kind:typeof i.kind==`string`?i.kind:`data`};I$(i.guard)&&(g.guard=K1(i.guard));let _={id:h,from:{nodeId:c},to:K1(I$(i.to)?i.to:{nodeId:o}),kind:typeof i.kind==`string`?i.kind:`data`};return q$({...e,nodes:{...s,[c]:w1(c,n,l,u)},edges:{...p,[m]:g,[h]:_}},{...d,[c]:f})}function KDe(e,t){return e.kind===`text`&&t.kind===`text`?!0:e.kind!==`json`||t.kind!==`json`?!1:JSON.stringify(e.schema??null)===JSON.stringify(t.schema??null)}function V1(e,t){let n=U1(e,t.from);return n&&I$(n.output)?n.output:void 0}function H1(e,t){let n=U1(e,t.to);return n&&I$(n.input)?n.input:void 0}function U1(e,t){let n=Y$(t);return n?L$(e)[n]:void 0}function W1(){return{kind:`text`}}function qDe(e){return{kind:`adapter`,language:`typescript`,id:e}}function JDe(e){return I$(e)&&e.kind===`adapter`&&e.language===`typescript`&&typeof e.id==`string`?e.id:``}function YDe(e,t){return e&&t?{x:(e.x+t.x)/2,y:(e.y+t.y)/2}:void 0}function G1(e,t){let n=t.replace(/[^a-zA-Z0-9_-]/g,`-`);if(!Object.hasOwn(e,n))return n;let r=2;for(;Object.hasOwn(e,`${n}_${r}`);)r+=1;return`${n}_${r}`}function K1(e){return JSON.parse(JSON.stringify(e))}function q1(e){let t=I$(e.metadata)?e.metadata:{};return{title:typeof e.title==`string`?e.title:``,description:typeof e.description==`string`?e.description:``,inputKind:c1(e.input,`text`),inputDescription:u1(e.input),inputSchemaText:d1(e.input),outputKind:c1(e.output,`text`),outputDescription:u1(e.output),outputSchemaText:d1(e.output),globalStateFields:J1(e),metadataTags:Q1(t.tags),metadataUseWhen:Q1(t.useWhen),metadataNotFor:Q1(t.notFor),metadataExamples:Q1(t.examples)}}function XDe(e,t){let n=I$(e.metadata)?{...e.metadata}:{};$1(n,`tags`,t.metadataTags),$1(n,`useWhen`,t.metadataUseWhen),$1(n,`notFor`,t.metadataNotFor),$1(n,`examples`,t.metadataExamples);let r={...e,input:m1(t.inputKind,t.inputDescription,e.input,t.inputSchemaText),output:m1(t.outputKind,t.outputDescription,e.output,t.outputSchemaText)};return $De(r,t.globalStateFields),S1(r,`title`,t.title),S1(r,`description`,t.description),Object.keys(n).length?r.metadata=n:delete r.metadata,r}function ZDe(e){let t=new Set(e.map(e=>e.path.trim()).filter(Boolean)),n=`projectGoal`,r=2;for(;t.has(n);)n=`projectGoal${r}`,r+=1;return{path:n,description:``,schemaText:f1(X$),mergeKind:`none`}}function J1(e){let t=I$(e.state)?e.state:void 0,n=t&&I$(t.global)?t.global:void 0;return n?Object.entries(n).flatMap(([e,t])=>I$(t)?[{path:e,description:typeof t.description==`string`?t.description:``,schemaText:f1(t.schema),mergeKind:QDe(t.merge)}]:[]):[]}function QDe(e){return!I$(e)||typeof e.kind!=`string`?`none`:[`replace`,`append`,`shallowMerge`].includes(e.kind)?e.kind:`none`}function $De(e,t){let n=I$(e.state)?{...e.state}:{},r={};for(let e of t){let t=YEe(e.path);if(!t)continue;let n={schema:p1(e.schemaText)};S1(n,`description`,e.description);let i=eOe(e.mergeKind);i&&(n.merge=i),r[t]=n}Object.keys(r).length?n.global=r:delete n.global,Object.keys(n).length?e.state=n:delete e.state}function eOe(e){return e===`none`?void 0:{kind:e}}function tOe(e,t){return JSON.stringify(J1(e))!==JSON.stringify(t.globalStateFields)}function Y1(e){return typeof e==`string`?e.trim():I$(e)&&typeof e.id==`string`?e.id.trim():``}function X1(e,t,n){let r=L$(e),i=r[t];if(!i)return e;let a={...i,promptBuilder:{kind:`promptBuilder`,language:`typescript`,id:n.id,revisionId:n.revisionId,contentHash:n.contentHash,source:n.source},metadata:Z1(i.metadata,n)};return delete a.promptTemplate,{...e,metadata:Z1(e.metadata,n),nodes:{...r,[t]:a}}}function Z1(e,t){let n=I$(e)?{...e}:{},r=Array.isArray(n.promptAssetRefs)?n.promptAssetRefs.filter(e=>typeof e==`string`&&e.trim().length>0):[];return n.promptAssetRefs=[...new Set([...r,t.id])],n.promptAssetPins=[...Array.isArray(n.promptAssetPins)?n.promptAssetPins.filter(e=>I$(e)&&e.assetId!==t.id):[],{assetId:t.id,revisionId:t.revisionId,contentHash:t.contentHash,source:t.source}],n}function Q1(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`
|
|
162
|
-
`):``}function nOe(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function $1(e,t,n){let r=nOe(n);r.length?e[t]=r:delete e[t]}function rOe({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,R.useState)(Y1(n.promptBuilder)),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(`idle`),[p,m]=(0,R.useState)(`saved`),[h,g]=(0,R.useState)();(0,R.useEffect)(()=>{o(Y1(n.promptBuilder))},[n,t]),(0,R.useEffect)(()=>{let e=!1;return Oye(a||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[a]),(0,R.useEffect)(()=>{let e=!1;return g(void 0),a?(f(`loading`),kye(a).then(t=>{e||(u(t.asset),f(`loaded`))}).catch(t=>{e||(u(void 0),f(`error`),g(t instanceof Error?t.message:`Failed to load prompt asset`))}),()=>{e=!0}):(u(void 0),f(`idle`),()=>{e=!0})},[a]);let _=s?.options.find(e=>e.id===a),v=typeof n.promptTemplate==`string`?n.promptTemplate:C1,y=l?.markdown??v,b=`${e.draftId}:${t}:${(l?.id??a)||`direct-prompt`}:${l?.revisionId??`draft`}`,x=!!Y1(n.promptBuilder),S=a.startsWith(`ui.promptAssets.`),C=`${typeof n.label==`string`&&n.label.trim()?n.label.trim():t} prompt asset`,w=(0,R.useCallback)(async n=>{try{let r=await Aye({assetId:S?a:void 0,sourceRefId:a||void 0,displayName:C,description:`Managed prompt asset for ${t} in draft ${e.draftId}.`,markdown:n});await i(X1(e.definition,t,r.asset),`Saved prompt asset revision ${r.asset.revisionId} and updated ${t}.`,{editTrigger:`prompt_edit`}),o(r.asset.id),u(r.asset),g(`Saved ${r.asset.displayName} as revision ${r.asset.revisionId}; draft now pins ${r.asset.contentHash}.`)}catch(e){throw g(e instanceof Error?e.message:`Failed to save prompt asset revision`),e}},[e.definition,e.draftId,t,i,C,a,S]),T=async()=>{l&&(await i(X1(e.definition,t,l),`Updated ${t} to use prompt asset ${l.id}.`,{editTrigger:`prompt_edit`}),g(`Draft node ${t} now uses ${l.displayName} at ${l.contentHash}.`))};return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Prompt asset Markdown editor`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Prompt asset Markdown editor`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Edit prompt assets with the same Markdown editor pattern as Context Files. Saving creates a managed UI asset revision, updates this draft node to a prompt asset ref, and pins the revision id plus content hash in the Pibo Workflow IR.`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Prompt asset ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a,onChange:e=>o(e.target.value),disabled:r,children:[(0,z.jsx)(`option`,{value:``,children:`Create managed asset from direct prompt template`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),_?(0,z.jsx)(L1,{option:_,badge:_.kind===`ui`?`managed prompt asset`:`registered prompt asset`}):null,d===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-2 text-[11px] leading-5 text-red-200`,role:`alert`,children:h??`Failed to load prompt asset.`}):null,(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:(0,z.jsx)(Gz,{documentKey:b,initialMarkdown:y,onPersist:w,onSaveStateChange:m})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:x?`promptBuilder ref`:`direct promptTemplate source`}),(0,z.jsx)(F1,{label:`Markdown save: ${p}`}),l?(0,z.jsx)(F1,{label:`${l.source} · ${l.revisionId}`}):null]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void T(),disabled:r||!l,children:[(0,z.jsx)(Bs,{size:13}),`Use selected asset on draft`]})}),h&&d!==`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-2 text-[11px] leading-5 text-emerald-200`,role:`status`,children:h}):null,(0,z.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Code/plugin prompt assets are not mutated. Editing a registered asset copies the Markdown into a managed UI prompt asset; later saves append revisions and only affect this draft or future workflow versions that reference the new revision.`})]})}function iOe({draft:e,selectedElement:t,nodeIds:n,isSaving:r,onSaveDefinition:i}){let a=t?.type===`node`?L$(e.definition)[t.id]:void 0,o=t?.type===`edge`?R$(e.definition)[t.id]:void 0;return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow inspectors`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Workflow inspectors`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Inspector saves update the same Pibo Workflow IR draft as the graph canvas; XState remains projection-only.`})]}),(0,z.jsx)(sOe,{draft:e,isSaving:r,onSaveDefinition:i}),t?.type===`node`&&a?(0,z.jsx)(cOe,{draft:e,nodeId:t.id,node:a,isSaving:r,onSaveDefinition:i}):t?.type===`edge`&&o?(0,z.jsx)(lOe,{draft:e,edgeId:t.id,edge:o,nodeIds:n,isSaving:r,onSaveDefinition:i}):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Select a canvas node or edge to open the node or edge inspector. Workflow settings remain editable at all times.`})]})}function aOe(e,t){return e.filter(e=>e.nodeId===t||e.path?.startsWith(`$.nodes.${t}`))}function oOe(e,t){return e.filter(e=>e.edgeId===t||e.path?.startsWith(`$.edges.${t}`))}function sOe({draft:e,isSaving:t,onSaveDefinition:n}){let[r,i]=(0,R.useState)(()=>q1(e.definition));(0,R.useEffect)(()=>{i(q1(e.definition))},[e.definition]);let a=(e,t)=>{i(n=>({...n,[e]:t}))};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:`Workflow settings inspector`}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Workflow title`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:r.title,onChange:e=>a(`title`,e.target.value)})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Workflow description`}),(0,z.jsx)(`textarea`,{className:`min-h-20 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:r.description,onChange:e=>a(`description`,e.target.value)})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(r0,{label:`Workflow input port`,kind:r.inputKind,description:r.inputDescription,schemaText:r.inputSchemaText,onKindChange:e=>a(`inputKind`,e),onDescriptionChange:e=>a(`inputDescription`,e),onSchemaChange:e=>a(`inputSchemaText`,e)}),(0,z.jsx)(r0,{label:`Workflow output port`,kind:r.outputKind,description:r.outputDescription,schemaText:r.outputSchemaText,onKindChange:e=>a(`outputKind`,e),onDescriptionChange:e=>a(`outputDescription`,e),onSchemaChange:e=>a(`outputSchemaText`,e)})]}),(0,z.jsx)(dOe,{fields:r.globalStateFields,onAddField:()=>{i(e=>({...e,globalStateFields:[...e.globalStateFields,ZDe(e.globalStateFields)]}))},onRemoveField:e=>{i(t=>({...t,globalStateFields:t.globalStateFields.filter((t,n)=>n!==e)}))},onUpdateField:(e,t,n)=>{i(r=>({...r,globalStateFields:r.globalStateFields.map((r,i)=>i===e?{...r,[t]:n}:r)}))}}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(o0,{label:`metadata.tags`,value:r.metadataTags,onChange:e=>a(`metadataTags`,e)}),(0,z.jsx)(o0,{label:`metadata.useWhen`,value:r.metadataUseWhen,onChange:e=>a(`metadataUseWhen`,e)}),(0,z.jsx)(o0,{label:`metadata.notFor`,value:r.metadataNotFor,onChange:e=>a(`metadataNotFor`,e)}),(0,z.jsx)(o0,{label:`metadata.examples`,value:r.metadataExamples,onChange:e=>a(`metadataExamples`,e)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{n(XDe(e.definition,r),`Saved workflow settings inspector edits to the draft IR.`,{editTrigger:tOe(e.definition,r)?`state_edit`:`schema_edit`})},disabled:t,children:[t?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save workflow settings`]})]})]})}function cOe({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,R.useState)(()=>a1(n)),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)(),_=B$(n),v=aOe(e.diagnostics,t),y=d?.options.find(e=>e.id===(d?.selectedRefId??a.adapterRef)),b=(0,R.useMemo)(()=>new Set(a.humanActionRefs.map(e=>e.id)),[a.humanActionRefs]);(0,R.useEffect)(()=>{o(a1(n))},[n,t]),(0,R.useEffect)(()=>{if(_!==`agent`)return;let e=!1;return aJ(a.profileId||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.profileId]),(0,R.useEffect)(()=>{if(_!==`code`)return;let e=!1;return oJ(a.handlerId||void 0).then(t=>{e||u(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.handlerId]),(0,R.useEffect)(()=>{if(_!==`adapter`)return;let e=!1;return sJ(a.adapterRef||void 0).then(t=>{e||f(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.adapterRef]),(0,R.useEffect)(()=>{if(_!==`workflow`)return;let e=!1,t=E1(a.workflowVersionKey);return lJ({selectedWorkflowId:t?.workflowId,selectedWorkflowVersion:t?.workflowVersion}).then(t=>{e||m(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.workflowVersionKey]),(0,R.useEffect)(()=>{if(_!==`human`)return;let e=!1;return cJ().then(t=>{e||g(t)}).catch(()=>void 0),()=>{e=!0}},[_]);let x=(e,t)=>{o(n=>({...n,[e]:t}))},S=(e,t)=>{o(n=>({...n,humanActionRefs:nDe(n.humanActionRefs,e,t)}))};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Node inspector: `,t]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${_} node`}),(0,z.jsx)(F1,{label:`${v.length} diagnostics`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Node label`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.label,onChange:e=>x(`label`,e.target.value)})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Node description`}),(0,z.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.description,onChange:e=>x(`description`,e.target.value)})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(i0,{label:`Node input port`,kind:a.inputKind,description:a.inputDescription,schemaText:a.inputSchemaText,onKindChange:e=>x(`inputKind`,e),onDescriptionChange:e=>x(`inputDescription`,e),onSchemaChange:e=>x(`inputSchemaText`,e)}),(0,z.jsx)(i0,{label:`Node output port`,kind:a.outputKind,description:a.outputDescription,schemaText:a.outputSchemaText,onKindChange:e=>x(`outputKind`,e),onDescriptionChange:e=>x(`outputDescription`,e),onSchemaChange:e=>x(`outputSchemaText`,e)})]}),(0,z.jsx)(e0,{label:`Node`,definition:e.definition,value:a.stateAccess,onChange:e=>x(`stateAccess`,e)}),_===`agent`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Agent node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Agent profile ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:s?.selectedProfileId??a.profileId,onChange:e=>x(`profileId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a non-archived profile`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:k1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Prompt template`}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-slate-100`,value:a.promptTemplate,onChange:e=>x(`promptTemplate`,e.target.value)}),(0,z.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Saving direct prompt text writes `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`promptTemplate`}),` on this Pibo Workflow IR node.`]})]}),(0,z.jsx)(rOe,{draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i})]}):null,_===`code`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Code node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered code handler`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l?.selectedHandlerId??a.handlerId,onChange:e=>x(`handlerId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered handler ref`}),l?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:A1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:l?.diagnostics??[]})]}):null,_===`adapter`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Adapter node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered adapter ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:d?.selectedRefId??a.adapterRef,onChange:e=>x(`adapterRef`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),d?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:d?.diagnostics??[]}),y?.paramsSchema?(0,z.jsx)(s0,{label:`Adapter params JSON`,schema:y.paramsSchema,value:a.adapterParamsText,onChange:e=>x(`adapterParamsText`,e)}):null,(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-500`,children:`Adapter nodes store only a registered deterministic adapter ref. Inline transformation code and hidden LLM coercion are not exposed by the UI.`})]}):null,_===`workflow`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Nested workflow ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:p?.selectedWorkflowId&&p.selectedWorkflowVersion?T1(p.selectedWorkflowId,p.selectedWorkflowVersion):a.workflowVersionKey,onChange:e=>x(`workflowVersionKey`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a published workflow version`}),p?.options.map(e=>(0,z.jsx)(`option`,{value:M1(e),children:N1(e)},M1(e)))]})]}),(0,z.jsx)(B1,{diagnostics:p?.diagnostics??[],ariaLabel:`Workflow node diagnostics`})]}):null,_===`human`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Human node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Human prompt`}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:a.humanPrompt,onChange:e=>x(`humanPrompt`,e.target.value)})]}),(0,z.jsx)(a0,{label:`Human node resume payload schema JSON`,value:a.humanSchemaText,onChange:e=>x(`humanSchemaText`,e)}),(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Human action choices`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered action choices`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Actions are selected from the Workflow Registry. The label, action kind, and payload requirements come from picker metadata.`})]}),h?.options.length?h.options.map(e=>(0,z.jsxs)(`label`,{className:`grid gap-1 rounded-sm border border-slate-800 bg-[#101d22] p-2 text-slate-300`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-semibold`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#11a4d4]`,checked:b.has(e.id),onChange:t=>S(e,t.target.checked)}),(0,z.jsx)(`span`,{children:e.displayName}),(0,z.jsx)(F1,{label:`kind: ${e.kind??`registered`}`})]}),(0,z.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:e.description??e.id}),(0,z.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Payload requirements: `,e.paramsSchema?JSON.stringify(e.paramsSchema):`none`]})]},e.id)):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No registered human actions are available from the picker.`}),(0,z.jsx)(I1,{diagnostics:h?.diagnostics??[]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,"aria-label":`Selected human action refs`,children:a.humanActionRefs.length?a.humanActionRefs.map(e=>(0,z.jsx)(F1,{label:`${e.id}${e.kind?` (${e.kind})`:``}`},`${e.id}:${e.kind??``}`)):(0,z.jsx)(`span`,{className:`text-slate-500`,children:`No human action refs selected.`})})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 md:grid-cols-[1fr_1fr]`,"aria-label":`Human node timeout`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Timeout kind`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.humanTimeoutKind,onChange:e=>x(`humanTimeoutKind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`No timeout`}),(0,z.jsx)(`option`,{value:`milliseconds`,children:`Milliseconds`}),(0,z.jsx)(`option`,{value:`seconds`,children:`Seconds`}),(0,z.jsx)(`option`,{value:`minutes`,children:`Minutes`}),(0,z.jsx)(`option`,{value:`iso8601`,children:`ISO-8601 duration`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Timeout value`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,type:a.humanTimeoutKind===`iso8601`?`text`:`number`,min:a.humanTimeoutKind===`iso8601`?void 0:1,placeholder:a.humanTimeoutKind===`iso8601`?`PT1H`:`60`,value:a.humanTimeoutValue,onChange:e=>x(`humanTimeoutValue`,e.target.value),disabled:a.humanTimeoutKind===`none`})]})]})]}):null,(0,z.jsx)(P1,{diagnostics:v,emptyLabel:`No diagnostics for selected node.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{let r=XEe(e.definition,t,a),o=JEe(n,a)?`state_edit`:_===`agent`||_===`human`?`prompt_edit`:`schema_edit`;i(r,`Saved node inspector edits for ${t}.`,{editTrigger:o})},disabled:r,children:[r?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save node inspector`]})]})]})}function e0({label:e,definition:t,value:n,onChange:r,allowEdgeWrites:i=!1}){let a=n1(t,n.readScope,[...n.reads,...n.writes]),o=i?Z$:qEe,s=n1(t,n.writeScope,[...n.reads,...n.writes]),c=!!n.readPath.trim(),l=!!n.writePath.trim()&&(i||n.writeScope!==`edge`),u=(e,t)=>r({...n,[e]:t}),d=e=>{let t=e===`reads`?n.readScope:n.writeScope,i=(e===`reads`?n.readPath:n.writePath).trim();if(!i)return;let a=`${t}.${i}`,o=n[e];o.includes(a)||r({...n,[e]:[...o,a]})},f=(e,t)=>r({...n,[e]:n[e].filter(e=>e!==t)});return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,"aria-label":`${e} simple state mapping controls`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[e,` simple state mappings`]}),(0,z.jsxs)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:[`Add simple scoped state reads and writes as Pibo Workflow IR `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.reads`}),` and `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.writes`}),` arrays. Complex state mapping DSLs remain raw Workflow IR only.`]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Read scope`}),(0,z.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.readScope,onChange:e=>u(`readScope`,e.target.value),children:Z$.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsx)(t0,{label:`Read path`,value:n.readPath,options:a,onChange:e=>u(`readPath`,e)}),(0,z.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`reads`),disabled:!c,children:`Add read`})]}),(0,z.jsx)(n0,{label:`Reads`,entries:n.reads,onRemove:e=>f(`reads`,e)}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Write scope`}),(0,z.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.writeScope,onChange:e=>u(`writeScope`,e.target.value),children:o.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsx)(t0,{label:`Write path`,value:n.writePath,options:s,onChange:e=>u(`writePath`,e)}),(0,z.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`writes`),disabled:!l,children:`Add write`})]}),(0,z.jsx)(n0,{label:`Writes`,entries:n.writes,onRemove:e=>f(`writes`,e)}),n.writeScope===`global`&&!r1(t).length?(0,z.jsx)(`div`,{className:`rounded-sm border border-amber-900/60 bg-amber-950/20 p-2 text-[11px] leading-5 text-amber-100`,children:`Declare global state fields in the workflow settings inspector before selecting global read/write paths.`}):null]})}function t0({label:e,value:t,options:n,onChange:r}){let i=t&&!n.includes(t)?[t,...n]:n;return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>r(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select path`}),i.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function n0({label:e,entries:t,onRemove:n}){return(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-semibold text-slate-400`,children:e}),t.length?(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-[11px] text-slate-300 transition hover:border-red-500/60 hover:text-red-100`,onClick:()=>n(e),title:`Remove ${e}`,children:[e,` ×`]},e))}):(0,z.jsxs)(`div`,{className:`text-[11px] text-slate-500`,children:[`No `,e.toLowerCase(),` declared.`]})]})}function lOe({draft:e,edgeId:t,edge:n,nodeIds:r,isSaving:i,onSaveDefinition:a}){let[o,s]=(0,R.useState)(()=>o1(n,r)),[c,l]=(0,R.useState)(),[u,d]=(0,R.useState)(),[f,p]=(0,R.useState)(!1),m=oOe(e.diagnostics,t),h=HDe(e.definition,n),g=m.some(e=>e.code===`WorkflowGraphError.incompatibleEdgePorts`),_=c?.options.find(e=>e.id===(c?.selectedRefId??o.guardHandler)),v=u?.options.find(e=>e.id===(u?.selectedRefId??o.adapterRef));(0,R.useEffect)(()=>{s(o1(n,r))},[n,t,r]),(0,R.useEffect)(()=>{p(!1)},[t]),(0,R.useEffect)(()=>{let e=!1;return Dye(o.guardHandler||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o.guardHandler]),(0,R.useEffect)(()=>{let e=!1;return sJ(o.adapterRef||void 0).then(t=>{e||d(t)}).catch(()=>void 0),()=>{e=!0}},[o.adapterRef]);let y=(e,t)=>{s(n=>({...n,[e]:t}))},b=()=>{let r=ZEe(e.definition,t,o),i=Q$(n.state,o.stateAccess)?`state_edit`:`edge_edit`;a(r,`Saved edge inspector edits for ${t}.`,{editTrigger:i})};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Edge inspector: `,t]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${o.kind} edge`}),(0,z.jsx)(F1,{label:`${m.length} diagnostics`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Source node`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourceNodeId,onChange:e=>y(`sourceNodeId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select source`}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Target node`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetNodeId,onChange:e=>y(`targetNodeId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select target`}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Source port id`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourcePortId,onChange:e=>y(`sourcePortId`,e.target.value),placeholder:`default`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Target port id`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetPortId,onChange:e=>y(`targetPortId`,e.target.value),placeholder:`default`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Edge kind`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.kind,onChange:e=>y(`kind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`data`,children:`data`}),(0,z.jsx)(`option`,{value:`control`,children:`control`}),(0,z.jsx)(`option`,{value:`error`,children:`error`}),(0,z.jsx)(`option`,{value:`resume`,children:`resume`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Guard ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:c?.selectedRefId??o.guardHandler,onChange:e=>y(`guardHandler`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No guard`}),c?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Guard priority`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.guardPriority,onChange:e=>y(`guardPriority`,e.target.value),placeholder:`optional integer`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,z.jsx)(`span`,{children:`Edge adapter ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:u?.selectedRefId??o.adapterRef,onChange:e=>y(`adapterRef`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No edge adapter`}),u?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]})]}),_?.paramsSchema?(0,z.jsx)(s0,{label:`Guard params JSON`,schema:_.paramsSchema,value:o.guardParamsText,onChange:e=>y(`guardParamsText`,e)}):null,v?.paramsSchema?(0,z.jsx)(s0,{label:`Edge adapter params JSON`,schema:v.paramsSchema,value:o.adapterParamsText,onChange:e=>y(`adapterParamsText`,e)}):null,(0,z.jsx)(e0,{label:`Edge`,definition:e.definition,value:o.stateAccess,onChange:e=>y(`stateAccess`,e),allowEdgeWrites:!0}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border px-3 py-2 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${g?`border-amber-600/70 text-amber-100 hover:border-amber-400`:`border-slate-700 text-slate-300 hover:border-[#11a4d4]/60 hover:text-slate-100`}`,onClick:()=>p(!0),disabled:i||!h.sourcePort||!h.targetPort,children:[(0,z.jsx)(bs,{size:13}),g?`Fix incompatible edge with adapter`:`Open compatible edge adapter dialog`]}),f?(0,z.jsx)(uOe,{draft:e,edgeId:t,edge:n,edgePortDetails:h,isSaving:i,onClose:()=>p(!1),onSaveDefinition:a}):null,(0,z.jsx)(I1,{diagnostics:[...c?.diagnostics??[],...u?.diagnostics??[]]}),(0,z.jsx)(P1,{diagnostics:m,emptyLabel:`No diagnostics for selected edge.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:b,disabled:i||!o.sourceNodeId||!o.targetNodeId,children:[i?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save edge inspector`]})]})]})}function uOe({draft:e,edgeId:t,edge:n,edgePortDetails:r,isSaving:i,onClose:a,onSaveDefinition:o}){let[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(UDe(n)),[d,f]=(0,R.useState)(`loading`),[p,m]=(0,R.useState)();(0,R.useEffect)(()=>{let e=!1;return f(`loading`),m(void 0),sJ(l||void 0).then(t=>{e||(c(t),u(e=>e||(t.options[0]?.id??``)),f(`loaded`))}).catch(t=>{e||(m(t instanceof Error?t.message:`Failed to load compatible adapters`),f(`error`))}),()=>{e=!0}},[l]);let h=s?.options.find(e=>e.id===l),g=!!(h&&r.sourcePort&&r.targetPort&&d===`loaded`&&!i),_=async()=>{l&&(await o(WDe(e.definition,t,l),`Applied ${l} as edge adapter for ${t}.`,{editTrigger:`edge_edit`}),a())},v=async()=>{l&&(await o(GDe(e.definition,t,l),`Inserted adapter node for ${t} using ${l}.`,{editTrigger:`graph_edit`}),a())};return(0,z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`workflow-edge-adapter-dialog-title`,children:(0,z.jsxs)(`div`,{className:`max-h-[88vh] w-full max-w-3xl overflow-auto rounded-sm border border-slate-700 bg-[#101d22] p-4 shadow-2xl shadow-black/40`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(bs,{size:13}),`Compatible edge adapter dialog`]}),(0,z.jsxs)(`h4`,{id:`workflow-edge-adapter-dialog-title`,className:`mt-1 text-sm font-bold text-slate-100`,children:[`Choose a registered adapter for `,t]}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:`The dialog shows the source output and target input schemas from the Pibo Workflow IR. Use a registered adapter as an explicit edge adapter, or insert a visible adapter node between the endpoints.`})]}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:a,children:`Close`})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,z.jsx)(R1,{label:`From schema${r.sourceNodeId?` (${r.sourceNodeId})`:``}`,schema:r.sourcePort??null}),(0,z.jsx)(R1,{label:`To schema${r.targetNodeId?` (${r.targetNodeId})`:``}`,schema:r.targetPort??null})]}),(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border p-3 text-xs leading-5 ${r.directlyCompatible?`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`:`border-amber-700/70 bg-amber-950/30 text-amber-100`}`,children:r.directlyCompatible?`These ports are directly compatible. An adapter is optional and remains explicit if selected.`:`These ports are not directly compatible. Select a registered adapter instead of hidden LLM coercion or inline transformation code.`}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 text-xs`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Compatible registered adapter`}),(0,z.jsxs)(`select`,{"aria-label":`Compatible registered adapter`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l,onChange:e=>u(e.target.value),disabled:d===`loading`||d===`error`||i,children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),d===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:p??`Failed to load compatible adapters.`}):null,(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),h?(0,z.jsx)(L1,{option:h,badge:`selected adapter`}):null,(0,z.jsxs)(`div`,{className:`grid gap-2`,"aria-label":`Compatible adapter candidates`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Compatible adapter candidates`}),s?.options.map(e=>(0,z.jsx)(L1,{option:e,badge:`compatible adapter`},e.id))]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void _(),disabled:!g,children:[(0,z.jsx)(bs,{size:13}),`Use as edge adapter`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void v(),disabled:!g,children:[(0,z.jsx)(Ps,{size:13}),`Insert adapter node`]})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Both actions persist Pibo Workflow IR only. Edge adapters store `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`adapter.transform.id`}),`; inserted adapter nodes store a visible deterministic adapter handler ref.`]})]})]})})}function r0({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,z.jsx)(`option`,{value:`text`,children:`text`}),(0,z.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),placeholder:`Optional port description`})]}),t===`json`?(0,z.jsx)(a0,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function i0({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`inherit/default`}),(0,z.jsx)(`option`,{value:`text`,children:`text`}),(0,z.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),disabled:t===`none`,placeholder:`Optional port description`})]}),t===`json`?(0,z.jsx)(a0,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function dOe({fields:e,onAddField:t,onRemoveField:n,onUpdateField:r}){return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow global state fields`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Workflow global state fields`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Declare simple global state paths for node and edge state mapping dropdowns. State schema changes run draft validation and may invalidate connected graph diagnostics without blocking draft save.`})]}),e.length?e.map((e,t)=>(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Global state path`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.path,onChange:e=>r(t,`path`,e.target.value),placeholder:`projectGoal`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Merge policy`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.mergeKind,onChange:e=>r(t,`mergeKind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`No merge policy`}),(0,z.jsx)(`option`,{value:`replace`,children:`replace`}),(0,z.jsx)(`option`,{value:`append`,children:`append`}),(0,z.jsx)(`option`,{value:`shallowMerge`,children:`shallowMerge`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.description,onChange:e=>r(t,`description`,e.target.value),placeholder:`Optional state description`})]}),(0,z.jsx)(`div`,{className:`md:col-span-2`,children:(0,z.jsx)(a0,{label:`Global state ${e.path||t+1} schema JSON`,value:e.schemaText,onChange:e=>r(t,`schemaText`,e)})}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-red-500/70 hover:text-red-100`,onClick:()=>n(t),children:`Remove state field`})]},`${t}:${e.path}`)):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No global state fields declared. Local and edge path dropdowns remain available for simple node-local state and edge payload access.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:t,children:[(0,z.jsx)(Ps,{size:13}),`Add global state field`]})]})}function a0({label:e,value:t,onChange:n}){return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`textarea`,{className:`min-h-36 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:JSON.stringify(X$,null,2),spellCheck:!1,"aria-label":e}),(0,z.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:`Raw JSON Schema subset only. Unsupported keywords return workflow diagnostics; no Zod, AJV, or form-builder schema layer is introduced.`})]})}function o0({label:e,value:t,onChange:n}){return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:`One value per line`})]})}function s0({label:e,schema:t,value:n,onChange:r}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,"aria-label":e,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,z.jsx)(R1,{label:`paramsSchema`,schema:t}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:n,onChange:e=>r(e.target.value),placeholder:`{}`,"aria-label":`${e} value`}),(0,z.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Params save as data on the selected registry ref. No inline code path is created.`})]})}function fOe(e){let t=new Map;for(let n of e){let e=t.get(n.id);if(e){e.records.push(n),n.status===`published`&&e.records[0]?.status!==`published`&&(e.title=n.title,e.source=n.source);continue}t.set(n.id,{workflowId:n.id,title:n.title,source:n.source,records:[n]})}return[...t.values()]}function pOe(e){return e.status===`published`?`Published workflow version — selectable for Project sessions and safe to duplicate into UI drafts.`:e.status===`archived`?`Archived workflow version — shown for lifecycle history but hidden from default Project session creation choices.`:e.status===`deleted`?`Deleted workflow definition — historical runs must render from immutable snapshots instead of live catalog links.`:`Draft workflow version — not published and unavailable for Project session creation.`}function c0(e,t){return e.actions.includes(t)}function mOe(e){switch(e){case`view`:return`View`;case`duplicate`:return`Duplicate`;case`create_project_session`:return`Create Project session`;case`edit_draft`:return`Edit draft`;case`validate`:return`Validate`;case`publish`:return`Publish`;case`create_next_draft`:return`Create next draft`;case`version_history`:return`Version history`;case`archive`:return`Archive`;case`delete`:return`Delete`}}function hOe({activeDraftId:e}){let[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(`loading`),[a,o]=(0,R.useState)(),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)(),[_,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(),x=!!(s||l||d||p),S=(0,R.useCallback)(async()=>{i(`loading`),o(void 0);try{n((await uJ()).options),i(`loaded`)}catch(e){o(e instanceof Error?e.message:`Failed to load workflow version history`),i(`error`)}},[]);(0,R.useEffect)(()=>{S()},[S]);let C=(0,R.useMemo)(()=>fOe(t),[t]),w=async(e,t)=>{c(T1(e,t)),b(void 0);try{O1((await Iye(e,{version:t})).builderPath)}catch(e){b(e instanceof Error?e.message:`Failed to duplicate workflow into a draft`),c(void 0)}},T=async(e,t)=>{u(T1(e,t)),b(void 0);try{O1((await Lye(e,{version:t})).builderPath)}catch(e){b(e instanceof Error?e.message:`Failed to create next-version draft`),u(void 0)}},E=(e,t)=>{v(``),b(void 0),g({kind:`archive`,workflowId:e,title:t})},D=(e,t)=>{v(``),b(void 0),g({kind:`delete`,workflowId:e,title:t})},O=async()=>{if(!h||h.kind!==`archive`)return;let{workflowId:e}=h;f(e),b(void 0);try{await Rye(e),g(void 0),await S()}catch(e){b(e instanceof Error?e.message:`Failed to archive workflow`)}finally{f(void 0)}},k=async()=>{if(!h||h.kind!==`delete`)return;let{workflowId:e}=h;m(e),b(void 0);try{await zye(e,{confirmWorkflowId:_}),g(void 0),v(``),await S()}catch(e){b(e instanceof Error?e.message:`Failed to delete workflow`)}finally{m(void 0)}};return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`UI draft`}),(0,z.jsx)(`h3`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Starter UI draft`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`A draft row opens the builder route and loads a partial Pibo Workflow IR wrapper with diagnostics.`})]}),(0,z.jsx)(`a`,{className:`shrink-0 rounded-sm border border-[#11a4d4]/50 px-3 py-1.5 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100`,href:_De(gDe),children:`Open draft`})]}),e===`v2-starter-draft`?(0,z.jsx)(`div`,{className:`mt-3 text-[11px] font-semibold text-emerald-300`,children:`Currently open in the builder.`}):null]}),(0,z.jsx)(yOe,{target:h,busy:x,deleteConfirmWorkflowId:_,onDeleteConfirmChange:v,onCancel:()=>{g(void 0),v(``)},onConfirmArchive:()=>void O(),onConfirmDelete:()=>void k()}),(0,z.jsxs)(`div`,{className:`grid gap-3`,"aria-label":`Workflow version history`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[(0,z.jsx)(hs,{size:13}),`Version history`]}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Published versions are listed in deterministic workflow/version order. Only published rows are selectable for Project sessions; archived rows stay visible as history while deleted workflows render from Project snapshots.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void S(),disabled:r===`loading`,children:[r===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),r===`loading`?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-xs text-slate-400`,"aria-live":`polite`,children:[(0,z.jsx)(Cs,{size:14,className:`animate-spin text-[#11a4d4]`}),`Loading workflow version history…`]}):null,r===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:a??`Failed to load workflow version history.`}):null,r===`loaded`&&C.length===0?(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#101d22]/70 p-4 text-xs text-slate-500`,children:`No workflow versions are registered yet.`}):null,r===`loaded`?C.map(e=>(0,z.jsx)(gOe,{group:e,busy:x,duplicatingKey:s,editingKey:l,archivingWorkflowId:d,deletingWorkflowId:p,onDuplicate:w,onEditPublished:T,onArchive:E,onDelete:D},e.workflowId)):null]}),y?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:y}):null]})}function gOe({group:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,"aria-label":`Version history for ${e.workflowId}`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`font-semibold text-slate-100`,children:e.title}),(0,z.jsx)(F1,{label:`${e.records.length} version${e.records.length===1?``:`s`}`}),(0,z.jsx)(F1,{label:`${e.source} source`})]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-500`,children:e.workflowId})]})}),(0,z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:e.records.map(e=>(0,z.jsx)(_Oe,{record:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l},T1(e.id,e.version)))})]})}function _Oe({record:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l}){let u=T1(e.id,e.version),d=e.status===`published`,f=c0(e,`create_next_draft`),p=c0(e,`duplicate`),m=c0(e,`create_project_session`),h=c0(e,`view`),g=d&&c0(e,`archive`),_=d&&c0(e,`delete`);return(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`font-mono text-[11px] font-semibold text-slate-200`,children:[e.id,`@`,e.version]}),(0,z.jsx)(F1,{label:e.status}),(0,z.jsx)(F1,{label:`${e.source} source`}),e.tags.map(e=>(0,z.jsx)(F1,{label:e},e))]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsx)(`div`,{className:`mt-2 text-[11px] ${d?`text-emerald-300`:`text-amber-200`}`,children:pOe(e)}),(0,z.jsx)(vOe,{actions:e.actions})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[f?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-[#11a4d4]/50 px-3 py-1.5 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void s(e.id,e.version),disabled:t,children:[r===u?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(vs,{size:13}),`Edit published`]}):null,p?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void o(e.id,e.version),disabled:t,children:[n===u?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Qo,{size:13}),`Duplicate to draft`]}):null,m?(0,z.jsxs)(`a`,{className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-700/70 px-3 py-1.5 text-xs font-semibold text-emerald-100 transition hover:border-emerald-500 hover:text-emerald-50`,href:`/apps/chat/projects`,children:[(0,z.jsx)(As,{size:13}),`Create Project session`]}):(0,z.jsx)(`div`,{className:`max-w-44 rounded-sm border border-amber-800/70 bg-amber-950/20 p-2 text-[11px] text-amber-100`,children:`Unavailable for Project session selection.`}),h?(0,z.jsxs)(`a`,{className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,href:D1(e.id,e.version),children:[(0,z.jsx)(rs,{size:13}),`View details`]}):null,g?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-amber-700/70 px-3 py-1.5 text-xs font-semibold text-amber-100 transition hover:border-amber-500 hover:text-amber-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>c(e.id,e.title),disabled:t,children:[i===e.id?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(To,{size:13}),`Archive workflow`]}):null,_?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-red-800/80 px-3 py-1.5 text-xs font-semibold text-red-100 transition hover:border-red-500 hover:text-red-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>l(e.id,e.title),disabled:t,children:[a===e.id?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(qs,{size:13}),`Delete workflow`]}):null]})]})})}function vOe({actions:e}){return(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Workflow Library source/status actions`,children:e.map(e=>(0,z.jsx)(F1,{label:mOe(e)},e))})}function yOe({target:e,busy:t,deleteConfirmWorkflowId:n,onDeleteConfirmChange:r,onCancel:i,onConfirmArchive:a,onConfirmDelete:o}){if(!e)return null;let s=e.kind===`delete`,c=n.trim()===e.workflowId;return(0,z.jsx)(`div`,{className:`rounded-sm border p-4 text-xs leading-5 ${s?`border-red-900/70 bg-red-950/25 text-red-100`:`border-amber-800/70 bg-amber-950/20 text-amber-100`}`,role:`region`,"aria-label":`${s?`Delete`:`Archive`} workflow confirmation`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em]`,children:[(0,z.jsx)(Js,{size:13}),`Confirm `,s?`delete`:`archive`]}),(0,z.jsx)(`h3`,{className:`mt-1 text-sm font-bold text-slate-100`,children:e.title}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.workflowId}),s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mt-3`,children:`Deleting tombstones the live workflow identity. It removes this workflow from the default catalog, workflow pickers, duplicate/edit/publish/archive actions, and new Project session creation.`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Historical Project runs remain inspectable from immutable snapshots and show a definition-deleted state instead of a broken live catalog link.`}),(0,z.jsxs)(`label`,{className:`mt-3 block text-[11px] font-semibold text-red-100`,children:[`Type the workflow id to confirm delete`,(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),className:`mt-1 w-full rounded-sm border border-red-900/70 bg-[#101d22] px-2 py-1.5 font-mono text-xs text-slate-100 outline-none focus:border-red-400`,placeholder:e.workflowId,disabled:t})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mt-3`,children:`Archiving applies to the whole workflow identity. It hides this workflow from the default catalog and Project workflow selection lists.`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Published versions stay available only through archive filters and historical run links, and historical Project runs continue to render from their snapshots.`})]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-slate-500 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:i,disabled:t,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border px-3 py-1.5 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${s?`border-red-700 text-red-100 hover:border-red-400`:`border-amber-600 text-amber-100 hover:border-amber-400`}`,onClick:s?o:a,disabled:t||s&&!c,children:s?`Delete workflow`:`Archive workflow`})]})]})})}var l0=`WorkflowBuilderWarning.invalidRawIrText`;function bOe({draft:e,onDraftChange:t}){let n=(0,R.useMemo)(()=>JSON.stringify(e.definition,null,2),[e.definition]),[r,i]=(0,R.useState)(n),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(`idle`),[l,u]=(0,R.useState)(),d=e.diagnostics.filter(e=>e.code===l0);(0,R.useEffect)(()=>{a||i(n)},[n,a]);let f=async()=>{c(`saving`),u(void 0);try{let n=await dJ(e.draftId,{rawDefinitionText:r,editTrigger:`raw_ir_edit`});if(t(n.draft),n.diagnostics.some(e=>e.code===l0)){o(!0),c(`warning`),u(`Raw Workflow IR text was not saved; the last valid draft object remains unchanged.`);return}i(JSON.stringify(n.draft.definition,null,2)),o(!1),c(`saved`),u(`Saved raw Workflow IR to the draft. Validation state: ${n.validation.validationState}.`)}catch(e){c(`error`),u(e instanceof Error?e.message:`Failed to save raw Workflow IR text`)}};return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Raw Pibo Workflow IR editor panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Raw Pibo Workflow IR editor`}),(0,z.jsx)(`h4`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Safe raw Workflow IR sync`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-xs leading-5 text-slate-400`,children:`Edit only Pibo Workflow IR JSON. Saving valid JSON parses into the same draft object used by the graph and inspectors. Invalid JSON or non-object text returns a warning diagnostic and keeps the last valid draft object unchanged; raw XState JSON is not exposed here.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`last valid rev ${e.revision}`}),a?(0,z.jsx)(F1,{label:`unsaved raw text`}):null]})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.72fr)]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{className:`text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500`,htmlFor:`workflow-raw-ir-editor`,children:`Editable Pibo Workflow IR JSON`}),(0,z.jsx)(`textarea`,{id:`workflow-raw-ir-editor`,"aria-label":`Raw Pibo Workflow IR editor`,className:`min-h-[26rem] rounded-sm border border-slate-800 bg-[#101d22] p-3 font-mono text-[11px] leading-5 text-slate-100 outline-none transition focus:border-[#11a4d4]`,spellCheck:!1,value:r,onChange:e=>{i(e.target.value),o(!0),c(`idle`),u(void 0)}}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-600/70 px-3 py-1.5 text-xs font-semibold text-emerald-200 transition hover:border-emerald-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void f(),disabled:s===`saving`,children:[s===`saving`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save raw IR`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-slate-500 hover:text-white`,onClick:()=>{i(n),o(!1),c(`idle`),u(`Reset the editor from the last valid Pibo Workflow IR object.`)},disabled:s===`saving`,children:[(0,z.jsx)(Ls,{size:13}),`Reset from current draft`]})]}),l?(0,z.jsx)(`div`,{className:`rounded-sm border p-3 text-xs leading-5 ${s===`error`?`border-red-900/70 bg-red-950/40 text-red-200`:s===`warning`?`border-amber-700/70 bg-amber-950/30 text-amber-100`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,role:s===`error`||s===`warning`?`alert`:`status`,children:l}):null,d.length?(0,z.jsx)(P1,{diagnostics:d,emptyLabel:`No raw IR parse diagnostics.`}):null]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Last valid Pibo Workflow IR object`}),(0,z.jsx)(`pre`,{"aria-label":`Pibo Workflow IR draft`,className:`max-h-[32rem] overflow-auto rounded-sm border border-slate-800 bg-[#101d22] p-3 text-[11px] leading-5 text-slate-200`,children:n})]})]})]})}function xOe({draftId:e,viewWorkflowId:t,viewWorkflowVersion:n}){return(0,z.jsx)(`main`,{className:`h-full min-h-0 overflow-auto bg-[#101d22]`,children:(0,z.jsxs)(`section`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6 p-6 max-[720px]:p-4`,"aria-labelledby":`workflows-title`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24] p-5 shadow-lg shadow-black/20`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.18em] text-[#11a4d4]`,children:`Workflow UI Authoring V2`}),(0,z.jsx)(`h1`,{id:`workflows-title`,className:`mt-2 text-2xl font-extrabold tracking-tight text-slate-100`,children:`Workflows`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-slate-400`,children:`Browse workflow definitions, duplicate published workflows into UI drafts, and open draft wrappers that edit Pibo Workflow IR from the authenticated Chat Web surface.`})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[0.9fr_1.1fr]`,children:[(0,z.jsx)(p0,{icon:jo,eyebrow:`Global catalog`,title:`Workflow Library`,description:`Open UI drafts or duplicate published workflow versions into a draft before editing.`,children:(0,z.jsx)(hOe,{activeDraftId:e})}),(0,z.jsx)(p0,{icon:vs,eyebrow:`Visual authoring`,title:`Workflow Builder`,description:`Load a UI draft wrapper and keep Pibo Workflow IR as the editable source of truth.`,children:e?(0,z.jsx)(COe,{draftId:e}):t&&n?(0,z.jsx)(bDe,{workflowId:t,workflowVersion:n}):(0,z.jsx)(SOe,{})})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24] p-4 text-xs text-slate-400 md:grid-cols-4`,children:[(0,z.jsx)(m0,{icon:Lo,label:`Pibo Workflow IR remains the source of truth`}),(0,z.jsx)(m0,{icon:Qo,label:`Code workflows can be duplicated into UI drafts`}),(0,z.jsx)(m0,{icon:Gs,label:`Workflow capabilities are registered refs only`}),(0,z.jsx)(m0,{icon:vs,label:`XState stays a read-only visualization projection`})]}),(0,z.jsx)(wOe,{})]})})}function SOe(){return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,z.jsx)(OOe,{title:`Open a draft to start authoring`,description:`Use the Workflow Library draft row or Duplicate to draft action. The builder route will load a draft wrapper around Pibo Workflow IR, not raw XState source.`}),(0,z.jsx)(u0,{}),(0,z.jsx)(SDe,{})]})}function COe({draftId:e}){let[t,n]=(0,R.useState)(),[r,i]=(0,R.useState)(`loading`),[a,o]=(0,R.useState)();return(0,R.useEffect)(()=>{let t=!1;return i(`loading`),o(void 0),Nye(e).then(e=>{t||(n(e.draft),i(`loaded`))}).catch(e=>{t||(o(e instanceof Error?e.message:`Failed to load workflow draft`),i(`error`))}),()=>{t=!0}},[e]),r===`loading`?(0,z.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-sm text-slate-300`,"aria-live":`polite`,children:[(0,z.jsx)(Cs,{size:16,className:`animate-spin text-[#11a4d4]`}),`Loading workflow draft `,e,`…`]}):r===`error`||!t?(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-4 text-sm leading-6 text-red-200`,role:`alert`,children:[(0,z.jsx)(`div`,{className:`font-bold`,children:`Could not load workflow draft`}),(0,z.jsx)(`div`,{className:`mt-1 text-xs`,children:a??`Draft '${e}' was not found.`})]}):(0,z.jsx)(TOe,{draft:t})}function wOe(){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/60 bg-amber-950/15 p-4 text-xs leading-5 text-amber-100`,"aria-label":`Workflow V2 explicit non-goals`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-amber-200`,children:[(0,z.jsx)(Gs,{size:13}),`V2 scope boundary`]}),(0,z.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`Workflows V2 is an authoring surface for Pibo Workflow IR and registered capability references, not a code or product import/export surface.`}),(0,z.jsxs)(`ul`,{className:`mt-3 grid gap-1 text-[11px] text-amber-100/75 md:grid-cols-2`,children:[(0,z.jsx)(`li`,{children:`No inline TypeScript, JavaScript, shell, eval, arbitrary executable code, or raw handler body authoring.`}),(0,z.jsx)(`li`,{children:`No raw XState editing, workflow templates, workflow slash commands, or workflow tools for agents.`}),(0,z.jsx)(`li`,{children:`No YAML/JSON product import/export or TypeScript export path from UI-authored workflows.`}),(0,z.jsx)(`li`,{children:`No Zod schema authoring; schema edits remain constrained to Pibo Workflow IR and registered metadata.`})]})]})}function u0(){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/15 p-4 text-xs leading-5 text-emerald-100`,"aria-label":`Registered capability security boundary`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-emerald-300`,children:[(0,z.jsx)(Gs,{size:13}),`Registered capability security boundary`]}),(0,z.jsx)(`p`,{className:`mt-2 text-emerald-100/90`,children:`V2 authoring composes registered refs only: non-archived Agent profiles, code handlers, adapters, guards, nested workflows, human actions, and prompt assets.`}),(0,z.jsxs)(`ul`,{className:`mt-3 grid gap-1 text-[11px] text-emerald-100/75`,children:[(0,z.jsx)(`li`,{children:`Existing Chat Web auth plus Project and Pibo Session visibility rules still gate workflow catalog, Project workflow sessions, snapshots, lifecycle events, prompt assets, and human actions.`}),(0,z.jsx)(`li`,{children:`Agent nodes select profile refs only; the UI does not grant extra tools, skills, context files, native tools, MCP servers, or compute-worker access beyond the selected runtime profile.`}),(0,z.jsx)(`li`,{children:`No inline JavaScript, TypeScript, shell, eval, arbitrary executable nodes, or raw handler bodies are created by the UI.`}),(0,z.jsx)(`li`,{children:`Incompatible schemas must use a visible registered adapter node or edge adapter; hidden LLM coercion is not used.`}),(0,z.jsx)(`li`,{children:`XState remains projection-only; Pibo Workflow IR is the persisted source of truth.`}),(0,z.jsx)(`li`,{children:`Workflow inputs, outputs, prompts, prompt assets, state, edge payloads, snapshots, and human action payloads remain sensitive workflow data; normal diagnostics expose only sanitized metadata.`})]})]})}function TOe({draft:e}){let[t,n]=(0,R.useState)(e),[r,i]=(0,R.useState)(e.versionIntent),[a,o]=(0,R.useState)(`idle`),[s,c]=(0,R.useState)(),l=a===`validating`||a===`publishing`,u=t.validation?.errorCount??t.diagnostics.filter(e=>e.severity===`error`).length,d=t.validation?.warningCount??t.diagnostics.filter(e=>e.severity===`warning`).length,f=t.validation?.blocksPublish===!0||u>0;(0,R.useEffect)(()=>{n(e),i(e.versionIntent),o(`idle`),c(void 0)},[e]);let p=async()=>{o(`validating`),c(void 0);try{let e=await Pye(t.draftId);n(e.draft),i(e.draft.versionIntent),o(`validated`),c(`Draft validation ${e.validation.ok?`passed`:`returned diagnostics`}. Publish remains a separate action.`)}catch(e){o(`error`),c(e instanceof Error?e.message:`Failed to validate workflow draft`)}},m=async()=>{o(`publishing`),c(void 0);try{let e=await Fye(t.draftId,{versionIntent:r});n(e.draft),i(e.draft.versionIntent),o(`published`),c(e.publishedVersion?`${e.message??`Published workflow draft.`} Definition hash ${e.publishedVersion.definitionHash}.`:e.message??`Publish validation passed.`)}catch(e){o(`error`),c(e instanceof Error?e.message:`Failed to publish workflow draft`)}};return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Loaded UI draft`}),(0,z.jsx)(`h3`,{className:`mt-1 text-lg font-bold text-slate-100`,children:String(t.definition.title??t.workflowId)}),(0,z.jsxs)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:[`Builder route `,(0,z.jsxs)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:[`/workflows/drafts/`,t.draftId]}),` loaded a draft wrapper around partial Pibo Workflow IR.`]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${t.source} source`}),(0,z.jsx)(F1,{label:t.status}),(0,z.jsx)(F1,{label:t.validationState}),(0,z.jsx)(F1,{label:`rev ${t.revision}`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 text-xs md:grid-cols-2`,"aria-label":`Workflow draft metadata`,children:[(0,z.jsx)(f0,{label:`Draft id`,value:t.draftId}),(0,z.jsx)(f0,{label:`Workflow id`,value:t.workflowId}),(0,z.jsx)(f0,{label:`Base workflow`,value:t.baseWorkflowId&&t.baseWorkflowVersion?`${t.baseWorkflowId}@${t.baseWorkflowVersion}`:`new UI draft`}),(0,z.jsx)(f0,{label:`Next version path`,value:t.targetWorkflowVersion??`not assigned yet`}),(0,z.jsx)(f0,{label:`Version intent`,value:t.versionIntent})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Workflow publish version panel`,children:[(0,z.jsxs)(`div`,{id:`workflow-publish-gate`,className:`mb-3 rounded-sm border p-3 text-xs leading-5 ${f?`border-amber-700/70 bg-amber-950/30 text-amber-100`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,"aria-label":`Workflow publish gate`,role:`status`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:f?`Publish blocked by draft diagnostics`:`Publish gate ready`}),(0,z.jsx)(`p`,{className:`mt-1`,children:f?`Publish is disabled because ${u} error diagnostic${u===1?``:`s`} ${u===1?`remains`:`remain`}. Draft save remains allowed while you fix errors; before-publish validation also requires workflow input/output ports and at least one node.`:d>0?`Warnings do not block publishing. Before-publish validation still runs and will block if workflow input/output ports, graph nodes, or registered refs are invalid.`:`No blocking diagnostics are present. Before-publish validation will run again before creating an immutable workflow version.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Publish version intent`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-400`,children:`Default publish increments the patch version. Choose minor or major when the release scope needs a larger semantic version bump.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Version bump intent`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-xs text-slate-100 outline-none transition focus:border-[#11a4d4]`,value:r,onChange:e=>i(e.target.value),disabled:l,"aria-label":`Version bump intent`,children:[(0,z.jsx)(`option`,{value:`patch`,children:`Patch version bump (default)`}),(0,z.jsx)(`option`,{value:`minor`,children:`Minor version bump`}),(0,z.jsx)(`option`,{value:`major`,children:`Major version bump`})]})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-200 transition hover:border-[#11a4d4] hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void p(),disabled:l,children:[a===`validating`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Ls,{size:13}),`Validate draft`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-600/70 px-3 py-1.5 text-xs font-semibold text-emerald-200 transition hover:border-emerald-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void m(),disabled:l||f,"aria-describedby":`workflow-publish-gate`,children:[a===`publishing`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Lo,{size:13}),`Publish draft`]})]})]}),s?(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border p-3 text-xs leading-5 ${a===`error`?`border-red-900/70 bg-red-950/40 text-red-200`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,role:a===`error`?`alert`:`status`,children:s}):null]}),(0,z.jsx)(u0,{}),(0,z.jsx)(RDe,{draft:t,onDraftChange:n,renderInspectors:e=>(0,z.jsx)(iOe,{...e})}),(0,z.jsx)(EOe,{draft:t}),(0,z.jsx)(bOe,{draft:t,onDraftChange:n}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Raw XState source is not opened as an editable document. XState remains projection-only; the editable source is the Pibo Workflow IR shown above and in the raw Pibo Workflow IR editor.`})]})}function EOe({draft:e}){let t=e.validation,n=t?.errorCount??e.diagnostics.filter(e=>e.severity===`error`).length,r=t?.warningCount??e.diagnostics.filter(e=>e.severity===`warning`).length,i=t?.infoCount??e.diagnostics.filter(e=>e.severity===`info`).length;return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Workflow validation panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Validation panel`}),(0,z.jsx)(`h4`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Structured draft diagnostics`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-400`,children:`Draft validation reports sanitized diagnostic fields from the Workflow IR pipeline. Publish remains gated by blocking error diagnostics and the backend before-publish route.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${n} errors`}),(0,z.jsx)(F1,{label:`${r} warnings`}),(0,z.jsx)(F1,{label:`${i} info`})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs md:grid-cols-3`,"aria-label":`Workflow validation summary`,children:[(0,z.jsx)(f0,{label:`Validation state`,value:e.validationState}),(0,z.jsx)(f0,{label:`Last trigger`,value:t?.trigger??`not checked`}),(0,z.jsx)(f0,{label:`Checked at`,value:t?.checkedAt??`not checked`}),(0,z.jsx)(f0,{label:`Publish gate`,value:t?.blocksPublish?`blocked`:`not blocked`}),(0,z.jsx)(f0,{label:`Run gate`,value:t?.blocksRun?`blocked`:`not blocked`}),(0,z.jsx)(f0,{label:`Diagnostic count`,value:String(e.diagnostics.length)})]}),e.diagnostics.length?(0,z.jsx)(DOe,{draft:e}):(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-3 text-xs text-emerald-200`,children:`No validation diagnostics returned by the draft pipeline.`})]})}function DOe({draft:e}){return(0,z.jsx)(`div`,{className:`mt-3 grid gap-2`,"aria-label":`Workflow structured diagnostics`,children:e.diagnostics.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:13}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(d0,{label:`Severity`,value:e.severity}),(0,z.jsx)(d0,{label:`Path`,value:e.path}),(0,z.jsx)(d0,{label:`Node`,value:e.nodeId}),(0,z.jsx)(d0,{label:`Edge`,value:e.edgeId}),(0,z.jsx)(d0,{label:`Registry ref`,value:e.registryRef})]}),e.hint?(0,z.jsx)(`div`,{className:`mt-2 text-amber-200/80`,children:e.hint}):null]},`${e.code}:${e.path??e.nodeId??e.edgeId??e.registryRef??`workflow`}`))})}function d0({label:e,value:t}){return t?(0,z.jsxs)(`span`,{className:`rounded-sm border border-amber-700/50 bg-amber-950/40 px-2 py-0.5`,children:[(0,z.jsxs)(`span`,{className:`font-semibold text-amber-200/80`,children:[e,`:`]}),` `,(0,z.jsx)(`code`,{children:t})]}):null}function f0({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,z.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-slate-200`,children:t})]})}function p0({icon:e,eyebrow:t,title:n,description:r,children:i}){return(0,z.jsxs)(`section`,{className:`flex min-h-72 flex-col rounded-sm border border-slate-800 bg-[#151f24] p-5 shadow-lg shadow-black/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-[#11a4d4]/35 bg-[#11a4d4]/10 text-[#11a4d4]`,children:(0,z.jsx)(e,{size:18})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:t}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-bold text-slate-100`,children:n}),(0,z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-400`,children:r})]})]}),(0,z.jsx)(`div`,{className:`mt-5 flex flex-1`,children:i})]})}function OOe({title:e,description:t}){return(0,z.jsxs)(`div`,{className:`flex w-full flex-col justify-center rounded-sm border border-dashed border-slate-700 bg-[#101d22]/70 p-4 text-center`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-slate-200`,children:e}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:t})]})}function m0({icon:e,label:t}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/60 px-3 py-2`,children:[(0,z.jsx)(e,{size:14,className:`shrink-0 text-[#11a4d4]`}),(0,z.jsx)(`span`,{children:t})]})}function h0(e,t=`new-agent`){return{displayName:t,description:``,nativeTools:[],skills:T0(e,`pi-agent-harness`)?[`pi-agent-harness`]:[],contextFiles:[],subagents:[],mcpServers:[],piPackages:[],mainModel:void 0,subagentModel:void 0,thinkingLevel:void 0,mainThinkingLevel:void 0,subagentThinkingLevel:void 0,fast:!1,mainFast:!1,subagentFast:!1,builtinTools:`default`,builtinToolNames:[...x0],autoContextFiles:!0,runControl:!1,brokenContextFiles:[],hardPinnedModel:void 0,source:`custom`}}function kOe(e){let t=new Set([...e].map(e=>e.trim()).filter(Boolean)),n=`new-agent`;if(!t.has(n))return n;for(let e=1;;e+=1){let r=`${n}-${e}`;if(!t.has(r))return r}}function g0(e){return{id:e.id,profileName:e.profileName,displayName:e.displayName,description:e.description??``,nativeTools:e.nativeTools,skills:e.skills,contextFiles:e.contextFiles,subagents:e.subagents,mcpServers:e.mcpServers,piPackages:e.piPackages??[],mainModel:e.mainModel,subagentModel:e.subagentModel,thinkingLevel:e.thinkingLevel,mainThinkingLevel:e.mainThinkingLevel,subagentThinkingLevel:e.subagentThinkingLevel,fast:e.fast??!1,mainFast:e.mainFast??!1,subagentFast:e.subagentFast??!1,builtinTools:e.builtinTools,builtinToolNames:b0(e.builtinToolNames,e.builtinTools),autoContextFiles:e.autoContextFiles??!0,runControl:e.runControl,brokenContextFiles:e.brokenContextFiles??[],archivedAt:e.archivedAt,hardPinnedModel:void 0,source:`custom`}}function _0(e,t){return{displayName:e.name,description:e.description??``,nativeTools:e.nativeTools??[],skills:e.skills??(T0(t,`pi-agent-harness`)?[`pi-agent-harness`]:[]),contextFiles:e.contextFiles??[],subagents:e.subagents??[],mcpServers:e.mcpServers??[],piPackages:e.piPackages??[],mainModel:e.mainModel??e.model,subagentModel:e.subagentModel??e.model,thinkingLevel:e.thinkingLevel,mainThinkingLevel:e.mainThinkingLevel??e.thinkingLevel,subagentThinkingLevel:e.subagentThinkingLevel??e.thinkingLevel,fast:e.fast??!1,mainFast:e.mainFast??e.fast??!1,subagentFast:e.subagentFast??e.fast??!1,builtinTools:e.builtinTools??`default`,builtinToolNames:b0(e.builtinToolNames,e.builtinTools),autoContextFiles:e.autoContextFiles??!0,runControl:e.runControl??!1,brokenContextFiles:[],hardPinnedModel:e.model,profileName:e.name,source:`profile`}}function AOe(e,t){return{..._0(e,t),displayName:`${e.name}-copy`,id:void 0,hardPinnedModel:void 0,profileName:void 0,source:`custom`}}function v0(e){return{...g0(e),displayName:`${e.profileName}-copy`,id:void 0,profileName:void 0,archivedAt:void 0,source:`custom`}}function jOe(e,t){let n=new Map;for(let t of e)n.set(t.name,t.name);for(let e of t)n.set(e.profileName,e.displayName);return[...n.entries()].map(([e,t])=>({value:e,label:t}))}function MOe(e){return e.trim()?e.length>120?`Agent name is too long.`:/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e)?null:`Use lowercase kebab-case only, for example test-agent.`:`Agent name is required.`}function y0(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function b0(e,t=`default`){if(t===`disabled`)return[];let n=new Set(e??x0);return x0.filter(e=>n.has(e))}var NOe=new Set([`apply_patch`,`web_search`,`view_image`]),x0=[`read`,`bash`,`edit`,`write`],POe={read:`Read workspace files.`,bash:`Run shell commands.`,edit:`Edit existing files.`,write:`Create or overwrite files.`};function FOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.pluginId??(NOe.has(t.name)?`pibo.codex-compat`:void 0),i=t.pluginName??(e===`pibo.codex-compat`?`Codex Compat`:void 0),a=!e||e===`pibo.core`,o=S0(r,a?`builtin`:`plugin:${e}`,{title:a?`Built-in Tools`:w0(e,i),description:a?`Built-in Pibo tool catalog`:e??`plugin`,kind:a?`builtin`:`plugin`});o.items.push(t),n.has(t.name)&&(o.selectedCount+=1),o.totalCount+=1}return C0(r,[`builtin`,`plugin`])}function IOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.kind,i=S0(r,e===`plugin`?`plugin:${t.pluginId??t.name}`:e,{title:ROe(t),description:zOe(t),kind:t.kind});i.items.push(t),n.has(t.name)&&(i.selectedCount+=1),i.totalCount+=1}return C0(r,[`builtin`,`plugin`,`user`])}function LOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.pluginId===`pibo.core`,i=!t.pluginId,a=S0(r,e?`builtin`:i?`custom`:`plugin:${t.pluginId}`,{title:e?`Built-in Context Files`:i?`Custom`:w0(t.pluginId,t.pluginName),description:e?`Pibo built-in context file catalog`:i?`Loose context files without a plugin namespace`:t.pluginId??`plugin`,kind:e?`builtin`:i?`custom`:`plugin`});a.items.push(t),n.has(t.key)&&(a.selectedCount+=1),a.totalCount+=1}return C0(r,[`builtin`,`custom`,`plugin`])}function S0(e,t,n){let r=e.get(t);if(r)return r;let i={key:t,title:n.title,description:n.description,kind:n.kind,items:[],selectedCount:0,totalCount:0,defaultOpen:!1};return e.set(t,i),i}function C0(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e.values()].sort((e,r)=>{let i=n.get(e.kind)??t.length,a=n.get(r.kind)??t.length;return i===a?e.title.localeCompare(r.title):i-a}).map(e=>({...e,defaultOpen:!1}))}function w0(e,t){return e===`pibo.codex-compat`?`Codex Compat`:t||(e?(e.split(`.`).filter(Boolean).at(-1)??e).split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `):`Plugin`)}function ROe(e){return e.kind===`builtin`?`Built-in Skills`:e.kind===`user`?`User Skills`:w0(e.pluginId,e.pluginName)}function zOe(e){return e.kind===`builtin`?`Pibo-owned built-in skill catalog`:e.kind===`user`?`User-managed skills`:e.pluginId??`plugin`}function BOe(e){return e.kind===`builtin`?`built-in skill`:e.kind===`user`?`user skill`:e.pluginName??e.pluginId??`plugin skill`}function T0(e,t){return e?.skills.some(e=>e.kind===`builtin`&&e.name===t)??!1}function VOe(e){let t=e.source??`plugin`,n=e.scope??`global`;return e.pluginId===`pibo.core`?`built-in global`:t===`plugin`?`plugin global`:n===`agent`?e.agentProfileName?`agent ${e.agentProfileName}`:`agent local`:`managed global`}function E0(e,t){return e.includes(t.id)||e.includes(t.name)}function HOe(e,t){return E0(e,t)?e.filter(e=>e!==t.id&&e!==t.name):[...e,t.id]}function UOe(e){return e.enabled&&e.installStatus===`installed`}function D0(e){let t=e.resourceTypes.length?e.resourceTypes.join(` + `):`resources pending`,n=e.version?`v${e.version}`:e.installStatus,r=e.diagnostics.some(e=>e.type===`error`)?` / needs attention`:``;return`${t} / ${n} / ${e.enabled?`enabled`:`disabled`}${r}`}function O0(){return`Agent Designer API unavailable. Restart the Pibo web gateway after pulling/building the latest backend.`}function WOe(e){return e.toLowerCase().includes(`not found`)||e.includes(`404`)}function k0({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`border border-slate-700 bg-[#1a262b] rounded-sm p-4`,children:[(0,z.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wider text-slate-400 mb-3`,children:e}),(0,z.jsx)(`div`,{className:`grid gap-3`,children:t})]})}function GOe({title:e,children:t}){return(0,z.jsx)(k0,{title:e,children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:t})})}function A0({groups:e,empty:t,renderItem:n}){return e.length===0?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(`div`,{className:`grid gap-2`,children:e.map(e=>(0,z.jsx)(KOe,{group:e,renderItem:n},e.key))})}function KOe({group:e,renderItem:t}){let[n,r]=(0,R.useState)(e.defaultOpen),i=e.items.slice(0,100),a=e.items.length-i.length,o=e.kind===`custom`||e.kind===`user`?`border-[#f59e0b]/70 text-amber-100 bg-[#f59e0b]/10`:`border-[#11a4d4]/70 text-sky-100 bg-[#11a4d4]/10`;return(0,z.jsxs)(`div`,{className:`border rounded-sm ${n?`border-slate-700 bg-[#101d22]`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-2 p-2 text-left`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 shrink-0 inline-flex items-center justify-center border rounded-sm ${o}`,children:n?(0,z.jsx)(zo,{size:14}):(0,z.jsx)(Bo,{size:14})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-slate-100`,children:e.title}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:e.description})]}),(0,z.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-sm font-semibold tabular-nums`,"aria-label":`${e.selectedCount} of ${e.totalCount} selected`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:e.selectedCount}),(0,z.jsxs)(`span`,{className:`text-slate-500`,children:[`/`,e.totalCount]})]})]}),n?(0,z.jsxs)(`div`,{className:`border-t border-slate-800 p-2`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:i.map(t)}),a>0?(0,z.jsxs)(`div`,{className:`mt-2 text-xs text-slate-500`,children:[`Showing first `,100,` of `,e.items.length,` items. Use Context to manage the full catalog.`]}):null]}):null]})}function j0({checked:e,disabled:t,title:n,description:r,meta:i,metaClass:a,actionLabel:o,actionIcon:s,actionDisabled:c,onAction:l,onToggle:u}){return(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{t||u()},"aria-disabled":t,className:`min-w-0 border rounded-sm p-2 text-left grid grid-cols-[18px_1fr] gap-2 ${t&&!l?`opacity-60`:``} ${e?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(F0,{checked:e,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:n})}),o&&l?(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsxs)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.preventDefault(),e.stopPropagation(),c||l()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&!c&&(e.preventDefault(),e.stopPropagation(),l())},className:`inline-flex h-6 items-center justify-center gap-1 border px-1.5 text-[10px] uppercase tracking-wider ${c?`border-slate-800 text-slate-600`:`border-[#11a4d4]/70 text-[#7dd3fc] hover:border-[#11a4d4] hover:text-sky-100`}`,children:[s,o]})}):null]}),r?(0,z.jsx)(`span`,{className:`block text-xs text-slate-500 truncate`,children:r}):null,i?(0,z.jsx)(`span`,{className:`block font-mono text-[10px] mt-1 ${a??`text-slate-600`}`,children:i}):null]})]})}function qOe({pkg:e,selected:t,readOnly:n,expanded:r,busy:i,onToggleSelected:a,onToggleExpanded:o,onToggleEnabled:s,onUnregister:c}){let l=e.diagnostics.some(e=>e.type===`error`),u=!n&&(e.enabled||t);return(0,z.jsxs)(`div`,{className:`border rounded-sm ${t?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24]`} ${e.enabled?``:`opacity-75`}`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 p-2`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:!u,onClick:a,className:`min-w-0 grid grid-cols-[18px_1fr] gap-2 text-left disabled:cursor-not-allowed`,children:[(0,z.jsx)(F0,{checked:t,disabled:!u,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-slate-200`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${e.enabled?`border-[#11a4d4]/60 text-[#7dd3fc]`:`border-slate-700 text-slate-500`}`,children:e.enabled?`enabled`:`disabled`})]}),(0,z.jsx)(`span`,{className:`block text-xs text-slate-500 truncate`,children:e.description??e.source}),(0,z.jsx)(`span`,{className:`block font-mono text-[10px] mt-1 ${l?`text-[#f59e0b]`:`text-[#11a4d4]`}`,children:D0(e)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,title:r?`Hide Details`:`Show Details`,"aria-label":r?`Hide Details`:`Show Details`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:r?(0,z.jsx)(zo,{size:13}):(0,z.jsx)(Bo,{size:13})}),s?(0,z.jsx)(`button`,{type:`button`,disabled:i,onClick:s,title:e.enabled?`Disable Package`:`Enable Package`,"aria-label":e.enabled?`Disable Package`:`Enable Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:e.enabled?(0,z.jsx)(Fs,{size:13}):(0,z.jsx)(Is,{size:13})}):null,c?(0,z.jsx)(`button`,{type:`button`,disabled:i,onClick:c,title:`Unregister Package`,"aria-label":`Unregister Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-400 hover:text-red-300 disabled:opacity-50`,children:(0,z.jsx)(qs,{size:13})}):null]})]}),r?(0,z.jsx)(M0,{pkg:e}):null]})}function M0({pkg:e}){return(0,z.jsxs)(`div`,{className:`border-t border-slate-800 p-3 grid gap-3 text-xs text-slate-300`,children:[(0,z.jsx)(JOe,{rows:[[`Source`,e.source],[`Install`,e.installSpec],[`Version`,e.version],[`Added`,e.addedAt],[`Updated`,e.updatedAt]]}),e.repositoryUrl?(0,z.jsxs)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-[#7dd3fc] hover:text-sky-100`,children:[(0,z.jsx)(rs,{size:12}),`Source repository`]}):null,(0,z.jsx)(N0,{title:`Extensions`,values:e.extensionPaths}),(0,z.jsx)(N0,{title:`Skills`,values:e.skillNames}),(0,z.jsx)(N0,{title:`Prompts`,values:e.promptNames}),(0,z.jsx)(N0,{title:`Themes`,values:e.themeNames}),(0,z.jsx)(N0,{title:`Tools`,values:e.discoveredToolNames}),e.diagnostics.length?(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Diagnostics`}),e.diagnostics.map((e,t)=>(0,z.jsxs)(`div`,{className:`border px-2 py-1 rounded-sm ${e.type===`error`?`border-red-500/50 text-red-200 bg-red-500/10`:e.type===`warning`?`border-[#f59e0b]/50 text-amber-100 bg-[#f59e0b]/10`:`border-slate-700 text-slate-400 bg-[#0e1116]`}`,children:[(0,z.jsx)(`span`,{className:`font-mono uppercase text-[10px] mr-2`,children:e.type}),e.message]},`${e.type}:${t}`))]}):null]})}function JOe({rows:e}){let t=e.filter(([,e])=>e);return t.length===0?null:(0,z.jsx)(`div`,{className:`grid gap-1`,children:t.map(([e,t])=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)] gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[11px] text-slate-300`,children:t})]},e))})}function N0({title:e,values:t}){return t?.length?(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,z.jsx)(`span`,{className:`max-w-full break-all border border-slate-700 bg-[#0e1116] px-2 py-1 font-mono text-[11px] text-slate-300 rounded-sm`,children:e},e))})]}):null}function P0({checked:e,disabled:t,title:n,onToggle:r}){return(0,z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":e,onClick:r,className:`inline-flex w-fit items-center gap-2 text-left text-sm text-slate-300 hover:text-slate-100 disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:e,disabled:t}),(0,z.jsx)(`span`,{children:n})]})}function F0({checked:e,disabled:t,className:n=``}){return(0,z.jsx)(`span`,{className:`h-4 w-4 shrink-0 border rounded-sm inline-flex items-center justify-center ${e?`border-[#11a4d4] text-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-600 text-transparent`} ${t?`opacity-70`:``} ${n}`,children:e?(0,z.jsx)(Ro,{size:12}):null})}function I0({message:e=`Agent Designer API unavailable`}){return(0,z.jsx)(`div`,{className:`text-xs text-amber-100 border border-dashed border-[#f59e0b]/50 bg-[#f59e0b]/10 rounded-sm p-3`,children:e})}function L0({title:e,modelTitle:t,model:n,thinking:r,fast:i,modelCatalog:a,readOnly:o,modelHint:s,configuredProvidersOnly:c=!1,onModelChange:l,onThinkingChange:u,onFastChange:d}){return(0,z.jsxs)(`div`,{className:`grid gap-2 border border-slate-800 rounded-sm p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(150px,190px)_auto] lg:items-start`,children:[(0,z.jsx)(XOe,{title:t,catalog:a,value:n,allowUnset:!0,readOnly:o,hint:s,emptyProviderLabel:`Default`,configuredProvidersOnly:c,onChange:l}),(0,z.jsx)(YOe,{title:`Thinking`,value:r,readOnly:o,reserveHintSpace:!0,onChange:u}),(0,z.jsxs)(`div`,{className:`grid gap-2 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:`Fast`}),(0,z.jsx)(`div`,{className:`h-4`,"aria-hidden":`true`}),(0,z.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>d(!i),className:`inline-flex h-9 w-fit items-center gap-2 text-left text-sm text-slate-300 hover:text-slate-100 disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:i===!0,disabled:o}),(0,z.jsx)(`span`,{children:i?`Fast on`:`Fast off`})]})]})]})]})}function YOe({title:e,value:t,readOnly:n,hint:r,reserveHintSpace:i=!1,onChange:a}){return(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`button`,{type:`button`,disabled:n||!t,onClick:()=>a(void 0),className:`text-[10px] uppercase tracking-wider text-slate-500 hover:text-slate-300 disabled:opacity-50`,children:`Unset`})]}),r?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:r}):i?(0,z.jsx)(`div`,{className:`h-4`,"aria-hidden":`true`}):null,(0,z.jsxs)(`select`,{value:t??``,disabled:n,onChange:e=>a(e.target.value?e.target.value:void 0),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:`Default`}),Zq.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function XOe({title:e,catalog:t,value:n,allowUnset:r,readOnly:i,hint:a,emptyProviderLabel:o=`Select provider`,configuredProvidersOnly:s=!1,onChange:c}){let[l,u]=(0,R.useState)(n?.provider??``),[d,f]=(0,R.useState)(n?.id??``),p=t?.providers??[],m=p.filter(e=>!s||e.authConfigured),h=m.find(e=>e.id===l),g=s?p.find(e=>e.id===l&&!e.authConfigured):void 0,_=!!l&&!h,v=_?g?`${g.label} (not configured)`:`${l} (unknown provider)`:``,y=h?.models.find(e=>e.id===d),b=!!(l&&d&&h&&!y),x=h?.models??[],S=h?.authConfigured;return(0,R.useEffect)(()=>{u(n?.provider??``),f(n?.id??``)},[n?.id,n?.provider]),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:e}),r?(0,z.jsx)(`button`,{type:`button`,disabled:i||!l&&!d,onClick:()=>{u(``),f(``),c(void 0)},className:`text-[10px] uppercase tracking-wider text-slate-500 hover:text-slate-300 disabled:opacity-50`,children:`Unset`}):null]}),a?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:a}):null,m.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:p.length===0?`Model catalog unavailable.`:`No configured providers. Configure a provider under Settings > Providers.`}):null,(0,z.jsxs)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:[(0,z.jsxs)(`select`,{value:l,disabled:i,onChange:e=>{let t=e.target.value;u(t),f(``)},className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:o}),m.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id)),_?(0,z.jsx)(`option`,{value:l,children:v}):null]}),(0,z.jsxs)(`select`,{value:d,disabled:i,onChange:e=>{let t=e.target.value;f(t),l&&t&&c({provider:l,id:t})},className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:l?`Select model`:`Select provider first`}),x.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id)),b?(0,z.jsx)(`option`,{value:d,children:`${d} (unknown model)`}):null]})]}),l?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:_?g?`Stored provider is no longer configured.`:`Stored provider is no longer present in the catalog.`:S?`Provider auth configured.`:`Provider auth missing.`}):null,b?(0,z.jsx)(`div`,{className:`text-xs text-amber-100`,children:`Stored model is no longer present in the catalog.`}):null]})}function ZOe({agents:e,initialCustomAgents:t,initialCatalog:n,modelCatalog:r,onSelect:i,onCreateSession:a,onEditContextFile:o,onEditMcpServer:s,onAgentsChanged:c,creatingSession:l}){let[u,d]=(0,R.useState)(n??null),[f,p]=(0,R.useState)(t),[m,h]=(0,R.useState)(()=>h0(n)),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(()=>localStorage.getItem(`pibo.chat.showArchivedAgents`)===`true`),[S,C]=(0,R.useState)(``),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(``),[O,k]=(0,R.useState)(`agent`),A=!!u;(0,R.useEffect)(()=>p(t),[t]),(0,R.useEffect)(()=>{n&&d(n)},[n]);let j=(0,R.useMemo)(()=>new Set(f.map(e=>e.profileName)),[f]),M=(0,R.useMemo)(()=>e.filter(e=>!j.has(e.name)),[e,j]),N=(0,R.useMemo)(()=>f.filter(e=>!e.archivedAt),[f]),P=(0,R.useMemo)(()=>f.filter(e=>e.archivedAt),[f]),F=(0,R.useMemo)(()=>jOe(e,N),[e,N]),ee=!!m.archivedAt,te=g&&m.source===`custom`&&!m.id,I=m.source===`profile`||ee,ne=I?null:MOe(m.displayName),L=m.profileName??(ne?`new custom profile`:m.displayName),re=(0,R.useMemo)(()=>u?.contextFiles.filter(e=>(e.scope??`global`)===`agent`?e.agentProfileName===L||m.contextFiles.includes(e.key):!0)??[],[u,m.contextFiles,L]),ie=(0,R.useMemo)(()=>FOe(u?.nativeTools??[],m.nativeTools),[u?.nativeTools,m.nativeTools]),ae=(0,R.useMemo)(()=>IOe(u?.skills??[],m.skills),[u?.skills,m.skills]),oe=(0,R.useMemo)(()=>LOe(re,m.contextFiles),[re,m.contextFiles]),se=()=>{let t=[...e.map(e=>e.name),...f.flatMap(e=>[e.profileName,e.displayName]),...te?[m.displayName]:[]];h(h0(u??void 0,kOe(t))),_(!0),T(null)},ce=async()=>{if(!I){if(ne){T(ne);return}if(!A){T(O0());return}y(!0);try{let e={displayName:m.displayName.trim(),description:(m.description??``).trim()||void 0,nativeTools:m.nativeTools,skills:m.skills,contextFiles:m.contextFiles,subagents:m.subagents.filter(e=>e.name.trim()&&e.targetProfile.trim()),mcpServers:m.mcpServers,piPackages:m.piPackages,mainModel:m.mainModel,subagentModel:m.subagentModel,thinkingLevel:m.thinkingLevel??null,mainThinkingLevel:m.mainThinkingLevel??null,subagentThinkingLevel:m.subagentThinkingLevel??null,fast:m.fast,mainFast:m.mainFast,subagentFast:m.subagentFast,builtinTools:m.builtinTools,builtinToolNames:m.builtinToolNames,autoContextFiles:m.autoContextFiles,runControl:m.runControl},t=m.id?await WW(m.id,e):await UW(e);p(e=>{let n=e.filter(e=>e.id!==t.agent.id);return[t.agent,...n]}),h(g0(t.agent)),_(!1),i(t.agent.profileName),c(),T(null)}catch(e){let t=e instanceof Error?e.message:String(e);T(WOe(t)?O0():t)}finally{y(!1)}}},le=async e=>{if(!(!m.id||m.source!==`custom`)){y(!0);try{let t=await WW(m.id,{archived:e});e&&(x(!0),localStorage.setItem(`pibo.chat.showArchivedAgents`,`true`)),p(e=>e.map(e=>e.id===t.agent.id?t.agent:e)),h(g0(t.agent)),C(``),c(),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}},ue=async()=>{if(!(I||!A||!E.trim())){if(ne){T(ne);return}y(!0);try{let e=(await sl({label:E.trim(),scope:O,agentProfileName:O===`agent`?L:void 0,markdown:``})).file;d(t=>t&&{...t,contextFiles:[...t.contextFiles,e]}),h(t=>({...t,contextFiles:t.contextFiles.includes(e.key)?t.contextFiles:[...t.contextFiles,e.key]})),D(``),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}},de=async()=>{if(!(!m.id||!m.profileName||!ee)){y(!0);try{await GW(m.id,S),p(e=>e.filter(e=>e.id!==m.id)),h(h0(u??void 0)),_(!1),C(``),c(),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}};return(0,z.jsxs)(`div`,{className:`h-full min-h-0 overflow-hidden grid grid-cols-[300px_minmax(0,1fr)] max-[920px]:grid-cols-1`,children:[(0,z.jsxs)(`aside`,{className:`border-r border-slate-800 bg-[#1a262b] min-h-0 overflow-auto`,children:[(0,z.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider`,children:[(0,z.jsx)(`span`,{children:`Agents`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:se,title:`New Agent`,"aria-label":`New Agent`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ps,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let e=!b;x(e),localStorage.setItem(`pibo.chat.showArchivedAgents`,String(e))},title:b?`Hide Archived Agents`:`Show Archived Agents`,"aria-label":b?`Hide Archived Agents`:`Show Archived Agents`,className:`p-1 border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${b?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:b?(0,z.jsx)(wo,{size:13}):(0,z.jsx)(To,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:c,title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ls,{size:13})})]})]}),(0,z.jsxs)(`div`,{className:`p-2`,children:[(0,z.jsxs)(R0,{title:`Custom Agents`,children:[te?(0,z.jsx)(z0,{title:m.displayName||`new-agent`,subtitle:`unsaved custom agent`,selected:!0,onSelect:()=>{},onCreateSession:()=>{},createSessionDisabled:!0},`unsaved-agent-draft`):null,N.map(e=>(0,z.jsx)(z0,{title:e.displayName,subtitle:e.profileName,selected:m.source===`custom`&&m.id===e.id,onSelect:()=>{_(!1),h(g0(e)),i(e.profileName)},onCopy:()=>{h(v0(e)),_(!0)},onCreateSession:()=>{i(e.profileName),a(e.profileName)},createSessionDisabled:l},e.id)),N.length===0&&!te?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No custom agents`}):null]}),b?(0,z.jsxs)(R0,{title:`Archived Custom Agents`,children:[P.map(e=>(0,z.jsx)(z0,{title:e.displayName,subtitle:e.profileName,selected:m.source===`custom`&&m.id===e.id,onSelect:()=>{_(!1),h(g0(e))},onCopy:()=>{h(v0(e)),_(!0)},onCreateSession:()=>{},createSessionDisabled:!0},e.id)),P.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No archived agents`}):null]}):null,(0,z.jsx)(R0,{title:`Read-only Profiles`,children:M.map(e=>(0,z.jsx)(z0,{title:e.name,subtitle:e.aliases.join(`, `)||`plugin`,selected:m.source===`profile`&&m.profileName===e.name,onSelect:()=>{_(!1),h(_0(e,u??void 0)),i(e.name)},onCopy:()=>{h(AOe(e,u??void 0)),_(!0)},onCreateSession:()=>{i(e.name),a(e.name)},createSessionDisabled:l},e.name))})]})]}),(0,z.jsxs)(`section`,{className:`min-h-0 overflow-auto p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-sm font-bold uppercase tracking-wider`,children:`Agent Designer`}),(0,z.jsx)(`div`,{className:`font-mono text-[11px] text-slate-500 truncate`,children:L}),(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:m.source===`profile`?`read-only plugin profile`:ee?`archived custom agent`:`custom agent`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>{m.profileName&&(i(m.profileName),a(m.profileName))},disabled:!m.profileName||l||ee,title:`New Session With Agent`,"aria-label":`New Session With Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ds,{size:14})}),m.source===`custom`&&m.id?(0,z.jsx)(`button`,{type:`button`,onClick:()=>void le(!ee),disabled:v,title:ee?`Restore Agent`:`Archive Agent`,"aria-label":ee?`Restore Agent`:`Archive Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:ee?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>void ce(),disabled:I||!A||v||!!ne,title:`Save Agent`,"aria-label":`Save Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-[#11a4d4] rounded-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:(0,z.jsx)(Bs,{size:14})})]})]}),A?null:(0,z.jsx)(`div`,{className:`mb-3 border border-[#f59e0b]/60 bg-[#f59e0b]/10 text-amber-100 px-3 py-2 text-sm rounded-sm`,children:O0()}),m.source===`profile`?(0,z.jsx)(`div`,{className:`mb-3 border border-slate-700 bg-[#151f24] text-slate-300 px-3 py-2 text-sm rounded-sm`,children:`This profile is registered by a plugin. Copy it to create an editable custom agent.`}):null,ee?(0,z.jsx)(`div`,{className:`mb-3 border border-[#f59e0b]/60 bg-[#f59e0b]/10 text-amber-100 px-3 py-2 text-sm rounded-sm`,children:`This agent is archived. Restore it before editing or starting new sessions.`}):null,w?(0,z.jsx)(`div`,{className:`mb-3 border border-red-500/60 bg-red-500/10 text-red-200 px-3 py-2 text-sm rounded-sm`,children:w}):null,(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(k0,{title:`Basics`,children:[(0,z.jsx)(`input`,{value:m.displayName,disabled:I,onChange:e=>h(t=>({...t,displayName:e.target.value})),className:`min-w-0 bg-[#0e1116] border rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60 ${ne?`border-[#f59e0b]`:`border-slate-700`}`,placeholder:`agent-name`}),ne?(0,z.jsx)(`div`,{className:`text-xs text-amber-100`,children:ne}):null,(0,z.jsx)(`textarea`,{value:m.description,disabled:I,onChange:e=>h(t=>({...t,description:e.target.value})),className:`min-h-[72px] bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`Description`}),m.source===`profile`&&m.hardPinnedModel?(0,z.jsxs)(`div`,{className:`border border-slate-700 bg-[#151f24] text-slate-300 px-3 py-2 text-xs rounded-sm`,children:[`This plugin profile hard-pins `,(0,z.jsx)(`span`,{className:`font-mono`,children:nke(m.hardPinnedModel)}),`. Main-agent and subagent defaults do not apply.`]}):null,(0,z.jsx)(L0,{title:`Main Agent`,modelTitle:`Main Agent Model`,model:m.mainModel,thinking:m.mainThinkingLevel,fast:m.mainFast??!1,modelCatalog:r,readOnly:I,modelHint:`Unset to use the settings default.`,onModelChange:e=>h(t=>({...t,mainModel:e})),onThinkingChange:e=>h(t=>({...t,mainThinkingLevel:e})),onFastChange:e=>h(t=>({...t,mainFast:e}))}),(0,z.jsx)(L0,{title:`Subagent`,modelTitle:`Subagent Model`,model:m.subagentModel,thinking:m.subagentThinkingLevel,fast:m.subagentFast??!1,modelCatalog:r,readOnly:I,modelHint:`Unset to use the settings default.`,onModelChange:e=>h(t=>({...t,subagentModel:e})),onThinkingChange:e=>h(t=>({...t,subagentThinkingLevel:e})),onFastChange:e=>h(t=>({...t,subagentFast:e}))}),(0,z.jsx)(P0,{disabled:I,checked:m.autoContextFiles,title:`Load AGENTS.md / CLAUDE.md`,onToggle:()=>h(e=>({...e,autoContextFiles:!e.autoContextFiles}))}),(0,z.jsx)($Oe,{draft:m,setDraft:h,readOnly:I})]}),(0,z.jsx)(k0,{title:`Tools`,children:(0,z.jsx)(A0,{groups:ie,empty:u?(0,z.jsx)(I0,{message:`No native tools registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.nativeTools.includes(e.name),title:e.name,description:e.description,meta:e.yieldable?`yieldable`:`direct only`,onToggle:()=>h(t=>({...t,nativeTools:y0(t.nativeTools,e.name)}))},e.name)})}),(0,z.jsx)(k0,{title:`Skills`,children:(0,z.jsx)(A0,{groups:ae,empty:u?(0,z.jsx)(I0,{message:`No skills registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.skills.includes(e.name),title:e.name,description:e.path,meta:BOe(e),metaClass:e.kind===`user`?`text-amber-200`:`text-[#11a4d4]`,onToggle:()=>h(t=>({...t,skills:y0(t.skills,e.name)}))},e.name)})}),(0,z.jsx)(GOe,{title:`Packages`,children:(0,z.jsx)(j0,{disabled:I,checked:m.runControl,title:`pibo-run-control`,description:`Expose pibo_run_* as one package for yielded native tools and subagents.`,meta:`package`,onToggle:()=>h(e=>({...e,runControl:!e.runControl}))})}),(0,z.jsx)(QOe,{packages:u?.piPackages,draft:m,setDraft:h,readOnly:I}),(0,z.jsxs)(k0,{title:`Context Files`,children:[m.brokenContextFiles?.length?(0,z.jsxs)(`div`,{className:`border border-red-500/60 bg-red-500/10 rounded-sm p-3 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-red-100`,children:[(0,z.jsx)(Js,{size:14,className:`mt-0.5 shrink-0`}),(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium`,children:`This agent references missing context files.`}),(0,z.jsx)(`div`,{className:`text-xs text-red-200/90`,children:`Remove these broken links and save the agent to persist the cleanup.`})]})]}),(0,z.jsx)(`div`,{className:`grid gap-2`,children:m.brokenContextFiles.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border border-red-500/40 bg-[#2a1417] rounded-sm px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm text-red-100`,children:e}),(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-red-300/80`,children:`Broken link`})]}),(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>h(t=>({...t,contextFiles:t.contextFiles.filter(t=>t!==e),brokenContextFiles:(t.brokenContextFiles??[]).filter(t=>t!==e)})),className:`h-8 w-8 inline-flex items-center justify-center border border-red-500/60 rounded-sm text-red-200 hover:border-red-400 hover:text-red-100 disabled:opacity-50`,title:`Remove Broken Context File`,"aria-label":`Remove Broken Context File`,children:(0,z.jsx)(Qs,{size:14})})]},e))})]}):null,(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,z.jsx)(`input`,{value:E,disabled:I,onChange:e=>D(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`New context file`}),(0,z.jsx)(`button`,{type:`button`,disabled:I||v||!E.trim()||!!ne,onClick:()=>void ue(),title:`Create Context File`,"aria-label":`Create Context File`,className:`h-9 w-9 inline-flex items-center justify-center border border-[#11a4d4] rounded-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})})]}),(0,z.jsxs)(`div`,{className:`inline-flex w-fit gap-1 border border-slate-800 bg-[#0e1116] rounded-sm p-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>k(`agent`),className:`px-2 py-1 text-xs rounded-sm ${O===`agent`?`bg-[#11a4d4]/20 text-sky-100`:`text-slate-500 hover:text-slate-300`}`,children:`Agent`}),(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>k(`global`),className:`px-2 py-1 text-xs rounded-sm ${O===`global`?`bg-[#11a4d4]/20 text-sky-100`:`text-slate-500 hover:text-slate-300`}`,children:`Global`})]}),(0,z.jsx)(A0,{groups:oe,empty:u?(0,z.jsx)(I0,{message:`No context files registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.contextFiles.includes(e.key),title:e.label??e.key,description:e.path,meta:VOe(e),metaClass:`text-[#11a4d4]`,actionLabel:`Edit`,actionIcon:(0,z.jsx)(Ms,{size:12}),onAction:()=>o(e.key),onToggle:()=>h(t=>({...t,contextFiles:y0(t.contextFiles,e.key)}))},e.key)})]}),(0,z.jsx)(eke,{draft:m,setDraft:h,profileOptions:F,readOnly:I}),(0,z.jsx)(tke,{servers:u?.mcpServers,draft:m,setDraft:h,readOnly:I,onEditServer:s}),ee&&m.profileName?(0,z.jsxs)(k0,{title:`Delete Agent`,children:[(0,z.jsxs)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:[`Permanently deleting this agent also deletes all Chat sessions that use profile `,(0,z.jsx)(`span`,{className:`font-mono`,children:m.profileName}),`.`]}),(0,z.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:m.profileName}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void de(),disabled:v||S!==m.profileName,className:`h-8 w-fit inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,z.jsx)(qs,{size:14}),`Delete permanently`]})]}):null]})]})]})}function R0({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),t]})}function z0({title:e,subtitle:t,selected:n,onSelect:r,onCopy:i,onCreateSession:a,createSessionDisabled:o}){return(0,z.jsx)(`div`,{className:`mb-1 border rounded-sm ${n?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-transparent hover:border-slate-700`}`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] items-center gap-1 p-1`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 text-left px-1 py-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:e}),(0,z.jsx)(`span`,{className:`block text-[10px] font-mono truncate text-slate-500`,children:t})]}),i?(0,z.jsx)(`button`,{type:`button`,onClick:i,title:`Copy To Custom Agent`,"aria-label":`Copy To Custom Agent`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qo,{size:13})}):(0,z.jsx)(`span`,{className:`h-7 w-7`}),(0,z.jsx)(`button`,{type:`button`,onClick:a,disabled:o,title:`New Session With Profile`,"aria-label":`New Session With Profile`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ds,{size:13})})]})})}function QOe({packages:e,draft:t,setDraft:n,readOnly:r}){let[i,a]=(0,R.useState)(()=>new Set),o=e??[],s=o.filter(UOe),c=s.filter(e=>E0(t.piPackages,e)).length,l=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,z.jsxs)(k0,{title:`Pi Packages`,children:[(0,z.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:[s.length,` available / `,c,` selected / `,o.length,` registered`]}),e?s.length?(0,z.jsx)(`div`,{className:`grid gap-2`,children:s.map(e=>(0,z.jsx)(qOe,{pkg:e,selected:E0(t.piPackages,e),readOnly:r,expanded:i.has(e.id),busy:!1,onToggleSelected:()=>{r||n(t=>({...t,piPackages:HOe(t.piPackages,e)}))},onToggleExpanded:()=>l(e.id)},e.id))}):(0,z.jsx)(I0,{message:`No installed and enabled Pi packages available. Manage Pi Packages in Settings.`}):(0,z.jsx)(I0,{})]})}function $Oe({draft:e,setDraft:t,readOnly:n}){let r=b0(e.builtinToolNames,e.builtinTools),[i,a]=(0,R.useState)(r.length!==x0.length),o=e=>{t(t=>{let n=y0(b0(t.builtinToolNames,t.builtinTools),e);return{...t,builtinTools:n.length===0?`disabled`:`default`,builtinToolNames:n}})};return(0,z.jsxs)(`div`,{className:`border rounded-sm ${i?`border-slate-700 bg-[#101d22]`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 p-2 text-left`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 shrink-0 inline-flex items-center justify-center border rounded-sm border-[#11a4d4]/70 text-sky-100 bg-[#11a4d4]/10`,children:i?(0,z.jsx)(zo,{size:14}):(0,z.jsx)(Bo,{size:14})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-slate-100`,children:`Pi Built-in Tools`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`basic model tools`})]}),(0,z.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-sm font-semibold tabular-nums`,"aria-label":`${r.length} of ${x0.length} enabled`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:r.length}),(0,z.jsxs)(`span`,{className:`text-slate-500`,children:[`/`,x0.length]})]})]}),i?(0,z.jsx)(`div`,{className:`border-t border-slate-800 p-2`,children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:x0.map(e=>(0,z.jsx)(j0,{disabled:n,checked:r.includes(e),title:e,description:POe[e],meta:`built-in`,onToggle:()=>o(e)},e))})}):null]})}function eke({draft:e,setDraft:t,profileOptions:n,readOnly:r}){let i=(e,n)=>{t(t=>({...t,subagents:t.subagents.map((t,r)=>r===e?{...t,...n}:t)}))};return(0,z.jsxs)(k0,{title:`Subagents`,children:[(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>t(e=>({...e,subagents:[...e.subagents,{name:`helper`,targetProfile:n[0]?.value??`base`,maxDepth:3}]})),className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,title:`Add Subagent`,"aria-label":`Add Subagent`,children:(0,z.jsx)(Ps,{size:13})})}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[e.subagents.map((e,a)=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr_80px_auto] max-[1100px]:grid-cols-1 gap-2 border border-slate-800 bg-[#151f24] p-2 rounded-sm`,children:[(0,z.jsx)(`input`,{value:e.name,disabled:r,onChange:e=>i(a,{name:e.target.value}),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`name`}),(0,z.jsx)(`select`,{value:e.targetProfile,disabled:r,onChange:e=>i(a,{targetProfile:e.target.value}),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:n.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`input`,{type:`number`,min:1,disabled:r,value:e.maxDepth??3,onChange:e=>i(a,{maxDepth:Number(e.target.value)||1}),className:`bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`}),(0,z.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>t(e=>({...e,subagents:e.subagents.filter((e,t)=>t!==a)})),className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-500 hover:text-red-300 disabled:opacity-50`,title:`Remove Subagent`,"aria-label":`Remove Subagent`,children:(0,z.jsx)(Qs,{size:14})})]},a)),e.subagents.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:`No subagents configured`}):null]})]})}function tke({servers:e,draft:t,setDraft:n,readOnly:r,onEditServer:i}){return(0,z.jsx)(k0,{title:`MCP Servers`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:[e?e.map(e=>{let a=r||!e.hasDescription;return(0,z.jsxs)(`div`,{className:`border rounded-sm bg-[#151f24] p-2 ${t.mcpServers.includes(e.name)?`border-[#11a4d4]`:e.hasDescription?`border-slate-800`:`border-[#f59e0b]/60`}`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>n(t=>({...t,mcpServers:y0(t.mcpServers,e.name)})),className:`grid w-full min-w-0 grid-cols-[18px_1fr] gap-2 text-left disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:t.mcpServers.includes(e.name),disabled:a,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Us,{size:13,className:`text-[#11a4d4]`}),(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:e.name})]}),(0,z.jsxs)(`span`,{className:`block font-mono text-[10px] mt-1 text-slate-600`,children:[e.transport,e.descriptionSource?` / ${e.descriptionSource}`:``]})]})]}),e.hasDescription?(0,z.jsx)(`div`,{className:`mt-2 text-xs text-slate-400`,children:e.description}):(0,z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-xs text-amber-100`,children:[(0,z.jsx)(Js,{size:13}),`Missing agent description`]}),(0,z.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(e.name),title:`Edit MCP Tool Context`,"aria-label":`Edit MCP Tool Context`,className:`inline-flex h-6 items-center justify-center gap-1 border border-[#11a4d4]/70 px-1.5 text-[10px] uppercase tracking-wider text-[#7dd3fc] hover:border-[#11a4d4] hover:text-sky-100`,children:[(0,z.jsx)(Ms,{size:12}),`Edit`]})})]},e.name)}):(0,z.jsx)(I0,{}),e&&e.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:`No MCP servers configured`}):null]})})}function nke(e){return`${e.provider}/${e.id}`}var B0=`pibo.chat.lastSelection`,V0=`pibo.chat.sessionView`,H0=`pibo.chat.composerDraft.`,U0=`pibo.chat.composerHistory`,W0=`pibo.chat.showThinking`,G0=`pibo.chat.expandThinking`,K0=`pibo.chat.showRawEvents`,q0=`pibo.chat.showArchived`,J0=`pibo.chat.showArchivedRooms`,Y0=`pibo.chat.newSessionProfile`,X0=100;function Z0(){try{let e=localStorage.getItem(B0);if(!e)return{};let t=JSON.parse(e);if(!u2(t))return{};let n=u2(t.sessionsByRoom)?Object.fromEntries(Object.entries(t.sessionsByRoom).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`&&!!e[1])):void 0;return{roomId:typeof t.roomId==`string`&&t.roomId?t.roomId:void 0,piboSessionId:typeof t.piboSessionId==`string`&&t.piboSessionId?t.piboSessionId:void 0,...n&&Object.keys(n).length?{sessionsByRoom:n}:{}}}catch{return{}}}function rke(e){try{let t={...Z0().sessionsByRoom??{},...e.sessionsByRoom??{}};e.roomId&&e.piboSessionId&&(t[e.roomId]=e.piboSessionId),localStorage.setItem(B0,JSON.stringify({roomId:e.roomId,piboSessionId:e.piboSessionId,...Object.keys(t).length?{sessionsByRoom:t}:{}}))}catch{}}function Q0(e){try{let t=Z0();if(!t.sessionsByRoom?.[e])return;let{[e]:n,...r}=t.sessionsByRoom;localStorage.setItem(B0,JSON.stringify({roomId:t.roomId,piboSessionId:t.piboSessionId,...Object.keys(r).length?{sessionsByRoom:r}:{}}))}catch{}}function $0(e){try{return localStorage.getItem(H0+e)??``}catch{return``}}function e2(e,t){try{let n=H0+e;t?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}function t2(){try{let e=localStorage.getItem(U0);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0).slice(-X0):[]}catch{return[]}}function ike(e){let t=e.trim();if(!t)return;let n=t2();if(n.at(-1)!==t)try{localStorage.setItem(U0,JSON.stringify([...n,t].slice(-X0)))}catch{}}function n2(){try{return localStorage.getItem(V0)===`terminal`?`terminal`:wc}catch{return wc}}function ake(e){try{localStorage.setItem(V0,e)}catch{}}function oke(){return c2(W0,!0)}function r2(e){l2(W0,e)}function ske(){return c2(G0,!0)}function i2(e){l2(G0,e)}function cke(){return c2(K0,!1)}function a2(e){l2(K0,e)}function lke(){return c2(q0,!1)}function uke(e){l2(q0,e)}function dke(){return c2(J0,!1)}function o2(e){l2(J0,e)}function fke(){try{return localStorage.getItem(Y0)??``}catch{return``}}function s2(e){try{localStorage.setItem(Y0,e)}catch{}}function pke(){try{localStorage.removeItem(B0)}catch{}}function c2(e,t){try{let n=localStorage.getItem(e);return n===`true`?!0:n===`false`?!1:t}catch{return t}}function l2(e,t){try{localStorage.setItem(e,String(t))}catch{}}function u2(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d2(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`),Promise.resolve()}finally{document.body.removeChild(t)}}function f2(e,t){return e.length>t?`${e.slice(0,Math.max(0,t-1))}…`:e}function mke({sessionId:e,disabled:t=!1,commands:n,skills:r,value:i,focusSignal:a,selectedWebAnnotations:o,selectedUploadAttachments:s,onValueChange:c,onCommand:l,onDetachWebAnnotation:u,onClearWebAnnotations:d,onAttachUploadedFiles:f,onDetachUploadAttachment:p,onClearUploadAttachments:m,onSend:h}){let g=(0,R.useRef)(null),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null),S=(0,R.useRef)(null),[C,w]=(0,R.useState)(0),[T,E]=(0,R.useState)(0),[D,O]=(0,R.useState)(0),[k,A]=(0,R.useState)([]),[j,M]=(0,R.useState)(!1),[N,P]=(0,R.useState)(null),[F,ee]=(0,R.useState)(null),te=(0,R.useMemo)(()=>{for(let e=D-1;e>=0;e--){let t=i[e];if(t===` `||t===`
|
|
162
|
+
`):``}function nOe(e){return e.split(/\r?\n|,/).map(e=>e.trim()).filter(Boolean)}function $1(e,t,n){let r=nOe(n);r.length?e[t]=r:delete e[t]}function rOe({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,R.useState)(Y1(n.promptBuilder)),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(`idle`),[p,m]=(0,R.useState)(`saved`),[h,g]=(0,R.useState)();(0,R.useEffect)(()=>{o(Y1(n.promptBuilder))},[n,t]),(0,R.useEffect)(()=>{let e=!1;return Oye(a||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[a]),(0,R.useEffect)(()=>{let e=!1;return g(void 0),a?(f(`loading`),kye(a).then(t=>{e||(u(t.asset),f(`loaded`))}).catch(t=>{e||(u(void 0),f(`error`),g(t instanceof Error?t.message:`Failed to load prompt asset`))}),()=>{e=!0}):(u(void 0),f(`idle`),()=>{e=!0})},[a]);let _=s?.options.find(e=>e.id===a),v=typeof n.promptTemplate==`string`?n.promptTemplate:C1,y=l?.markdown??v,b=`${e.draftId}:${t}:${(l?.id??a)||`direct-prompt`}:${l?.revisionId??`draft`}`,x=!!Y1(n.promptBuilder),S=a.startsWith(`ui.promptAssets.`),C=`${typeof n.label==`string`&&n.label.trim()?n.label.trim():t} prompt asset`,w=(0,R.useCallback)(async n=>{try{let r=await Aye({assetId:S?a:void 0,sourceRefId:a||void 0,displayName:C,description:`Managed prompt asset for ${t} in draft ${e.draftId}.`,markdown:n});await i(X1(e.definition,t,r.asset),`Saved prompt asset revision ${r.asset.revisionId} and updated ${t}.`,{editTrigger:`prompt_edit`}),o(r.asset.id),u(r.asset),g(`Saved ${r.asset.displayName} as revision ${r.asset.revisionId}; draft now pins ${r.asset.contentHash}.`)}catch(e){throw g(e instanceof Error?e.message:`Failed to save prompt asset revision`),e}},[e.definition,e.draftId,t,i,C,a,S]),T=async()=>{l&&(await i(X1(e.definition,t,l),`Updated ${t} to use prompt asset ${l.id}.`,{editTrigger:`prompt_edit`}),g(`Draft node ${t} now uses ${l.displayName} at ${l.contentHash}.`))};return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Prompt asset Markdown editor`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Prompt asset Markdown editor`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Edit prompt assets with the same Markdown editor pattern as Context Files. Saving creates a managed UI asset revision, updates this draft node to a prompt asset ref, and pins the revision id plus content hash in the Pibo Workflow IR.`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Prompt asset ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a,onChange:e=>o(e.target.value),disabled:r,children:[(0,z.jsx)(`option`,{value:``,children:`Create managed asset from direct prompt template`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),_?(0,z.jsx)(L1,{option:_,badge:_.kind===`ui`?`managed prompt asset`:`registered prompt asset`}):null,d===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-2 text-[11px] leading-5 text-red-200`,role:`alert`,children:h??`Failed to load prompt asset.`}):null,(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:(0,z.jsx)(Gz,{documentKey:b,initialMarkdown:y,onPersist:w,onSaveStateChange:m})}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:x?`promptBuilder ref`:`direct promptTemplate source`}),(0,z.jsx)(F1,{label:`Markdown save: ${p}`}),l?(0,z.jsx)(F1,{label:`${l.source} · ${l.revisionId}`}):null]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void T(),disabled:r||!l,children:[(0,z.jsx)(Bs,{size:13}),`Use selected asset on draft`]})}),h&&d!==`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-2 text-[11px] leading-5 text-emerald-200`,role:`status`,children:h}):null,(0,z.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Code/plugin prompt assets are not mutated. Editing a registered asset copies the Markdown into a managed UI prompt asset; later saves append revisions and only affect this draft or future workflow versions that reference the new revision.`})]})}function iOe({draft:e,selectedElement:t,nodeIds:n,isSaving:r,onSaveDefinition:i}){let a=t?.type===`node`?L$(e.definition)[t.id]:void 0,o=t?.type===`edge`?R$(e.definition)[t.id]:void 0;return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow inspectors`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Workflow inspectors`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Inspector saves update the same Pibo Workflow IR draft as the graph canvas; XState remains projection-only.`})]}),(0,z.jsx)(sOe,{draft:e,isSaving:r,onSaveDefinition:i}),t?.type===`node`&&a?(0,z.jsx)(cOe,{draft:e,nodeId:t.id,node:a,isSaving:r,onSaveDefinition:i}):t?.type===`edge`&&o?(0,z.jsx)(lOe,{draft:e,edgeId:t.id,edge:o,nodeIds:n,isSaving:r,onSaveDefinition:i}):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Select a canvas node or edge to open the node or edge inspector. Workflow settings remain editable at all times.`})]})}function aOe(e,t){return e.filter(e=>e.nodeId===t||e.path?.startsWith(`$.nodes.${t}`))}function oOe(e,t){return e.filter(e=>e.edgeId===t||e.path?.startsWith(`$.edges.${t}`))}function sOe({draft:e,isSaving:t,onSaveDefinition:n}){let[r,i]=(0,R.useState)(()=>q1(e.definition));(0,R.useEffect)(()=>{i(q1(e.definition))},[e.definition]);let a=(e,t)=>{i(n=>({...n,[e]:t}))};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsx)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:`Workflow settings inspector`}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Workflow title`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:r.title,onChange:e=>a(`title`,e.target.value)})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Workflow description`}),(0,z.jsx)(`textarea`,{className:`min-h-20 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:r.description,onChange:e=>a(`description`,e.target.value)})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(r0,{label:`Workflow input port`,kind:r.inputKind,description:r.inputDescription,schemaText:r.inputSchemaText,onKindChange:e=>a(`inputKind`,e),onDescriptionChange:e=>a(`inputDescription`,e),onSchemaChange:e=>a(`inputSchemaText`,e)}),(0,z.jsx)(r0,{label:`Workflow output port`,kind:r.outputKind,description:r.outputDescription,schemaText:r.outputSchemaText,onKindChange:e=>a(`outputKind`,e),onDescriptionChange:e=>a(`outputDescription`,e),onSchemaChange:e=>a(`outputSchemaText`,e)})]}),(0,z.jsx)(dOe,{fields:r.globalStateFields,onAddField:()=>{i(e=>({...e,globalStateFields:[...e.globalStateFields,ZDe(e.globalStateFields)]}))},onRemoveField:e=>{i(t=>({...t,globalStateFields:t.globalStateFields.filter((t,n)=>n!==e)}))},onUpdateField:(e,t,n)=>{i(r=>({...r,globalStateFields:r.globalStateFields.map((r,i)=>i===e?{...r,[t]:n}:r)}))}}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(o0,{label:`metadata.tags`,value:r.metadataTags,onChange:e=>a(`metadataTags`,e)}),(0,z.jsx)(o0,{label:`metadata.useWhen`,value:r.metadataUseWhen,onChange:e=>a(`metadataUseWhen`,e)}),(0,z.jsx)(o0,{label:`metadata.notFor`,value:r.metadataNotFor,onChange:e=>a(`metadataNotFor`,e)}),(0,z.jsx)(o0,{label:`metadata.examples`,value:r.metadataExamples,onChange:e=>a(`metadataExamples`,e)})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{n(XDe(e.definition,r),`Saved workflow settings inspector edits to the draft IR.`,{editTrigger:tOe(e.definition,r)?`state_edit`:`schema_edit`})},disabled:t,children:[t?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save workflow settings`]})]})]})}function cOe({draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i}){let[a,o]=(0,R.useState)(()=>a1(n)),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)(),_=B$(n),v=aOe(e.diagnostics,t),y=d?.options.find(e=>e.id===(d?.selectedRefId??a.adapterRef)),b=(0,R.useMemo)(()=>new Set(a.humanActionRefs.map(e=>e.id)),[a.humanActionRefs]);(0,R.useEffect)(()=>{o(a1(n))},[n,t]),(0,R.useEffect)(()=>{if(_!==`agent`)return;let e=!1;return aJ(a.profileId||void 0).then(t=>{e||c(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.profileId]),(0,R.useEffect)(()=>{if(_!==`code`)return;let e=!1;return oJ(a.handlerId||void 0).then(t=>{e||u(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.handlerId]),(0,R.useEffect)(()=>{if(_!==`adapter`)return;let e=!1;return sJ(a.adapterRef||void 0).then(t=>{e||f(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.adapterRef]),(0,R.useEffect)(()=>{if(_!==`workflow`)return;let e=!1,t=E1(a.workflowVersionKey);return lJ({selectedWorkflowId:t?.workflowId,selectedWorkflowVersion:t?.workflowVersion}).then(t=>{e||m(t)}).catch(()=>void 0),()=>{e=!0}},[_,a.workflowVersionKey]),(0,R.useEffect)(()=>{if(_!==`human`)return;let e=!1;return cJ().then(t=>{e||g(t)}).catch(()=>void 0),()=>{e=!0}},[_]);let x=(e,t)=>{o(n=>({...n,[e]:t}))},S=(e,t)=>{o(n=>({...n,humanActionRefs:nDe(n.humanActionRefs,e,t)}))};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Node inspector: `,t]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${_} node`}),(0,z.jsx)(F1,{label:`${v.length} diagnostics`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Node label`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.label,onChange:e=>x(`label`,e.target.value)})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Node description`}),(0,z.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.description,onChange:e=>x(`description`,e.target.value)})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsx)(i0,{label:`Node input port`,kind:a.inputKind,description:a.inputDescription,schemaText:a.inputSchemaText,onKindChange:e=>x(`inputKind`,e),onDescriptionChange:e=>x(`inputDescription`,e),onSchemaChange:e=>x(`inputSchemaText`,e)}),(0,z.jsx)(i0,{label:`Node output port`,kind:a.outputKind,description:a.outputDescription,schemaText:a.outputSchemaText,onKindChange:e=>x(`outputKind`,e),onDescriptionChange:e=>x(`outputDescription`,e),onSchemaChange:e=>x(`outputSchemaText`,e)})]}),(0,z.jsx)(e0,{label:`Node`,definition:e.definition,value:a.stateAccess,onChange:e=>x(`stateAccess`,e)}),_===`agent`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Agent node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Agent profile ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:s?.selectedProfileId??a.profileId,onChange:e=>x(`profileId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a non-archived profile`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:k1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Prompt template`}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-slate-100`,value:a.promptTemplate,onChange:e=>x(`promptTemplate`,e.target.value)}),(0,z.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Saving direct prompt text writes `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`promptTemplate`}),` on this Pibo Workflow IR node.`]})]}),(0,z.jsx)(rOe,{draft:e,nodeId:t,node:n,isSaving:r,onSaveDefinition:i})]}):null,_===`code`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Code node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered code handler`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l?.selectedHandlerId??a.handlerId,onChange:e=>x(`handlerId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered handler ref`}),l?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:A1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:l?.diagnostics??[]})]}):null,_===`adapter`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Adapter node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Registered adapter ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:d?.selectedRefId??a.adapterRef,onChange:e=>x(`adapterRef`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),d?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsx)(I1,{diagnostics:d?.diagnostics??[]}),y?.paramsSchema?(0,z.jsx)(s0,{label:`Adapter params JSON`,schema:y.paramsSchema,value:a.adapterParamsText,onChange:e=>x(`adapterParamsText`,e)}):null,(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 text-[11px] leading-5 text-slate-500`,children:`Adapter nodes store only a registered deterministic adapter ref. Inline transformation code and hidden LLM coercion are not exposed by the UI.`})]}):null,_===`workflow`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Nested workflow ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:p?.selectedWorkflowId&&p.selectedWorkflowVersion?T1(p.selectedWorkflowId,p.selectedWorkflowVersion):a.workflowVersionKey,onChange:e=>x(`workflowVersionKey`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select a published workflow version`}),p?.options.map(e=>(0,z.jsx)(`option`,{value:M1(e),children:N1(e)},M1(e)))]})]}),(0,z.jsx)(B1,{diagnostics:p?.diagnostics??[],ariaLabel:`Workflow node diagnostics`})]}):null,_===`human`?(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Human node fields`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Human prompt`}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:a.humanPrompt,onChange:e=>x(`humanPrompt`,e.target.value)})]}),(0,z.jsx)(a0,{label:`Human node resume payload schema JSON`,value:a.humanSchemaText,onChange:e=>x(`humanSchemaText`,e)}),(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,"aria-label":`Human action choices`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Registered action choices`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Actions are selected from the Workflow Registry. The label, action kind, and payload requirements come from picker metadata.`})]}),h?.options.length?h.options.map(e=>(0,z.jsxs)(`label`,{className:`grid gap-1 rounded-sm border border-slate-800 bg-[#101d22] p-2 text-slate-300`,children:[(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-semibold`,children:[(0,z.jsx)(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 accent-[#11a4d4]`,checked:b.has(e.id),onChange:t=>S(e,t.target.checked)}),(0,z.jsx)(`span`,{children:e.displayName}),(0,z.jsx)(F1,{label:`kind: ${e.kind??`registered`}`})]}),(0,z.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:e.description??e.id}),(0,z.jsxs)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:[`Payload requirements: `,e.paramsSchema?JSON.stringify(e.paramsSchema):`none`]})]},e.id)):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No registered human actions are available from the picker.`}),(0,z.jsx)(I1,{diagnostics:h?.diagnostics??[]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,"aria-label":`Selected human action refs`,children:a.humanActionRefs.length?a.humanActionRefs.map(e=>(0,z.jsx)(F1,{label:`${e.id}${e.kind?` (${e.kind})`:``}`},`${e.id}:${e.kind??``}`)):(0,z.jsx)(`span`,{className:`text-slate-500`,children:`No human action refs selected.`})})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 md:grid-cols-[1fr_1fr]`,"aria-label":`Human node timeout`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Timeout kind`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:a.humanTimeoutKind,onChange:e=>x(`humanTimeoutKind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`No timeout`}),(0,z.jsx)(`option`,{value:`milliseconds`,children:`Milliseconds`}),(0,z.jsx)(`option`,{value:`seconds`,children:`Seconds`}),(0,z.jsx)(`option`,{value:`minutes`,children:`Minutes`}),(0,z.jsx)(`option`,{value:`iso8601`,children:`ISO-8601 duration`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Timeout value`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,type:a.humanTimeoutKind===`iso8601`?`text`:`number`,min:a.humanTimeoutKind===`iso8601`?void 0:1,placeholder:a.humanTimeoutKind===`iso8601`?`PT1H`:`60`,value:a.humanTimeoutValue,onChange:e=>x(`humanTimeoutValue`,e.target.value),disabled:a.humanTimeoutKind===`none`})]})]})]}):null,(0,z.jsx)(P1,{diagnostics:v,emptyLabel:`No diagnostics for selected node.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>{let r=XEe(e.definition,t,a),o=JEe(n,a)?`state_edit`:_===`agent`||_===`human`?`prompt_edit`:`schema_edit`;i(r,`Saved node inspector edits for ${t}.`,{editTrigger:o})},disabled:r,children:[r?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save node inspector`]})]})]})}function e0({label:e,definition:t,value:n,onChange:r,allowEdgeWrites:i=!1}){let a=n1(t,n.readScope,[...n.reads,...n.writes]),o=i?Z$:qEe,s=n1(t,n.writeScope,[...n.reads,...n.writes]),c=!!n.readPath.trim(),l=!!n.writePath.trim()&&(i||n.writeScope!==`edge`),u=(e,t)=>r({...n,[e]:t}),d=e=>{let t=e===`reads`?n.readScope:n.writeScope,i=(e===`reads`?n.readPath:n.writePath).trim();if(!i)return;let a=`${t}.${i}`,o=n[e];o.includes(a)||r({...n,[e]:[...o,a]})},f=(e,t)=>r({...n,[e]:n[e].filter(e=>e!==t)});return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,"aria-label":`${e} simple state mapping controls`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[e,` simple state mappings`]}),(0,z.jsxs)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:[`Add simple scoped state reads and writes as Pibo Workflow IR `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.reads`}),` and `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`state.writes`}),` arrays. Complex state mapping DSLs remain raw Workflow IR only.`]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Read scope`}),(0,z.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.readScope,onChange:e=>u(`readScope`,e.target.value),children:Z$.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsx)(t0,{label:`Read path`,value:n.readPath,options:a,onChange:e=>u(`readPath`,e)}),(0,z.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`reads`),disabled:!c,children:`Add read`})]}),(0,z.jsx)(n0,{label:`Reads`,entries:n.reads,onRemove:e=>f(`reads`,e)}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[0.7fr_1fr_auto]`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Write scope`}),(0,z.jsx)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n.writeScope,onChange:e=>u(`writeScope`,e.target.value),children:o.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsx)(t0,{label:`Write path`,value:n.writePath,options:s,onChange:e=>u(`writePath`,e)}),(0,z.jsx)(`button`,{type:`button`,className:`self-end rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>d(`writes`),disabled:!l,children:`Add write`})]}),(0,z.jsx)(n0,{label:`Writes`,entries:n.writes,onRemove:e=>f(`writes`,e)}),n.writeScope===`global`&&!r1(t).length?(0,z.jsx)(`div`,{className:`rounded-sm border border-amber-900/60 bg-amber-950/20 p-2 text-[11px] leading-5 text-amber-100`,children:`Declare global state fields in the workflow settings inspector before selecting global read/write paths.`}):null]})}function t0({label:e,value:t,options:n,onChange:r}){let i=t&&!n.includes(t)?[t,...n]:n;return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>r(e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select path`}),i.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function n0({label:e,entries:t,onRemove:n}){return(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-semibold text-slate-400`,children:e}),t.length?(0,z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`rounded-full border border-slate-700 px-2 py-1 text-[11px] text-slate-300 transition hover:border-red-500/60 hover:text-red-100`,onClick:()=>n(e),title:`Remove ${e}`,children:[e,` ×`]},e))}):(0,z.jsxs)(`div`,{className:`text-[11px] text-slate-500`,children:[`No `,e.toLowerCase(),` declared.`]})]})}function lOe({draft:e,edgeId:t,edge:n,nodeIds:r,isSaving:i,onSaveDefinition:a}){let[o,s]=(0,R.useState)(()=>o1(n,r)),[c,l]=(0,R.useState)(),[u,d]=(0,R.useState)(),[f,p]=(0,R.useState)(!1),m=oOe(e.diagnostics,t),h=HDe(e.definition,n),g=m.some(e=>e.code===`WorkflowGraphError.incompatibleEdgePorts`),_=c?.options.find(e=>e.id===(c?.selectedRefId??o.guardHandler)),v=u?.options.find(e=>e.id===(u?.selectedRefId??o.adapterRef));(0,R.useEffect)(()=>{s(o1(n,r))},[n,t,r]),(0,R.useEffect)(()=>{p(!1)},[t]),(0,R.useEffect)(()=>{let e=!1;return Dye(o.guardHandler||void 0).then(t=>{e||l(t)}).catch(()=>void 0),()=>{e=!0}},[o.guardHandler]),(0,R.useEffect)(()=>{let e=!1;return sJ(o.adapterRef||void 0).then(t=>{e||d(t)}).catch(()=>void 0),()=>{e=!0}},[o.adapterRef]);let y=(e,t)=>{s(n=>({...n,[e]:t}))},b=()=>{let r=ZEe(e.definition,t,o),i=Q$(n.state,o.stateAccess)?`state_edit`:`edge_edit`;a(r,`Saved edge inspector edits for ${t}.`,{editTrigger:i})};return(0,z.jsxs)(`details`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,open:!0,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-xs font-bold text-slate-200`,children:[`Edge inspector: `,t]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${o.kind} edge`}),(0,z.jsx)(F1,{label:`${m.length} diagnostics`})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Source node`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourceNodeId,onChange:e=>y(`sourceNodeId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select source`}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Target node`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetNodeId,onChange:e=>y(`targetNodeId`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`Select target`}),r.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Source port id`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.sourcePortId,onChange:e=>y(`sourcePortId`,e.target.value),placeholder:`default`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Target port id`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.targetPortId,onChange:e=>y(`targetPortId`,e.target.value),placeholder:`default`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Edge kind`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.kind,onChange:e=>y(`kind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`data`,children:`data`}),(0,z.jsx)(`option`,{value:`control`,children:`control`}),(0,z.jsx)(`option`,{value:`error`,children:`error`}),(0,z.jsx)(`option`,{value:`resume`,children:`resume`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Guard ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:c?.selectedRefId??o.guardHandler,onChange:e=>y(`guardHandler`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No guard`}),c?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Guard priority`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:o.guardPriority,onChange:e=>y(`guardPriority`,e.target.value),placeholder:`optional integer`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,z.jsx)(`span`,{children:`Edge adapter ref`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:u?.selectedRefId??o.adapterRef,onChange:e=>y(`adapterRef`,e.target.value),children:[(0,z.jsx)(`option`,{value:``,children:`No edge adapter`}),u?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]})]}),_?.paramsSchema?(0,z.jsx)(s0,{label:`Guard params JSON`,schema:_.paramsSchema,value:o.guardParamsText,onChange:e=>y(`guardParamsText`,e)}):null,v?.paramsSchema?(0,z.jsx)(s0,{label:`Edge adapter params JSON`,schema:v.paramsSchema,value:o.adapterParamsText,onChange:e=>y(`adapterParamsText`,e)}):null,(0,z.jsx)(e0,{label:`Edge`,definition:e.definition,value:o.stateAccess,onChange:e=>y(`stateAccess`,e),allowEdgeWrites:!0}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border px-3 py-2 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${g?`border-amber-600/70 text-amber-100 hover:border-amber-400`:`border-slate-700 text-slate-300 hover:border-[#11a4d4]/60 hover:text-slate-100`}`,onClick:()=>p(!0),disabled:i||!h.sourcePort||!h.targetPort,children:[(0,z.jsx)(bs,{size:13}),g?`Fix incompatible edge with adapter`:`Open compatible edge adapter dialog`]}),f?(0,z.jsx)(uOe,{draft:e,edgeId:t,edge:n,edgePortDetails:h,isSaving:i,onClose:()=>p(!1),onSaveDefinition:a}):null,(0,z.jsx)(I1,{diagnostics:[...c?.diagnostics??[],...u?.diagnostics??[]]}),(0,z.jsx)(P1,{diagnostics:m,emptyLabel:`No diagnostics for selected edge.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:b,disabled:i||!o.sourceNodeId||!o.targetNodeId,children:[i?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save edge inspector`]})]})]})}function uOe({draft:e,edgeId:t,edge:n,edgePortDetails:r,isSaving:i,onClose:a,onSaveDefinition:o}){let[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(UDe(n)),[d,f]=(0,R.useState)(`loading`),[p,m]=(0,R.useState)();(0,R.useEffect)(()=>{let e=!1;return f(`loading`),m(void 0),sJ(l||void 0).then(t=>{e||(c(t),u(e=>e||(t.options[0]?.id??``)),f(`loaded`))}).catch(t=>{e||(m(t instanceof Error?t.message:`Failed to load compatible adapters`),f(`error`))}),()=>{e=!0}},[l]);let h=s?.options.find(e=>e.id===l),g=!!(h&&r.sourcePort&&r.targetPort&&d===`loaded`&&!i),_=async()=>{l&&(await o(WDe(e.definition,t,l),`Applied ${l} as edge adapter for ${t}.`,{editTrigger:`edge_edit`}),a())},v=async()=>{l&&(await o(GDe(e.definition,t,l),`Inserted adapter node for ${t} using ${l}.`,{editTrigger:`graph_edit`}),a())};return(0,z.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`workflow-edge-adapter-dialog-title`,children:(0,z.jsxs)(`div`,{className:`max-h-[88vh] w-full max-w-3xl overflow-auto rounded-sm border border-slate-700 bg-[#101d22] p-4 shadow-2xl shadow-black/40`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(bs,{size:13}),`Compatible edge adapter dialog`]}),(0,z.jsxs)(`h4`,{id:`workflow-edge-adapter-dialog-title`,className:`mt-1 text-sm font-bold text-slate-100`,children:[`Choose a registered adapter for `,t]}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:`The dialog shows the source output and target input schemas from the Pibo Workflow IR. Use a registered adapter as an explicit edge adapter, or insert a visible adapter node between the endpoints.`})]}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:a,children:`Close`})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-2`,children:[(0,z.jsx)(R1,{label:`From schema${r.sourceNodeId?` (${r.sourceNodeId})`:``}`,schema:r.sourcePort??null}),(0,z.jsx)(R1,{label:`To schema${r.targetNodeId?` (${r.targetNodeId})`:``}`,schema:r.targetPort??null})]}),(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border p-3 text-xs leading-5 ${r.directlyCompatible?`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`:`border-amber-700/70 bg-amber-950/30 text-amber-100`}`,children:r.directlyCompatible?`These ports are directly compatible. An adapter is optional and remains explicit if selected.`:`These ports are not directly compatible. Select a registered adapter instead of hidden LLM coercion or inline transformation code.`}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 text-xs`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Compatible registered adapter`}),(0,z.jsxs)(`select`,{"aria-label":`Compatible registered adapter`,className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:l,onChange:e=>u(e.target.value),disabled:d===`loading`||d===`error`||i,children:[(0,z.jsx)(`option`,{value:``,children:`Select a registered adapter ref`}),s?.options.map(e=>(0,z.jsx)(`option`,{value:e.id,children:j1(e)},e.id))]})]}),d===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:p??`Failed to load compatible adapters.`}):null,(0,z.jsx)(I1,{diagnostics:s?.diagnostics??[]}),h?(0,z.jsx)(L1,{option:h,badge:`selected adapter`}):null,(0,z.jsxs)(`div`,{className:`grid gap-2`,"aria-label":`Compatible adapter candidates`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Compatible adapter candidates`}),s?.options.map(e=>(0,z.jsx)(L1,{option:e,badge:`compatible adapter`},e.id))]}),(0,z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void _(),disabled:!g,children:[(0,z.jsx)(bs,{size:13}),`Use as edge adapter`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/50 px-3 py-2 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void v(),disabled:!g,children:[(0,z.jsx)(Ps,{size:13}),`Insert adapter node`]})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:[`Both actions persist Pibo Workflow IR only. Edge adapters store `,(0,z.jsx)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:`adapter.transform.id`}),`; inserted adapter nodes store a visible deterministic adapter handler ref.`]})]})]})})}function r0({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,z.jsx)(`option`,{value:`text`,children:`text`}),(0,z.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),placeholder:`Optional port description`})]}),t===`json`?(0,z.jsx)(a0,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function i0({label:e,kind:t,description:n,schemaText:r,onKindChange:i,onDescriptionChange:a,onSchemaChange:o}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>i(e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`inherit/default`}),(0,z.jsx)(`option`,{value:`text`,children:`text`}),(0,z.jsx)(`option`,{value:`json`,children:`json`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 text-slate-100`,value:n,onChange:e=>a(e.target.value),disabled:t===`none`,placeholder:`Optional port description`})]}),t===`json`?(0,z.jsx)(a0,{label:`${e} raw JSON schema`,value:r,onChange:o}):null]})}function dOe({fields:e,onAddField:t,onRemoveField:n,onUpdateField:r}){return(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#101d22] p-3`,"aria-label":`Workflow global state fields`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Workflow global state fields`}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Declare simple global state paths for node and edge state mapping dropdowns. State schema changes run draft validation and may invalidate connected graph diagnostics without blocking draft save.`})]}),e.length?e.map((e,t)=>(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#151f24]/70 p-2 md:grid-cols-2`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Global state path`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.path,onChange:e=>r(t,`path`,e.target.value),placeholder:`projectGoal`})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Merge policy`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.mergeKind,onChange:e=>r(t,`mergeKind`,e.target.value),children:[(0,z.jsx)(`option`,{value:`none`,children:`No merge policy`}),(0,z.jsx)(`option`,{value:`replace`,children:`replace`}),(0,z.jsx)(`option`,{value:`append`,children:`append`}),(0,z.jsx)(`option`,{value:`shallowMerge`,children:`shallowMerge`})]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300 md:col-span-2`,children:[(0,z.jsx)(`span`,{children:`Description`}),(0,z.jsx)(`input`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:e.description,onChange:e=>r(t,`description`,e.target.value),placeholder:`Optional state description`})]}),(0,z.jsx)(`div`,{className:`md:col-span-2`,children:(0,z.jsx)(a0,{label:`Global state ${e.path||t+1} schema JSON`,value:e.schemaText,onChange:e=>r(t,`schemaText`,e)})}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-red-500/70 hover:text-red-100`,onClick:()=>n(t),children:`Remove state field`})]},`${t}:${e.path}`)):(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 p-2 text-[11px] leading-5 text-slate-500`,children:`No global state fields declared. Local and edge path dropdowns remain available for simple node-local state and edge payload access.`}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-2 rounded-sm border border-slate-700 px-3 py-2 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,onClick:t,children:[(0,z.jsx)(Ps,{size:13}),`Add global state field`]})]})}function a0({label:e,value:t,onChange:n}){return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`textarea`,{className:`min-h-36 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:JSON.stringify(X$,null,2),spellCheck:!1,"aria-label":e}),(0,z.jsx)(`span`,{className:`text-[11px] font-normal leading-5 text-slate-500`,children:`Raw JSON Schema subset only. Unsupported keywords return workflow diagnostics; no Zod, AJV, or form-builder schema layer is introduced.`})]})}function o0({label:e,value:t,onChange:n}){return(0,z.jsxs)(`label`,{className:`grid gap-1 font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:e}),(0,z.jsx)(`textarea`,{className:`min-h-16 rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-slate-100`,value:t,onChange:e=>n(e.target.value),placeholder:`One value per line`})]})}function s0({label:e,schema:t,value:n,onChange:r}){return(0,z.jsxs)(`div`,{className:`grid gap-2 rounded-sm border border-slate-800 bg-[#101d22] p-2`,"aria-label":e,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,z.jsx)(R1,{label:`paramsSchema`,schema:t}),(0,z.jsx)(`textarea`,{className:`min-h-24 rounded-sm border border-slate-700 bg-[#151f24] px-2 py-1.5 font-mono text-[11px] leading-5 text-slate-100`,value:n,onChange:e=>r(e.target.value),placeholder:`{}`,"aria-label":`${e} value`}),(0,z.jsx)(`div`,{className:`text-[11px] leading-5 text-slate-500`,children:`Params save as data on the selected registry ref. No inline code path is created.`})]})}function fOe(e){let t=new Map;for(let n of e){let e=t.get(n.id);if(e){e.records.push(n),n.status===`published`&&e.records[0]?.status!==`published`&&(e.title=n.title,e.source=n.source);continue}t.set(n.id,{workflowId:n.id,title:n.title,source:n.source,records:[n]})}return[...t.values()]}function pOe(e){return e.status===`published`?`Published workflow version — selectable for Project sessions and safe to duplicate into UI drafts.`:e.status===`archived`?`Archived workflow version — shown for lifecycle history but hidden from default Project session creation choices.`:e.status===`deleted`?`Deleted workflow definition — historical runs must render from immutable snapshots instead of live catalog links.`:`Draft workflow version — not published and unavailable for Project session creation.`}function c0(e,t){return e.actions.includes(t)}function mOe(e){switch(e){case`view`:return`View`;case`duplicate`:return`Duplicate`;case`create_project_session`:return`Create Project session`;case`edit_draft`:return`Edit draft`;case`validate`:return`Validate`;case`publish`:return`Publish`;case`create_next_draft`:return`Create next draft`;case`version_history`:return`Version history`;case`archive`:return`Archive`;case`delete`:return`Delete`}}function hOe({activeDraftId:e}){let[t,n]=(0,R.useState)([]),[r,i]=(0,R.useState)(`loading`),[a,o]=(0,R.useState)(),[s,c]=(0,R.useState)(),[l,u]=(0,R.useState)(),[d,f]=(0,R.useState)(),[p,m]=(0,R.useState)(),[h,g]=(0,R.useState)(),[_,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(),x=!!(s||l||d||p),S=(0,R.useCallback)(async()=>{i(`loading`),o(void 0);try{n((await uJ()).options),i(`loaded`)}catch(e){o(e instanceof Error?e.message:`Failed to load workflow version history`),i(`error`)}},[]);(0,R.useEffect)(()=>{S()},[S]);let C=(0,R.useMemo)(()=>fOe(t),[t]),w=async(e,t)=>{c(T1(e,t)),b(void 0);try{O1((await Iye(e,{version:t})).builderPath)}catch(e){b(e instanceof Error?e.message:`Failed to duplicate workflow into a draft`),c(void 0)}},T=async(e,t)=>{u(T1(e,t)),b(void 0);try{O1((await Lye(e,{version:t})).builderPath)}catch(e){b(e instanceof Error?e.message:`Failed to create next-version draft`),u(void 0)}},E=(e,t)=>{v(``),b(void 0),g({kind:`archive`,workflowId:e,title:t})},D=(e,t)=>{v(``),b(void 0),g({kind:`delete`,workflowId:e,title:t})},O=async()=>{if(!h||h.kind!==`archive`)return;let{workflowId:e}=h;f(e),b(void 0);try{await Rye(e),g(void 0),await S()}catch(e){b(e instanceof Error?e.message:`Failed to archive workflow`)}finally{f(void 0)}},k=async()=>{if(!h||h.kind!==`delete`)return;let{workflowId:e}=h;m(e),b(void 0);try{await zye(e,{confirmWorkflowId:_}),g(void 0),v(``),await S()}catch(e){b(e instanceof Error?e.message:`Failed to delete workflow`)}finally{m(void 0)}};return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`UI draft`}),(0,z.jsx)(`h3`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Starter UI draft`}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:`A draft row opens the builder route and loads a partial Pibo Workflow IR wrapper with diagnostics.`})]}),(0,z.jsx)(`a`,{className:`shrink-0 rounded-sm border border-[#11a4d4]/50 px-3 py-1.5 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100`,href:_De(gDe),children:`Open draft`})]}),e===`v2-starter-draft`?(0,z.jsx)(`div`,{className:`mt-3 text-[11px] font-semibold text-emerald-300`,children:`Currently open in the builder.`}):null]}),(0,z.jsx)(yOe,{target:h,busy:x,deleteConfirmWorkflowId:_,onDeleteConfirmChange:v,onCancel:()=>{g(void 0),v(``)},onConfirmArchive:()=>void O(),onConfirmDelete:()=>void k()}),(0,z.jsxs)(`div`,{className:`grid gap-3`,"aria-label":`Workflow version history`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:[(0,z.jsx)(hs,{size:13}),`Version history`]}),(0,z.jsx)(`p`,{className:`mt-1 text-[11px] leading-5 text-slate-500`,children:`Published versions are listed in deterministic workflow/version order. Only published rows are selectable for Project sessions; archived rows stay visible as history while deleted workflows render from Project snapshots.`})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 px-2 py-1 text-[11px] font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void S(),disabled:r===`loading`,children:[r===`loading`?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ls,{size:12}),`Refresh`]})]}),r===`loading`?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-xs text-slate-400`,"aria-live":`polite`,children:[(0,z.jsx)(Cs,{size:14,className:`animate-spin text-[#11a4d4]`}),`Loading workflow version history…`]}):null,r===`error`?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:a??`Failed to load workflow version history.`}):null,r===`loaded`&&C.length===0?(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-700 bg-[#101d22]/70 p-4 text-xs text-slate-500`,children:`No workflow versions are registered yet.`}):null,r===`loaded`?C.map(e=>(0,z.jsx)(gOe,{group:e,busy:x,duplicatingKey:s,editingKey:l,archivingWorkflowId:d,deletingWorkflowId:p,onDuplicate:w,onEditPublished:T,onArchive:E,onDelete:D},e.workflowId)):null]}),y?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs leading-5 text-red-200`,role:`alert`,children:y}):null]})}function gOe({group:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,"aria-label":`Version history for ${e.workflowId}`,children:[(0,z.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`font-semibold text-slate-100`,children:e.title}),(0,z.jsx)(F1,{label:`${e.records.length} version${e.records.length===1?``:`s`}`}),(0,z.jsx)(F1,{label:`${e.source} source`})]}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-500`,children:e.workflowId})]})}),(0,z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:e.records.map(e=>(0,z.jsx)(_Oe,{record:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l},T1(e.id,e.version)))})]})}function _Oe({record:e,busy:t,duplicatingKey:n,editingKey:r,archivingWorkflowId:i,deletingWorkflowId:a,onDuplicate:o,onEditPublished:s,onArchive:c,onDelete:l}){let u=T1(e.id,e.version),d=e.status===`published`,f=c0(e,`create_next_draft`),p=c0(e,`duplicate`),m=c0(e,`create_project_session`),h=c0(e,`view`),g=d&&c0(e,`archive`),_=d&&c0(e,`delete`);return(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-xs leading-5 text-slate-400`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`font-mono text-[11px] font-semibold text-slate-200`,children:[e.id,`@`,e.version]}),(0,z.jsx)(F1,{label:e.status}),(0,z.jsx)(F1,{label:`${e.source} source`}),e.tags.map(e=>(0,z.jsx)(F1,{label:e},e))]}),e.description?(0,z.jsx)(`div`,{className:`mt-2 text-slate-500`,children:e.description}):null,(0,z.jsx)(`div`,{className:`mt-2 text-[11px] ${d?`text-emerald-300`:`text-amber-200`}`,children:pOe(e)}),(0,z.jsx)(vOe,{actions:e.actions})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[f?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-[#11a4d4]/50 px-3 py-1.5 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void s(e.id,e.version),disabled:t,children:[r===u?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(vs,{size:13}),`Edit published`]}):null,p?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void o(e.id,e.version),disabled:t,children:[n===u?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Qo,{size:13}),`Duplicate to draft`]}):null,m?(0,z.jsxs)(`a`,{className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-700/70 px-3 py-1.5 text-xs font-semibold text-emerald-100 transition hover:border-emerald-500 hover:text-emerald-50`,href:`/apps/chat/projects`,children:[(0,z.jsx)(As,{size:13}),`Create Project session`]}):(0,z.jsx)(`div`,{className:`max-w-44 rounded-sm border border-amber-800/70 bg-amber-950/20 p-2 text-[11px] text-amber-100`,children:`Unavailable for Project session selection.`}),h?(0,z.jsxs)(`a`,{className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-[#11a4d4]/60 hover:text-slate-100`,href:D1(e.id,e.version),children:[(0,z.jsx)(rs,{size:13}),`View details`]}):null,g?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-amber-700/70 px-3 py-1.5 text-xs font-semibold text-amber-100 transition hover:border-amber-500 hover:text-amber-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>c(e.id,e.title),disabled:t,children:[i===e.id?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(To,{size:13}),`Archive workflow`]}):null,_?(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-red-800/80 px-3 py-1.5 text-xs font-semibold text-red-100 transition hover:border-red-500 hover:text-red-50 disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>l(e.id,e.title),disabled:t,children:[a===e.id?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(qs,{size:13}),`Delete workflow`]}):null]})]})})}function vOe({actions:e}){return(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1`,"aria-label":`Workflow Library source/status actions`,children:e.map(e=>(0,z.jsx)(F1,{label:mOe(e)},e))})}function yOe({target:e,busy:t,deleteConfirmWorkflowId:n,onDeleteConfirmChange:r,onCancel:i,onConfirmArchive:a,onConfirmDelete:o}){if(!e)return null;let s=e.kind===`delete`,c=n.trim()===e.workflowId;return(0,z.jsx)(`div`,{className:`rounded-sm border p-4 text-xs leading-5 ${s?`border-red-900/70 bg-red-950/25 text-red-100`:`border-amber-800/70 bg-amber-950/20 text-amber-100`}`,role:`region`,"aria-label":`${s?`Delete`:`Archive`} workflow confirmation`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em]`,children:[(0,z.jsx)(Js,{size:13}),`Confirm `,s?`delete`:`archive`]}),(0,z.jsx)(`h3`,{className:`mt-1 text-sm font-bold text-slate-100`,children:e.title}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-slate-300`,children:e.workflowId}),s?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mt-3`,children:`Deleting tombstones the live workflow identity. It removes this workflow from the default catalog, workflow pickers, duplicate/edit/publish/archive actions, and new Project session creation.`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Historical Project runs remain inspectable from immutable snapshots and show a definition-deleted state instead of a broken live catalog link.`}),(0,z.jsxs)(`label`,{className:`mt-3 block text-[11px] font-semibold text-red-100`,children:[`Type the workflow id to confirm delete`,(0,z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),className:`mt-1 w-full rounded-sm border border-red-900/70 bg-[#101d22] px-2 py-1.5 font-mono text-xs text-slate-100 outline-none focus:border-red-400`,placeholder:e.workflowId,disabled:t})]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`mt-3`,children:`Archiving applies to the whole workflow identity. It hides this workflow from the default catalog and Project workflow selection lists.`}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Published versions stay available only through archive filters and historical run links, and historical Project runs continue to render from their snapshots.`})]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-slate-500 hover:text-slate-100 disabled:cursor-not-allowed disabled:opacity-50`,onClick:i,disabled:t,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,className:`rounded-sm border px-3 py-1.5 text-xs font-semibold transition disabled:cursor-not-allowed disabled:opacity-50 ${s?`border-red-700 text-red-100 hover:border-red-400`:`border-amber-600 text-amber-100 hover:border-amber-400`}`,onClick:s?o:a,disabled:t||s&&!c,children:s?`Delete workflow`:`Archive workflow`})]})]})})}var l0=`WorkflowBuilderWarning.invalidRawIrText`;function bOe({draft:e,onDraftChange:t}){let n=(0,R.useMemo)(()=>JSON.stringify(e.definition,null,2),[e.definition]),[r,i]=(0,R.useState)(n),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(`idle`),[l,u]=(0,R.useState)(),d=e.diagnostics.filter(e=>e.code===l0);(0,R.useEffect)(()=>{a||i(n)},[n,a]);let f=async()=>{c(`saving`),u(void 0);try{let n=await dJ(e.draftId,{rawDefinitionText:r,editTrigger:`raw_ir_edit`});if(t(n.draft),n.diagnostics.some(e=>e.code===l0)){o(!0),c(`warning`),u(`Raw Workflow IR text was not saved; the last valid draft object remains unchanged.`);return}i(JSON.stringify(n.draft.definition,null,2)),o(!1),c(`saved`),u(`Saved raw Workflow IR to the draft. Validation state: ${n.validation.validationState}.`)}catch(e){c(`error`),u(e instanceof Error?e.message:`Failed to save raw Workflow IR text`)}};return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Raw Pibo Workflow IR editor panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Raw Pibo Workflow IR editor`}),(0,z.jsx)(`h4`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Safe raw Workflow IR sync`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-xs leading-5 text-slate-400`,children:`Edit only Pibo Workflow IR JSON. Saving valid JSON parses into the same draft object used by the graph and inspectors. Invalid JSON or non-object text returns a warning diagnostic and keeps the last valid draft object unchanged; raw XState JSON is not exposed here.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`last valid rev ${e.revision}`}),a?(0,z.jsx)(F1,{label:`unsaved raw text`}):null]})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.72fr)]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,z.jsx)(`label`,{className:`text-[11px] font-semibold uppercase tracking-[0.12em] text-slate-500`,htmlFor:`workflow-raw-ir-editor`,children:`Editable Pibo Workflow IR JSON`}),(0,z.jsx)(`textarea`,{id:`workflow-raw-ir-editor`,"aria-label":`Raw Pibo Workflow IR editor`,className:`min-h-[26rem] rounded-sm border border-slate-800 bg-[#101d22] p-3 font-mono text-[11px] leading-5 text-slate-100 outline-none transition focus:border-[#11a4d4]`,spellCheck:!1,value:r,onChange:e=>{i(e.target.value),o(!0),c(`idle`),u(void 0)}}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-600/70 px-3 py-1.5 text-xs font-semibold text-emerald-200 transition hover:border-emerald-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void f(),disabled:s===`saving`,children:[s===`saving`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Bs,{size:13}),`Save raw IR`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-300 transition hover:border-slate-500 hover:text-white`,onClick:()=>{i(n),o(!1),c(`idle`),u(`Reset the editor from the last valid Pibo Workflow IR object.`)},disabled:s===`saving`,children:[(0,z.jsx)(Ls,{size:13}),`Reset from current draft`]})]}),l?(0,z.jsx)(`div`,{className:`rounded-sm border p-3 text-xs leading-5 ${s===`error`?`border-red-900/70 bg-red-950/40 text-red-200`:s===`warning`?`border-amber-700/70 bg-amber-950/30 text-amber-100`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,role:s===`error`||s===`warning`?`alert`:`status`,children:l}):null,d.length?(0,z.jsx)(P1,{diagnostics:d,emptyLabel:`No raw IR parse diagnostics.`}):null]}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Last valid Pibo Workflow IR object`}),(0,z.jsx)(`pre`,{"aria-label":`Pibo Workflow IR draft`,className:`max-h-[32rem] overflow-auto rounded-sm border border-slate-800 bg-[#101d22] p-3 text-[11px] leading-5 text-slate-200`,children:n})]})]})]})}function xOe({draftId:e,viewWorkflowId:t,viewWorkflowVersion:n}){return(0,z.jsx)(`main`,{className:`h-full min-h-0 overflow-auto bg-[#101d22]`,children:(0,z.jsxs)(`section`,{className:`mx-auto flex w-full max-w-6xl flex-col gap-6 p-6 max-[720px]:p-4`,"aria-labelledby":`workflows-title`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24] p-5 shadow-lg shadow-black/20`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.18em] text-[#11a4d4]`,children:`Workflow UI Authoring V2`}),(0,z.jsx)(`h1`,{id:`workflows-title`,className:`mt-2 text-2xl font-extrabold tracking-tight text-slate-100`,children:`Workflows`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-slate-400`,children:`Browse workflow definitions, duplicate published workflows into UI drafts, and open draft wrappers that edit Pibo Workflow IR from the authenticated Chat Web surface.`})]}),(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[0.9fr_1.1fr]`,children:[(0,z.jsx)(p0,{icon:jo,eyebrow:`Global catalog`,title:`Workflow Library`,description:`Open UI drafts or duplicate published workflow versions into a draft before editing.`,children:(0,z.jsx)(hOe,{activeDraftId:e})}),(0,z.jsx)(p0,{icon:vs,eyebrow:`Visual authoring`,title:`Workflow Builder`,description:`Load a UI draft wrapper and keep Pibo Workflow IR as the editable source of truth.`,children:e?(0,z.jsx)(COe,{draftId:e}):t&&n?(0,z.jsx)(bDe,{workflowId:t,workflowVersion:n}):(0,z.jsx)(SOe,{})})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 rounded-sm border border-slate-800 bg-[#151f24] p-4 text-xs text-slate-400 md:grid-cols-4`,children:[(0,z.jsx)(m0,{icon:Lo,label:`Pibo Workflow IR remains the source of truth`}),(0,z.jsx)(m0,{icon:Qo,label:`Code workflows can be duplicated into UI drafts`}),(0,z.jsx)(m0,{icon:Gs,label:`Workflow capabilities are registered refs only`}),(0,z.jsx)(m0,{icon:vs,label:`XState stays a read-only visualization projection`})]}),(0,z.jsx)(wOe,{})]})})}function SOe(){return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,z.jsx)(OOe,{title:`Open a draft to start authoring`,description:`Use the Workflow Library draft row or Duplicate to draft action. The builder route will load a draft wrapper around Pibo Workflow IR, not raw XState source.`}),(0,z.jsx)(u0,{}),(0,z.jsx)(SDe,{})]})}function COe({draftId:e}){let[t,n]=(0,R.useState)(),[r,i]=(0,R.useState)(`loading`),[a,o]=(0,R.useState)();return(0,R.useEffect)(()=>{let t=!1;return i(`loading`),o(void 0),Nye(e).then(e=>{t||(n(e.draft),i(`loaded`))}).catch(e=>{t||(o(e instanceof Error?e.message:`Failed to load workflow draft`),i(`error`))}),()=>{t=!0}},[e]),r===`loading`?(0,z.jsxs)(`div`,{className:`flex w-full items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4 text-sm text-slate-300`,"aria-live":`polite`,children:[(0,z.jsx)(Cs,{size:16,className:`animate-spin text-[#11a4d4]`}),`Loading workflow draft `,e,`…`]}):r===`error`||!t?(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-900/70 bg-red-950/40 p-4 text-sm leading-6 text-red-200`,role:`alert`,children:[(0,z.jsx)(`div`,{className:`font-bold`,children:`Could not load workflow draft`}),(0,z.jsx)(`div`,{className:`mt-1 text-xs`,children:a??`Draft '${e}' was not found.`})]}):(0,z.jsx)(TOe,{draft:t})}function wOe(){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/60 bg-amber-950/15 p-4 text-xs leading-5 text-amber-100`,"aria-label":`Workflow V2 explicit non-goals`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-amber-200`,children:[(0,z.jsx)(Gs,{size:13}),`V2 scope boundary`]}),(0,z.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`Workflows V2 is an authoring surface for Pibo Workflow IR and registered capability references, not a code or product import/export surface.`}),(0,z.jsxs)(`ul`,{className:`mt-3 grid gap-1 text-[11px] text-amber-100/75 md:grid-cols-2`,children:[(0,z.jsx)(`li`,{children:`No inline TypeScript, JavaScript, shell, eval, arbitrary executable code, or raw handler body authoring.`}),(0,z.jsx)(`li`,{children:`No raw XState editing, workflow templates, workflow slash commands, or workflow tools for agents.`}),(0,z.jsx)(`li`,{children:`No YAML/JSON product import/export or TypeScript export path from UI-authored workflows.`}),(0,z.jsx)(`li`,{children:`No Zod schema authoring; schema edits remain constrained to Pibo Workflow IR and registered metadata.`})]})]})}function u0(){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-emerald-900/60 bg-emerald-950/15 p-4 text-xs leading-5 text-emerald-100`,"aria-label":`Registered capability security boundary`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-emerald-300`,children:[(0,z.jsx)(Gs,{size:13}),`Registered capability security boundary`]}),(0,z.jsx)(`p`,{className:`mt-2 text-emerald-100/90`,children:`V2 authoring composes registered refs only: non-archived Agent profiles, code handlers, adapters, guards, nested workflows, human actions, and prompt assets.`}),(0,z.jsxs)(`ul`,{className:`mt-3 grid gap-1 text-[11px] text-emerald-100/75`,children:[(0,z.jsx)(`li`,{children:`Existing Chat Web auth plus Project and Pibo Session visibility rules still gate workflow catalog, Project workflow sessions, snapshots, lifecycle events, prompt assets, and human actions.`}),(0,z.jsx)(`li`,{children:`Agent nodes select profile refs only; the UI does not grant extra tools, skills, context files, native tools, MCP servers, or compute-worker access beyond the selected runtime profile.`}),(0,z.jsx)(`li`,{children:`No inline JavaScript, TypeScript, shell, eval, arbitrary executable nodes, or raw handler bodies are created by the UI.`}),(0,z.jsx)(`li`,{children:`Incompatible schemas must use a visible registered adapter node or edge adapter; hidden LLM coercion is not used.`}),(0,z.jsx)(`li`,{children:`XState remains projection-only; Pibo Workflow IR is the persisted source of truth.`}),(0,z.jsx)(`li`,{children:`Workflow inputs, outputs, prompts, prompt assets, state, edge payloads, snapshots, and human action payloads remain sensitive workflow data; normal diagnostics expose only sanitized metadata.`})]})]})}function TOe({draft:e}){let[t,n]=(0,R.useState)(e),[r,i]=(0,R.useState)(e.versionIntent),[a,o]=(0,R.useState)(`idle`),[s,c]=(0,R.useState)(),l=a===`validating`||a===`publishing`,u=t.validation?.errorCount??t.diagnostics.filter(e=>e.severity===`error`).length,d=t.validation?.warningCount??t.diagnostics.filter(e=>e.severity===`warning`).length,f=t.validation?.blocksPublish===!0||u>0;(0,R.useEffect)(()=>{n(e),i(e.versionIntent),o(`idle`),c(void 0)},[e]);let p=async()=>{o(`validating`),c(void 0);try{let e=await Pye(t.draftId);n(e.draft),i(e.draft.versionIntent),o(`validated`),c(`Draft validation ${e.validation.ok?`passed`:`returned diagnostics`}. Publish remains a separate action.`)}catch(e){o(`error`),c(e instanceof Error?e.message:`Failed to validate workflow draft`)}},m=async()=>{o(`publishing`),c(void 0);try{let e=await Fye(t.draftId,{versionIntent:r});n(e.draft),i(e.draft.versionIntent),o(`published`),c(e.publishedVersion?`${e.message??`Published workflow draft.`} Definition hash ${e.publishedVersion.definitionHash}.`:e.message??`Publish validation passed.`)}catch(e){o(`error`),c(e instanceof Error?e.message:`Failed to publish workflow draft`)}};return(0,z.jsxs)(`div`,{className:`flex w-full flex-col gap-4 rounded-sm border border-slate-800 bg-[#101d22]/70 p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:`Loaded UI draft`}),(0,z.jsx)(`h3`,{className:`mt-1 text-lg font-bold text-slate-100`,children:String(t.definition.title??t.workflowId)}),(0,z.jsxs)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-500`,children:[`Builder route `,(0,z.jsxs)(`code`,{className:`rounded bg-slate-900 px-1 text-slate-300`,children:[`/workflows/drafts/`,t.draftId]}),` loaded a draft wrapper around partial Pibo Workflow IR.`]})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${t.source} source`}),(0,z.jsx)(F1,{label:t.status}),(0,z.jsx)(F1,{label:t.validationState}),(0,z.jsx)(F1,{label:`rev ${t.revision}`})]})]}),(0,z.jsxs)(`div`,{className:`grid gap-3 text-xs md:grid-cols-2`,"aria-label":`Workflow draft metadata`,children:[(0,z.jsx)(f0,{label:`Draft id`,value:t.draftId}),(0,z.jsx)(f0,{label:`Workflow id`,value:t.workflowId}),(0,z.jsx)(f0,{label:`Base workflow`,value:t.baseWorkflowId&&t.baseWorkflowVersion?`${t.baseWorkflowId}@${t.baseWorkflowVersion}`:`new UI draft`}),(0,z.jsx)(f0,{label:`Next version path`,value:t.targetWorkflowVersion??`not assigned yet`}),(0,z.jsx)(f0,{label:`Version intent`,value:t.versionIntent})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Workflow publish version panel`,children:[(0,z.jsxs)(`div`,{id:`workflow-publish-gate`,className:`mb-3 rounded-sm border p-3 text-xs leading-5 ${f?`border-amber-700/70 bg-amber-950/30 text-amber-100`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,"aria-label":`Workflow publish gate`,role:`status`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:f?`Publish blocked by draft diagnostics`:`Publish gate ready`}),(0,z.jsx)(`p`,{className:`mt-1`,children:f?`Publish is disabled because ${u} error diagnostic${u===1?``:`s`} ${u===1?`remains`:`remain`}. Draft save remains allowed while you fix errors; before-publish validation also requires workflow input/output ports and at least one node.`:d>0?`Warnings do not block publishing. Before-publish validation still runs and will block if workflow input/output ports, graph nodes, or registered refs are invalid.`:`No blocking diagnostics are present. Before-publish validation will run again before creating an immutable workflow version.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Publish version intent`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-400`,children:`Default publish increments the patch version. Choose minor or major when the release scope needs a larger semantic version bump.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Version bump intent`}),(0,z.jsxs)(`select`,{className:`rounded-sm border border-slate-700 bg-[#101d22] px-2 py-1.5 text-xs text-slate-100 outline-none transition focus:border-[#11a4d4]`,value:r,onChange:e=>i(e.target.value),disabled:l,"aria-label":`Version bump intent`,children:[(0,z.jsx)(`option`,{value:`patch`,children:`Patch version bump (default)`}),(0,z.jsx)(`option`,{value:`minor`,children:`Minor version bump`}),(0,z.jsx)(`option`,{value:`major`,children:`Major version bump`})]})]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-slate-700 px-3 py-1.5 text-xs font-semibold text-slate-200 transition hover:border-[#11a4d4] hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void p(),disabled:l,children:[a===`validating`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Ls,{size:13}),`Validate draft`]}),(0,z.jsxs)(`button`,{type:`button`,className:`inline-flex items-center justify-center gap-1 rounded-sm border border-emerald-600/70 px-3 py-1.5 text-xs font-semibold text-emerald-200 transition hover:border-emerald-400 hover:text-white disabled:cursor-not-allowed disabled:opacity-50`,onClick:()=>void m(),disabled:l||f,"aria-describedby":`workflow-publish-gate`,children:[a===`publishing`?(0,z.jsx)(Cs,{size:13,className:`animate-spin`}):(0,z.jsx)(Lo,{size:13}),`Publish draft`]})]})]}),s?(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border p-3 text-xs leading-5 ${a===`error`?`border-red-900/70 bg-red-950/40 text-red-200`:`border-emerald-900/60 bg-emerald-950/20 text-emerald-200`}`,role:a===`error`?`alert`:`status`,children:s}):null]}),(0,z.jsx)(u0,{}),(0,z.jsx)(RDe,{draft:t,onDraftChange:n,renderInspectors:e=>(0,z.jsx)(iOe,{...e})}),(0,z.jsx)(EOe,{draft:t}),(0,z.jsx)(bOe,{draft:t,onDraftChange:n}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3 text-[11px] leading-5 text-slate-500`,children:`Raw XState source is not opened as an editable document. XState remains projection-only; the editable source is the Pibo Workflow IR shown above and in the raw Pibo Workflow IR editor.`})]})}function EOe({draft:e}){let t=e.validation,n=t?.errorCount??e.diagnostics.filter(e=>e.severity===`error`).length,r=t?.warningCount??e.diagnostics.filter(e=>e.severity===`warning`).length,i=t?.infoCount??e.diagnostics.filter(e=>e.severity===`info`).length;return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-4`,"aria-label":`Workflow validation panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:`Validation panel`}),(0,z.jsx)(`h4`,{className:`mt-1 text-sm font-bold text-slate-100`,children:`Structured draft diagnostics`}),(0,z.jsx)(`p`,{className:`mt-2 max-w-2xl text-xs leading-5 text-slate-400`,children:`Draft validation reports sanitized diagnostic fields from the Workflow IR pipeline. Publish remains gated by blocking error diagnostics and the backend before-publish route.`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(F1,{label:`${n} errors`}),(0,z.jsx)(F1,{label:`${r} warnings`}),(0,z.jsx)(F1,{label:`${i} info`})]})]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 text-xs md:grid-cols-3`,"aria-label":`Workflow validation summary`,children:[(0,z.jsx)(f0,{label:`Validation state`,value:e.validationState}),(0,z.jsx)(f0,{label:`Last trigger`,value:t?.trigger??`not checked`}),(0,z.jsx)(f0,{label:`Checked at`,value:t?.checkedAt??`not checked`}),(0,z.jsx)(f0,{label:`Publish gate`,value:t?.blocksPublish?`blocked`:`not blocked`}),(0,z.jsx)(f0,{label:`Run gate`,value:t?.blocksRun?`blocked`:`not blocked`}),(0,z.jsx)(f0,{label:`Diagnostic count`,value:String(e.diagnostics.length)})]}),e.diagnostics.length?(0,z.jsx)(DOe,{draft:e}):(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border border-emerald-900/60 bg-emerald-950/20 p-3 text-xs text-emerald-200`,children:`No validation diagnostics returned by the draft pipeline.`})]})}function DOe({draft:e}){return(0,z.jsx)(`div`,{className:`mt-3 grid gap-2`,"aria-label":`Workflow structured diagnostics`,children:e.diagnostics.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-700/70 bg-amber-950/30 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 font-bold text-amber-200`,children:[(0,z.jsx)(Js,{size:13}),e.code]}),(0,z.jsx)(`div`,{className:`mt-1`,children:e.message}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[11px]`,children:[(0,z.jsx)(d0,{label:`Severity`,value:e.severity}),(0,z.jsx)(d0,{label:`Path`,value:e.path}),(0,z.jsx)(d0,{label:`Node`,value:e.nodeId}),(0,z.jsx)(d0,{label:`Edge`,value:e.edgeId}),(0,z.jsx)(d0,{label:`Registry ref`,value:e.registryRef})]}),e.hint?(0,z.jsx)(`div`,{className:`mt-2 text-amber-200/80`,children:e.hint}):null]},`${e.code}:${e.path??e.nodeId??e.edgeId??e.registryRef??`workflow`}`))})}function d0({label:e,value:t}){return t?(0,z.jsxs)(`span`,{className:`rounded-sm border border-amber-700/50 bg-amber-950/40 px-2 py-0.5`,children:[(0,z.jsxs)(`span`,{className:`font-semibold text-amber-200/80`,children:[e,`:`]}),` `,(0,z.jsx)(`code`,{children:t})]}):null}function f0({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#151f24]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-slate-500`,children:e}),(0,z.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px] text-slate-200`,children:t})]})}function p0({icon:e,eyebrow:t,title:n,description:r,children:i}){return(0,z.jsxs)(`section`,{className:`flex min-h-72 flex-col rounded-sm border border-slate-800 bg-[#151f24] p-5 shadow-lg shadow-black/20`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-[#11a4d4]/35 bg-[#11a4d4]/10 text-[#11a4d4]`,children:(0,z.jsx)(e,{size:18})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-[0.16em] text-slate-500`,children:t}),(0,z.jsx)(`h2`,{className:`mt-1 text-lg font-bold text-slate-100`,children:n}),(0,z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-slate-400`,children:r})]})]}),(0,z.jsx)(`div`,{className:`mt-5 flex flex-1`,children:i})]})}function OOe({title:e,description:t}){return(0,z.jsxs)(`div`,{className:`flex w-full flex-col justify-center rounded-sm border border-dashed border-slate-700 bg-[#101d22]/70 p-4 text-center`,children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-slate-200`,children:e}),(0,z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-slate-500`,children:t})]})}function m0({icon:e,label:t}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-slate-800 bg-[#101d22]/60 px-3 py-2`,children:[(0,z.jsx)(e,{size:14,className:`shrink-0 text-[#11a4d4]`}),(0,z.jsx)(`span`,{children:t})]})}function h0(e,t=`new-agent`){return{displayName:t,description:``,nativeTools:[],skills:T0(e,`pi-agent-harness`)?[`pi-agent-harness`]:[],contextFiles:[],subagents:[],mcpServers:[],piPackages:[],mainModel:void 0,subagentModel:void 0,thinkingLevel:void 0,mainThinkingLevel:void 0,subagentThinkingLevel:void 0,fast:!1,mainFast:!1,subagentFast:!1,builtinTools:`default`,builtinToolNames:[...x0],autoContextFiles:!0,runControl:!1,brokenContextFiles:[],hardPinnedModel:void 0,source:`custom`}}function kOe(e){let t=new Set([...e].map(e=>e.trim()).filter(Boolean)),n=`new-agent`;if(!t.has(n))return n;for(let e=1;;e+=1){let r=`${n}-${e}`;if(!t.has(r))return r}}function g0(e){return{id:e.id,profileName:e.profileName,displayName:e.displayName,description:e.description??``,nativeTools:e.nativeTools,skills:e.skills,contextFiles:e.contextFiles,subagents:e.subagents,mcpServers:e.mcpServers,piPackages:e.piPackages??[],mainModel:e.mainModel,subagentModel:e.subagentModel,thinkingLevel:e.thinkingLevel,mainThinkingLevel:e.mainThinkingLevel,subagentThinkingLevel:e.subagentThinkingLevel,fast:e.fast??!1,mainFast:e.mainFast??!1,subagentFast:e.subagentFast??!1,builtinTools:e.builtinTools,builtinToolNames:b0(e.builtinToolNames,e.builtinTools),autoContextFiles:e.autoContextFiles??!0,runControl:e.runControl,brokenContextFiles:e.brokenContextFiles??[],archivedAt:e.archivedAt,hardPinnedModel:void 0,source:`custom`}}function _0(e,t){return{displayName:e.name,description:e.description??``,nativeTools:e.nativeTools??[],skills:e.skills??(T0(t,`pi-agent-harness`)?[`pi-agent-harness`]:[]),contextFiles:e.contextFiles??[],subagents:e.subagents??[],mcpServers:e.mcpServers??[],piPackages:e.piPackages??[],mainModel:e.mainModel??e.model,subagentModel:e.subagentModel??e.model,thinkingLevel:e.thinkingLevel,mainThinkingLevel:e.mainThinkingLevel??e.thinkingLevel,subagentThinkingLevel:e.subagentThinkingLevel??e.thinkingLevel,fast:e.fast??!1,mainFast:e.mainFast??e.fast??!1,subagentFast:e.subagentFast??e.fast??!1,builtinTools:e.builtinTools??`default`,builtinToolNames:b0(e.builtinToolNames,e.builtinTools),autoContextFiles:e.autoContextFiles??!0,runControl:e.runControl??!1,brokenContextFiles:[],hardPinnedModel:e.model,profileName:e.name,source:`profile`}}function AOe(e,t){return{..._0(e,t),displayName:`${e.name}-copy`,id:void 0,hardPinnedModel:void 0,profileName:void 0,source:`custom`}}function v0(e){return{...g0(e),displayName:`${e.profileName}-copy`,id:void 0,profileName:void 0,archivedAt:void 0,source:`custom`}}function jOe(e,t){let n=new Map;for(let t of e)n.set(t.name,t.name);for(let e of t)n.set(e.profileName,e.displayName);return[...n.entries()].map(([e,t])=>({value:e,label:t}))}function MOe(e){return e.trim()?e.length>120?`Agent name is too long.`:/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e)?null:`Use lowercase kebab-case only, for example test-agent.`:`Agent name is required.`}function y0(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function b0(e,t=`default`){if(t===`disabled`)return[];let n=new Set(e??x0);return x0.filter(e=>n.has(e))}var NOe=new Set([`apply_patch`,`web_search`,`view_image`]),x0=[`read`,`bash`,`edit`,`write`],POe={read:`Read workspace files.`,bash:`Run shell commands.`,edit:`Edit existing files.`,write:`Create or overwrite files.`};function FOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.pluginId??(NOe.has(t.name)?`pibo.codex-compat`:void 0),i=t.pluginName??(e===`pibo.codex-compat`?`Codex Compat`:void 0),a=!e||e===`pibo.core`,o=S0(r,a?`builtin`:`plugin:${e}`,{title:a?`Built-in Tools`:w0(e,i),description:a?`Built-in Pibo tool catalog`:e??`plugin`,kind:a?`builtin`:`plugin`});o.items.push(t),n.has(t.name)&&(o.selectedCount+=1),o.totalCount+=1}return C0(r,[`builtin`,`plugin`])}function IOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.kind,i=S0(r,e===`plugin`?`plugin:${t.pluginId??t.name}`:e,{title:ROe(t),description:zOe(t),kind:t.kind});i.items.push(t),n.has(t.name)&&(i.selectedCount+=1),i.totalCount+=1}return C0(r,[`builtin`,`plugin`,`user`])}function LOe(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=t.pluginId===`pibo.core`,i=!t.pluginId,a=S0(r,e?`builtin`:i?`custom`:`plugin:${t.pluginId}`,{title:e?`Built-in Context Files`:i?`Custom`:w0(t.pluginId,t.pluginName),description:e?`Pibo built-in context file catalog`:i?`Loose context files without a plugin namespace`:t.pluginId??`plugin`,kind:e?`builtin`:i?`custom`:`plugin`});a.items.push(t),n.has(t.key)&&(a.selectedCount+=1),a.totalCount+=1}return C0(r,[`builtin`,`custom`,`plugin`])}function S0(e,t,n){let r=e.get(t);if(r)return r;let i={key:t,title:n.title,description:n.description,kind:n.kind,items:[],selectedCount:0,totalCount:0,defaultOpen:!1};return e.set(t,i),i}function C0(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e.values()].sort((e,r)=>{let i=n.get(e.kind)??t.length,a=n.get(r.kind)??t.length;return i===a?e.title.localeCompare(r.title):i-a}).map(e=>({...e,defaultOpen:!1}))}function w0(e,t){return e===`pibo.codex-compat`?`Codex Compat`:t||(e?(e.split(`.`).filter(Boolean).at(-1)??e).split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `):`Plugin`)}function ROe(e){return e.kind===`builtin`?`Built-in Skills`:e.kind===`user`?`User Skills`:w0(e.pluginId,e.pluginName)}function zOe(e){return e.kind===`builtin`?`Pibo-owned built-in skill catalog`:e.kind===`user`?`User-managed skills`:e.pluginId??`plugin`}function BOe(e){return e.kind===`builtin`?`built-in skill`:e.kind===`user`?`user skill`:e.pluginName??e.pluginId??`plugin skill`}function T0(e,t){return e?.skills.some(e=>e.kind===`builtin`&&e.name===t)??!1}function VOe(e){let t=e.source??`plugin`,n=e.scope??`global`;return e.pluginId===`pibo.core`?`built-in global`:t===`plugin`?`plugin global`:n===`agent`?e.agentProfileName?`agent ${e.agentProfileName}`:`agent local`:`managed global`}function E0(e,t){return e.includes(t.id)||e.includes(t.name)}function HOe(e,t){return E0(e,t)?e.filter(e=>e!==t.id&&e!==t.name):[...e,t.id]}function UOe(e){return e.enabled&&e.installStatus===`installed`}function D0(e){let t=e.resourceTypes.length?e.resourceTypes.join(` + `):`resources pending`,n=e.version?`v${e.version}`:e.installStatus,r=e.diagnostics.some(e=>e.type===`error`)?` / needs attention`:``;return`${t} / ${n} / ${e.enabled?`enabled`:`disabled`}${r}`}function O0(){return`Agent Designer API unavailable. Restart the Pibo web gateway after pulling/building the latest backend.`}function WOe(e){return e.toLowerCase().includes(`not found`)||e.includes(`404`)}function k0({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`border border-slate-700 bg-[#1a262b] rounded-sm p-4`,children:[(0,z.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wider text-slate-400 mb-3`,children:e}),(0,z.jsx)(`div`,{className:`grid gap-3`,children:t})]})}function GOe({title:e,children:t}){return(0,z.jsx)(k0,{title:e,children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:t})})}function A0({groups:e,empty:t,renderItem:n}){return e.length===0?(0,z.jsx)(z.Fragment,{children:t}):(0,z.jsx)(`div`,{className:`grid gap-2`,children:e.map(e=>(0,z.jsx)(KOe,{group:e,renderItem:n},e.key))})}function KOe({group:e,renderItem:t}){let[n,r]=(0,R.useState)(e.defaultOpen),i=e.items.slice(0,100),a=e.items.length-i.length,o=e.kind===`custom`||e.kind===`user`?`border-[#f59e0b]/70 text-amber-100 bg-[#f59e0b]/10`:`border-[#11a4d4]/70 text-sky-100 bg-[#11a4d4]/10`;return(0,z.jsxs)(`div`,{className:`border rounded-sm ${n?`border-slate-700 bg-[#101d22]`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center gap-2 p-2 text-left`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 shrink-0 inline-flex items-center justify-center border rounded-sm ${o}`,children:n?(0,z.jsx)(zo,{size:14}):(0,z.jsx)(Bo,{size:14})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-slate-100`,children:e.title}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:e.description})]}),(0,z.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-sm font-semibold tabular-nums`,"aria-label":`${e.selectedCount} of ${e.totalCount} selected`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:e.selectedCount}),(0,z.jsxs)(`span`,{className:`text-slate-500`,children:[`/`,e.totalCount]})]})]}),n?(0,z.jsxs)(`div`,{className:`border-t border-slate-800 p-2`,children:[(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:i.map(t)}),a>0?(0,z.jsxs)(`div`,{className:`mt-2 text-xs text-slate-500`,children:[`Showing first `,100,` of `,e.items.length,` items. Use Context to manage the full catalog.`]}):null]}):null]})}function j0({checked:e,disabled:t,title:n,description:r,meta:i,metaClass:a,actionLabel:o,actionIcon:s,actionDisabled:c,onAction:l,onToggle:u}){return(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{t||u()},"aria-disabled":t,className:`min-w-0 border rounded-sm p-2 text-left grid grid-cols-[18px_1fr] gap-2 ${t&&!l?`opacity-60`:``} ${e?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(F0,{checked:e,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:n})}),o&&l?(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsxs)(`span`,{role:`button`,tabIndex:0,onClick:e=>{e.preventDefault(),e.stopPropagation(),c||l()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&!c&&(e.preventDefault(),e.stopPropagation(),l())},className:`inline-flex h-6 items-center justify-center gap-1 border px-1.5 text-[10px] uppercase tracking-wider ${c?`border-slate-800 text-slate-600`:`border-[#11a4d4]/70 text-[#7dd3fc] hover:border-[#11a4d4] hover:text-sky-100`}`,children:[s,o]})}):null]}),r?(0,z.jsx)(`span`,{className:`block text-xs text-slate-500 truncate`,children:r}):null,i?(0,z.jsx)(`span`,{className:`block font-mono text-[10px] mt-1 ${a??`text-slate-600`}`,children:i}):null]})]})}function qOe({pkg:e,selected:t,readOnly:n,expanded:r,busy:i,onToggleSelected:a,onToggleExpanded:o,onToggleEnabled:s,onUnregister:c}){let l=e.diagnostics.some(e=>e.type===`error`),u=!n&&(e.enabled||t);return(0,z.jsxs)(`div`,{className:`border rounded-sm ${t?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24]`} ${e.enabled?``:`opacity-75`}`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 p-2`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:!u,onClick:a,className:`min-w-0 grid grid-cols-[18px_1fr] gap-2 text-left disabled:cursor-not-allowed`,children:[(0,z.jsx)(F0,{checked:t,disabled:!u,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-slate-200`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${e.enabled?`border-[#11a4d4]/60 text-[#7dd3fc]`:`border-slate-700 text-slate-500`}`,children:e.enabled?`enabled`:`disabled`})]}),(0,z.jsx)(`span`,{className:`block text-xs text-slate-500 truncate`,children:e.description??e.source}),(0,z.jsx)(`span`,{className:`block font-mono text-[10px] mt-1 ${l?`text-[#f59e0b]`:`text-[#11a4d4]`}`,children:D0(e)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,title:r?`Hide Details`:`Show Details`,"aria-label":r?`Hide Details`:`Show Details`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:r?(0,z.jsx)(zo,{size:13}):(0,z.jsx)(Bo,{size:13})}),s?(0,z.jsx)(`button`,{type:`button`,disabled:i,onClick:s,title:e.enabled?`Disable Package`:`Enable Package`,"aria-label":e.enabled?`Disable Package`:`Enable Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:e.enabled?(0,z.jsx)(Fs,{size:13}):(0,z.jsx)(Is,{size:13})}):null,c?(0,z.jsx)(`button`,{type:`button`,disabled:i,onClick:c,title:`Unregister Package`,"aria-label":`Unregister Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-400 hover:text-red-300 disabled:opacity-50`,children:(0,z.jsx)(qs,{size:13})}):null]})]}),r?(0,z.jsx)(M0,{pkg:e}):null]})}function M0({pkg:e}){return(0,z.jsxs)(`div`,{className:`border-t border-slate-800 p-3 grid gap-3 text-xs text-slate-300`,children:[(0,z.jsx)(JOe,{rows:[[`Source`,e.source],[`Install`,e.installSpec],[`Version`,e.version],[`Added`,e.addedAt],[`Updated`,e.updatedAt]]}),e.repositoryUrl?(0,z.jsxs)(`a`,{href:e.repositoryUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-[#7dd3fc] hover:text-sky-100`,children:[(0,z.jsx)(rs,{size:12}),`Source repository`]}):null,(0,z.jsx)(N0,{title:`Extensions`,values:e.extensionPaths}),(0,z.jsx)(N0,{title:`Skills`,values:e.skillNames}),(0,z.jsx)(N0,{title:`Prompts`,values:e.promptNames}),(0,z.jsx)(N0,{title:`Themes`,values:e.themeNames}),(0,z.jsx)(N0,{title:`Tools`,values:e.discoveredToolNames}),e.diagnostics.length?(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Diagnostics`}),e.diagnostics.map((e,t)=>(0,z.jsxs)(`div`,{className:`border px-2 py-1 rounded-sm ${e.type===`error`?`border-red-500/50 text-red-200 bg-red-500/10`:e.type===`warning`?`border-[#f59e0b]/50 text-amber-100 bg-[#f59e0b]/10`:`border-slate-700 text-slate-400 bg-[#0e1116]`}`,children:[(0,z.jsx)(`span`,{className:`font-mono uppercase text-[10px] mr-2`,children:e.type}),e.message]},`${e.type}:${t}`))]}):null]})}function JOe({rows:e}){let t=e.filter(([,e])=>e);return t.length===0?null:(0,z.jsx)(`div`,{className:`grid gap-1`,children:t.map(([e,t])=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[84px_minmax(0,1fr)] gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[11px] text-slate-300`,children:t})]},e))})}function N0({title:e,values:t}){return t?.length?(0,z.jsxs)(`div`,{className:`grid gap-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.map(e=>(0,z.jsx)(`span`,{className:`max-w-full break-all border border-slate-700 bg-[#0e1116] px-2 py-1 font-mono text-[11px] text-slate-300 rounded-sm`,children:e},e))})]}):null}function P0({checked:e,disabled:t,title:n,onToggle:r}){return(0,z.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":e,onClick:r,className:`inline-flex w-fit items-center gap-2 text-left text-sm text-slate-300 hover:text-slate-100 disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:e,disabled:t}),(0,z.jsx)(`span`,{children:n})]})}function F0({checked:e,disabled:t,className:n=``}){return(0,z.jsx)(`span`,{className:`h-4 w-4 shrink-0 border rounded-sm inline-flex items-center justify-center ${e?`border-[#11a4d4] text-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-600 text-transparent`} ${t?`opacity-70`:``} ${n}`,children:e?(0,z.jsx)(Ro,{size:12}):null})}function I0({message:e=`Agent Designer API unavailable`}){return(0,z.jsx)(`div`,{className:`text-xs text-amber-100 border border-dashed border-[#f59e0b]/50 bg-[#f59e0b]/10 rounded-sm p-3`,children:e})}function L0({title:e,modelTitle:t,model:n,thinking:r,fast:i,modelCatalog:a,readOnly:o,modelHint:s,configuredProvidersOnly:c=!1,onModelChange:l,onThinkingChange:u,onFastChange:d}){return(0,z.jsxs)(`div`,{className:`grid gap-2 border border-slate-800 rounded-sm p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(150px,190px)_auto] lg:items-start`,children:[(0,z.jsx)(XOe,{title:t,catalog:a,value:n,allowUnset:!0,readOnly:o,hint:s,emptyProviderLabel:`Default`,configuredProvidersOnly:c,onChange:l}),(0,z.jsx)(YOe,{title:`Thinking`,value:r,readOnly:o,reserveHintSpace:!0,onChange:u}),(0,z.jsxs)(`div`,{className:`grid gap-2 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:`Fast`}),(0,z.jsx)(`div`,{className:`h-4`,"aria-hidden":`true`}),(0,z.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>d(!i),className:`inline-flex h-9 w-fit items-center gap-2 text-left text-sm text-slate-300 hover:text-slate-100 disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:i===!0,disabled:o}),(0,z.jsx)(`span`,{children:i?`Fast on`:`Fast off`})]})]})]})]})}function YOe({title:e,value:t,readOnly:n,hint:r,reserveHintSpace:i=!1,onChange:a}){return(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:e}),(0,z.jsx)(`button`,{type:`button`,disabled:n||!t,onClick:()=>a(void 0),className:`text-[10px] uppercase tracking-wider text-slate-500 hover:text-slate-300 disabled:opacity-50`,children:`Unset`})]}),r?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:r}):i?(0,z.jsx)(`div`,{className:`h-4`,"aria-hidden":`true`}):null,(0,z.jsxs)(`select`,{value:t??``,disabled:n,onChange:e=>a(e.target.value?e.target.value:void 0),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:`Default`}),Zq.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))]})]})}function XOe({title:e,catalog:t,value:n,allowUnset:r,readOnly:i,hint:a,emptyProviderLabel:o=`Select provider`,configuredProvidersOnly:s=!1,onChange:c}){let[l,u]=(0,R.useState)(n?.provider??``),[d,f]=(0,R.useState)(n?.id??``),p=t?.providers??[],m=p.filter(e=>!s||e.authConfigured),h=m.find(e=>e.id===l),g=s?p.find(e=>e.id===l&&!e.authConfigured):void 0,_=!!l&&!h,v=_?g?`${g.label} (not configured)`:`${l} (unknown provider)`:``,y=h?.models.find(e=>e.id===d),b=!!(l&&d&&h&&!y),x=h?.models??[],S=h?.authConfigured;return(0,R.useEffect)(()=>{u(n?.provider??``),f(n?.id??``)},[n?.id,n?.provider]),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:e}),r?(0,z.jsx)(`button`,{type:`button`,disabled:i||!l&&!d,onClick:()=>{u(``),f(``),c(void 0)},className:`text-[10px] uppercase tracking-wider text-slate-500 hover:text-slate-300 disabled:opacity-50`,children:`Unset`}):null]}),a?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:a}):null,m.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:p.length===0?`Model catalog unavailable.`:`No configured providers. Configure a provider under Settings > Providers.`}):null,(0,z.jsxs)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:[(0,z.jsxs)(`select`,{value:l,disabled:i,onChange:e=>{let t=e.target.value;u(t),f(``),t||c(void 0)},className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:o}),m.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id)),_?(0,z.jsx)(`option`,{value:l,children:v}):null]}),(0,z.jsxs)(`select`,{value:d,disabled:i,onChange:e=>{let t=e.target.value;f(t),t?c({provider:l,id:t}):l&&c(void 0)},className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:[(0,z.jsx)(`option`,{value:``,children:l?`Select model`:`Select provider first`}),x.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.label},e.id)),b?(0,z.jsx)(`option`,{value:d,children:`${d} (unknown model)`}):null]})]}),l?(0,z.jsx)(`div`,{className:`text-xs text-slate-500`,children:_?g?`Stored provider is no longer configured.`:`Stored provider is no longer present in the catalog.`:S?`Provider auth configured.`:`Provider auth missing.`}):null,b?(0,z.jsx)(`div`,{className:`text-xs text-amber-100`,children:`Stored model is no longer present in the catalog.`}):null]})}function ZOe({agents:e,initialCustomAgents:t,initialCatalog:n,modelCatalog:r,onSelect:i,onCreateSession:a,onEditContextFile:o,onEditMcpServer:s,onAgentsChanged:c,creatingSession:l}){let[u,d]=(0,R.useState)(n??null),[f,p]=(0,R.useState)(t),[m,h]=(0,R.useState)(()=>h0(n)),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(()=>localStorage.getItem(`pibo.chat.showArchivedAgents`)===`true`),[S,C]=(0,R.useState)(``),[w,T]=(0,R.useState)(null),[E,D]=(0,R.useState)(``),[O,k]=(0,R.useState)(`agent`),A=!!u;(0,R.useEffect)(()=>p(t),[t]),(0,R.useEffect)(()=>{n&&d(n)},[n]);let j=(0,R.useMemo)(()=>new Set(f.map(e=>e.profileName)),[f]),M=(0,R.useMemo)(()=>e.filter(e=>!j.has(e.name)),[e,j]),N=(0,R.useMemo)(()=>f.filter(e=>!e.archivedAt),[f]),P=(0,R.useMemo)(()=>f.filter(e=>e.archivedAt),[f]),F=(0,R.useMemo)(()=>jOe(e,N),[e,N]),ee=!!m.archivedAt,te=g&&m.source===`custom`&&!m.id,I=m.source===`profile`||ee,ne=I?null:MOe(m.displayName),L=m.profileName??(ne?`new custom profile`:m.displayName),re=(0,R.useMemo)(()=>u?.contextFiles.filter(e=>(e.scope??`global`)===`agent`?e.agentProfileName===L||m.contextFiles.includes(e.key):!0)??[],[u,m.contextFiles,L]),ie=(0,R.useMemo)(()=>FOe(u?.nativeTools??[],m.nativeTools),[u?.nativeTools,m.nativeTools]),ae=(0,R.useMemo)(()=>IOe(u?.skills??[],m.skills),[u?.skills,m.skills]),oe=(0,R.useMemo)(()=>LOe(re,m.contextFiles),[re,m.contextFiles]),se=()=>{let t=[...e.map(e=>e.name),...f.flatMap(e=>[e.profileName,e.displayName]),...te?[m.displayName]:[]];h(h0(u??void 0,kOe(t))),_(!0),T(null)},ce=async()=>{if(!I){if(ne){T(ne);return}if(!A){T(O0());return}y(!0);try{let e={displayName:m.displayName.trim(),description:(m.description??``).trim()||void 0,nativeTools:m.nativeTools,skills:m.skills,contextFiles:m.contextFiles,subagents:m.subagents.filter(e=>e.name.trim()&&e.targetProfile.trim()),mcpServers:m.mcpServers,piPackages:m.piPackages,mainModel:m.mainModel,subagentModel:m.subagentModel,thinkingLevel:m.thinkingLevel??null,mainThinkingLevel:m.mainThinkingLevel??null,subagentThinkingLevel:m.subagentThinkingLevel??null,fast:m.fast,mainFast:m.mainFast,subagentFast:m.subagentFast,builtinTools:m.builtinTools,builtinToolNames:m.builtinToolNames,autoContextFiles:m.autoContextFiles,runControl:m.runControl},t=m.id?await WW(m.id,e):await UW(e);p(e=>{let n=e.filter(e=>e.id!==t.agent.id);return[t.agent,...n]}),h(g0(t.agent)),_(!1),i(t.agent.profileName),c(),T(null)}catch(e){let t=e instanceof Error?e.message:String(e);T(WOe(t)?O0():t)}finally{y(!1)}}},le=async e=>{if(!(!m.id||m.source!==`custom`)){y(!0);try{let t=await WW(m.id,{archived:e});e&&(x(!0),localStorage.setItem(`pibo.chat.showArchivedAgents`,`true`)),p(e=>e.map(e=>e.id===t.agent.id?t.agent:e)),h(g0(t.agent)),C(``),c(),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}},ue=async()=>{if(!(I||!A||!E.trim())){if(ne){T(ne);return}y(!0);try{let e=(await sl({label:E.trim(),scope:O,agentProfileName:O===`agent`?L:void 0,markdown:``})).file;d(t=>t&&{...t,contextFiles:[...t.contextFiles,e]}),h(t=>({...t,contextFiles:t.contextFiles.includes(e.key)?t.contextFiles:[...t.contextFiles,e.key]})),D(``),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}},de=async()=>{if(!(!m.id||!m.profileName||!ee)){y(!0);try{await GW(m.id,S),p(e=>e.filter(e=>e.id!==m.id)),h(h0(u??void 0)),_(!1),C(``),c(),T(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}}};return(0,z.jsxs)(`div`,{className:`h-full min-h-0 overflow-hidden grid grid-cols-[300px_minmax(0,1fr)] max-[920px]:grid-cols-1`,children:[(0,z.jsxs)(`aside`,{className:`border-r border-slate-800 bg-[#1a262b] min-h-0 overflow-auto`,children:[(0,z.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider`,children:[(0,z.jsx)(`span`,{children:`Agents`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:se,title:`New Agent`,"aria-label":`New Agent`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ps,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{let e=!b;x(e),localStorage.setItem(`pibo.chat.showArchivedAgents`,String(e))},title:b?`Hide Archived Agents`:`Show Archived Agents`,"aria-label":b?`Hide Archived Agents`:`Show Archived Agents`,className:`p-1 border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${b?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:b?(0,z.jsx)(wo,{size:13}):(0,z.jsx)(To,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:c,title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ls,{size:13})})]})]}),(0,z.jsxs)(`div`,{className:`p-2`,children:[(0,z.jsxs)(R0,{title:`Custom Agents`,children:[te?(0,z.jsx)(z0,{title:m.displayName||`new-agent`,subtitle:`unsaved custom agent`,selected:!0,onSelect:()=>{},onCreateSession:()=>{},createSessionDisabled:!0},`unsaved-agent-draft`):null,N.map(e=>(0,z.jsx)(z0,{title:e.displayName,subtitle:e.profileName,selected:m.source===`custom`&&m.id===e.id,onSelect:()=>{_(!1),h(g0(e)),i(e.profileName)},onCopy:()=>{h(v0(e)),_(!0)},onCreateSession:()=>{i(e.profileName),a(e.profileName)},createSessionDisabled:l},e.id)),N.length===0&&!te?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No custom agents`}):null]}),b?(0,z.jsxs)(R0,{title:`Archived Custom Agents`,children:[P.map(e=>(0,z.jsx)(z0,{title:e.displayName,subtitle:e.profileName,selected:m.source===`custom`&&m.id===e.id,onSelect:()=>{_(!1),h(g0(e))},onCopy:()=>{h(v0(e)),_(!0)},onCreateSession:()=>{},createSessionDisabled:!0},e.id)),P.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No archived agents`}):null]}):null,(0,z.jsx)(R0,{title:`Read-only Profiles`,children:M.map(e=>(0,z.jsx)(z0,{title:e.name,subtitle:e.aliases.join(`, `)||`plugin`,selected:m.source===`profile`&&m.profileName===e.name,onSelect:()=>{_(!1),h(_0(e,u??void 0)),i(e.name)},onCopy:()=>{h(AOe(e,u??void 0)),_(!0)},onCreateSession:()=>{i(e.name),a(e.name)},createSessionDisabled:l},e.name))})]})]}),(0,z.jsxs)(`section`,{className:`min-h-0 overflow-auto p-5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-sm font-bold uppercase tracking-wider`,children:`Agent Designer`}),(0,z.jsx)(`div`,{className:`font-mono text-[11px] text-slate-500 truncate`,children:L}),(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-slate-500`,children:m.source===`profile`?`read-only plugin profile`:ee?`archived custom agent`:`custom agent`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>{m.profileName&&(i(m.profileName),a(m.profileName))},disabled:!m.profileName||l||ee,title:`New Session With Agent`,"aria-label":`New Session With Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ds,{size:14})}),m.source===`custom`&&m.id?(0,z.jsx)(`button`,{type:`button`,onClick:()=>void le(!ee),disabled:v,title:ee?`Restore Agent`:`Archive Agent`,"aria-label":ee?`Restore Agent`:`Archive Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:ee?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>void ce(),disabled:I||!A||v||!!ne,title:`Save Agent`,"aria-label":`Save Agent`,className:`h-8 w-8 inline-flex items-center justify-center border border-[#11a4d4] rounded-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:(0,z.jsx)(Bs,{size:14})})]})]}),A?null:(0,z.jsx)(`div`,{className:`mb-3 border border-[#f59e0b]/60 bg-[#f59e0b]/10 text-amber-100 px-3 py-2 text-sm rounded-sm`,children:O0()}),m.source===`profile`?(0,z.jsx)(`div`,{className:`mb-3 border border-slate-700 bg-[#151f24] text-slate-300 px-3 py-2 text-sm rounded-sm`,children:`This profile is registered by a plugin. Copy it to create an editable custom agent.`}):null,ee?(0,z.jsx)(`div`,{className:`mb-3 border border-[#f59e0b]/60 bg-[#f59e0b]/10 text-amber-100 px-3 py-2 text-sm rounded-sm`,children:`This agent is archived. Restore it before editing or starting new sessions.`}):null,w?(0,z.jsx)(`div`,{className:`mb-3 border border-red-500/60 bg-red-500/10 text-red-200 px-3 py-2 text-sm rounded-sm`,children:w}):null,(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(k0,{title:`Basics`,children:[(0,z.jsx)(`input`,{value:m.displayName,disabled:I,onChange:e=>h(t=>({...t,displayName:e.target.value})),className:`min-w-0 bg-[#0e1116] border rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60 ${ne?`border-[#f59e0b]`:`border-slate-700`}`,placeholder:`agent-name`}),ne?(0,z.jsx)(`div`,{className:`text-xs text-amber-100`,children:ne}):null,(0,z.jsx)(`textarea`,{value:m.description,disabled:I,onChange:e=>h(t=>({...t,description:e.target.value})),className:`min-h-[72px] bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`Description`}),m.source===`profile`&&m.hardPinnedModel?(0,z.jsxs)(`div`,{className:`border border-slate-700 bg-[#151f24] text-slate-300 px-3 py-2 text-xs rounded-sm`,children:[`This plugin profile hard-pins `,(0,z.jsx)(`span`,{className:`font-mono`,children:nke(m.hardPinnedModel)}),`. Main-agent and subagent defaults do not apply.`]}):null,(0,z.jsx)(L0,{title:`Main Agent`,modelTitle:`Main Agent Model`,model:m.mainModel,thinking:m.mainThinkingLevel,fast:m.mainFast??!1,modelCatalog:r,readOnly:I,modelHint:`Unset to use the settings default.`,onModelChange:e=>h(t=>({...t,mainModel:e})),onThinkingChange:e=>h(t=>({...t,mainThinkingLevel:e})),onFastChange:e=>h(t=>({...t,mainFast:e}))}),(0,z.jsx)(L0,{title:`Subagent`,modelTitle:`Subagent Model`,model:m.subagentModel,thinking:m.subagentThinkingLevel,fast:m.subagentFast??!1,modelCatalog:r,readOnly:I,modelHint:`Unset to use the settings default.`,onModelChange:e=>h(t=>({...t,subagentModel:e})),onThinkingChange:e=>h(t=>({...t,subagentThinkingLevel:e})),onFastChange:e=>h(t=>({...t,subagentFast:e}))}),(0,z.jsx)(P0,{disabled:I,checked:m.autoContextFiles,title:`Load AGENTS.md / CLAUDE.md`,onToggle:()=>h(e=>({...e,autoContextFiles:!e.autoContextFiles}))}),(0,z.jsx)($Oe,{draft:m,setDraft:h,readOnly:I})]}),(0,z.jsx)(k0,{title:`Tools`,children:(0,z.jsx)(A0,{groups:ie,empty:u?(0,z.jsx)(I0,{message:`No native tools registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.nativeTools.includes(e.name),title:e.name,description:e.description,meta:e.yieldable?`yieldable`:`direct only`,onToggle:()=>h(t=>({...t,nativeTools:y0(t.nativeTools,e.name)}))},e.name)})}),(0,z.jsx)(k0,{title:`Skills`,children:(0,z.jsx)(A0,{groups:ae,empty:u?(0,z.jsx)(I0,{message:`No skills registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.skills.includes(e.name),title:e.name,description:e.path,meta:BOe(e),metaClass:e.kind===`user`?`text-amber-200`:`text-[#11a4d4]`,onToggle:()=>h(t=>({...t,skills:y0(t.skills,e.name)}))},e.name)})}),(0,z.jsx)(GOe,{title:`Packages`,children:(0,z.jsx)(j0,{disabled:I,checked:m.runControl,title:`pibo-run-control`,description:`Expose pibo_run_* as one package for yielded native tools and subagents.`,meta:`package`,onToggle:()=>h(e=>({...e,runControl:!e.runControl}))})}),(0,z.jsx)(QOe,{packages:u?.piPackages,draft:m,setDraft:h,readOnly:I}),(0,z.jsxs)(k0,{title:`Context Files`,children:[m.brokenContextFiles?.length?(0,z.jsxs)(`div`,{className:`border border-red-500/60 bg-red-500/10 rounded-sm p-3 space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-red-100`,children:[(0,z.jsx)(Js,{size:14,className:`mt-0.5 shrink-0`}),(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`div`,{className:`text-sm font-medium`,children:`This agent references missing context files.`}),(0,z.jsx)(`div`,{className:`text-xs text-red-200/90`,children:`Remove these broken links and save the agent to persist the cleanup.`})]})]}),(0,z.jsx)(`div`,{className:`grid gap-2`,children:m.brokenContextFiles.map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-2 border border-red-500/40 bg-[#2a1417] rounded-sm px-3 py-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm text-red-100`,children:e}),(0,z.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-red-300/80`,children:`Broken link`})]}),(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>h(t=>({...t,contextFiles:t.contextFiles.filter(t=>t!==e),brokenContextFiles:(t.brokenContextFiles??[]).filter(t=>t!==e)})),className:`h-8 w-8 inline-flex items-center justify-center border border-red-500/60 rounded-sm text-red-200 hover:border-red-400 hover:text-red-100 disabled:opacity-50`,title:`Remove Broken Context File`,"aria-label":`Remove Broken Context File`,children:(0,z.jsx)(Qs,{size:14})})]},e))})]}):null,(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2`,children:[(0,z.jsx)(`input`,{value:E,disabled:I,onChange:e=>D(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`New context file`}),(0,z.jsx)(`button`,{type:`button`,disabled:I||v||!E.trim()||!!ne,onClick:()=>void ue(),title:`Create Context File`,"aria-label":`Create Context File`,className:`h-9 w-9 inline-flex items-center justify-center border border-[#11a4d4] rounded-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})})]}),(0,z.jsxs)(`div`,{className:`inline-flex w-fit gap-1 border border-slate-800 bg-[#0e1116] rounded-sm p-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>k(`agent`),className:`px-2 py-1 text-xs rounded-sm ${O===`agent`?`bg-[#11a4d4]/20 text-sky-100`:`text-slate-500 hover:text-slate-300`}`,children:`Agent`}),(0,z.jsx)(`button`,{type:`button`,disabled:I,onClick:()=>k(`global`),className:`px-2 py-1 text-xs rounded-sm ${O===`global`?`bg-[#11a4d4]/20 text-sky-100`:`text-slate-500 hover:text-slate-300`}`,children:`Global`})]}),(0,z.jsx)(A0,{groups:oe,empty:u?(0,z.jsx)(I0,{message:`No context files registered`}):(0,z.jsx)(I0,{}),renderItem:e=>(0,z.jsx)(j0,{disabled:I,checked:m.contextFiles.includes(e.key),title:e.label??e.key,description:e.path,meta:VOe(e),metaClass:`text-[#11a4d4]`,actionLabel:`Edit`,actionIcon:(0,z.jsx)(Ms,{size:12}),onAction:()=>o(e.key),onToggle:()=>h(t=>({...t,contextFiles:y0(t.contextFiles,e.key)}))},e.key)})]}),(0,z.jsx)(eke,{draft:m,setDraft:h,profileOptions:F,readOnly:I}),(0,z.jsx)(tke,{servers:u?.mcpServers,draft:m,setDraft:h,readOnly:I,onEditServer:s}),ee&&m.profileName?(0,z.jsxs)(k0,{title:`Delete Agent`,children:[(0,z.jsxs)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:[`Permanently deleting this agent also deletes all Chat sessions that use profile `,(0,z.jsx)(`span`,{className:`font-mono`,children:m.profileName}),`.`]}),(0,z.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:m.profileName}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void de(),disabled:v||S!==m.profileName,className:`h-8 w-fit inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,z.jsx)(qs,{size:14}),`Delete permanently`]})]}):null]})]})]})}function R0({title:e,children:t}){return(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:e}),t]})}function z0({title:e,subtitle:t,selected:n,onSelect:r,onCopy:i,onCreateSession:a,createSessionDisabled:o}){return(0,z.jsx)(`div`,{className:`mb-1 border rounded-sm ${n?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-transparent hover:border-slate-700`}`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto_auto] items-center gap-1 p-1`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 text-left px-1 py-1`,children:[(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:e}),(0,z.jsx)(`span`,{className:`block text-[10px] font-mono truncate text-slate-500`,children:t})]}),i?(0,z.jsx)(`button`,{type:`button`,onClick:i,title:`Copy To Custom Agent`,"aria-label":`Copy To Custom Agent`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qo,{size:13})}):(0,z.jsx)(`span`,{className:`h-7 w-7`}),(0,z.jsx)(`button`,{type:`button`,onClick:a,disabled:o,title:`New Session With Profile`,"aria-label":`New Session With Profile`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ds,{size:13})})]})})}function QOe({packages:e,draft:t,setDraft:n,readOnly:r}){let[i,a]=(0,R.useState)(()=>new Set),o=e??[],s=o.filter(UOe),c=s.filter(e=>E0(t.piPackages,e)).length,l=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,z.jsxs)(k0,{title:`Pi Packages`,children:[(0,z.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:[s.length,` available / `,c,` selected / `,o.length,` registered`]}),e?s.length?(0,z.jsx)(`div`,{className:`grid gap-2`,children:s.map(e=>(0,z.jsx)(qOe,{pkg:e,selected:E0(t.piPackages,e),readOnly:r,expanded:i.has(e.id),busy:!1,onToggleSelected:()=>{r||n(t=>({...t,piPackages:HOe(t.piPackages,e)}))},onToggleExpanded:()=>l(e.id)},e.id))}):(0,z.jsx)(I0,{message:`No installed and enabled Pi packages available. Manage Pi Packages in Settings.`}):(0,z.jsx)(I0,{})]})}function $Oe({draft:e,setDraft:t,readOnly:n}){let r=b0(e.builtinToolNames,e.builtinTools),[i,a]=(0,R.useState)(r.length!==x0.length),o=e=>{t(t=>{let n=y0(b0(t.builtinToolNames,t.builtinTools),e);return{...t,builtinTools:n.length===0?`disabled`:`default`,builtinToolNames:n}})};return(0,z.jsxs)(`div`,{className:`border rounded-sm ${i?`border-slate-700 bg-[#101d22]`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 p-2 text-left`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 shrink-0 inline-flex items-center justify-center border rounded-sm border-[#11a4d4]/70 text-sky-100 bg-[#11a4d4]/10`,children:i?(0,z.jsx)(zo,{size:14}):(0,z.jsx)(Bo,{size:14})}),(0,z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm font-medium text-slate-100`,children:`Pi Built-in Tools`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`basic model tools`})]}),(0,z.jsxs)(`span`,{className:`shrink-0 text-right font-mono text-sm font-semibold tabular-nums`,"aria-label":`${r.length} of ${x0.length} enabled`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:r.length}),(0,z.jsxs)(`span`,{className:`text-slate-500`,children:[`/`,x0.length]})]})]}),i?(0,z.jsx)(`div`,{className:`border-t border-slate-800 p-2`,children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:x0.map(e=>(0,z.jsx)(j0,{disabled:n,checked:r.includes(e),title:e,description:POe[e],meta:`built-in`,onToggle:()=>o(e)},e))})}):null]})}function eke({draft:e,setDraft:t,profileOptions:n,readOnly:r}){let i=(e,n)=>{t(t=>({...t,subagents:t.subagents.map((t,r)=>r===e?{...t,...n}:t)}))};return(0,z.jsxs)(k0,{title:`Subagents`,children:[(0,z.jsx)(`div`,{className:`flex justify-end`,children:(0,z.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>t(e=>({...e,subagents:[...e.subagents,{name:`helper`,targetProfile:n[0]?.value??`base`,maxDepth:3}]})),className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,title:`Add Subagent`,"aria-label":`Add Subagent`,children:(0,z.jsx)(Ps,{size:13})})}),(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[e.subagents.map((e,a)=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_1fr_80px_auto] max-[1100px]:grid-cols-1 gap-2 border border-slate-800 bg-[#151f24] p-2 rounded-sm`,children:[(0,z.jsx)(`input`,{value:e.name,disabled:r,onChange:e=>i(a,{name:e.target.value}),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`name`}),(0,z.jsx)(`select`,{value:e.targetProfile,disabled:r,onChange:e=>i(a,{targetProfile:e.target.value}),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:n.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,z.jsx)(`input`,{type:`number`,min:1,disabled:r,value:e.maxDepth??3,onChange:e=>i(a,{maxDepth:Number(e.target.value)||1}),className:`bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`}),(0,z.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>t(e=>({...e,subagents:e.subagents.filter((e,t)=>t!==a)})),className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-500 hover:text-red-300 disabled:opacity-50`,title:`Remove Subagent`,"aria-label":`Remove Subagent`,children:(0,z.jsx)(Qs,{size:14})})]},a)),e.subagents.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:`No subagents configured`}):null]})]})}function tke({servers:e,draft:t,setDraft:n,readOnly:r,onEditServer:i}){return(0,z.jsx)(k0,{title:`MCP Servers`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-2 max-[1100px]:grid-cols-1 gap-2`,children:[e?e.map(e=>{let a=r||!e.hasDescription;return(0,z.jsxs)(`div`,{className:`border rounded-sm bg-[#151f24] p-2 ${t.mcpServers.includes(e.name)?`border-[#11a4d4]`:e.hasDescription?`border-slate-800`:`border-[#f59e0b]/60`}`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>n(t=>({...t,mcpServers:y0(t.mcpServers,e.name)})),className:`grid w-full min-w-0 grid-cols-[18px_1fr] gap-2 text-left disabled:opacity-60`,children:[(0,z.jsx)(F0,{checked:t.mcpServers.includes(e.name),disabled:a,className:`mt-0.5`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Us,{size:13,className:`text-[#11a4d4]`}),(0,z.jsx)(`span`,{className:`block text-sm truncate text-slate-200`,children:e.name})]}),(0,z.jsxs)(`span`,{className:`block font-mono text-[10px] mt-1 text-slate-600`,children:[e.transport,e.descriptionSource?` / ${e.descriptionSource}`:``]})]})]}),e.hasDescription?(0,z.jsx)(`div`,{className:`mt-2 text-xs text-slate-400`,children:e.description}):(0,z.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-xs text-amber-100`,children:[(0,z.jsx)(Js,{size:13}),`Missing agent description`]}),(0,z.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(e.name),title:`Edit MCP Tool Context`,"aria-label":`Edit MCP Tool Context`,className:`inline-flex h-6 items-center justify-center gap-1 border border-[#11a4d4]/70 px-1.5 text-[10px] uppercase tracking-wider text-[#7dd3fc] hover:border-[#11a4d4] hover:text-sky-100`,children:[(0,z.jsx)(Ms,{size:12}),`Edit`]})})]},e.name)}):(0,z.jsx)(I0,{}),e&&e.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm p-3`,children:`No MCP servers configured`}):null]})})}function nke(e){return`${e.provider}/${e.id}`}var B0=`pibo.chat.lastSelection`,V0=`pibo.chat.sessionView`,H0=`pibo.chat.composerDraft.`,U0=`pibo.chat.composerHistory`,W0=`pibo.chat.showThinking`,G0=`pibo.chat.expandThinking`,K0=`pibo.chat.showRawEvents`,q0=`pibo.chat.showArchived`,J0=`pibo.chat.showArchivedRooms`,Y0=`pibo.chat.newSessionProfile`,X0=100;function Z0(){try{let e=localStorage.getItem(B0);if(!e)return{};let t=JSON.parse(e);if(!u2(t))return{};let n=u2(t.sessionsByRoom)?Object.fromEntries(Object.entries(t.sessionsByRoom).filter(e=>typeof e[0]==`string`&&typeof e[1]==`string`&&!!e[1])):void 0;return{roomId:typeof t.roomId==`string`&&t.roomId?t.roomId:void 0,piboSessionId:typeof t.piboSessionId==`string`&&t.piboSessionId?t.piboSessionId:void 0,...n&&Object.keys(n).length?{sessionsByRoom:n}:{}}}catch{return{}}}function rke(e){try{let t={...Z0().sessionsByRoom??{},...e.sessionsByRoom??{}};e.roomId&&e.piboSessionId&&(t[e.roomId]=e.piboSessionId),localStorage.setItem(B0,JSON.stringify({roomId:e.roomId,piboSessionId:e.piboSessionId,...Object.keys(t).length?{sessionsByRoom:t}:{}}))}catch{}}function Q0(e){try{let t=Z0();if(!t.sessionsByRoom?.[e])return;let{[e]:n,...r}=t.sessionsByRoom;localStorage.setItem(B0,JSON.stringify({roomId:t.roomId,piboSessionId:t.piboSessionId,...Object.keys(r).length?{sessionsByRoom:r}:{}}))}catch{}}function $0(e){try{return localStorage.getItem(H0+e)??``}catch{return``}}function e2(e,t){try{let n=H0+e;t?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}function t2(){try{let e=localStorage.getItem(U0);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim().length>0).slice(-X0):[]}catch{return[]}}function ike(e){let t=e.trim();if(!t)return;let n=t2();if(n.at(-1)!==t)try{localStorage.setItem(U0,JSON.stringify([...n,t].slice(-X0)))}catch{}}function n2(){try{return localStorage.getItem(V0)===`terminal`?`terminal`:wc}catch{return wc}}function ake(e){try{localStorage.setItem(V0,e)}catch{}}function oke(){return c2(W0,!0)}function r2(e){l2(W0,e)}function ske(){return c2(G0,!0)}function i2(e){l2(G0,e)}function cke(){return c2(K0,!1)}function a2(e){l2(K0,e)}function lke(){return c2(q0,!1)}function uke(e){l2(q0,e)}function dke(){return c2(J0,!1)}function o2(e){l2(J0,e)}function fke(){try{return localStorage.getItem(Y0)??``}catch{return``}}function s2(e){try{localStorage.setItem(Y0,e)}catch{}}function pke(){try{localStorage.removeItem(B0)}catch{}}function c2(e,t){try{let n=localStorage.getItem(e);return n===`true`?!0:n===`false`?!1:t}catch{return t}}function l2(e,t){try{localStorage.setItem(e,String(t))}catch{}}function u2(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d2(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`),Promise.resolve()}finally{document.body.removeChild(t)}}function f2(e,t){return e.length>t?`${e.slice(0,Math.max(0,t-1))}…`:e}function mke({sessionId:e,disabled:t=!1,commands:n,skills:r,value:i,focusSignal:a,selectedWebAnnotations:o,selectedUploadAttachments:s,onValueChange:c,onCommand:l,onDetachWebAnnotation:u,onClearWebAnnotations:d,onAttachUploadedFiles:f,onDetachUploadAttachment:p,onClearUploadAttachments:m,onSend:h}){let g=(0,R.useRef)(null),_=(0,R.useRef)(null),v=(0,R.useRef)(null),y=(0,R.useRef)(null),b=(0,R.useRef)(null),x=(0,R.useRef)(null),S=(0,R.useRef)(null),[C,w]=(0,R.useState)(0),[T,E]=(0,R.useState)(0),[D,O]=(0,R.useState)(0),[k,A]=(0,R.useState)([]),[j,M]=(0,R.useState)(!1),[N,P]=(0,R.useState)(null),[F,ee]=(0,R.useState)(null),te=(0,R.useMemo)(()=>{for(let e=D-1;e>=0;e--){let t=i[e];if(t===` `||t===`
|
|
163
163
|
`||t===` `)break;if(t===`$`){if(e>0&&i[e-1]===`\\`)continue;return{query:i.slice(e+1,D).toLowerCase(),startPos:e,endPos:D}}}return null},[i,D]),I=i.trim().startsWith(`/`)?i.trim().split(/\s+/)[0]:null,ne=te?p2(te.startPos,i.slice(te.startPos,D)):null,L=I?m2(I):null,re=(0,R.useMemo)(()=>te?r.filter(e=>e.name.toLowerCase().startsWith(te.query)):[],[te,r]),ie=(0,R.useMemo)(()=>I?n.filter(e=>e.slash.startsWith(I)):[],[I,n]),ae=ne&&k.includes(ne)?[]:re,oe=L&&k.includes(L)?[]:ie,se=(0,R.useCallback)(e=>{e&&A(t=>t.includes(e)?t:[...t,e])},[]),ce=(0,R.useCallback)(()=>{let e=[re.length?ne:null,ie.length?L:null].filter(e=>!!e);e.length&&A(t=>{let n=new Set(t);for(let t of e)n.add(t);return n.size===t.length?t:[...n]})},[L,ie.length,re.length,ne]);(0,R.useEffect)(()=>{let e=[ne,L].filter(e=>!!e);A(t=>t.filter(t=>e.includes(t)))},[L,ne]),(0,R.useEffect)(()=>{!oe.length||C<oe.length||w(0)},[C,oe.length]),(0,R.useEffect)(()=>{!ae.length||T<ae.length||E(0)},[T,ae.length]),(0,R.useEffect)(()=>{let e=requestAnimationFrame(()=>b.current?.scrollIntoView({block:`nearest`}));return()=>cancelAnimationFrame(e)},[C,oe.length]),(0,R.useEffect)(()=>{let e=requestAnimationFrame(()=>x.current?.scrollIntoView({block:`nearest`}));return()=>cancelAnimationFrame(e)},[T,ae.length]),(0,R.useEffect)(()=>{S.current=null},[e]),(0,R.useEffect)(()=>{if(!F)return;let e=requestAnimationFrame(()=>y.current?.focus());return()=>{cancelAnimationFrame(e),URL.revokeObjectURL(F.previewUrl)}},[F]),(0,R.useEffect)(()=>{if(a<=0)return;let e=_.current;if(!e)return;let t=e.value.length;e.focus(),e.setSelectionRange(t,t),O(t)},[a]),(0,R.useEffect)(()=>{if(!oe.length&&!ae.length)return;let e=e=>{let t=e.target;t instanceof Node&&(g.current?.contains(t)||ce())};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[ce,oe.length,ae.length]),(0,R.useLayoutEffect)(()=>{bke(_.current)},[i]);let le=e=>{if(!te||!_.current)return;let t=i.slice(0,te.startPos),n=i.slice(te.endPos);c(t+`$`+e+n),se(p2(te.startPos,`$${e}`));let r=te.startPos+1+e.length;O(r),requestAnimationFrame(()=>{_.current?.setSelectionRange(r,r),O(r)})},ue=e=>{c(e),requestAnimationFrame(()=>{let e=_.current;if(!e)return;let t=e.value.length;e.setSelectionRange(t,t),O(t)})},de=e=>{let t=S.current;if(!t){if(e===`next`||i!==``)return!1;let t=t2();if(!t.length)return!1;let n=e===`previous`?t.length-1:0;return S.current={entries:t,index:n,draft:i},ue(t[n]),!0}if(e===`previous`){let e=Math.max(0,t.index-1);return S.current={...t,index:e},ue(t.entries[e]),!0}let n=t.index+1;return n>=t.entries.length?(S.current=null,ue(t.draft),!0):(S.current={...t,index:n},ue(t.entries[n]),!0)},fe=()=>{t||j||v.current?.click()},pe=()=>{ee(null)},me=e=>{if(t||j)return;let n=hke(e.clipboardData);if(!n.length)return;e.preventDefault(),ce(),P(null);let r=n[0];ee(e=>(e&&URL.revokeObjectURL(e.previewUrl),{file:r,previewUrl:URL.createObjectURL(r)}))},he=async()=>{if(!F||j)return;let e=F.file;ee(null),await ge([e])},ge=async e=>{if(e.length){M(!0),P({message:`Uploading ${e.length} file${e.length===1?``:`s`}...`,error:!1});try{f((await Nc(e)).files),P(null)}catch(e){P({message:e instanceof Error?e.message:String(e),error:!0})}finally{M(!1)}}},_e=async()=>{if(t)return;let e=i.trim();if(e){if(ae.length){le(ae[Math.min(T,ae.length-1)].name);return}if(oe.length&&!n.some(t=>t.slash===e.split(/\s+/)[0])){let e=oe[Math.min(C,oe.length-1)].slash;c(e),se(m2(e));return}if(S.current=null,ike(e),c(``),e.split(/\s+/)[0]===`/upload`){fe();return}e.startsWith(`/`)&&await l(e)||await h(e)}};return(0,z.jsxs)(`div`,{ref:g,"data-pibo-debug":`composer`,"data-pibo-session-id":e??void 0,"data-pibo-state":t?`disabled`:i?`non-empty`:`empty`,className:`relative p-3 bg-[#151f24] border-t border-slate-800 max-[980px]:p-2`,children:[(0,z.jsx)(`input`,{ref:v,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.target.files??[]);e.target.value=``,ge(t)}}),N?(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-sm border px-3 py-2 text-xs ${N.error?`border-red-900 bg-red-950/40 text-red-200`:N.copyText?`border-green-900/60 bg-green-950/30 text-green-300`:`border-slate-700 bg-[#0e1116] text-slate-300`}`,children:[(0,z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:N.message}),N.copyText?(0,z.jsx)(`button`,{type:`button`,onClick:()=>void d2(N.copyText),title:`Copy uploaded file path`,"aria-label":`Copy uploaded file path`,className:`shrink-0 rounded-sm p-0.5 text-slate-400 hover:bg-slate-800 hover:text-[#11a4d4]`,children:(0,z.jsx)($o,{size:13})}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>P(null),title:`Hide upload status`,"aria-label":`Hide upload status`,className:`shrink-0 rounded-sm p-0.5 text-slate-500 hover:bg-slate-800 hover:text-slate-200`,children:(0,z.jsx)(Qs,{size:13})})]}):null,F?(0,z.jsx)(`div`,{className:`fixed inset-0 z-50 grid place-items-center bg-black/60 px-4`,role:`dialog`,"aria-modal":`true`,"aria-label":`Upload pasted image`,onKeyDown:e=>{e.key===`Escape`&&pe()},children:(0,z.jsxs)(`div`,{className:`w-full max-w-md rounded-sm border border-slate-700 bg-[#151f24] shadow-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-slate-800 px-4 py-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-sm font-semibold text-slate-100`,children:`Pasted image detected`}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-slate-400`,children:`Upload this clipboard image to ~/.pibo/uploads?`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:pe,className:`rounded-sm p-1 text-slate-500 hover:bg-slate-800 hover:text-slate-200`,"aria-label":`Cancel pasted image upload`,children:(0,z.jsx)(Qs,{size:14})})]}),(0,z.jsxs)(`div`,{className:`space-y-3 px-4 py-4`,children:[(0,z.jsx)(`img`,{src:F.previewUrl,alt:`Pasted clipboard image preview`,className:`max-h-64 w-full rounded-sm border border-slate-800 bg-[#0e1116] object-contain`}),(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-xs text-slate-400`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono`,children:F.file.name}),(0,z.jsx)(`span`,{className:`shrink-0 font-mono`,children:yke(F.file.size)})]})]}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-slate-800 px-4 py-3`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:pe,className:`h-8 rounded-sm border border-slate-700 px-3 text-xs text-slate-300 hover:border-slate-500 hover:text-slate-100`,children:`Cancel`}),(0,z.jsx)(`button`,{ref:y,type:`button`,onClick:()=>void he(),disabled:j,className:`h-8 rounded-sm bg-[#11a4d4] px-3 text-xs font-medium text-white disabled:opacity-50`,children:`Upload image`})]})]})}):null,ae.length?(0,z.jsx)(`div`,{className:`absolute left-3 bottom-full mb-2 w-[min(520px,calc(100%-24px))] max-h-72 overflow-auto bg-[#0e1116] border border-emerald-500 rounded-sm shadow-xl`,children:ae.map((e,t)=>(0,z.jsxs)(`button`,{ref:t===T?x:null,type:`button`,onClick:()=>le(e.name),className:`w-full grid grid-cols-[120px_1fr] gap-2 px-3 py-2 text-left border-b border-slate-800 ${t===T?`bg-emerald-500/15`:``}`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-emerald-400`,children:[`$`,e.name]}),(0,z.jsx)(`span`,{className:`text-xs text-slate-400`,children:e.description??e.path??``})]},e.name))}):null,s.length?(0,z.jsxs)(`div`,{className:`mb-2 rounded-sm border border-slate-800 bg-[#0e1116] px-2.5 py-1.5`,"data-pibo-debug":`composer-upload-attachments`,"data-upload-attachment-count":s.length,children:[(0,z.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-[#11a4d4]`,children:`Attached uploads`}),(0,z.jsx)(`button`,{type:`button`,onClick:m,className:`text-[11px] text-slate-500 hover:text-[#11a4d4]`,children:`Clear`})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,z.jsxs)(`div`,{title:e.path,className:`inline-flex max-w-80 items-center gap-1 rounded-sm border border-emerald-500/45 bg-emerald-500/10 px-2 py-1 text-left text-[11px] text-slate-200`,"data-pibo-debug":`composer-upload-attachment-chip`,"data-upload-path":e.path,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:f2(e.name||e.path,100)}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void d2(e.path),title:`Copy uploaded file path`,"aria-label":`Copy uploaded file path`,className:`shrink-0 rounded-sm p-0.5 text-emerald-300 hover:bg-slate-800 hover:text-[#11a4d4]`,children:(0,z.jsx)($o,{size:11})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>p(e.id),title:`Detach ${e.name||e.path}`,"aria-label":`Detach ${e.name||e.path}`,className:`shrink-0 rounded-sm p-0.5 text-emerald-300 hover:bg-slate-800 hover:text-slate-100`,children:(0,z.jsx)(Qs,{size:11})})]},e.id))})]}):null,o.length?(0,z.jsxs)(`div`,{className:`mb-2 rounded-sm border border-slate-800 bg-[#0e1116] px-3 py-2`,"data-pibo-debug":`composer-web-annotations`,"data-web-annotation-count":o.length,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-[#11a4d4]`,children:`Attached web annotations`}),(0,z.jsx)(`button`,{type:`button`,onClick:d,className:`text-[11px] text-slate-500 hover:text-[#11a4d4]`,children:`Clear`})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(e.id),title:`Detach ${e.id}`,className:`inline-flex max-w-72 items-center gap-1 rounded-sm border border-[#11a4d4]/50 bg-[#11a4d4]/10 px-2 py-1 text-left text-[11px] text-slate-200`,"data-pibo-debug":`composer-web-annotation-chip`,"data-web-annotation-id":e.id,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate`,children:f2(e.primaryTarget||e.label||e.note||e.id,100)}),(0,z.jsx)(Qs,{size:11,className:`shrink-0 text-[#11a4d4]`})]},e.id))})]}):null,oe.length?(0,z.jsx)(`div`,{className:`absolute left-3 bottom-full mb-2 w-[min(520px,calc(100%-24px))] max-h-72 overflow-auto bg-[#0e1116] border border-[#11a4d4] rounded-sm shadow-xl`,children:oe.map((e,t)=>(0,z.jsxs)(`button`,{ref:t===C?b:null,type:`button`,onClick:()=>{c(e.slash),se(m2(e.slash)),w(t)},className:`w-full grid grid-cols-[120px_1fr] gap-2 px-3 py-2 text-left border-b border-slate-800 ${t===C?`bg-[#11a4d4]/15`:``}`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[#11a4d4]`,children:e.slash}),(0,z.jsx)(`span`,{className:`text-xs text-slate-400`,children:e.description})]},e.slash))}):null,(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-end gap-2`,children:[(0,z.jsx)(`textarea`,{ref:_,"data-pibo-debug":`composer-input`,"data-pibo-session-id":e??void 0,"data-pibo-state":t?`disabled`:i?`non-empty`:`empty`,rows:1,value:i,disabled:t,onChange:e=>{S.current=null,c(e.target.value),O(e.target.selectionStart)},onKeyDown:e=>{if(e.key===`Escape`&&(ae.length||oe.length)){e.preventDefault(),e.stopPropagation(),ce();return}if(ae.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),E(t=>e.key===`ArrowDown`?(t+1)%ae.length:(t-1+ae.length)%ae.length);return}if(oe.length&&(e.key===`ArrowDown`||e.key===`ArrowUp`)){e.preventDefault(),w(t=>e.key===`ArrowDown`?(t+1)%oe.length:(t-1+oe.length)%oe.length);return}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&de(e.key===`ArrowUp`?`previous`:`next`)){e.preventDefault();return}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_e())},onPaste:me,placeholder:t?`Select a session to message`:`Send Message (/ for commands or $ for skills)`,className:`h-10 min-h-10 resize-none overflow-hidden bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm leading-5 outline-none focus:border-[#11a4d4] disabled:opacity-50 [scrollbar-gutter:stable]`}),(0,z.jsx)(`button`,{type:`button`,disabled:t||j,onClick:()=>void _e(),title:`Send message`,"aria-label":`Send message`,className:`h-10 w-10 self-end inline-flex items-center justify-center bg-[#11a4d4] rounded-sm text-white disabled:opacity-50`,children:(0,z.jsx)(Hs,{size:16})})]})]})}function p2(e,t){return`skill:${e}:${t}`}function m2(e){return`command:${e}`}function hke(e){let t=Array.from(e.items).filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);return(t.length?t:Array.from(e.files).filter(e=>e.type.startsWith(`image/`))).map(gke)}function gke(e){return e.name&&e.name!==`image.png`?e:new File([e],_ke(e.type),{type:e.type||`image/png`,lastModified:Date.now()})}function _ke(e){let t=vke(e),n=new Date;return`screenshot-${[n.getFullYear(),h2(n.getMonth()+1),h2(n.getDate()),`-`,h2(n.getHours()),h2(n.getMinutes()),h2(n.getSeconds())].join(``)}${t}`}function vke(e){switch(e){case`image/jpeg`:return`.jpg`;case`image/gif`:return`.gif`;case`image/webp`:return`.webp`;case`image/svg+xml`:return`.svg`;default:return`.png`}}function h2(e){return String(e).padStart(2,`0`)}function yke(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function bke(e){if(!e)return;if(!e.value.includes(`
|
|
164
164
|
`)&&e.value.length<80){e.style.height=``,e.style.overflowY=`hidden`;return}let t=window.getComputedStyle(e),n=g2(t.lineHeight,20),r=g2(t.borderTopWidth)+g2(t.borderBottomWidth),i=n*5+g2(t.paddingTop)+g2(t.paddingBottom);e.style.height=`auto`;let a=e.scrollHeight,o=a>i;e.style.height=`${Math.min(a,i)+r}px`,e.style.overflowY=o?`auto`:`hidden`,o&&e.selectionStart===e.value.length&&e.selectionEnd===e.value.length&&(e.scrollTop=a)}function g2(e,t=0){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}async function xke(e,t={}){let n=new URLSearchParams({piboSessionId:e});return t.status&&n.set(`status`,t.status),t.limit&&n.set(`limit`,String(t.limit)),t.scope&&n.set(`scope`,t.scope),V(`/api/web-annotations?${n.toString()}`)}async function Ske(e,t){return V(`/api/web-annotations/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(v2(t))})}async function Cke(e){let t=new URLSearchParams;return e?.trim()&&t.set(`cdpUrl`,e.trim()),V(`/api/web-annotations/targets${t.size?`?${t.toString()}`:``}`)}async function _2(e){return V(`/api/web-annotations/bindings`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(v2(e))})}async function wke(e,t){return V(`/api/web-annotations/bindings/${encodeURIComponent(e)}/inject`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(v2(t))})}function v2(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``))}var y2=`pibo.chat.webAnnotations.cdpUrl`,b2=`pibo.chat.webAnnotations.selected.`,Tke=`pibo.chat.webAnnotations.overlay.`,x2=`pibo.chat.webAnnotations.panelCollapsed`,S2=`pibo.chat.shortcuts.webAnnotationsToggle`,C2=`Alt+Shift+A`;function Eke(){try{return localStorage.getItem(y2)??``}catch{return``}}function Dke(e){try{e.trim()?localStorage.setItem(y2,e.trim()):localStorage.removeItem(y2)}catch{}}function w2(){try{return localStorage.getItem(S2)||`Alt+Shift+A`}catch{return C2}}function T2(e){let t=D2(e)||`Alt+Shift+A`;try{localStorage.setItem(S2,t)}catch{}}function E2(e){window.__piboWebAnnotations?.setShortcut?.(e);try{window.dispatchEvent(new CustomEvent(`pibo:web-annotation-shortcut-changed`,{detail:{shortcut:e}}))}catch{}}function D2(e){return e.replace(/[\u0000-\u001f\u007f]/g,``).trim().slice(0,80)}function O2(e){try{return A2(localStorage.getItem(k2(e)))}catch{return null}}function k2(e){return Tke+e}function A2(e){if(!e)return null;try{return j2(JSON.parse(e))}catch{return null}}function j2(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.piboSessionId==`string`?t.piboSessionId.trim():``;return n?{bindingId:typeof t.bindingId==`string`?t.bindingId:void 0,piboSessionId:n,installed:t.installed!==!1,active:t.active===!0,toolbarExpanded:t.toolbarExpanded===!0,mode:typeof t.mode==`string`?t.mode:void 0,reason:typeof t.reason==`string`?t.reason:void 0,updatedAt:typeof t.updatedAt==`string`?t.updatedAt:void 0}:null}function Oke(e){try{let t=localStorage.getItem(b2+e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&!!e.trim()).slice(0,5):[]}catch{return[]}}function M2(e,t){try{let n=b2+e,r=[...new Set(t.filter(e=>e.trim()))].slice(0,5);r.length?localStorage.setItem(n,JSON.stringify(r)):localStorage.removeItem(n)}catch{}}function kke(){try{return localStorage.getItem(x2)===`true`}catch{return!1}}function Ake(e){try{localStorage.setItem(x2,String(e))}catch{}}function jke({piboSessionId:e,annotations:t,selectedIds:n,loading:r,error:i,collapsed:a,onRefresh:o,onToggle:s,onClear:c,onCollapse:l,onClose:u}){return e?(0,z.jsxs)(`section`,{className:`border-t border-slate-800 bg-[#101d22] px-3 py-2 sm:px-4`,"data-pibo-debug":`web-annotations-session-panel`,"data-pibo-session-id":e,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-[#11a4d4]`,children:`Web annotations`}),(0,z.jsx)(`span`,{className:`rounded-sm border border-slate-700 px-1.5 py-0.5 text-[10px] text-slate-400`,children:t.length}),n.length?(0,z.jsxs)(`span`,{className:`rounded-sm border border-[#11a4d4]/50 px-1.5 py-0.5 text-[10px] text-[#11a4d4]`,children:[n.length,` attached`]}):null]}),a?null:(0,z.jsx)(`div`,{className:`text-[11px] text-slate-500`,children:`Global annotation list. Selected attachments are remembered per session.`})]}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:o,disabled:r,title:`Refresh annotations`,"aria-label":`Refresh annotations`,className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50 sm:h-7 sm:w-7`,"data-pibo-debug":`web-annotations-refresh`,children:(0,z.jsx)(Ls,{size:12,className:r?`animate-spin`:void 0})}),(0,z.jsx)(`button`,{type:`button`,onClick:c,disabled:r||!t.length,title:`Clear visible annotations`,"aria-label":`Clear visible annotations`,className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-red-500 hover:text-red-300 disabled:opacity-50 sm:h-7 sm:w-7`,children:(0,z.jsx)(qs,{size:12})}),(0,z.jsx)(`button`,{type:`button`,onClick:l,title:a?`Expand annotations panel`:`Collapse annotations panel`,"aria-label":a?`Expand annotations panel`:`Collapse annotations panel`,className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] sm:h-7 sm:w-7`,children:a?(0,z.jsx)(Wo,{size:12}):(0,z.jsx)(Ho,{size:12})}),(0,z.jsx)(`button`,{type:`button`,onClick:u,title:`Hide annotations panel`,"aria-label":`Hide annotations panel`,className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] sm:h-7 sm:w-7`,children:(0,z.jsx)(Qs,{size:12})})]})]}),a?null:i?(0,z.jsx)(`div`,{className:`rounded-sm border border-red-900 bg-red-950/40 px-3 py-2 text-xs text-red-200`,"data-pibo-debug":`web-annotations-error`,children:L2(i,220)}):r&&!t.length?(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0e1116] px-3 py-2 text-xs text-slate-400`,"data-pibo-debug":`web-annotations-loading`,children:`Loading annotations…`}):t.length?(0,z.jsx)(`div`,{className:`mt-2 grid max-h-[min(40svh,18rem)] grid-cols-1 gap-2 overflow-y-auto pr-1 sm:max-h-56 sm:grid-cols-[repeat(auto-fill,minmax(16rem,1fr))]`,"data-pibo-debug":`web-annotations-list`,children:t.map(e=>{let t=n.includes(e.id);return(0,z.jsxs)(`div`,{"data-pibo-debug":`web-annotation-chip`,"data-web-annotation-id":e.id,"data-web-annotation-session-id":e.piboSessionId,"data-web-annotation-selected":t?`true`:`false`,className:`min-w-0 rounded-sm border px-3 py-2 text-xs ${t?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#0e1116]`}`,children:[(0,z.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`span`,{className:`min-w-0 truncate font-mono text-[11px] text-slate-500`,children:[e.status,` · `,e.targetKind]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>s(e.id),className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-sm border px-2 text-[11px] sm:h-6 sm:px-1.5 ${t?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4]`}`,children:[t?(0,z.jsx)(Qs,{size:11}):(0,z.jsx)(Ps,{size:11}),` `,t?`Detach`:`Attach`]})]}),(0,z.jsx)(`div`,{className:`truncate text-slate-200`,title:e.primaryTarget||e.label||e.selector||e.id,children:L2(e.primaryTarget||e.label||e.selector||e.id,120)}),e.piboContext?(0,z.jsx)(`div`,{className:`truncate font-mono text-[11px] text-[#11a4d4]`,title:e.piboContext,children:L2(e.piboContext,140)}):null,(0,z.jsx)(`div`,{className:`truncate font-mono text-[11px] text-slate-500`,title:e.url,children:I2(e.url)}),(0,z.jsx)(`div`,{className:`mt-1 line-clamp-2 text-slate-400`,title:e.note,children:L2(e.note,180)}),(0,z.jsx)(`div`,{className:`mt-1 text-[11px] text-slate-600`,children:Ike(e.createdAt)})]},e.id)})}):(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0e1116] px-3 py-2 text-xs text-slate-500`,"data-pibo-debug":`web-annotations-empty`,children:`No open annotations for this session.`})]}):null}function Mke({piboSessionId:e,piboRoomId:t,disabled:n,panelVisible:r,onShowPanel:i,onHidePanel:a,onError:o}){let[s,c]=(0,R.useState)(!1),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(()=>Eke()),[p,m]=(0,R.useState)([]),[h,g]=(0,R.useState)(`idle`),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null);(0,R.useEffect)(()=>{n&&c(!1)},[n]),(0,R.useEffect)(()=>{Dke(d)},[d]);let x=async()=>{if(e){g(`loading`),b(null);try{m((await Cke(d)).targets.filter(e=>e.type===`page`||e.attachable)),g(`loaded`)}catch(e){let t=P2(e,`CDP unavailable`);m([]),g(`error`),b({kind:`error`,message:t}),o(t)}}},S=async n=>{if(!e)throw Error(`No active session context`);return wke(n.binding.id,N2({piboSessionId:e,piboRoomId:t,cdpUrl:d,annotationShortcut:w2()}))},C=async()=>{if(!(!e||_)){i(),v(!0),b({kind:`info`,message:`Injecting annotation overlay into this Pibo page…`});try{let n=await _2({piboSessionId:e,piboRoomId:t,url:window.location.href,title:document.title,sameOrigin:!0,annotationShortcut:w2()});if(!n.overlay)throw Error(`Overlay config missing from same-origin binding response`);await Fke(n.overlay),b({kind:`success`,message:`Annotation overlay is ready on this Pibo page. Open the overlay controls or use the shortcut to start annotating.`}),o(null)}catch(e){let t=P2(e,`Current-page annotation failed`);b({kind:`error`,message:t}),o(t)}finally{v(!1)}}},w=async()=>{if(!e||_)return;i();let n=l.trim();if(!n){b({kind:`error`,message:`URL is required`});return}if(Pke(n)){let e=`That looks like a CDP endpoint. Put it in CDP URL, and put the page you want to annotate in Annotate URL.`;b({kind:`error`,message:e}),o(e);return}v(!0),b({kind:`info`,message:`Opening target and injecting overlay…`});try{let r=await _2(N2({piboSessionId:e,piboRoomId:t,url:n,cdpUrl:d})),i=await S(r);b({kind:`success`,message:`Annotation overlay injected for ${F2(i.target??r.target,i.binding.url)}`}),u(``),o(null)}catch(e){let t=P2(e,`Annotation failed`);b({kind:`error`,message:t}),o(t)}finally{v(!1)}},T=async n=>{if(!(!e||_)){i(),v(!0),b({kind:`info`,message:`Binding selected target and injecting overlay…`});try{let r=await S(await _2(N2({piboSessionId:e,piboRoomId:t,targetId:n.id,cdpUrl:d})));b({kind:`success`,message:`Annotation overlay injected for ${F2(r.target??n,r.binding.url)}`}),o(null)}catch(e){let t=P2(e,n.attachable?`Target annotation failed`:`Target not attachable`);b({kind:`error`,message:t}),o(t)}finally{v(!1)}}};return(0,z.jsxs)(`div`,{className:`relative`,"data-pibo-debug":`web-annotations-entry`,"data-pibo-session-id":e??void 0,children:[(0,z.jsx)(Nke,{onClick:()=>{n||(c(e=>!e),r||i())},title:n?`Select an active session to annotate a web page`:r?`Web Annotations`:`Show Web Annotations`,ariaLabel:`Web Annotations`,active:s||r,children:(0,z.jsx)(Ao,{size:14})}),s&&!n?(0,z.jsxs)(`div`,{className:`fixed inset-x-2 bottom-3 z-40 max-h-[calc(100svh-1.5rem)] overflow-y-auto rounded-sm border border-slate-700 bg-[#0e1116] p-3 text-sm shadow-xl sm:absolute sm:inset-auto sm:right-0 sm:top-full sm:bottom-auto sm:mt-2 sm:w-[min(420px,calc(100vw-24px))] sm:max-h-[calc(100svh-5rem)]`,role:`dialog`,"aria-label":`Web Annotations`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wider text-[#11a4d4]`,children:`Web Annotations`}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-slate-500`,children:`Start an inactive overlay for this Pibo page, or bind a CDP target for external pages.`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:r?a:i,className:`rounded-sm p-1 text-slate-500 hover:bg-slate-800 hover:text-slate-200`,"aria-label":r?`Hide annotation list`:`Show annotation list`,title:r?`Hide annotation list`:`Show annotation list`,children:(0,z.jsx)(zs,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>c(!1),className:`rounded-sm p-1 text-slate-500 hover:bg-slate-800 hover:text-slate-200`,"aria-label":`Close Web Annotations panel`,children:(0,z.jsx)(Qs,{size:14})})]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`mb-3 h-10 w-full rounded-sm bg-emerald-600 px-3 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-50 sm:h-9`,"data-pibo-debug":`web-annotations-current-page`,children:`Annotate this Pibo page`}),(0,z.jsx)(`label`,{className:`mb-2 block text-[11px] font-bold uppercase tracking-wider text-slate-500`,htmlFor:`web-annotation-url`,children:`Annotate URL via CDP`}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-[1fr_auto]`,children:[(0,z.jsx)(`input`,{id:`web-annotation-url`,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&w()},placeholder:`http://localhost:5173`,disabled:_,className:`h-10 min-w-0 rounded-sm border border-slate-700 bg-[#151f24] px-2 text-base text-slate-100 outline-none focus:border-[#11a4d4] disabled:opacity-60 sm:h-9 sm:text-xs`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void w(),disabled:_||!l.trim(),className:`h-10 rounded-sm bg-[#11a4d4] px-3 text-xs font-medium text-white disabled:opacity-50 sm:h-9`,children:`Annotate`})]}),(0,z.jsx)(`label`,{className:`mt-3 mb-1 block text-[11px] font-bold uppercase tracking-wider text-slate-500`,htmlFor:`web-annotation-cdp-url`,children:`CDP URL (optional)`}),(0,z.jsx)(`input`,{id:`web-annotation-cdp-url`,value:d,onChange:e=>f(e.target.value),placeholder:`Use gateway default`,disabled:_,className:`h-10 w-full rounded-sm border border-slate-800 bg-[#151f24] px-2 font-mono text-base text-slate-300 outline-none focus:border-[#11a4d4] disabled:opacity-60 sm:h-8 sm:text-[11px]`}),(0,z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-slate-500`,children:`Existing targets`}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void x(),disabled:_||h===`loading`,className:`inline-flex h-7 items-center gap-1 rounded-sm border border-slate-700 px-2 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[(0,z.jsx)(Ls,{size:12,className:h===`loading`?`animate-spin`:void 0}),` Refresh`]})]}),(0,z.jsxs)(`div`,{className:`mt-2 max-h-[min(34svh,14rem)] overflow-auto rounded-sm border border-slate-800 sm:max-h-56`,children:[h===`idle`?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-slate-500`,children:`Refresh to list reachable browser targets.`}):null,h===`loading`?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-slate-400`,children:`Loading targets…`}):null,h===`loaded`&&!p.length?(0,z.jsx)(`div`,{className:`px-3 py-3 text-xs text-slate-500`,children:`No attachable browser targets found.`}):null,p.map(e=>(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 border-b border-slate-800 px-3 py-2 last:border-b-0 sm:grid-cols-[1fr_auto]`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-xs text-slate-200`,title:e.title||e.url,children:L2(e.title||`Untitled target`,120)}),(0,z.jsx)(`div`,{className:`truncate font-mono text-[11px] text-slate-500`,title:e.url,children:L2(e.url||e.id,160)})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void T(e),disabled:_||!e.attachable,title:e.attachable?`Attach selected target`:`Target is not attachable`,className:`h-9 rounded-sm border border-slate-700 px-2 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-40 sm:h-8`,children:`Attach`})]},e.id))]}),y?(0,z.jsx)(`div`,{className:`mt-2 rounded-sm border px-2 py-2 text-xs ${y.kind===`error`?`border-red-900 bg-red-950/40 text-red-200`:y.kind===`success`?`border-emerald-900/60 bg-emerald-950/30 text-emerald-300`:`border-slate-700 bg-[#151f24] text-slate-300`}`,children:y.message}):null]}):null]})}function Nke({title:e,ariaLabel:t,active:n,onClick:r,children:i}){return(0,z.jsx)(`button`,{type:`button`,onClick:r,title:e,"aria-label":t,className:`h-8 w-8 inline-flex items-center justify-center border rounded-sm transition-colors ${n?`border-[#11a4d4] bg-[#11a4d4]/10 text-[#11a4d4]`:`border-slate-700 text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`}`,children:i})}function N2(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e&&e.trim()))}function Pke(e){try{let t=new URL(e);return t.port===`56663`||t.pathname.startsWith(`/json/`)}catch{return!1}}function Fke(e){return new Promise((t,n)=>{let r=window;try{r.__piboWebAnnotations?.remove?.(),r.__piboWebAnnotationConfig=e;let i=document.createElement(`script`);i.src=`/apps/web-annotations/overlay.js?ts=${Date.now()}`,i.async=!0,i.onload=()=>t(),i.onerror=()=>n(Error(`Could not load Web Annotation overlay script`)),document.head.appendChild(i)}catch(e){n(e)}})}function P2(e,t){let n=Lke(e);return!n||n===`undefined`?t:/target.*not found|selected cdp target/i.test(n)?`Target not found: ${n}`:/inject|overlay|evaluation/i.test(n)?`Injection failed: ${n}`:/cdp endpoint.*is unreachable|failed to fetch|fetch failed|chrome target discovery|cdp unavailable|econnrefused|connect/i.test(n)?`CDP unavailable: ${n}`:`${t}: ${n}`}function F2(e,t){let n=e?.url||t||e?.title||`target`;return I2(e?.title||n)}function I2(e){try{let t=new URL(e);return`${t.host}${t.pathname===`/`?``:t.pathname}`}catch{return L2(e,80)}}function L2(e,t){return e.length>t?`${e.slice(0,Math.max(0,t-1))}…`:e}function Ike(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:`short`,timeStyle:`short`})}function Lke(e){return e instanceof Error?e.message:String(e)}var Rke={terminal:[`terminal`],workflow:[`workflow`]},R2=`1970-01-01T00:00:00.000Z`;function z2(e){return!!e.workflowRunId||e.state===`workflow`||e.workflowId!==`simple-chat`}function zke(e){return z2(e)&&e.state===`configured`&&!e.workflowRunId}function Bke(e){let t=e.selectedSessionNode?.workflowSessionKind??Vke(e.selectedSession?.metadata);if(t===`main_workflow`||t===`nested_workflow`){if(e.selectedProjectSession&&!z2(e.selectedProjectSession)||!e.selectedProjectSession&&t===`main_workflow`&&B2(e.selectedSession?.metadata)===`simple-chat`)return{viewId:`terminal`};let n=e.selectedProjectSession&&z2(e.selectedProjectSession)?e.selectedProjectSession:Hke({selectedSessionNode:e.selectedSessionNode,selectedSession:e.selectedSession,selectedProject:e.selectedProject,workflowSessionKind:t});return{viewId:`workflow`,...n?{workflowProjectSession:n}:{}}}return t===`agent_node`||t===`subagent`?{viewId:`terminal`}:e.selectedProjectSession&&z2(e.selectedProjectSession)?{viewId:`workflow`,workflowProjectSession:e.selectedProjectSession}:{viewId:`terminal`}}function Vke(e){let t=V2(e,`workflowSessionKind`);if(t===`main_workflow`||t===`nested_workflow`||t===`agent_node`||t===`subagent`)return t;if(V2(e,`projectSessionKind`)===`main`)return`main_workflow`}function B2(e){return V2(e,`projectWorkflowId`)??V2(e,`workflowId`)}function Hke(e){let t=e.selectedSessionNode?.piboSessionId??e.selectedSession?.id;if(!t)return;let n=e.selectedSession?.metadata,r=B2(n)??(e.workflowSessionKind===`nested_workflow`?`nested-workflow-session`:`workflow-session`),i=V2(n,`projectWorkflowVersion`)??V2(n,`workflowVersion`),a=V2(n,`workflowRunId`);return{projectId:e.selectedProject?.id??V2(n,`projectId`)??`project`,piboSessionId:t,kind:e.workflowSessionKind===`nested_workflow`?`sub`:`main`,workflowId:r,...i?{workflowVersion:i}:{},...a?{workflowRunId:a}:{},...e.selectedSessionNode?.parentId?{parentMainSessionId:e.selectedSessionNode.parentId}:{},...e.selectedSessionNode?.title||e.selectedSession?.title?{title:e.selectedSessionNode?.title??e.selectedSession?.title}:{},state:Uke(e.selectedSessionNode,a),...e.selectedSessionNode?.archived===void 0?{}:{archived:e.selectedSessionNode.archived},createdAt:e.selectedSession?.createdAt??R2,updatedAt:e.selectedSession?.updatedAt??e.selectedSessionNode?.lastActivityAt??R2}}function Uke(e,t){return e?.status===`error`?`failed`:e?.status===`running`?`running`:t?`workflow`:`configured`}function V2(e,t){let n=e?.[t];return typeof n==`string`&&n.trim()?n.trim():void 0}function Wke(e){if(!z2(e))return`Workflow: ${e.workflowId}`;let t=e.workflowRunId?` · run ${W2(e.workflowRunId)}`:``;return`Workflow: ${e.workflowId}${t} · ${H2(e)}`}function Gke(e,t){return{workflowId:e.workflowId,state:H2(e,t),...e.workflowRunId?{workflowRunId:e.workflowRunId}:{}}}function Kke({summary:e}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-slate-600`,children:`·`}),(0,z.jsxs)(`span`,{className:`min-w-0 max-w-52 truncate rounded border border-[#11a4d4]/35 bg-[#11a4d4]/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[#11a4d4]`,title:e.workflowId,children:[`workflow `,e.workflowId]}),(0,z.jsxs)(`span`,{className:U2(e.state),children:[`state `,e.state]}),e.workflowRunId?(0,z.jsxs)(`span`,{className:`min-w-0 max-w-40 truncate rounded border border-slate-700 bg-slate-900/40 px-1.5 py-0.5 text-[10px] text-slate-400`,title:e.workflowRunId,children:[`run `,W2(e.workflowRunId)]}):null]})}function H2(e,t){return e.archived?`archived`:e.state&&e.state!==`workflow`?e.state.replace(/_/g,` `):t===`running`?`running`:t===`error`?`failed`:e.state?e.state.replace(/_/g,` `):e.workflowRunId?`workflow`:e.kind}function qke(e,t){return U2(H2(e,t),e.archived)}function U2(e,t=!1){let n=e.toLowerCase(),r=`shrink-0 rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide`;return t?`${r} border-slate-700 text-slate-500`:n.includes(`failed`)||n.includes(`error`)?`${r} border-red-500/40 text-red-300 bg-red-500/10`:n.includes(`waiting`)?`${r} border-amber-500/40 text-amber-300 bg-amber-500/10`:n.includes(`complete`)||n.includes(`done`)?`${r} border-emerald-500/40 text-emerald-300 bg-emerald-500/10`:`${r} border-[#11a4d4]/40 text-[#11a4d4] bg-[#11a4d4]/10`}function W2(e){return e.length>18?`${e.slice(0,10)}…${e.slice(-6)}`:e}function Jke({title:e,roomLabel:t,headerPiboSessionId:n,piboSessionId:r,piboRoomId:i,webAnnotationsDisabled:a,webAnnotationsPanelRendered:o,workflowHeader:s,sessionViewId:c,sessionViews:l,currentSessionView:u,allowedSessionViewIds:d,showRawEvents:f,showThinking:p,expandThinking:m,onShowWebAnnotationsPanel:h,onHideWebAnnotationsPanel:g,onSelectSessionView:_,onToggleRawEvents:v,onToggleThinking:y,onToggleExpandThinking:b,onError:x}){let[S,C]=(0,R.useState)(null),w=(0,R.useRef)(void 0),T=S===n,E=(0,R.useMemo)(()=>d?new Set(d):null,[d]);(0,R.useEffect)(()=>()=>{w.current&&window.clearTimeout(w.current)},[]);let D=()=>{n&&(d2(n).catch(()=>void 0),C(n),w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>C(null),900))};return(0,z.jsxs)(`div`,{className:`h-14 px-4 bg-[#151f24] border-b border-slate-800 flex items-center justify-between max-[980px]:h-auto max-[980px]:flex-wrap max-[980px]:py-2 max-[980px]:gap-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-base font-semibold truncate`,children:e}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 font-mono text-[11px] text-slate-500`,children:[(0,z.jsx)(`span`,{className:`truncate`,children:t}),n?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-slate-600`,children:`·`}),(0,z.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>void D(),title:T?`Copied Pibo session ID`:`Copy Pibo session ID`,"aria-label":T?`Copied Pibo session ID`:`Copy Pibo session ID`,className:`min-w-0 max-w-48 truncate rounded-sm px-1 font-mono underline-offset-2 transition-colors duration-150 focus:outline-none focus:ring-1 focus:ring-[#11a4d4] ${T?`bg-emerald-500/15 text-emerald-300 ring-1 ring-emerald-400/50`:`text-slate-400 hover:text-[#11a4d4] hover:underline`}`,children:n})]}):null,s?(0,z.jsx)(Kke,{summary:s}):null]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(Mke,{piboSessionId:r,piboRoomId:i,disabled:a,panelVisible:o,onShowPanel:h,onHidePanel:g,onError:x}),(0,z.jsx)(`div`,{className:`flex items-center rounded-sm border border-slate-700 bg-[#0e1116] p-0.5`,children:l.map(e=>{let t=!!(E&&!E.has(e.id));return(0,z.jsx)(`button`,{type:`button`,onClick:()=>{t||_(e.id)},disabled:t,title:t?`Project session routing uses the ${u.label} view for this session kind.`:e.description??e.label,"aria-label":t?`${e.label} view unavailable for this Project session kind`:`Switch to ${e.label} view`,className:`min-w-20 px-2.5 py-1 text-[11px] font-bold tracking-wide max-[980px]:min-w-0 max-[980px]:px-1.5 disabled:cursor-not-allowed disabled:text-slate-600 ${c===e.id?`bg-[#11a4d4]/10 text-[#11a4d4]`:`text-slate-400 hover:text-[#11a4d4] disabled:hover:text-slate-600`}`,children:e.label},e.id)})}),(0,z.jsx)(G2,{onClick:v,title:f?`Hide Raw Events`:`Show Raw Events`,ariaLabel:f?`Hide Raw Events`:`Show Raw Events`,active:f,children:(0,z.jsx)(Fo,{size:14})}),(0,z.jsx)(G2,{onClick:y,title:p?`Hide Thinking`:`Show Thinking`,ariaLabel:p?`Hide Thinking`:`Show Thinking`,active:p,children:p?(0,z.jsx)(Po,{size:14}):(0,z.jsx)(is,{size:14})}),p?(0,z.jsx)(G2,{onClick:b,title:m?`Collapse Thinking`:`Expand Thinking`,ariaLabel:m?`Collapse Thinking`:`Expand Thinking`,active:m,children:m?(0,z.jsx)(Ho,{size:14}):(0,z.jsx)(Wo,{size:14})}):null]})]})}function G2({title:e,ariaLabel:t,active:n,onClick:r,children:i}){return(0,z.jsx)(`button`,{type:`button`,onClick:r,title:e,"aria-label":t,className:`h-8 w-8 inline-flex items-center justify-center border rounded-sm transition-colors ${n?`border-[#11a4d4] bg-[#11a4d4]/10 text-[#11a4d4]`:`border-slate-700 text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`}`,children:i})}function Yke(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&Xke(e,n)){e.count+=1,e.createdAt=n.createdAt,e.payload={...J2(e.payload)?e.payload:{},text:`${K2(e.payload)}${K2(n.payload)}`};continue}t.push({...n,count:1})}return t}function Xke(e,t){if(e.type!==t.type||e.type!==`assistant_delta`&&e.type!==`thinking_delta`&&e.type!==`TEXT_MESSAGE_CONTENT`&&e.type!==`REASONING_MESSAGE_CONTENT`)return!1;let n=J2(e.payload)?e.payload:{},r=J2(t.payload)?t.payload:{};return q2(n)===q2(r)}function K2(e){return J2(e)?typeof e.text==`string`?e.text:typeof e.delta==`string`?e.delta:``:``}function q2(e){return e.eventId??e.messageId}function J2(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Zke({traceView:e,eventLimit:t,isFetching:n,visible:r,onLoadOlder:i}){let a=(0,R.useMemo)(()=>r?Yke(e?.rawEvents??[]):[],[e?.rawEvents,r]);return r?(0,z.jsxs)(`aside`,{className:`min-h-0 overflow-auto bg-[#0e1116] border-l border-slate-800 max-[980px]:hidden`,children:[(0,z.jsx)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center text-xs font-bold uppercase tracking-wider`,children:`Raw Events`}),(0,z.jsxs)(`div`,{className:`p-3 flex flex-col gap-2`,children:[e&&a.length>=t?(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`mb-1 rounded-sm border border-slate-700 px-2 py-1 text-xs text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-60`,children:n?`Loading raw events…`:`Load older raw events (${a.length})`}):null,a.slice(-t).reverse().map(e=>(0,z.jsxs)(`div`,{className:`border-l-2 border-[#11a4d4] bg-[#151f24] p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[#11a4d4] font-mono text-[11px] mb-1`,children:[(0,z.jsx)(`span`,{children:e.type}),e.count>1?(0,z.jsxs)(`span`,{className:`text-slate-500`,children:[`x`,e.count]}):null]}),(0,z.jsx)(yq,{value:e.payload,showControls:!1})]},e.id))]})]}):null}function Qke({traceView:e,eventLimit:t,isFetching:n,onLoadOlder:r}){if(!e?.hasOlderEvents)return null;let i=Math.min(e.eventLimit??t,e.eventCount??t),a=e.eventCount??`many`;return(0,z.jsx)(`div`,{className:`border-b border-slate-800 bg-[#101d22] px-4 py-2 text-center`,children:(0,z.jsx)(`button`,{type:`button`,onClick:r,disabled:n,className:`rounded-sm border border-slate-700 px-3 py-1 text-xs text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-60`,children:n?`Loading history…`:`Load older trace history (${i} of ${a} events)`})})}function $ke({selectedPiboSessionId:e,selectedRoomId:t,fallbackRoomId:n,sessionViewId:r,loadingTrace:i,traceError:a,showRawEvents:o,currentTraceView:s,traceEventLimit:c,rawEventLimit:l,tracePageFetching:u,onLoadOlderTracePage:d,onLoadMoreRawEvents:f,headerProps:p,projectSessionCreatePanel:m,workflowStartPanel:h,currentSessionView:g,sessionViewProps:_,webAnnotationsPanelRendered:v,webAnnotationsPanelProps:y,composerProps:b}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`main`,{"data-pibo-debug":`chat-shell`,"data-pibo-session-id":e??void 0,"data-pibo-room-id":t??n??void 0,"data-pibo-view-id":r,"data-pibo-state":i?`loading`:a?`error`:e?`ready`:`empty`,className:`min-h-0 flex flex-col`,children:[(0,z.jsx)(Jke,{...p}),m?(0,z.jsx)(`div`,{className:`border-b border-slate-800 bg-[#101d22] px-4 py-3`,children:m}):null,h?(0,z.jsx)(`div`,{className:`border-b border-slate-800 bg-[#101d22] px-4 py-3`,children:h}):null,(0,z.jsx)(Qke,{traceView:s,eventLimit:c,isFetching:u,onLoadOlder:()=>d(s?.nextBeforeSequence)}),a&&!s?(0,z.jsx)(`div`,{className:`min-h-0 flex-1 p-4 text-sm text-red-200`,children:a}):g.render(_),v?(0,z.jsx)(jke,{...y}):null,(0,z.jsx)(mke,{...b})]}),(0,z.jsx)(Zke,{traceView:s,eventLimit:l,isFetching:u,visible:o,onLoadOlder:f})]})}var eAe=5e3,tAe=50,Y2=new Map;function nAe(e){let t=Y2.get(e);return t||(t={snapshots:[],pending:null,pendingTimer:null},Y2.set(e,t)),t}function X2(){try{return localStorage.getItem(`pibo.chat.traceDebug`)===`true`}catch{return!1}}function rAe(e){let t=0;for(let n of e)for(let e=0;e<n.length;e++){let r=n.charCodeAt(e);t=(t<<5)-t+r,t|=0}return t.toString(36)}function Z2(e){if(!e.pending)return;let t=e.pending;if(t.layers.length===0){e.pending=null;return}let n=e.snapshots.at(-1);n&&n.trigger===t.trigger&&n.traceVersion===t.traceVersion&&JSON.stringify(n.layers.map(e=>e.ids))===JSON.stringify(t.layers.map(e=>e.ids))||(e.snapshots.push(t),e.snapshots.length>eAe&&e.snapshots.shift()),e.pending=null}function iAe(e){if(!X2())return;let t=nAe(e.piboSessionId);if(t.pendingTimer&&=(clearTimeout(t.pendingTimer),null),(!t.pending||t.pending.trigger!==e.trigger||t.pending.piboSessionId!==e.piboSessionId)&&(Z2(t),t.pending={timestamp:Date.now(),piboSessionId:e.piboSessionId,trigger:e.trigger,layers:[],expansionOverrides:e.expansionOverrides,traceVersion:e.traceVersion,latestStreamId:e.latestStreamId,lastRawEventId:e.lastRawEventId}),e.layer){let n=t.pending.layers.findIndex(t=>t.kind===e.layer.kind);n>=0?t.pending.layers[n]=e.layer:t.pending.layers.push(e.layer)}e.expansionOverrides!==void 0&&(t.pending.expansionOverrides=e.expansionOverrides),t.pendingTimer=setTimeout(()=>{Z2(t),t.pendingTimer=null},tAe)}function aAe(e,t,n,r){let i=e4(n);iAe({piboSessionId:e,trigger:t,layer:{kind:`backendNodes`,ids:i.map(e=>e.id),digest:rAe(i.map(e=>e.id)),meta:i.map(e=>({id:e.id,type:e.type,orderKey:JSON.stringify(e.orderKey),parentId:e.parentId}))},...r})}function Q2(e){let t=Y2.get(e);return t?(Z2(t),t.snapshots):[]}function $2(e){if(e){let t=Q2(e);return JSON.stringify({piboSessionId:e,snapshots:t},null,2)}let t={};for(let[e,n]of Y2)Z2(n),t[e]=n.snapshots;return JSON.stringify(t,null,2)}function oAe(e){e?Y2.delete(e):Y2.clear()}function e4(e){return e.flatMap(e=>[e,...e4(e.children??[])])}typeof window<`u`&&(window.__piboTraceSnapshots={exportAsJson:e=>{let t=$2(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`trace-snapshots-${e??`all`}-${Date.now()}.json`,i.click(),URL.revokeObjectURL(r)},getSnapshots:Q2,clearSnapshots:oAe,exportSnapshots:$2});function t4(e){let t=!1,n=e.map(e=>e.children.length?(t=!0,{...e,children:t4(e.children)}):e);return sAe(n)?t?n:[...e]:[...n].sort(n4)}function sAe(e){for(let t=1;t<e.length;t+=1)if(n4(e[t-1],e[t])>0)return!1;return!0}function n4(e,t){let n=cAe(e.startedAt,t.startedAt);if(n!==0)return n;let r=Jc(e.orderKey,t.orderKey);return r===0?e.id.localeCompare(t.id):r}function cAe(e,t){return!e&&!t?0:e?t?e.localeCompare(t):-1:1}function r4(e){let t=[],n=[...e].reverse();for(;n.length;){let e=n.pop();if(e){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}}return t}function lAe(e,t,n,r){if(!i4(t))return;let i=r.get(e)?.filter(e=>e.metadata?.subagentToolName===t)??[],a=dAe(n);return a?i.find(e=>e.metadata?.threadKey===a)?.id:i.length===1?i[0].id:void 0}function i4(e){return e.startsWith(`pibo_subagent_`)}function uAe(e){return e.slice(14)}function dAe(e){let t=`args`in e&&e.args&&typeof e.args==`object`&&!Array.isArray(e.args)?e.args:void 0,n=t&&`threadKey`in t?t.threadKey:void 0;return typeof n==`string`&&n.trim()?n.trim():void 0}function a4(e,t,n,r){let i=pAe(e,t,n,r);if(!i)return;let a=e.children.find(e=>e.id===i.id);if(a){mAe(a,i),a.runId=i.runId??a.runId;return}e.children.push(i)}function fAe(e){let t=new Map;for(let n of r4(e)){let e=s4(n.output);if(!e)continue;let r=l4(e.runId);r&&t.set(r,{snapshot:e,completedAt:l4(e.completedAt)??l4(e.updatedAt)??n.completedAt})}for(let n of r4(e)){if(n.type!==`agent.async`||!n.runId)continue;let e=t.get(n.runId);if(!e)continue;let r=l4(e.snapshot.status);r!==`completed`&&r!==`cancelled`&&r!==`failed`||(n.status=r===`failed`?`error`:`done`,n.completedAt=e.completedAt??n.completedAt,n.output=e.snapshot,r===`failed`&&(n.error=l4(e.snapshot.summary)??n.error))}}function pAe(e,t,n,r){if(!o4(e))return;let i=s4(e.output),a=u4(e.input)?e.input:{},o=l4(i?.toolName)??l4(a.toolName)??r?.title;if(!o||!i4(o))return;let s=l4(r?.summary)??uAe(o),c=l4(i?.runId),l=l4(i?.status),u=a.arguments,d=l4(i?.completionPolicy)??l4(a.completionPolicy);return{id:`${e.id}:async-agent`,parentId:e.id,piboSessionId:t,eventId:e.eventId,toolCallId:e.toolCallId,runId:c,type:`agent.async`,title:s,status:hAe(e,l),startedAt:r?.startedAt??n??e.startedAt,completedAt:l===`completed`||l===`cancelled`?e.completedAt:void 0,summary:`Started by ${e.title}`,input:{startedBy:e.title,startToolCallId:e.toolCallId,toolName:o,subagentName:s,runId:c,completionPolicy:d,arguments:u,threadKey:u4(r?.input)?r.input.threadKey:void 0},output:i,error:e.error,linkedPiboSessionId:r?.linkedPiboSessionId??e.linkedPiboSessionId,source:e.source,stableKey:c?`async-agent:${c}`:`${e.stableKey??e.id}:async-agent`,orderKey:qc(e.orderKey,`agent.async`),children:[]}}function o4(e){return e.type===`tool.call`&&e.title===`pibo_run_start`}function mAe(e,t){e.status=t.status,e.summary=t.summary??e.summary,e.input=t.input??e.input,e.output=t.output??e.output,e.error=t.error??e.error,e.completedAt=t.completedAt??e.completedAt,e.linkedPiboSessionId=t.linkedPiboSessionId??e.linkedPiboSessionId}function s4(e){if(u4(e)){if(c4(e))return e;if(u4(e.details)&&c4(e.details))return e.details}}function c4(e){return typeof e.runId==`string`&&typeof e.toolName==`string`}function l4(e){return typeof e==`string`?e:void 0}function hAe(e,t){return e.status===`error`||t===`failed`?`error`:t===`completed`||t===`cancelled`?`done`:`running`}function u4(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function gAe(e){let t=(e??``).trim();if(!t.startsWith(`<pibo_run_notification>`)||!t.endsWith(`</pibo_run_notification>`))return;let n=t.slice(23,t.length-24).trim();try{let e=JSON.parse(n);return!e||typeof e!=`object`||Array.isArray(e)?void 0:e}catch{return}}function _Ae(e){let t=vAe(e.notification),n=t.length===1?t[0]:void 0,r=f4(e.notification.failed),i=f4(e.notification.running);return{id:e.id,entryId:e.entryId,piboSessionId:e.piboSessionId,eventId:e.eventId,runId:typeof n?.runId==`string`?n.runId:void 0,type:`yielded.run`,title:`Run Notification`,status:r>0?`error`:i>0?`running`:`done`,startedAt:e.startedAt,summary:yAe(e.notification),output:e.notification,source:e.source,stableKey:e.stableKey??e.id,orderKey:e.orderKey,children:[]}}function vAe(e){return[...d4(e.completed),...d4(e.failed),...d4(e.cancelled),...d4(e.running)]}function d4(e){return Array.isArray(e)?e.filter(bAe):[]}function f4(e){return Array.isArray(e)?e.length:0}function yAe(e){let t=[[f4(e.completed),`completed`],[f4(e.failed),`failed`],[f4(e.cancelled),`cancelled`],[f4(e.running),`running`]].filter(([e])=>Number(e)>0).map(([e,t])=>`${e} ${t}`);return t.length?t.join(`, `):`No yielded run updates`}function bAe(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function xAe(e,t,n,r,i,a,o,s,c){let l=r.payload;if(o&&FAe(l)&&!IAe(l,s)||o&&LAe(l,c))return;if(l.type===`assistant_delta`){jAe(e,t,l,c,r.createdAt,r.eventSequence,r.streamId,r.streamFrameIndex);return}if(l.type===`thinking_delta`){MAe(e,t,l,c,r.createdAt,r.eventSequence,r.streamId,r.streamFrameIndex);return}if(l.type===`assistant_message`){let i=SAe(n,l,r.createdAt,r.eventSequence,r.streamId,r.streamFrameIndex),a=t.get(i.id);if(a){m4(a,i),h4(t,a);return}h4(t,i),e.push(i),t.set(i.id,i);return}let u=AAe(n,l,i,a,c,r.createdAt,r.eventSequence,r.streamId,r.streamFrameIndex);if(u){if(u.type===`agent.turn`&&u.eventId){let e=[...t.values()].find(e=>e.type===`agent.turn`&&e.eventId===u.eventId);if(e){e.status=u.status,e.completedAt=u.completedAt??e.completedAt;return}}if(u.type===`assistant.message`){let e=t.get(u.id);if(e){m4(e,u),h4(t,e);return}h4(t,u)}if(u.type===`execution.compaction`){let t=zAe(e);if(t){BAe(t,u);return}}if(u.type===`model.reasoning`){let e=t.get(u.id);if(e){NAe(e,u);return}}if(u.toolCallId){let e=[...t.values()].find(e=>e.toolCallId===u.toolCallId&&(e.type===`tool.call`||e.type===`agent.delegation`));if(e){if(o4(e)&&u.type===`agent.delegation`){a4(e,n,r.createdAt,u);return}RAe(e,u),a4(e,n,r.createdAt);return}}if(!(u.eventId&&t.has(u.id))){CAe(u,t),a4(u,n,r.createdAt),e.push(u);for(let e of r4([u]))t.set(e.id,e)}}}function SAe(e,t,n,r,i,a){let o=typeof t.eventId==`string`?t.eventId:void 0,s=x4(t);return{id:s?b4(s):`event:${t.type}:${w4(t)}`,piboSessionId:e,eventId:o,parentId:o?y4(o):void 0,type:`assistant.message`,title:`Agent Message`,status:`done`,startedAt:n,summary:t.text,output:t.text,source:`event-log`,stableKey:s?`assistant:${s}`:v4(t),orderKey:g4(r,t.type,i,a),children:[]}}function CAe(e,t){if(e.type!==`execution.command`||e.parentId&&t.has(e.parentId))return;let n=[...t.values()].filter(n=>{if(n.type!==`agent.turn`||!n.startedAt||!e.startedAt||n.startedAt>e.startedAt)return!1;let r=wAe(n,t);return r===void 0||e.startedAt<=r}).sort(n4).at(-1);n&&(e.parentId=n.id)}function wAe(e,t){return e.completedAt?e.completedAt:[...t.values()].filter(t=>t.type===`error`&&t.eventId!==void 0&&t.eventId===e.eventId&&t.startedAt!==void 0).sort(n4).at(0)?.startedAt}function TAe(e){return e.some(e=>{let t=e.payload.type;return t!==`assistant_delta`&&t!==`thinking_delta`})}function EAe(e){if(e.type===`assistant_delta`){if(e.text.length===0)return;let t=x4(e);return t?b4(t):void 0}if(e.type===`thinking_delta`){if(e.text.length===0)return;let t=C4(e);return t?S4(t):void 0}}function DAe(e,t){let n=t.payload;if(n.type!==`message_queued`||n.source!==`user`)return!1;let r=typeof n.eventId==`string`?n.eventId:t.eventId,i=typeof n.text==`string`?n.text:void 0;return e.some(e=>e.type!==`user.message`||e.source!==`transcript`?!1:r&&(e.entryId===r||e.stableKey===`entry:${r}`)?!0:!!(i&&OAe(e)===i))}function OAe(e){if(typeof e.output==`string`)return e.output;if(typeof e.summary==`string`)return e.summary}function p4(e){if(e.streamId!==void 0){let t=e.payload;return e.streamFrameIndex===void 0?`stream:${e.streamId}:${t.type}`:`stream:${e.streamId}:${e.streamFrameIndex}:${t.type}`}return e.eventSequence===void 0?`id:${e.id}`:`sequence:${e.piboSessionId??``}:${e.eventSequence}`}function kAe(e,t){let n=t;for(let t of e)t.streamId!==void 0&&(n=n===void 0?t.streamId:Math.max(n,t.streamId));return n}function AAe(e,t,n,r,i,a,o,s,c){let l=`eventId`in t&&typeof t.eventId==`string`?t.eventId:void 0,u=`event:${t.type}:${l??w4(t)}`,d=l?y4(l):void 0,f={id:u,piboSessionId:e,eventId:l,startedAt:a,source:`event-log`,stableKey:v4(t),orderKey:g4(o,t.type,s,c),children:[]};switch(t.type){case`message_queued`:{let n=gAe(t.text);return t.source===`service`&&n?_Ae({id:u,piboSessionId:e,eventId:l,startedAt:a,source:`event-log`,stableKey:l?`run-notification:${l}`:u,orderKey:g4(o,t.type,s,c),notification:n}):{...f,type:`user.message`,title:`User Message`,status:`done`,summary:t.text,output:t.text}}case`message_started`:case`message_finished`:return t.source===`service`?void 0:{...f,id:l?y4(l):u,type:`agent.turn`,title:`Agent Turn`,status:t.type===`message_finished`||i!==`running`?`done`:`running`,completedAt:t.type===`message_finished`?a:void 0,stableKey:l?`turn:${l}`:f.stableKey};case`thinking_finished`:{if(!VAe(t.text))return;let e=C4(t);return{...f,id:e?S4(e):u,parentId:d,type:`model.reasoning`,title:`Thinking`,status:`done`,summary:t.text,output:t.text,stableKey:e?`reasoning:${e}`:f.stableKey}}case`assistant_message`:{let e=x4(t);return{...f,id:e?b4(e):u,parentId:d,type:`assistant.message`,title:`Agent Message`,status:`done`,summary:t.text,output:t.text,stableKey:e?`assistant:${e}`:f.stableKey}}case`tool_call`:case`tool_execution_started`:case`tool_execution_updated`:case`tool_execution_finished`:{let o=i4(t.toolName),s=r.get(t.toolCallId)??(o?lAe(e,t.toolName,t,n):void 0);return{...f,id:`tool:${t.toolCallId}`,parentId:d,toolCallId:t.toolCallId,type:o?`agent.delegation`:`tool.call`,title:t.toolName,status:t.type===`tool_execution_finished`?t.isError?`error`:`done`:i===`running`&&(t.type===`tool_execution_started`||t.type===`tool_execution_updated`)?`running`:`done`,completedAt:t.type===`tool_execution_finished`?a:void 0,input:`args`in t?t.args:void 0,output:t.type===`tool_execution_finished`?t.result:t.type===`tool_execution_updated`?t.partialResult:void 0,error:t.type===`tool_execution_finished`&&t.isError?HAe(t.result):void 0,linkedPiboSessionId:s,stableKey:`tool:${t.toolCallId}`,children:[]}}case`subagent_session`:return{...f,id:t.toolCallId?`tool:${t.toolCallId}`:u,eventId:l,toolCallId:t.toolCallId,type:`agent.delegation`,title:t.toolName,status:i===`running`?`running`:`done`,summary:t.subagentName,input:{subagentName:t.subagentName,threadKey:t.threadKey},linkedPiboSessionId:t.childPiboSessionId,stableKey:t.toolCallId?`tool:${t.toolCallId}`:`subagent:${t.childPiboSessionId}`,children:[]};case`execution_result`:return PAe(t.action)?void 0:{...f,type:`execution.command`,title:t.action,status:`done`,input:{action:t.action},output:t.result};case`compaction_start`:return{...f,id:`event:compaction:${o??s??w4(t)}`,type:`execution.compaction`,title:`compact`,status:`running`,summary:`Compacting`,input:{reason:t.reason},stableKey:`compaction:active`};case`compaction_end`:return{...f,id:`event:compaction:end:${o??s??w4(t)}`,type:`execution.compaction`,title:`compact`,status:t.errorMessage?`error`:`done`,completedAt:a,summary:t.aborted?`Compaction skipped`:t.errorMessage?`Compaction failed`:`Compacted`,input:{reason:t.reason},output:t.result,error:t.errorMessage,stableKey:`compaction:active`};case`session_error`:return{...f,type:`error`,title:`Session Error`,status:`error`,summary:t.errorDetails?.userMessage,input:t.errorDetails,error:t.error,output:t.error};default:return}}function jAe(e,t,n,r,i,a,o,s){if(n.text.length===0)return;let c=x4(n),l=c?b4(c):`event:assistant_delta:${w4(n)}`,u=t.get(l);if(u){let e=`${typeof u.output==`string`?u.output:``}${n.text}`;u.status=r===`running`?`running`:`done`,u.summary=e,u.output=e;return}let d={id:l,parentId:n.eventId?y4(n.eventId):void 0,piboSessionId:n.piboSessionId,eventId:n.eventId,type:`assistant.message`,title:`Agent Message`,status:r===`running`?`running`:`done`,startedAt:i,summary:n.text,output:n.text,source:`event-log`,stableKey:c?`assistant:${c}`:l,orderKey:g4(a,n.type,o,s),children:[]};e.push(d),t.set(d.id,d)}function m4(e,t){e.status=t.status,e.summary=t.summary??e.summary,e.output=t.output??e.output,e.error=t.error??e.error,e.completedAt=t.completedAt??e.completedAt}function MAe(e,t,n,r,i,a,o,s){if(n.text.length===0)return;let c=C4(n),l=c?S4(c):`event:thinking_delta:${w4(n)}`,u=t.get(l);if(u){let e=`${typeof u.output==`string`?u.output:``}${n.text}`;u.status=r===`running`?`running`:`done`,u.summary=e,u.output=e;return}let d={id:l,parentId:n.eventId?y4(n.eventId):void 0,piboSessionId:n.piboSessionId,eventId:n.eventId,type:`model.reasoning`,title:`Thinking`,status:r===`running`?`running`:`done`,startedAt:i,summary:n.text,output:n.text,source:`event-log`,stableKey:c?`reasoning:${c}`:l,orderKey:g4(a,n.type,o,s),children:[]};e.push(d),t.set(d.id,d)}function NAe(e,t){e.status=t.status,e.summary=t.summary??e.summary,e.output=t.output??e.output,e.completedAt=t.completedAt??e.completedAt}function h4(e,t){if(!t.parentId||t.status!==`done`)return;let n=e.get(t.parentId);!n||n.type!==`agent.turn`||(n.status=`done`,n.completedAt=t.completedAt??t.startedAt??n.completedAt)}function PAe(e){return e===`session.fork`||e===`session.clone`||e===`session.switch`}function FAe(e){return e.type===`message_queued`||e.type===`message_started`||e.type===`message_finished`||e.type===`assistant_delta`||e.type===`assistant_message`||e.type===`thinking_started`||e.type===`thinking_delta`||e.type===`thinking_finished`}function IAe(e,t){let n=`eventId`in e&&typeof e.eventId==`string`?e.eventId:void 0;return!!(n&&t.has(n))}function LAe(e,t){return t!==`running`&&e.type===`tool_call`}function g4(e,t,n,r){return e===void 0&&(n!==void 0||r!==void 0)?Gc(n,r,_4(t)):Wc(e,_4(t))}function _4(e){switch(e){case`message_queued`:return`user.message`;case`message_started`:case`message_finished`:return`agent.turn`;case`thinking_started`:case`thinking_delta`:case`thinking_finished`:return`model.reasoning`;case`tool_call`:case`tool_execution_started`:case`tool_execution_updated`:case`tool_execution_finished`:case`subagent_session`:return`tool.call`;case`assistant_delta`:case`assistant_message`:return`assistant.message`;case`execution_result`:return`execution.command`;case`compaction_start`:case`compaction_end`:return`execution.compaction`;case`session_error`:return`error`;default:return`execution.command`}}function v4(e){let t=`eventId`in e&&typeof e.eventId==`string`?e.eventId:void 0;if(e.type===`tool_call`||e.type===`tool_execution_started`||e.type===`tool_execution_updated`||e.type===`tool_execution_finished`||e.type===`subagent_session`&&e.toolCallId)return`tool:${e.toolCallId}`;if(t&&(e.type===`message_started`||e.type===`message_finished`))return`turn:${t}`;if(e.type===`thinking_started`||e.type===`thinking_delta`||e.type===`thinking_finished`){let t=C4(e);if(t)return`reasoning:${t}`}if(e.type===`assistant_delta`||e.type===`assistant_message`){let t=x4(e);if(t)return`assistant:${t}`}return`event:${e.type}:${t??w4(e)}`}function y4(e){return`event:message:${e}`}function b4(e){return`event:assistant:${e}`}function x4(e){if(!e.eventId)return;let t=typeof e.assistantIndex==`number`?e.assistantIndex:e.contentIndex;return typeof t==`number`?`${e.eventId}:assistant:${t}`:e.eventId}function S4(e){return`event:thinking:${e}`}function C4(e){if(!e.eventId)return;let t=typeof e.thinkingIndex==`number`?e.thinkingIndex:e.contentIndex;return typeof t==`number`?`${e.eventId}:thinking:${t}`:e.eventId}function RAe(e,t){e.status=t.status,e.summary=t.summary??e.summary,e.input=t.input??e.input,e.output=t.output??e.output,e.error=t.error??e.error,e.completedAt=t.completedAt??e.completedAt,e.linkedPiboSessionId=t.linkedPiboSessionId??e.linkedPiboSessionId}function zAe(e){return r4([...e]).reverse().find(e=>e.type===`execution.compaction`&&e.status===`running`)}function BAe(e,t){e.status=t.status,e.summary=t.summary??e.summary,e.input=t.input??e.input,e.output=t.output??e.output,e.error=t.error??e.error,e.completedAt=t.completedAt??e.completedAt}function VAe(e){return typeof e==`string`&&e.trim().length>0}function HAe(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function w4(e){return UAe(new TextEncoder().encode(JSON.stringify(e))).slice(0,48)}function UAe(e){let t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`,n=``,r=0;for(;r+2<e.length;r+=3){let i=e[r]<<16|e[r+1]<<8|e[r+2];n+=t[i>>18&63]+t[i>>12&63]+t[i>>6&63]+t[i&63]}if(r<e.length){let i=e[r],a=r+1<e.length?e[r+1]:0,o=i<<16|a<<8;n+=t[o>>18&63]+t[o>>12&63],r+1<e.length&&(n+=t[o>>6&63])}return n}function WAe(e){let t=new Map;for(let n of e)t.set(n.id,n);let n=[];for(let r of e){if(!r.parentId){n.push(r);continue}let e=t.get(r.parentId);e?e.children.push(r):n.push(r)}return t4(n)}function GAe(e,t,n){return t.map(t=>T4(e,t,n))}function T4(e,t,n){let r=e.get(t.id);if(t.children.length===0){let e=r!==void 0&&r.children.length===0;return r&&e&&(n&&!n.has(t.id)||E4(r,t))?r:e?{...t,children:r.children}:{...t,children:[]}}let i=t.children.map(t=>T4(e,t,n)),a=r!==void 0&&r.children.length===i.length&&r.children.every((e,t)=>e===i[t]);return r&&a&&(n&&!n.has(t.id)||E4(r,t))?r:a?{...t,children:r?.children??i}:{...t,children:i}}function E4(e,t){return e.id===t.id&&e.parentId===t.parentId&&e.entryId===t.entryId&&e.piboSessionId===t.piboSessionId&&e.eventId===t.eventId&&e.toolCallId===t.toolCallId&&e.runId===t.runId&&e.type===t.type&&e.title===t.title&&e.status===t.status&&e.startedAt===t.startedAt&&e.completedAt===t.completedAt&&e.durationMs===t.durationMs&&e.summary===t.summary&&e.input===t.input&&e.output===t.output&&e.error===t.error&&e.linkedPiboSessionId===t.linkedPiboSessionId&&e.source===t.source&&e.stableKey===t.stableKey&&KAe(e.orderKey,t.orderKey)}function KAe(e,t){return e===t?!0:!e||!t?!1:e.sourceRank===t.sourceRank&&e.turnSeq===t.turnSeq&&e.transcriptIndex===t.transcriptIndex&&e.contentPartIndex===t.contentPartIndex&&e.eventSequence===t.eventSequence&&e.streamId===t.streamId&&e.streamFrameIndex===t.streamFrameIndex&&e.phaseRank===t.phaseRank}function qAe(e,t,n){if(!t.length)return e;let r=new Set(e.rawEvents.map(e=>p4(e))),i=[];for(let e of t){let t=p4(e);r.has(t)||(r.add(t),i.push(e))}if(!i.length)return e;let a=r4(e.nodes),o=[],s=new Map,c=new Map;for(let e of a){c.set(e.id,e);let t={...e,children:[]};o.push(t),s.set(t.id,t)}let l=new Map,u=new Map,d=new Set,f=[],p=new Set;for(let t of i){if(DAe(o,t))continue;f.push(t);let r=EAe(t.payload);p&&r?p.add(r):p=void 0,xAe(o,s,e.piboSessionId,t,l,u,!1,d,n)}if(!f.length)return e;let m=WAe(o);TAe(f)&&fAe(m);let h=GAe(c,m,p);return{...e,rawEvents:e.rawEvents.length?[...e.rawEvents,...f]:f,nodes:h,latestStreamId:kAe(f,e.latestStreamId)}}function D4(e){let t=new Map;if(k4(e.nodes,t),!t.size)return e;let{nodes:n,changed:r}=A4(e.nodes,t);return r?{...e,nodes:n}:e}function JAe(e){return e.some(O4)}function YAe(e){let t=new Map;return M4(e,e=>{if(e.type!==`user.message`||!e.entryId)return;let n=N4(e),r=t.get(n);r?r.push(e.entryId):t.set(n,[e.entryId])}),t}function XAe(e,t){if(!t.size)return;let n=new Map;M4(e,e=>{if(e.type!==`user.message`||e.entryId)return;let r=N4(e),i=t.get(r);if(!i?.length)return;let a=n.get(r)??0,o=i[a];o&&(e.entryId=o,n.set(r,a+1))})}function O4(e){let t=e.payload;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&`type`in t&&t.type===`message_queued`&&`source`in t&&t.source===`user`&&`text`in t&&typeof t.text==`string`)}function k4(e,t){for(let n of e){if(n.type===`user.message`&&!j4(n)){let e=N4(n);e&&t.set(e,(t.get(e)??0)+1)}k4(n.children,t)}}function A4(e,t){let n=!1,r=[];for(let i of e){if(j4(i)){let e=N4(i),r=e?t.get(e)??0:0;if(r>0){t.set(e,r-1),n=!0;continue}}let e=A4(i.children,t);n||=e.changed,r.push(e.changed?{...i,children:e.nodes}:i)}return{nodes:n?r:e,changed:n}}function j4(e){return e.type===`user.message`?e.source===`event-log`&&e.id.startsWith(`event:message_queued:`)?!0:[e.id,e.stableKey,e.eventId].filter(e=>typeof e==`string`).some(e=>e.startsWith(`optimistic:user-message:`)||e.includes(`:optimistic:user-message:`)):!1}function M4(e,t){for(let n of e)t(n),M4(n.children,t)}function N4(e){return typeof e.output==`string`?e.output:typeof e.summary==`string`?e.summary:``}function ZAe({selectedPiboSessionId:e,reconciledBaseTraceView:t,liveTraceOverlay:n,selectedSessionStatus:r,persistedUserMessageIndexForBaseTrace:i,now:a}){if(!e||t?.piboSessionId!==e)return{traceView:null};let o=n?.piboSessionId===e?n.events:[];if(!o.length)return{traceView:t};let s=a?.(),c=qAe(t,o,r??`idle`),l=JAe(o);return l&&XAe(c.nodes,i),{traceView:l?D4(c):c,liveTraceComputeDurationMs:s!==void 0&&a?a()-s:void 0}}function P4(e,t){for(let n of e)t(n),P4(n.children,t)}function QAe(e){return typeof e.output==`string`?e.output:typeof e.summary==`string`?e.summary:``}function F4(e){if(!e)return;let t=0;return P4(e.nodes,e=>{e.type===`assistant.message`&&(t+=QAe(e).length)}),t}function $Ae({selectedPiboSessionId:e,baseTraceView:t,liveTraceOverlay:n,selectedSessionStatus:r}){let i=(0,R.useMemo)(()=>t?D4(t):null,[t]),a=(0,R.useMemo)(()=>i?YAe(i.nodes):new Map,[i]),o=(0,R.useMemo)(()=>ZAe({selectedPiboSessionId:e,reconciledBaseTraceView:i,liveTraceOverlay:n,selectedSessionStatus:r,persistedUserMessageIndexForBaseTrace:a,now:BU()?()=>performance.now():void 0}),[n,e,r,i,a]),s=o.traceView;return(0,R.useEffect)(()=>{!e||!s?.piboSessionId||!BU()||(ZU(s.piboSessionId,{overlayEventCount:n?.piboSessionId===s.piboSessionId?n.events.length:0,traceBaseOutputLength:F4(t),currentOutputLength:F4(s)}),o.liveTraceComputeDurationMs!==void 0&&KU(s.piboSessionId,o.liveTraceComputeDurationMs))},[t,o.liveTraceComputeDurationMs,s,n,e]),(0,R.useEffect)(()=>{let e=()=>{!s?.piboSessionId||!X2()||aAe(s.piboSessionId,`tab:${document.visibilityState}`,s.nodes,{traceVersion:s.version,latestStreamId:s.latestStreamId,lastRawEventId:s.rawEvents.at(-1)?.id})};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[s]),s}var I4=1e4,L4=30*6e4,R4=2e3;function eje(e,t=!1,n){return[`chat`,`bootstrap`,e??``,t?`archived`:`active`,n??``]}function tje(e=!1,t,n){return[`chat`,`sessions`,e?`archived`:`active`,t??``,n??``]}function nje(e){return[`chat`,`trace-summary`,e]}function rje(e,t=!1,n,r=t?60:120){return[`chat`,`session-page`,e,t?`archived`:`active`,n??``,r]}function z4(e,t={}){let n=t.pageSize??t.eventLimit??2e3;return[`chat`,`trace-page`,e,t.includeRawEvents?`raw`:`compact`,t.rawEventsLimit??80,n,t.beforeSequence===void 0?`tail`:String(t.beforeSequence)]}function B4(e){return[`chat`,`trace-summary`,e]}function V4(e){return[`chat`,`trace-page`,e]}function ije(e,t){if(!e||e.piboSessionId!==t.piboSessionId)return e;let n=t.latestStreamId,r=aje(t),i=H4(t.nodes),a=e.events.filter(e=>{if(n!==void 0&&e.streamId!==void 0&&e.streamId<=n||O4(e)&&i.has(e.payload.text))return!1;let t=W4(e);return!t||!r.has(t)});return a.length?{...e,events:a}:null}function H4(e){let t=new Set;for(let n of e){if(n.type===`user.message`&&n.source===`transcript`){let e=oje(n);e&&t.add(e)}for(let e of H4(n.children))t.add(e)}return t}function aje(e){let t=new Set;for(let n of e.rawEvents){let e=W4(n);e&&t.add(e)}return U4(e.nodes,t),t}function U4(e,t){for(let n of e){if(n.type===`user.message`){let e=n.id.startsWith(`event:message_queued:`)?n.id.slice(21):void 0;e&&t.add(`${n.piboSessionId}:message_queued:${e}`),n.source===`transcript`&&n.entryId&&t.add(`${n.piboSessionId}:message_queued:${n.entryId}`)}n.eventId&&n.type===`assistant.message`&&(t.add(`${n.piboSessionId}:assistant_delta:${n.eventId}`),t.add(`${n.piboSessionId}:assistant_message:${n.eventId}`)),n.eventId&&n.type===`model.reasoning`&&(t.add(`${n.piboSessionId}:thinking_delta:${n.eventId}`),t.add(`${n.piboSessionId}:thinking_finished:${n.eventId}`)),U4(n.children,t)}}function W4(e){let t=e.payload;if(!t||typeof t!=`object`||Array.isArray(t))return;let n=`eventId`in t&&typeof t.eventId==`string`?t.eventId:e.eventId,r=`piboSessionId`in t&&typeof t.piboSessionId==`string`?t.piboSessionId:e.piboSessionId;if(!(!n||!r))return`${r}:${e.type}:${n}`}function oje(e){return typeof e.output==`string`?e.output:e.output&&typeof e.output==`object`&&`text`in e.output&&typeof e.output.text==`string`?e.output.text:``}function sje(e,t){if(e.piboSessionId!==t.piboSessionId)return e;let n=new Set,r=[...t.nodes,...e.nodes].filter(e=>n.has(e.id)?!1:(n.add(e.id),!0)),i=new Set,a=[...t.rawEvents,...e.rawEvents].filter(e=>{let t=e.id||`${e.eventSequence??``}:${e.type}:${e.createdAt}`;return i.has(t)?!1:(i.add(t),!0)});return{...e,version:e.version,nodes:r,rawEvents:a,firstEventSequence:t.firstEventSequence??e.firstEventSequence,nextBeforeSequence:t.nextBeforeSequence,hasOlderEvents:t.hasOlderEvents,eventLimit:(e.eventLimit??0)+(t.eventLimit??t.pageSize??0)}}function cje({selectedPiboSessionId:e,showRawEvents:t,setLiveTraceOverlay:n}){let r=Yt(),[i,a]=(0,R.useState)(R4),[o,s]=(0,R.useState)(80),[c,l]=(0,R.useState)(null),u=(0,R.useMemo)(()=>e?nje(e):null,[e]),d=(0,R.useMemo)(()=>e?z4(e,{includeRawEvents:t,rawEventsLimit:o,pageSize:R4}):null,[o,e,t]),f=dn({queryKey:u??[`chat`,`trace-summary`,`idle`],queryFn:async()=>{if(!e||!u)throw Error(`Session is required`);let t=r.getQueryData(u),n=await Ic(e,t?.version);if(n.notModified&&t)return t;if(!n.summary)throw Error(`Trace summary response missing payload.`);return n.summary},enabled:!!e,staleTime:I4,gcTime:L4,refetchOnWindowFocus:!1,retry:1}),p=dn({queryKey:d??[`chat`,`trace-page`,`idle`,`compact`,o,2e3,`tail`],queryFn:async()=>{if(!e||!d)throw Error(`Session is required`);let n=r.getQueryData(d),i=await Lc(e,{includeRawEvents:t,rawEventsLimit:o,pageSize:R4,knownVersion:n?.version});if(i.notModified&&n)return n;if(!i.trace)throw Error(`Trace page response missing payload.`);return i.trace},enabled:!!e,staleTime:I4,gcTime:L4,refetchOnWindowFocus:!1,retry:1});(0,R.useEffect)(()=>{a(R4),s(80),l(null),n(null)},[e,n]),(0,R.useEffect)(()=>{let t=p.data;!t||t.piboSessionId!==e||(BU()&&ZU(t.piboSessionId,{overlayEventCount:0,traceBaseOutputLength:F4(t),traceBaseUpdated:!0}),(0,R.startTransition)(()=>{l(t),n(e=>ije(e,t))}))},[e,n,p.data]);let m=(0,R.useCallback)(async n=>{if(!e||!n)return;let i=z4(e,{includeRawEvents:t,rawEventsLimit:o,pageSize:R4,beforeSequence:n}),s=await r.fetchQuery({queryKey:i,queryFn:async()=>{let a=r.getQueryData(i),s=await Lc(e,{includeRawEvents:t,rawEventsLimit:o,pageSize:R4,beforeSequence:n,knownVersion:a?.version});if(s.notModified&&a)return a;if(!s.trace)throw Error(`Trace page response missing payload.`);return s.trace},staleTime:I4,gcTime:L4});(0,R.startTransition)(()=>{l(e=>e?sje(e,s):s),a(e=>e+(s.pageSize??2e3))})},[r,o,e,t]),h=(0,R.useCallback)(()=>{s(e=>e+80)},[]);return{baseTraceView:c,traceEventLimit:i,rawEventLimit:o,traceSummaryQuery:f,tracePageQuery:p,tracePageReady:!!d,loadOlderTracePage:m,loadMoreRawEvents:h}}function lje(e){let t=e.currentEvents,n,r,i=()=>(r??=new Set(t.map(q4)),r),a=e=>{n??=t.slice(),n.push(e),t=n};for(let o of e.streamEvents){let s=fje(o,e.piboSessionId,e.nextSequence,e.now??(()=>new Date().toISOString()));if(!s)continue;if(uje(s)){t=dje(t,s),n=t,r=void 0;continue}let c=q4(s),l=i();l.has(c)||(l.add(c),a(s))}return t}function uje(e){return e.type===`assistant_message`||e.type===`thinking_finished`||e.type===`tool_execution_finished`}function dje(e,t){return t.type===`assistant_message`?[...K4(e,t,`assistant_delta`),t]:t.type===`thinking_finished`?[...K4(e,t,`thinking_delta`),t]:t.type===`tool_execution_finished`?[...K4(e,t,`tool_execution_updated`),t]:e}function fje(e,t,n,r){if(e.type===`RAW_EVENT`&&X4(e.event)&&typeof e.event.type==`string`){let i=e.event;return G4(e,t,e.event.type,i,n,r)}if(e.type===`TEXT_MESSAGE_CONTENT`&&typeof e.delta==`string`)return G4(e,t,`assistant_delta`,{type:`assistant_delta`,piboSessionId:t,eventId:typeof e.runId==`string`?e.runId:void 0,...Y4(typeof e.messageId==`string`?e.messageId:void 0,`assistant`),text:e.delta},n,r);if(e.type===`REASONING_MESSAGE_CONTENT`&&typeof e.delta==`string`)return G4(e,t,`thinking_delta`,{type:`thinking_delta`,piboSessionId:t,eventId:typeof e.runId==`string`?e.runId:void 0,...Y4(typeof e.messageId==`string`?e.messageId:void 0,`thinking`),text:e.delta},n,r);if(e.type===`TOOL_CALL_START`&&typeof e.toolCallId==`string`&&typeof e.toolName==`string`)return G4(e,t,`tool_execution_started`,{type:`tool_execution_started`,piboSessionId:t,eventId:typeof e.runId==`string`?e.runId:void 0,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args},n,r);if(e.type===`TOOL_CALL_ARGS`&&typeof e.toolCallId==`string`&&typeof e.toolName==`string`){let i=typeof e.runId==`string`?e.runId:void 0,a=e.sourceEventType===`tool_execution_updated`?`tool_execution_updated`:`tool_call`;return G4(e,t,a,a===`tool_execution_updated`?{type:`tool_execution_updated`,piboSessionId:t,eventId:i,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,partialResult:e.partialResult}:{type:`tool_call`,piboSessionId:t,eventId:i,toolCallId:e.toolCallId,toolName:e.toolName,args:e.args,argsComplete:!!e.argsComplete},n,r)}if(e.type===`TOOL_CALL_RESULT`&&typeof e.toolCallId==`string`&&typeof e.toolName==`string`)return G4(e,t,`tool_execution_finished`,{type:`tool_execution_finished`,piboSessionId:t,eventId:typeof e.runId==`string`?e.runId:void 0,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:!!e.isError},n,r);if(e.type===`RUN_ERROR`&&typeof e.message==`string`)return G4(e,t,`session_error`,{type:`session_error`,piboSessionId:t,eventId:typeof e.runId==`string`?e.runId:void 0,error:e.message,errorDetails:e.errorDetails},n,r)}function G4(e,t,n,r,i,a){let o=typeof e.streamFrameId==`string`?e.streamFrameId:void 0,s=typeof e.streamFrameIndex==`number`?e.streamFrameIndex:void 0,c=typeof e.liveReplayId==`number`&&Number.isFinite(e.liveReplayId)?e.liveReplayId:void 0,l=i();return{id:typeof e.streamId==`number`?`stream:${e.streamId}:${s??`raw`}:${n}`:c===void 0?o?`stream:${o}:${n}`:`live:${l}:${n}`:`live-replay:${c}:${n}`,piboSessionId:t,eventSequence:l,streamId:typeof e.streamId==`number`?e.streamId:void 0,streamFrameIndex:s,eventId:typeof r.eventId==`string`?r.eventId:void 0,type:n,createdAt:a(),payload:r}}function K4(e,t,n){let r=J4(t);return e.filter(e=>e.type!==n||J4(e)!==r)}function q4(e){return e.streamId===void 0?`${e.id}:${e.type}`:e.streamFrameIndex===void 0?`stream:${e.streamId}:${e.id}:${e.type}`:`stream:${e.streamId}:${e.streamFrameIndex}:${e.type}`}function J4(e){let t=X4(e.payload)?e.payload:{},n=typeof t.piboSessionId==`string`?t.piboSessionId:e.piboSessionId??``,r=typeof t.eventId==`string`?t.eventId:e.eventId??``;if(typeof t.toolCallId==`string`)return`${n}:${r}:tool:${t.toolCallId}`;let i=typeof t.assistantIndex==`number`?t.assistantIndex:void 0,a=typeof t.thinkingIndex==`number`?t.thinkingIndex:void 0,o=typeof t.contentIndex==`number`?t.contentIndex:0;return`${n}:${r}:${i??a??o}`}function Y4(e,t){let n=e?.match(RegExp(`:${t}:(\\d+)$`));if(!n)return{};let r=Number(n[1]);return Number.isInteger(r)?t===`assistant`?{assistantIndex:r}:{thinkingIndex:r}:{}}function X4(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}var pje=500,mje=1e4,hje=45e3,gje=100;function _je({selectedPiboSessionId:e,tracePageData:t,currentTraceView:n,liveEventSeqRef:r,selectedSessionStatus:i,tracePageReady:a,setLiveTraceOverlay:o,onRefreshTrace:s,onRefreshBootstrap:c,onError:l}){let u=(0,R.useRef)(new Map),d=(0,R.useRef)(void 0),f=(0,R.useRef)(void 0),p=(0,R.useRef)(new Map),m=(0,R.useRef)(new Map),h=(0,R.useRef)(null),g=(0,R.useRef)(void 0),_=(0,R.useRef)(0),[v,y]=(0,R.useState)(0);(0,R.useEffect)(()=>{let n=t;if(!n||n.piboSessionId!==e)return;let i=n.rawEvents.map(e=>e.eventSequence??0).reduce((e,t)=>Math.max(e,t),0);r.current=Math.max(r.current,i+1),n.latestStreamId!==void 0&&Xc(m.current,n.piboSessionId,n.latestStreamId)},[r,e,t]);let b=(0,R.useCallback)(e=>{let t=u.current.get(e);t?.length&&(o(n=>{let i=lje({currentEvents:n?.piboSessionId===e?n.events:[],streamEvents:t,piboSessionId:e,nextSequence:()=>r.current++});return GU(e,t.length,i.length),{piboSessionId:e,events:i}}),u.current.delete(e))},[]),x=(0,R.useCallback)(()=>{if(!(d.current!==void 0||f.current!==void 0||!e)){if(document.hidden){f.current=setTimeout(()=>{f.current=void 0,b(e)},gje);return}d.current=requestAnimationFrame(()=>{d.current=void 0,b(e)})}},[b,e]),S=(0,R.useCallback)((t,n,r=!1)=>{nl(p.current,t,n);let i=r||rl(p.current,t,n),a=u.current.get(t)??[];a.push(n),u.current.set(t,a),WU(t,n,a.length,i),i||t!==e?b(t):x()},[b,x,e]);(0,R.useEffect)(()=>()=>{d.current!==void 0&&cancelAnimationFrame(d.current),f.current!==void 0&&clearTimeout(f.current),g.current!==void 0&&clearTimeout(g.current)},[]);let C=(0,R.useCallback)((e,t)=>{Zc(m.current,e,t)},[]),w=(0,R.useCallback)((e=0)=>{if(g.current!==void 0){if(e>0)return;clearTimeout(g.current)}g.current=setTimeout(()=>{g.current=void 0,y(e=>e+1)},e)},[]),T=(0,R.useCallback)(()=>{if(!e)return;b(e),s().catch(e=>l(Z4(e))),c().catch(e=>l(Z4(e)));let t=h.current;(!t||t.piboSessionId!==e||t.events.readyState===2||Date.now()-t.lastActivityAt>hje)&&w()},[b,l,c,s,w,e]);(0,R.useEffect)(()=>{if(!e||!a||!n||n.piboSessionId!==e)return;let t=new URLSearchParams({piboSessionId:e});t.set(`mode`,`live`);let r=m.current.get(e),i=r?.cursor??(n.latestStreamId===void 0?void 0:Qc(n.latestStreamId));i!==void 0&&t.set(`since`,i),r?.liveReplayId!==void 0&&t.set(`liveSince`,String(r.liveReplayId));let o=new EventSource(`/api/chat/events?${t.toString()}`),u=Date.now();h.current={piboSessionId:e,events:o,openedAt:u,lastActivityAt:u};let d=!1,f,p,v=!1,y=!1,x=(t,n=!1)=>{if(f){if(!n)return;clearTimeout(f)}JU(e,t),f=setTimeout(()=>{f=void 0,s().catch(e=>l(Z4(e)))},t)},T=()=>{if(v){y=!0;return}v=!0,c().catch(e=>l(Z4(e))).finally(()=>{v=!1,y&&(y=!1,E(250,!0))})},E=(e,t=!1)=>{if(p){if(!t)return;clearTimeout(p)}p=setTimeout(()=>{p=void 0,T()},e)},D=()=>{E(900,!0)};return o.onopen=()=>{_.current=0,g.current!==void 0&&(clearTimeout(g.current),g.current=void 0),VU(e,o.readyState);let t=h.current;t?.events===o&&(t.lastActivityAt=Date.now())},o.onerror=()=>{if(d)return;HU(e,o.readyState);let t=h.current;t?.events===o&&(t.lastErrorAt=Date.now());let n=_.current++;w(Math.min(mje,pje*2**n))},o.addEventListener(`pibo`,t=>{if(d)return;let n=Yc(t);if(!n)return;let r=n.piboSessionId||e,i=h.current;if(i?.events===o&&(i.lastActivityAt=Date.now()),C(r,n),UU(r,n,t.lastEventId,o.readyState),r===e&&n.type===`ready`&&n.liveReplay?.missed&&x(0,!0),QU(n))return;let a=n.type!==`TEXT_MESSAGE_CONTENT`&&n.type!==`REASONING_MESSAGE_CONTENT`;r===e&&tl(n)&&S(r,n,a);let s=$c(n);r===e&&s!==void 0?x(s,!0):r===e&&n.type!==`ready`&&n.type!==`RAW_EVENT`&&x(1500,!0),el(n)&&(n.type===`RUN_FINISHED`||n.type===`RUN_ERROR`||n.type===`TEXT_MESSAGE_END`?D():E(r===e?0:150))}),()=>{d=!0,f&&clearTimeout(f),p&&clearTimeout(p),b(e),h.current?.events===o&&(h.current=null),o.close()}},[n?.piboSessionId,S,b,l,c,s,C,w,v,e,a]),(0,R.useEffect)(()=>{n?.piboSessionId&&b(n.piboSessionId)},[n?.piboSessionId,b]),(0,R.useEffect)(()=>{let e=()=>T(),t=()=>{document.hidden||T()};return window.addEventListener(`focus`,e),window.addEventListener(`online`,e),window.addEventListener(`pageshow`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),window.removeEventListener(`online`,e),window.removeEventListener(`pageshow`,e),document.removeEventListener(`visibilitychange`,t)}},[T]),(0,R.useEffect)(()=>{if(!e||i!==`running`)return;let t=window.setInterval(()=>{b(e),s().catch(e=>l(Z4(e)))},1e3);return()=>window.clearInterval(t)},[b,l,s,e,i])}function Z4(e){return e instanceof Error?e.message:String(e)}var vje=10;function yje(e,t,n,r){if(!t||!n.length)return e;let i=e[t]??[],a=new Set(i.map(e=>e.path)),o=n.filter(e=>e.path&&!a.has(e.path)).map(e=>({...e,id:r()}));return o.length?{...e,[t]:[...i,...o].slice(0,vje)}:e}function bje(e,t,n){if(!t)return e;let r=e[t]??[],i=r.filter(e=>e.id!==n);return i.length===r.length?e:{...e,[t]:i}}function xje(e,t){return!t||!e[t]?.length?e:{...e,[t]:[]}}function Sje(e,t){let[n,r]=(0,R.useState)({});return{selectedUploadAttachments:(0,R.useMemo)(()=>e?n[e]??[]:[],[e,n]),attachUploadedFiles:(0,R.useCallback)(n=>{r(r=>yje(r,e,n,t))},[t,e]),detachUploadAttachment:(0,R.useCallback)(t=>{r(n=>bje(n,e,t))},[e]),clearSelectedUploadAttachments:(0,R.useCallback)(()=>{r(t=>xje(t,e))},[e])}}function Cje({selectedPiboSessionId:e,onError:t,formatError:n}){let[r,i]=(0,R.useState)([]),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(()=>e?O2(e):null),[l,u]=(0,R.useState)(()=>kke()),[d,f]=(0,R.useState)(!1),p=!!(e&&s?.piboSessionId===e&&s.installed),m=!!e&&(a||p),h=dn({queryKey:[`web-annotations`,`app`,e],queryFn:async()=>{if(!e)throw Error(`Session is required`);return xke(e,{limit:100,scope:`app`})},enabled:!!e&&(m||r.length>0),staleTime:1e3,refetchOnWindowFocus:m,refetchInterval:m?5e3:!1,retry:1}),g=h.refetch,_=(0,R.useMemo)(()=>(h.data?.annotations??[]).filter(e=>e.status!==`resolved`&&e.status!==`dismissed`),[h.data?.annotations]),v=(0,R.useMemo)(()=>r.map(e=>_.find(t=>t.id===e)).filter(e=>!!e),[r,_]);(0,R.useEffect)(()=>{i(e?Oke(e):[]),c(e?O2(e):null)},[e]),(0,R.useEffect)(()=>{if(!e)return;let t=t=>{!t||t.piboSessionId!==e||(c(e=>t.installed?t:e?.installed&&e.bindingId&&t.bindingId&&e.bindingId!==t.bindingId?e:t),t.installed?g():o(!1))},n=e=>t(j2(e.detail)),r=n=>{n.key===k2(e)&&t(A2(n.newValue))},i=()=>t(O2(e));return window.addEventListener(`pibo:web-annotation-overlay-state`,n),window.addEventListener(`storage`,r),window.addEventListener(`focus`,i),document.addEventListener(`visibilitychange`,i),i(),()=>{window.removeEventListener(`pibo:web-annotation-overlay-state`,n),window.removeEventListener(`storage`,r),window.removeEventListener(`focus`,i),document.removeEventListener(`visibilitychange`,i)}},[g,e]),(0,R.useEffect)(()=>{if(!h.data)return;if(!_.length){i(t=>(t.length&&e&&M2(e,[]),t.length?[]:t));return}let t=new Set(_.map(e=>e.id));i(n=>{let r=n.filter(e=>t.has(e));return r.length!==n.length&&e&&M2(e,r),r.length===n.length?n:r})},[e,_,h.data]),(0,R.useEffect)(()=>{let e=()=>{o(!0),g()};return window.addEventListener(`pibo:web-annotation-saved`,e),()=>window.removeEventListener(`pibo:web-annotation-saved`,e)},[g]);let y=(0,R.useCallback)(t=>{i(n=>{let r=t(n);return e&&M2(e,r),r})},[e]),b=(0,R.useCallback)(e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e].slice(0,5))},[y]),x=(0,R.useCallback)(()=>y(()=>[]),[y]);return{selectedWebAnnotationIds:r,selectedWebAnnotations:v,visibleWebAnnotations:_,webAnnotationsPanelCollapsed:l,webAnnotationsPanelRendered:m,webAnnotationsPanelVisible:a,webAnnotationsQuery:h,clearingWebAnnotations:d,setWebAnnotationsPanelVisible:o,toggleWebAnnotationAttachment:b,detachWebAnnotationAttachment:(0,R.useCallback)(e=>{y(t=>t.filter(t=>t!==e))},[y]),clearSelectedWebAnnotationAttachments:x,toggleWebAnnotationsPanelCollapsed:(0,R.useCallback)(()=>{u(e=>{let t=!e;return Ake(t),t})},[]),clearVisibleWebAnnotations:(0,R.useCallback)(async()=>{if(!(!_.length||d)&&window.confirm(`Dismiss ${_.length} visible web annotations? This keeps sent messages but clears the annotation list.`)){f(!0);try{await Promise.all(_.map(e=>Ske(e.id,{piboSessionId:e.piboSessionId,status:`dismissed`,summary:`Cleared from Chat Web UI`}))),x(),await g()}catch(e){t(n(e,`Could not clear web annotations`))}finally{f(!1)}}},[d,x,n,t,g,_])}}function Q4(e){return e.session?.profile??e.agents[0]?.name??e.customAgents[0]?.profileName??``}function wje(e){return e?.identity??{userId:`user`}}function $4(e,t){let n=Eje(e,t);return n?Tje(n):void 0}function e3(e,t){for(let n of e){if(n.piboSessionId===t)return n;let e=e3(n.children,t);if(e)return e}}function t3(e,t,n=[]){for(let r of e){let e=[...n,r];if(r.piboSessionId===t)return e;let i=t3(r.children,t,e);if(i.length)return i}return[]}function n3(){let e=globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2);return`web-${Date.now().toString(36)}-${e}`}function Tje(e){return`${e.provider}/${e.id}`}function Eje(e,t){if(t.activeModel)return t.activeModel;let n=e.agents.find(e=>e.name===t.profile);if(n?.model)return n.model;let r=e.customAgents.find(e=>e.profileName===t.profile),i=n??r;return t.parentId?i?.subagentModel??e.modelDefaults?.subagent:i?.mainModel??e.modelDefaults?.main}function Dje(e,t){return t?{sessionBreadcrumbs:Mje(e,t),originSession:Aje(e,t),derivedSessions:jje(e,t)}:{sessionBreadcrumbs:[],originSession:void 0,derivedSessions:[]}}function Oje(e){let t=e.selectedPiboSessionId?e3(e.bootstrap.sessions,e.selectedPiboSessionId):void 0,n=Ije(e.currentTraceView);return Fje(e.selectedSessionActiveModel,e.bootstrap.runtimeStatus?.thinkingLevel??n.level??Nje(e.bootstrap,e.selectedSessionProfile,!!t?.parentId),e.bootstrap.runtimeStatus?.fastMode??n.fast??Pje(e.bootstrap,e.selectedSessionProfile,!!t?.parentId)??!1)}function kje(e){return{traceView:e.currentTraceView,selectedTrace:null,isLoading:e.isLoading,showThinking:e.showThinking,expandThinking:e.expandThinking,sessionAgentProfile:e.selectedSessionProfile,sessionActiveModel:e.sessionActiveModelBadge,selectedSessionStatus:e.selectedSessionStatus,selectedSessionSignal:e.selectedSessionSignal,workflowProjectSession:e.workflowProjectSession,workflowLifecycleEvents:e.workflowLifecycleEvents,sessionNodes:e.sessionNodes,sessionBreadcrumbs:e.sessionLinks.sessionBreadcrumbs,originSession:e.sessionLinks.originSession,derivedSessions:e.sessionLinks.derivedSessions,agentProfiles:e.agentProfiles,sessionProfileChangeDisabled:e.sessionProfileChangeDisabled,onSessionAgentProfileChange:e.onSessionAgentProfileChange,onFork:e.onFork,onOpenSession:e.onOpenSession,onThinkingLevelChange:e.onThinkingLevelChange,onModelChanged:async()=>{await e.onRefreshBootstrap(),await e.onRefreshTrace()},onRefreshBootstrap:e.onRefreshBootstrap,onError:e.onError}}function Aje(e,t){let n=e3(e,t);if(!n?.originId)return;let r=e3(e,n.originId);return{piboSessionId:n.originId,label:r?i3(r,0):n.originId}}function jje(e,t){return e3(e,t)?.derivedSessions.map(e=>({piboSessionId:e.piboSessionId,label:Rje(e),profile:e.profile,status:e.status}))??[]}function Mje(e,t){return t3(e,t).map((e,t)=>({piboSessionId:e.piboSessionId,label:i3(e,t)}))}function Nje(e,t,n=!1){let r=e.agents.find(e=>e.name===t),i=e.customAgents.find(e=>e.profileName===t),a=r??i;return n?a?.subagentThinkingLevel??a?.thinkingLevel??e.modelDefaults?.subagentThinking??e.modelDefaults?.thinking:a?.mainThinkingLevel??a?.thinkingLevel??e.modelDefaults?.mainThinking??e.modelDefaults?.thinking}function Pje(e,t,n=!1){let r=e.agents.find(e=>e.name===t),i=e.customAgents.find(e=>e.profileName===t),a=r??i;return n?a?.subagentFast??a?.fast??e.modelDefaults?.subagentFast??e.modelDefaults?.fast:a?.mainFast??a?.fast??e.modelDefaults?.mainFast??e.modelDefaults?.fast}function Fje(e,t,n){if(e)return[e,t,n?`fast`:void 0].filter(Boolean).join(` `)}function Ije(e){let t={};if(!e)return t;for(let n of r3(e.nodes)){if(n.type!==`execution.command`||n.title!==`thinking`&&n.title!==`fast_mode`)continue;let e=n.output&&typeof n.output==`object`?n.output:void 0;t={level:(typeof e?.level==`string`&&Lje(e.level)?e.level:void 0)??t.level,fast:n.title===`fast_mode`?e?.mode===`fast`:t.fast}}return t}function r3(e){return e.flatMap(e=>[e,...r3(e.children)])}function Lje(e){return Zq.includes(e)}function i3(e,t){return t?e.subagentName&&e.subagentName!==e.profile?`${e.subagentName} (${e.profile})`:e.profile||e.subagentName||e.title:e.profile||e.title}function Rje(e){return e.subagentName&&e.subagentName!==e.profile?`${e.subagentName} (${e.profile})`:e.title||e.profile||e.subagentName||`Untitled Session`}function zje({piboSessionId:e,text:t,selectedWebAnnotations:n,selectedUploadAttachments:r,eventSequence:i,now:a,clientTxnId:o}){let s=n.map(e=>e.id),c=r.map(e=>e.path);return{text:t,webAnnotationIds:s,fileAttachmentPaths:c,clientTxnId:o,optimisticEvent:{id:o,piboSessionId:e,eventSequence:i,eventId:o,type:`message_queued`,createdAt:a,payload:{type:`message_queued`,piboSessionId:e,eventId:o,clientTxnId:o,queuedMessages:1,text:t,...c.length?{fileAttachmentPaths:c}:{},source:`user`}}}}function Bje(e,t,n){return{piboSessionId:t,events:[...e?.piboSessionId===t?e.events:[],n]}}function a3(e){return e instanceof Error?e.message:String(e)}function o3({bootstrap:e,selectedPiboSessionId:t,selectedRoomId:n,selectedRoomArchived:r,selectedSessionProfile:i,selectedSessionActiveModel:a,selectedSessionStatus:o,selectedSessionSignal:s,workflowProjectSession:c,workflowLifecycleEvents:l,projectSessionCreatePanel:u,workflowStartPanel:d,sessionViewId:f,sessionViews:p,currentSessionView:m,allowedSessionViewIds:h,creatingSession:g,showRawEvents:_,showThinking:v,expandThinking:y,commands:b,skills:x,composerText:S,composerFocusSignal:C,onComposerTextChange:w,onToggleRawEvents:T,onToggleThinking:E,onToggleExpandThinking:D,onSessionAgentProfileChange:O,onFork:k,onOpenSession:A,onSelectSessionView:j,onCommand:M,onThinkingLevelChange:N,onRefreshTrace:P,onRefreshBootstrap:F,onSend:ee,onError:te}){let I=(0,R.useRef)(0),[ne,L]=(0,R.useState)(null),{baseTraceView:re,traceEventLimit:ie,rawEventLimit:ae,traceSummaryQuery:oe,tracePageQuery:se,tracePageReady:ce,loadOlderTracePage:le,loadMoreRawEvents:ue}=cje({selectedPiboSessionId:t,showRawEvents:_,setLiveTraceOverlay:L}),{selectedWebAnnotationIds:de,selectedWebAnnotations:fe,visibleWebAnnotations:pe,webAnnotationsPanelCollapsed:me,webAnnotationsPanelRendered:he,webAnnotationsPanelVisible:ge,webAnnotationsQuery:_e,clearingWebAnnotations:ve,setWebAnnotationsPanelVisible:ye,toggleWebAnnotationAttachment:be,detachWebAnnotationAttachment:xe,clearSelectedWebAnnotationAttachments:Se,toggleWebAnnotationsPanelCollapsed:Ce,clearVisibleWebAnnotations:we}=Cje({selectedPiboSessionId:t,onError:te,formatError:P2}),{selectedUploadAttachments:Te,attachUploadedFiles:Ee,detachUploadAttachment:De,clearSelectedUploadAttachments:Oe}=Sje(t,(0,R.useCallback)(()=>`upload-${n3()}`,[])),ke=$Ae({selectedPiboSessionId:t,baseTraceView:re,liveTraceOverlay:ne,selectedSessionStatus:o});_je({selectedPiboSessionId:t,tracePageData:se.data,currentTraceView:ke,liveEventSeqRef:I,selectedSessionStatus:o,tracePageReady:ce,setLiveTraceOverlay:L,onRefreshTrace:P,onRefreshBootstrap:F,onError:te});let Ae=Oje({bootstrap:e,selectedPiboSessionId:t,selectedSessionProfile:i,selectedSessionActiveModel:a,currentTraceView:ke}),je=(0,R.useMemo)(()=>Dje(e.sessions,t),[e.sessions,t]),Me=!!t&&se.isFetching&&!ke,Ne=se.error?a3(se.error):oe.error?a3(oe.error):null,Pe=ke?.piboSessionId??t??``,Fe=c&&z2(c)?Gke(c,o):null,Ie=async e=>{if(!t)return;let n=zje({piboSessionId:t,text:e,selectedWebAnnotations:fe,selectedUploadAttachments:Te,eventSequence:I.current++,now:new Date().toISOString(),clientTxnId:n3()});L(e=>Bje(e,t,n.optimisticEvent)),await ee(n.text,n.webAnnotationIds,n.fileAttachmentPaths,n.clientTxnId),Se(),Oe(),await Promise.all([se.refetch(),_e.refetch()])},Le=kje({currentTraceView:ke,isLoading:Me,showThinking:v,expandThinking:y,selectedSessionProfile:i,sessionActiveModelBadge:Ae,selectedSessionStatus:o,selectedSessionSignal:s,workflowProjectSession:c,workflowLifecycleEvents:l,sessionNodes:e.sessions,sessionLinks:je,agentProfiles:e.agents,sessionProfileChangeDisabled:g||r,onSessionAgentProfileChange:O,onFork:k,onOpenSession:A,onThinkingLevelChange:N,onRefreshTrace:P,onRefreshBootstrap:F,onError:te});return(0,z.jsx)($ke,{selectedPiboSessionId:t,selectedRoomId:n,fallbackRoomId:e.selectedRoomId??void 0,sessionViewId:f,loadingTrace:Me,traceError:Ne,showRawEvents:_,currentTraceView:ke,traceEventLimit:ie,rawEventLimit:ae,tracePageFetching:se.isFetching,onLoadOlderTracePage:e=>void le(e),onLoadMoreRawEvents:ue,headerProps:{title:ke?.title??t??e.room?.name??n,roomLabel:e.room?.name??n??`Room`,headerPiboSessionId:Pe,piboSessionId:t,piboRoomId:n??e.selectedRoomId??void 0,webAnnotationsDisabled:!t||r,webAnnotationsPanelRendered:he,workflowHeader:Fe,sessionViewId:f,sessionViews:p,currentSessionView:m,allowedSessionViewIds:h,showRawEvents:_,showThinking:v,expandThinking:y,onShowWebAnnotationsPanel:()=>ye(!0),onHideWebAnnotationsPanel:()=>ye(!1),onSelectSessionView:j,onToggleRawEvents:T,onToggleThinking:E,onToggleExpandThinking:D,onError:te},projectSessionCreatePanel:u,workflowStartPanel:d,currentSessionView:m,sessionViewProps:Le,webAnnotationsPanelRendered:he,webAnnotationsPanelProps:{piboSessionId:t,annotations:pe,selectedIds:de,loading:_e.isLoading||_e.isFetching||ve,error:_e.error?a3(_e.error):null,collapsed:me,onRefresh:()=>void _e.refetch(),onToggle:be,onClear:()=>void we(),onCollapse:Ce,onClose:()=>ye(!1)},composerProps:{sessionId:t,disabled:!t||r,commands:b,skills:x,value:S,focusSignal:C,selectedWebAnnotations:fe,selectedUploadAttachments:Te,onValueChange:w,onCommand:M,onDetachWebAnnotation:xe,onClearWebAnnotations:Se,onAttachUploadedFiles:Ee,onDetachUploadAttachment:De,onClearUploadAttachments:Oe,onSend:Ie}})}var s3=3e3;function Vje(e){return`${e.name||`Untitled Room`}\n${e.id}`}function Hje(e){return`${c3(e)}\n${e.piboSessionId}`}function c3(e){return typeof e.title==`string`&&e.title?e.title:`Untitled Session`}function Uje(e,t){let n=`session-signal h-2 w-2 rounded-full`;return e.status===`error`?{className:`${n} session-signal-error`,title:(e.unreadCount??0)>0?`Run failed`:`Run failed (read)`}:e.status===`running`?{className:`${n} session-signal-running`,title:`Runtime is working`}:(e.unreadCount??0)>0||Wje(e,t)?{className:`${n} session-signal-unread`,title:`New completed assistant message`}:{className:`${n} session-signal-idle`,title:`Idle`}}function Wje(e,t){if(!e.lastActivityAt)return!1;let n=Date.parse(e.lastActivityAt);return Number.isFinite(n)&&t-n<s3}function Gje(e,t){let n,r=e=>{if(e.status!==`running`&&e.status!==`error`&&(e.unreadCount??0)===0&&e.lastActivityAt){let r=Date.parse(e.lastActivityAt);if(Number.isFinite(r)){let e=s3-(t-r);e>0&&(n=n===void 0?e:Math.min(n,e))}}for(let t of e.children)r(t)};for(let t of e)r(t);return n===void 0?void 0:n+50}function l3(e,t){return e.some(e=>e.piboSessionId===t||l3(e.children,t))}function u3(e,t=!0){let n=[],r=[];for(let i of e){if(i.archived){t&&r.push(i);continue}let e=u3(i.children,t);n.push({...i,children:e.active}),t&&r.push(...e.archived)}return{active:n,archived:r}}function Kje(e,t,n){if(e.length<=t)return e;let r=e.slice(0,t);if(!n)return r;let i=e.find(e=>e.piboSessionId===n||l3(e.children,n));return!i||r.some(e=>e.piboSessionId===i.piboSessionId)?r:[...r,i]}function d3(e){for(let t of e){if(m3(t))return t;let e=d3(t.children??[]);if(e)return e}}function f3(e,t){for(let n of e){if(n.id===t)return n;let e=f3(n.children??[],t);if(e)return e}}function qje(e){return e.reduce((e,t)=>e+(t.unreadCount??0),0)}function p3(e){let t=[],n=[];for(let r of e){if(m3(r)){let e=p3(r.children??[]);t.push(...e.active),n.push(...e.archived);continue}if(h3(r)){n.push(r);continue}let e=p3(r.children??[]);t.push({...r,children:e.active}),n.push(...e.archived)}return{active:t,archived:n}}function m3(e){return e.metadata.default===!0}function h3(e){return typeof e.metadata.chatRoomArchivedAt==`string`}function Jje(e){return e.topic&&e.workspace?`${e.topic} | ${e.workspace}`:e.topic?e.topic:e.workspace?e.workspace:e.type}function g3({node:e,signalNow:t,selectedPiboSessionId:n,selectedSessionPathIds:r,onSelect:i,onRename:a,onArchive:o,onDelete:s,onViewContext:c,depth:l=0,loadingPiboSessionId:u,autoRename:d=!1,onAutoRenameConsumed:f,showWorkflowSessionKindMarkers:p=!1}){let m=c3(e),h=Hje(e),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(m),b=(0,R.useRef)(null),x=e.children.length>0,S=n!==null&&e.piboSessionId!==n&&r.has(e.piboSessionId),[C,w]=(0,R.useState)(S),[T,E]=(0,R.useState)(!1),D=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!T)return;let e=e=>{D.current&&!D.current.contains(e.target)&&E(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[T]),(0,R.useEffect)(()=>{g||y(m)},[g,m]),(0,R.useEffect)(()=>{d&&(y(m===`Untitled Session`?``:m),_(!0),f?.())},[d,m,f]),(0,R.useLayoutEffect)(()=>{g&&(b.current?.focus(),b.current?.select())},[g]),(0,R.useEffect)(()=>{S&&w(!0)},[S]);let O=()=>{let t=v.trim();a(e.piboSessionId,t||null),_(!1)},k=Uje(e,t),A=u===e.piboSessionId,j=p?Yje(e.workflowSessionKind):null,M=j?.Icon;return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{"data-pibo-component":`SessionNode`,"data-pibo-debug":`session-row`,"data-pibo-session-id":e.piboSessionId,"data-pibo-title":m,"data-pibo-selected":e.piboSessionId===n?`true`:`false`,"data-pibo-state":A?`loading`:e.status??`idle`,"data-pibo-archived":e.archived?`true`:`false`,"data-pibo-unread-count":e.unreadCount??0,className:`group w-full grid grid-cols-[1fr_auto] gap-1 items-center mb-1 border rounded-sm ${e.piboSessionId===n?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-transparent`}`,style:{paddingLeft:8+l*14},title:h,children:[g?(0,z.jsxs)(`form`,{className:`min-w-0 grid grid-cols-[1fr_auto_auto] gap-1 py-1 pr-1`,onSubmit:e=>{e.preventDefault(),O()},children:[(0,z.jsx)(`input`,{ref:b,value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),_(!1),y(m))},autoFocus:!0,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`button`,{type:`submit`,title:`Save Session Title`,"aria-label":`Save Session Title`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ro,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{_(!1),y(m)},title:`Cancel Rename`,"aria-label":`Cancel Rename`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qs,{size:13})})]}):(0,z.jsxs)(`div`,{className:`min-w-0 grid grid-cols-[1fr_auto] gap-2 items-center py-1 pr-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>{if(x&&e.piboSessionId===n){w(e=>!e);return}i(e.piboSessionId)},"aria-label":j?`${j.ariaLabel}: ${m}`:`Open session ${m}`,className:`min-w-0 text-left px-1 py-1 grid grid-cols-[minmax(0,1fr)_auto] gap-2 items-center`,children:(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[j&&M?(0,z.jsx)(`span`,{className:`h-4 w-4 shrink-0 inline-flex items-center justify-center rounded-sm border ${j.className}`,title:j.ariaLabel,"aria-label":j.ariaLabel,children:(0,z.jsx)(M,{size:11,"aria-hidden":`true`})}):null,(0,z.jsx)(`span`,{className:`block min-w-0 truncate text-sm ${e.archived?`text-slate-500`:`text-slate-200`}`,children:m})]}),(0,z.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5`,children:[j?(0,z.jsx)(`span`,{className:`shrink-0 rounded-sm border px-1 py-0.5 text-[9px] font-bold uppercase tracking-wide ${j.className}`,title:j.ariaLabel,children:j.label}):null,(0,z.jsx)(`span`,{className:`min-w-0 truncate font-mono text-[10px] text-slate-500`,children:e.piboSessionId})]})]})}),(0,z.jsxs)(`span`,{className:`grid grid-rows-[16px_16px] place-items-center gap-0.5`,children:[A?(0,z.jsx)(Cs,{size:13,className:`text-[#11a4d4] animate-spin`,"aria-label":`Loading session`}):(0,z.jsx)(`span`,{className:k.className,title:k.title,"aria-label":k.title}),x?(0,z.jsx)(`button`,{type:`button`,onClick:()=>w(e=>!e),"aria-expanded":C,title:C?`Collapse Subsessions`:`Expand Subsessions`,"aria-label":C?`Collapse Subsessions`:`Expand Subsessions`,className:`h-4 w-4 inline-flex items-center justify-center rounded-sm transition-colors ${C?`text-[#0bda57]`:`text-slate-600 hover:text-[#11a4d4]`}`,children:(0,z.jsx)(vs,{size:13})}):(0,z.jsx)(`span`,{className:`h-4 w-4`})]})]}),g?null:(0,z.jsx)(`div`,{className:`flex items-center gap-1 pr-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity max-[980px]:opacity-100`,children:(0,z.jsxs)(`div`,{className:`relative`,ref:D,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>E(e=>!e),title:`Session actions`,"aria-label":`Session actions`,className:`h-7 w-7 max-[980px]:h-9 max-[980px]:w-9 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(ns,{size:24,className:`w-3.5 h-3.5 max-[980px]:w-5 max-[980px]:h-5`})}),T&&(0,z.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-48 bg-[#1a262b] border border-slate-700 rounded-sm shadow-lg py-1`,children:e.archived?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),o(e.piboSessionId,!1)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(wo,{size:16}),` Restore Session`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),c(e.piboSessionId)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Fo,{size:16}),` View Context`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),s(e)},className:`w-full text-left px-3 py-2.5 text-sm text-red-300 hover:bg-red-500/10 flex items-center gap-2`,children:[(0,z.jsx)(qs,{size:16}),` Delete Session`]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),_(!0)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Ms,{size:16}),` Rename Session`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),o(e.piboSessionId,!0)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(To,{size:16}),` Archive Session`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{E(!1),c(e.piboSessionId)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Fo,{size:16}),` View Context`]})]})})]})})]}),C?e.children.map(e=>(0,z.jsx)(g3,{node:e,signalNow:t,selectedPiboSessionId:n,selectedSessionPathIds:r,onSelect:i,onRename:a,onArchive:o,onDelete:s,onViewContext:c,depth:l+1,loadingPiboSessionId:u,showWorkflowSessionKindMarkers:p},e.piboSessionId)):null]})}function Yje(e){switch(e){case`main_workflow`:return{label:`main workflow`,ariaLabel:`Main workflow session`,className:`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-[#11a4d4]`,Icon:vs};case`nested_workflow`:return{label:`nested workflow`,ariaLabel:`Nested workflow session`,className:`border-violet-400/40 bg-violet-500/10 text-violet-300`,Icon:$o};case`agent_node`:return{label:`agent node`,ariaLabel:`Workflow agent node session`,className:`border-emerald-400/40 bg-emerald-500/10 text-emerald-300`,Icon:Ys};case`subagent`:return{label:`subagent`,ariaLabel:`Subagent session`,className:`border-amber-400/40 bg-amber-500/10 text-amber-300`,Icon:Xs};default:return null}}var Xje=`240px 0px`,_3=192,v3=4,y3=8;function Zje(e){return e>99?`99+`:String(e)}function Qje({count:e}){return!e||e<=0?null:(0,z.jsx)(`span`,{className:`min-w-5 h-5 px-1.5 inline-flex items-center justify-center rounded-full bg-[#38bdf8] text-[#0e1116] text-[10px] font-bold tabular-nums leading-none`,"aria-label":`${e} unread messages`,title:`${e} unread messages`,children:Zje(e)})}function $je({bootstrap:e,selectedRoomId:t,selectedPiboSessionId:n,showArchivedRooms:r,onToggleArchivedRooms:i,creatingRoom:a,onCreateRoom:o,onSelectRoom:s,onUpdateRoom:c,onArchiveRoom:l,onReadAllRoom:u,onDeleteRoom:d,newSessionProfile:f,onNewSessionProfileChange:p,selectedRoomArchived:m,creatingSession:h,onCreateSession:g,showArchived:_,onToggleArchivedSessions:v,loadingArchivedSessions:y,visibleActiveSessions:b,visibleArchivedSessions:x,totalActiveSessionCount:S,totalArchivedSessionCount:C,hasMoreActiveSessions:w,hasMoreArchivedSessions:T,loadingActiveSessions:E,sessionListScrollRef:D,onLoadMoreSessions:O,signalNow:k,selectedSessionPathIds:A,onSelectSession:j,onRenameSession:M,onArchiveSession:N,onDeleteSession:P,onViewContext:F,loadingPiboSessionId:ee,autoRenameSessionId:te,onAutoRenameConsumed:I}){let ne=!!(e.selectedRoomId||e.room||e.rooms.length),L=e.agents,re=d3(e.rooms),ie=p3(e.rooms);return(0,z.jsxs)(`div`,{"data-pibo-debug":`session-list`,"data-pibo-room-id":t??e.selectedRoomId??void 0,"data-pibo-selected-session-id":n??void 0,"data-pibo-state":_?`archived-visible`:`active-only`,className:`min-h-0 flex-1 overflow-hidden p-2 flex flex-col gap-3`,children:[ne?(0,z.jsxs)(z.Fragment,{children:[re?(0,z.jsxs)(`div`,{className:`shrink-0`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Shared Chat`}),(0,z.jsx)(x3,{room:re,selectedRoomId:t,onSelect:e=>void s(e),onUpdate:(e,t)=>void c(e,t),onArchive:(e,t)=>void l(e,t),onReadAll:e=>void u(e),onDelete:d})]}):null,(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 basis-0 overflow-hidden flex flex-col`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-2 px-1 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Rooms`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>void o(),disabled:a,title:`New Room`,"aria-label":`New Room`,className:`h-6 w-6 max-[980px]:h-8 max-[980px]:w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:i,title:r?`Hide Archived Rooms`:`Show Archived Rooms`,"aria-label":r?`Hide Archived Rooms`:`Show Archived Rooms`,className:`h-6 w-6 max-[980px]:h-8 max-[980px]:w-8 inline-flex items-center justify-center border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${r?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:r?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})})]})]}),(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[ie.active.map(e=>(0,z.jsx)(x3,{room:e,selectedRoomId:t,onSelect:e=>void s(e),onUpdate:(e,t)=>void c(e,t),onArchive:(e,t)=>void l(e,t),onReadAll:e=>void u(e),onDelete:d},e.id)),ie.active.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No rooms`}):null,r?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Archived Rooms`}),ie.archived.length?(0,z.jsx)(eMe,{rooms:ie.archived,selectedRoomId:t,onSelect:e=>void s(e),onUpdate:(e,t)=>void c(e,t),onArchive:(e,t)=>void l(e,t),onReadAll:e=>void u(e),onDelete:d}):(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No archived rooms`})]}):null]})]})]}):null,(0,z.jsxs)(`div`,{className:`min-h-0 flex-1 basis-0 overflow-hidden flex flex-col border-t border-slate-700/80 pt-3`,children:[(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-2 px-1 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Sessions`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`select`,{value:f,onChange:e=>p(e.target.value),disabled:!L.length||m,title:`Agent for new sessions`,"aria-label":`Agent for new sessions`,className:`h-6 w-28 max-[980px]:h-8 max-[980px]:w-32 max-[980px]:text-sm rounded-sm border border-slate-700 bg-[#101d22] px-1.5 text-[11px] font-medium normal-case tracking-normal text-slate-300 outline-none hover:border-[#11a4d4] focus:border-[#11a4d4] disabled:opacity-50`,children:L.map(e=>(0,z.jsx)(`option`,{value:e.name,title:e.description??e.name,children:e.name},e.name))}),(0,z.jsx)(`button`,{"data-pibo-debug":`new-session-button`,"data-pibo-room-id":t??e.selectedRoomId??void 0,"data-pibo-state":h?`creating`:m?`archived-disabled`:`ready`,type:`button`,onClick:()=>void g(),disabled:h||m,title:`New Session`,"aria-label":`New Session`,className:`h-6 w-6 max-[980px]:h-8 max-[980px]:w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void v(),disabled:y,title:_?`Hide Archived Sessions`:`Show Archived Sessions`,"aria-label":_?`Hide Archived Sessions`:`Show Archived Sessions`,className:`h-6 w-6 max-[980px]:h-8 max-[980px]:w-8 inline-flex items-center justify-center border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-70 ${_?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:y?(0,z.jsx)(Cs,{size:14,className:`animate-spin`}):_?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})})]})]}),(0,z.jsxs)(`div`,{ref:D,className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[b.map(e=>(0,z.jsx)(g3,{node:e,signalNow:k,selectedPiboSessionId:n,selectedSessionPathIds:A,onSelect:e=>void j(e),onRename:(e,t)=>void M(e,t),onArchive:(e,t)=>void N(e,t),onDelete:P,onViewContext:F,loadingPiboSessionId:ee,autoRename:te===e.piboSessionId,onAutoRenameConsumed:()=>I()},e.piboSessionId)),S===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No active sessions`}):null,w?(0,z.jsx)(b3,{debugName:`active-session-load-more`,loading:E,rootRef:D,onLoadMore:()=>O(!1),children:E?`Loading active sessions…`:`Load more active sessions (${b.length} of ${S})`}):null,_?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500 flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{children:`Archived Sessions`}),y?(0,z.jsx)(Cs,{size:12,className:`text-[#11a4d4] animate-spin`,"aria-label":`Loading archived sessions`}):null]}),y?(0,z.jsxs)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm flex items-center gap-2`,children:[(0,z.jsx)(Cs,{size:13,className:`text-[#11a4d4] animate-spin`}),` Loading archived sessions`]}):C?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(tMe,{sessions:x,signalNow:k,selectedPiboSessionId:n,selectedSessionPathIds:A,onSelect:e=>void j(e),onRename:(e,t)=>void M(e,t),onArchive:(e,t)=>void N(e,t),onDelete:P,onViewContext:F,loadingPiboSessionId:ee,autoRenameSessionId:te,onAutoRenameConsumed:()=>I()}),T?(0,z.jsx)(b3,{debugName:`archived-session-load-more`,loading:y,rootRef:D,onLoadMore:()=>O(!0),children:y?`Loading archived sessions…`:`Load more archived sessions (${x.length} of ${C})`}):null]}):(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No archived sessions`})]}):null]})]})]})}function eMe({rooms:e,selectedRoomId:t,onSelect:n,onUpdate:r,onArchive:i,onReadAll:a,onDelete:o}){return(0,z.jsx)(`div`,{children:e.map(e=>(0,z.jsx)(x3,{room:e,selectedRoomId:t,onSelect:n,onUpdate:r,onArchive:i,onReadAll:a,onDelete:o},e.id))})}function b3({children:e,debugName:t,loading:n,rootRef:r,onLoadMore:i}){let a=(0,R.useRef)(null),o=(0,R.useRef)(i),s=(0,R.useRef)(!1);(0,R.useEffect)(()=>{o.current=i},[i]),(0,R.useEffect)(()=>{n||(s.current=!1)},[n]);let c=(0,R.useCallback)(()=>{s.current||n||(s.current=!0,Promise.resolve(o.current()).finally(()=>{s.current=!1}))},[n]);return(0,R.useEffect)(()=>{if(n||typeof IntersectionObserver>`u`)return;let e=a.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&c()},{root:r.current,rootMargin:Xje,threshold:0});return t.observe(e),()=>t.disconnect()},[n,r,c]),(0,z.jsx)(`button`,{ref:a,"data-pibo-debug":t,type:`button`,onClick:c,disabled:n,className:`mt-2 w-full px-2 py-2 text-[11px] text-slate-400 border border-dashed border-slate-700 rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-60`,children:e})}function tMe({sessions:e,signalNow:t,selectedPiboSessionId:n,selectedSessionPathIds:r,onSelect:i,onRename:a,onArchive:o,onDelete:s,onViewContext:c,loadingPiboSessionId:l,autoRenameSessionId:u,onAutoRenameConsumed:d}){return(0,z.jsx)(`div`,{children:e.map(e=>(0,z.jsx)(g3,{node:e,signalNow:t,selectedPiboSessionId:n,selectedSessionPathIds:r,onSelect:i,onRename:a,onArchive:o,onDelete:s,onViewContext:c,loadingPiboSessionId:l,autoRename:u===e.piboSessionId,onAutoRenameConsumed:d},e.piboSessionId))})}function x3({room:e,selectedRoomId:t,onSelect:n,onUpdate:r,onArchive:i,onReadAll:a,onDelete:o,depth:s=0}){let[c,l]=(0,R.useState)(!1),[u,d]=(0,R.useState)(e.name),[f,p]=(0,R.useState)(e.topic??``),[m,h]=(0,R.useState)(e.workspace??``),g=m3(e),_=h3(e),[v,y]=(0,R.useState)(!1),[b,x]=(0,R.useState)(null),S=(0,R.useRef)(null),C=(0,R.useRef)(null),w=Vje(e),T=()=>{d2(e.id).catch(()=>void 0)},E=(0,R.useCallback)(()=>{let e=S.current;if(!e)return;let t=e.getBoundingClientRect(),n=C.current?.offsetWidth??_3,r=_?144:192,i=C.current?.offsetHeight??r,a=Math.max(y3,window.innerWidth-n-y3),o=Math.min(Math.max(y3,t.right-n),a),s=t.bottom+v3,c=s+i<=window.innerHeight-y3?s:Math.max(y3,t.top-v3-i);x(e=>e?.top===c&&e.left===o?e:{top:c,left:o})},[_]);(0,R.useEffect)(()=>{if(!v){x(null);return}E();let e=()=>E();return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[v,E]),(0,R.useLayoutEffect)(()=>{v&&b&&E()},[v,b,E]),(0,R.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;S.current?.contains(t)||C.current?.contains(t)||y(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[v]),(0,R.useEffect)(()=>{c||(d(e.name),p(e.topic??``),h(e.workspace??``))},[c,e.name,e.topic,e.workspace]);let D=()=>{let t=u.trim();t&&(r(e.id,{name:t,topic:f.trim()||null,workspace:m.trim()||null}),l(!1))};return(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`group mb-1 border rounded-sm ${g?e.id===t?`border-[#0bda57] bg-[#0bda57]/10`:`border-[#0bda57]/50 bg-[#0bda57]/5`:e.id===t?`border-[#11a4d4] bg-[#11a4d4]/10`:_?`border-[#f59e0b]/40 bg-[#f59e0b]/5`:`border-transparent`}`,style:{marginLeft:s*12},title:w,children:c&&!g?(0,z.jsxs)(`form`,{className:`grid gap-1 p-1`,onSubmit:e=>{e.preventDefault(),D()},children:[(0,z.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4]`,autoFocus:!0}),(0,z.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`Topic`,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-xs outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`Workspace (/absolute/path)`,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-xs font-mono outline-none focus:border-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,z.jsx)(`button`,{type:`submit`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ro,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qs,{size:13})})]})]}):(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center gap-1 py-1 pr-1`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),className:`min-w-0 text-left px-2 py-1 grid grid-cols-[auto_minmax(0,1fr)_auto] gap-2 items-center`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 inline-flex items-center justify-center rounded-sm ${g?`bg-[#0bda57]/15 text-[#0bda57]`:_?`bg-[#f59e0b]/15 text-[#f59e0b]`:`bg-[#151f24] text-slate-500`}`,children:g?(0,z.jsx)(Ts,{size:13}):_?(0,z.jsx)(To,{size:13}):(0,z.jsx)(ls,{size:13})}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block text-sm truncate ${_?`text-slate-500`:`text-slate-200`}`,children:e.name}),(0,z.jsx)(`span`,{className:`block text-[10px] font-mono truncate text-slate-500`,children:g?`shared default room`:_?`archived`:Jje(e)})]}),(0,z.jsx)(Qje,{count:e.unreadCount})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-1 pr-1 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity max-[980px]:opacity-100`,children:g?(0,z.jsx)(`span`,{title:`Shared Chat is locked`,"aria-label":`Shared Chat is locked`,className:`h-7 w-7 max-[980px]:h-9 max-[980px]:w-9 inline-flex items-center justify-center border border-[#0bda57]/50 rounded-sm text-[#0bda57]`,children:(0,z.jsx)(Ts,{size:24,className:`w-3.5 h-3.5 max-[980px]:w-5 max-[980px]:h-5`})}):(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`button`,{ref:S,type:`button`,onClick:()=>y(e=>!e),title:`Room actions`,"aria-label":`Room actions`,className:`h-7 w-7 max-[980px]:h-9 max-[980px]:w-9 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(ns,{size:24,className:`w-3.5 h-3.5 max-[980px]:w-5 max-[980px]:h-5`})}),v&&b?(0,Na.createPortal)((0,z.jsx)(`div`,{ref:C,className:`fixed z-[1000] bg-[#1a262b] border border-slate-700 rounded-sm shadow-lg py-1`,style:{top:b.top,left:b.left,width:_3},children:_?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{T(),y(!1)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)($o,{size:16}),` Copy Room ID`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{y(!1),i(e.id,!1)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(wo,{size:16}),` Restore Room`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{y(!1),o(e)},className:`w-full text-left px-3 py-2.5 text-sm text-red-300 hover:bg-red-500/10 flex items-center gap-2`,children:[(0,z.jsx)(qs,{size:16}),` Delete Room`]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{T(),y(!1)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)($o,{size:16}),` Copy Room ID`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{y(!1),l(!0)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Ms,{size:16}),` Edit Room`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{y(!1),a(e.id)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Lo,{size:16}),` Read All`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{y(!1),i(e.id,!0)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(To,{size:16}),` Archive Room`]})]})}),document.body):null]})})]})}),(e.children??[]).map(e=>(0,z.jsx)(x3,{room:e,selectedRoomId:t,onSelect:n,onUpdate:r,onArchive:i,onReadAll:a,onDelete:o,depth:s+1},e.id))]})}var S3=0,C3=1,w3=2,T3=4;function nMe(e){return()=>e}function rMe(e){e()}function E3(e,t){return n=>e(t(n))}function iMe(e,t){return()=>e(t)}function aMe(e,t){return n=>e(t,n)}function D3(e){return e!==void 0}function oMe(...e){return()=>{e.map(rMe)}}function O3(){}function k3(e,t){return t(e),e}function sMe(e,t){return t(e)}function A3(...e){return e}function j3(e,t){return e(C3,t)}function M3(e,t){e(S3,t)}function N3(e){e(w3)}function P3(e){return e(T3)}function F3(e,t){return j3(e,aMe(t,S3))}function I3(e,t){let n=e(C3,e=>{n(),t(e)});return n}function L3(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function R3(e,t){return e===t}function z3(e=R3){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function B3(e){return t=>n=>{e(n)&&t(n)}}function V3(e){return t=>E3(t,e)}function H3(e){return t=>()=>{t(e)}}function Q(e,...t){let n=cMe(...t);return((t,r)=>{switch(t){case w3:N3(e);return;case C3:return j3(e,n(r))}})}function U3(e,t){return n=>r=>{n(t=e(t,r))}}function W3(e){return t=>n=>{e>0?e--:t(n)}}function G3(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function K3(...e){let t=Array(e.length),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;j3(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function cMe(...e){return t=>e.reduceRight(sMe,t)}function lMe(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case C3:return a?n===a?void 0:(r(),n=a,t=j3(e,a),t):(r(),O3);case w3:r(),n=null;return}}}function $(e){let t=e,n=J3();return((e,r)=>{switch(e){case S3:t=r;break;case C3:r(t);break;case T3:return t}return n(e,r)})}function q3(e,t){return k3($(t),t=>F3(e,t))}function J3(){let e=[];return((t,n)=>{switch(t){case S3:e.slice().forEach(e=>{e(n)});return;case w3:e.splice(0,e.length);return;case C3:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function Y3(e){return k3(J3(),t=>F3(e,t))}function X3(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:uMe(),singleton:n}}var uMe=()=>Symbol();function dMe(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function Z3(...e){let t=J3(),n=Array(e.length),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;j3(e,e=>{n[a]=e,r|=o,r===i&&M3(t,n)})}),function(e,a){switch(e){case w3:N3(t);return;case C3:return r===i&&a(n),j3(t,a)}}}function Q3(e,t=R3){return Q(e,z3(t))}function $3(...e){return function(t,n){switch(t){case w3:return;case C3:return oMe(...e.map(e=>j3(e,n)))}}}var e6={DEBUG:0,INFO:1,WARN:2,ERROR:3},fMe={[e6.DEBUG]:`debug`,[e6.ERROR]:`error`,[e6.INFO]:`log`,[e6.WARN]:`warn`},pMe=()=>typeof globalThis>`u`?window:globalThis,t6=X3(()=>{let e=$(e6.ERROR);return{log:$((t,n,r=e6.INFO)=>{r>=(pMe().VIRTUOSO_LOG_LEVEL??P3(e))&&console[fMe[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function n6(e,t,n){return r6(e,t,n).callbackRef}function r6(e,t,n){let r=R.useRef(null),i=e=>{},a=R.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function i6(e,t,n,r,i,a,o,s,c){return r6(R.useCallback(n=>{let c=mMe(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollLeft:o.scrollTop:u?s?d.scrollX||d.document.documentElement.scrollLeft:d.scrollY||d.document.documentElement.scrollTop:s?l.scrollLeft:l.scrollTop,p=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,m=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight;r({scrollHeight:p,scrollTop:Math.max(f,0),viewportHeight:m}),a?.(s?a6(`column-gap`,getComputedStyle(n).columnGap,i):a6(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function mMe(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},e6.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function a6(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,e6.WARN),t===`normal`?0:parseInt(t??`0`,10)}function o6(e,t,n){let r=R.useRef(null),i=R.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=r6(i,!0,n),s=R.useCallback(()=>{i(o.current)},[i,o]);return R.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var s6=X3(()=>{let e=J3(),t=J3(),n=$(0),r=J3(),i=$(0),a=J3(),o=J3(),s=$(0),c=$(0),l=$(0),u=$(0),d=J3(),f=J3(),p=$(!1),m=$(!1),h=$(!1);return F3(Q(e,V3(({scrollTop:e})=>e)),t),F3(Q(e,V3(({scrollHeight:e})=>e)),o),F3(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),c6={lvl:0};function l6(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function u6(e){return e===c6}function d6(e,t){if(!u6(e))return t===e.k?e.v:t<e.k?d6(e.l,t):d6(e.r,t)}function f6(e,t,n=`k`){if(u6(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=f6(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return f6(e.l,t,n)}function p6(e,t,n){return u6(e)?w6(t,n,1):t===e.k?b6(e,{k:t,v:n}):t<e.k?T6(b6(e,{l:p6(e.l,t,n)})):T6(b6(e,{r:p6(e.r,t,n)}))}function m6(){return c6}function h6(e,t,n){if(u6(e))return[];let r=f6(e,t)[0];return hMe(v6(e,r,n))}function g6(e,t){if(u6(e))return c6;let{k:n,l:r,r:i}=e;if(t===n){if(u6(r))return i;if(u6(i))return r;let[t,n]=C6(r);return y6(b6(e,{k:t,l:x6(r),v:n}))}return y6(t<n?b6(e,{l:g6(r,t)}):b6(e,{r:g6(i,t)}))}function _6(e){return u6(e)?[]:[..._6(e.l),{k:e.k,v:e.v},..._6(e.r)]}function v6(e,t,n){if(u6(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(v6(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(v6(a,t,n))),s}function y6(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(S6(t))return E6(b6(e,{lvl:n-1}));if(!u6(t)&&!u6(t.r))return b6(t.r,{l:b6(t,{r:t.r.l}),lvl:n,r:b6(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(S6(e))return D6(b6(e,{lvl:n-1}));if(!u6(r)&&!u6(r.l)){let t=r.l,i=S6(t)?r.lvl-1:r.lvl;return b6(t,{l:b6(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:D6(b6(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function b6(e,t){return w6(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function x6(e){return u6(e.r)?e.l:y6(b6(e,{r:x6(e.r)}))}function S6(e){return u6(e)||e.lvl>e.r.lvl}function C6(e){return u6(e.r)?[e.k,e.v]:C6(e.r)}function w6(e,t,n,r=c6,i=c6){return{k:e,l:r,lvl:n,r:i,v:t}}function T6(e){return D6(E6(e))}function E6(e){let{l:t}=e;return!u6(t)&&t.lvl===e.lvl?b6(t,{r:b6(e,{l:t.r})}):e}function D6(e){let{lvl:t,r:n}=e;return!u6(n)&&!u6(n.r)&&n.lvl===t&&n.r.lvl===t?b6(n,{l:b6(e,{r:n.l}),lvl:t+1}):e}function hMe(e){return l6(e,({k:e,v:t})=>({index:e,value:t}))}function O6(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function k6(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var A6=X3(()=>({recalcInProgress:$(!1)}),[],{singleton:!0});function j6(e,t,n){return e[M6(e,t,n)]}function M6(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function gMe(e,t,n,r){let i=M6(e,t,r),a=M6(e,n,r,i);return e.slice(i,a+1)}function N6(e,t){return Math.round(e.getBoundingClientRect()[t])}function P6(e){return!u6(e.groupOffsetTree)}function F6({index:e},t){return t===e?0:t<e?-1:1}function _Me(){return{groupIndices:[],groupOffsetTree:m6(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:m6()}}function vMe(e,t){let n=u6(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),u6(e)){e=p6(e,0,i);continue}let o=h6(e,a-1,t+1);if(o.some(TMe(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=g6(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=p6(e,t+1,a));c&&(e=p6(e,a,i))}return[e,n]}function yMe(e){return typeof e.groupIndex<`u`}function bMe({offset:e},t){return t===e?0:t<e?-1:1}function I6(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=j6(t,e,F6),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function L6(e,t){if(!P6(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function R6(e,t,n){if(yMe(e))return t.groupIndices[e.groupIndex]+1;let r=L6(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function xMe(e,t,n,r=0){return r>0&&(t=Math.max(t,j6(e,r,F6).offset)),l6(gMe(e,t,n,bMe),wMe)}function SMe(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,e6.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&u6(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>p6(p6(t,n,e),n+1,r),o)}else [o,s]=vMe(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=B6(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>p6(e,t,I6(t,d,i)),m6()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function CMe(e){return _6(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function z6(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function B6(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t!==0){c=M6(i,t-1,F6),s=i[c].offset;let e=f6(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===f6(n,t)[1]&&--c,i=i.slice(0,c+1)}else i=[];for(let{start:e,value:c}of h6(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function wMe(e){return{index:e.index,value:e}}function TMe(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var EMe={offsetHeight:`height`,offsetWidth:`width`},V6=X3(([{log:e},{recalcInProgress:t}])=>{let n=J3(),r=J3(),i=q3(r,0),a=J3(),o=J3(),s=$(0),c=$([]),l=$(void 0),u=$(void 0),d=$(void 0),f=$(void 0),p=$((e,t)=>N6(e,EMe[t])),m=$(void 0),h=$(0),g=_Me(),_=q3(Q(n,K3(c,e,h),U3(SMe,g),z3()),g),v=q3(Q(c,z3(),U3((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),V3(({prev:e})=>e)),[]);F3(Q(c,B3(e=>e.length>0),K3(_,h),V3(([e,t,n])=>{let r=e.reduce((e,r,i)=>p6(e,r,I6(r,t.offsetTree,n)||i),m6());return{...t,groupIndices:e,groupOffsetTree:r}})),_),F3(Q(r,K3(_),B3(([e,{lastIndex:t}])=>e<t),V3(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),F3(l,u);let y=q3(Q(l,V3(e=>e===void 0)),!0);F3(Q(u,B3(e=>e!==void 0&&u6(P3(_).sizeTree)),V3(e=>{let t=P3(d),n=P3(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),F3(Q(f,B3(e=>e!==void 0&&e.length>0&&u6(P3(_).sizeTree)),V3(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),F3(Q(c,K3(d,u),B3(([,e,t])=>e!==void 0&&t!==void 0),V3(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=Y3(Q(n,K3(_),U3(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),V3(e=>e.changed)));j3(Q(s,U3((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),V3(e=>e.diff)),e=>{let{groupIndices:n}=P3(_);if(e>0)M3(t,!0),M3(a,e+z6(e,n));else if(e<0){let t=P3(v);t.length>0&&(e-=z6(-e,t)),M3(o,e)}}),j3(Q(s,K3(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},e6.ERROR)});let x=Y3(a);F3(Q(a,K3(_),V3(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=d6(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=_6(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return _6(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=Y3(Q(o,K3(_,h),V3(([e,{offsetTree:t},n])=>I6(-e,t,n))));return F3(Q(o,K3(_,h),V3(([e,t,n])=>{if(t.groupIndices.length>0){if(u6(t.sizeTree))return t;let r=m6(),i=P3(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=_6(t.sizeTree).reduce((t,{k:n,v:r})=>p6(t,Math.max(0,n+e),r),r),a!==-e){let n=d6(t.sizeTree,s);r=p6(r,0,n);let i=f6(t.sizeTree,-e+1)[1];r=p6(r,1,i)}return{...t,sizeTree:r,...B6(t.offsetTree,0,r,n)}}let r=_6(t.sizeTree).reduce((t,{k:n,v:r})=>p6(t,Math.max(0,n+e),r),m6());return{...t,sizeTree:r,...B6(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},A3(t6,A6),{singleton:!0});function DMe(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var H6=X3(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=J3(),o=J3(),s=Y3(Q(a,V3(DMe)));return F3(Q(s,V3(e=>e.totalCount)),n),F3(Q(s,V3(e=>e.groupIndices)),e),F3(Q(Z3(i,t,r),B3(([e,t])=>P6(t)),V3(([e,t,n])=>f6(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),z3(),V3(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},A3(V6,s6)),U6=X3(([{log:e}])=>{let t=$(!1),n=Y3(Q(t,B3(e=>e),z3()));return j3(t,t=>{t&&P3(e)(`props updated`,{},e6.DEBUG)}),{didMount:n,propsReady:t}},A3(t6),{singleton:!0}),OMe=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function W6(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!OMe)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var G6=X3(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=J3(),m=J3(),h=$(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),M3(c,!1)}return F3(Q(p,K3(n,d,r,h,s,o,f),K3(e,a,i),V3(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=W6(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=R6(b,n,w),E=I6(T,n.offsetTree,d)+o;x===`end`?(E+=f+f6(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+f6(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},e6.DEBUG),M3(p,e)):(M3(m,!0),l(`list did not change, scroll successful`,{},e6.DEBUG))};if(y(),S===`smooth`){let e=!1;v=j3(t,t=>{e||=t}),g=I3(u,()=>{D(e)})}else g=I3(Q(t,kMe(150)),D);return _=setTimeout(()=>{y()},1200),M3(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},e6.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},A3(V6,s6,t6),{singleton:!0});function kMe(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function K6(e,t){e===0?t():requestAnimationFrame(()=>{K6(e-1,t)})}function q6(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var J6=X3(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=$(!0),c=$(0),l=$(!0);return F3(Q(o,K3(c),B3(([e,t])=>t!==0),H3(!1)),s),F3(Q(o,K3(c),B3(([e,t])=>t!==0),H3(!1)),l),j3(Q(Z3(t,o),K3(s,n,e,l),B3(([[,e],t,{sizeTree:n},r,i])=>e&&(!u6(n)||D3(r))&&!t&&!i),K3(c)),([,e])=>{I3(i,()=>{M3(l,!0)}),K6(4,()=>{I3(r,()=>{M3(s,!0)}),M3(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},A3(V6,s6,G6,U6),{singleton:!0});function Y6(e,t){return Math.abs(e-t)<1.01}var X6=`up`,Z6=`down`,AMe=`none`,jMe={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},MMe=0,Q6=X3(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=$(!1),s=$(!0),c=J3(),l=J3(),u=$(4),d=$(MMe),f=q3(Q($3(Q(Q3(i),W3(1),H3(!0)),Q(Q3(i),W3(1),H3(!1),L3(100))),z3()),!1),p=q3(Q($3(Q(n,H3(!0)),Q(n,H3(!1),L3(200))),z3()),!1);F3(Q(Z3(Q3(i),Q3(d)),V3(([e,t])=>e<=t),z3()),s),F3(Q(s,G3(50)),l);let m=Y3(Q(Z3(r,Q3(a),Q3(t),Q3(e),Q3(u)),U3((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},jMe),z3((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=q3(Q(r,U3((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Y6(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),B3(e=>e.changed),V3(e=>e.jump)),0);F3(Q(m,V3(e=>e.atBottom)),o),F3(Q(o,G3(50)),c);let g=$(Z6);F3(Q(r,V3(({scrollTop:e})=>e),z3(),U3((e,t)=>P3(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?X6:Z6,prevScrollTop:t},{direction:Z6,prevScrollTop:0}),V3(e=>e.direction)),g),F3(Q(r,G3(50),H3(AMe)),g);let _=$(0);return F3(Q(f,B3(e=>!e),H3(0)),_),F3(Q(i,G3(100),K3(f),B3(([e,t])=>t),U3(([e,t],[n])=>[t,n],[0,0]),V3(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},A3(s6)),$6=`top`,e8=`bottom`,t8=`none`;function n8(e,t,n){return typeof e==`number`?n===X6&&t===$6||n===Z6&&t===e8?e:0:n===X6?t===$6?e.main:e.reverse:t===e8?e.main:e.reverse}function r8(e,t){return typeof e==`number`?e:e[t]??0}var i8=X3(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=J3(),o=$(0),s=$(0),c=$(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:q3(Q(Z3(Q3(r),Q3(i),Q3(n),Q3(a,k6),Q3(c),Q3(o),Q3(t),Q3(e),Q3(s)),V3(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=t8,m=r8(l,$6),h=r8(l,e8);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=X6),i<e-f+t+h&&(p=Z6),p===t8?null:[Math.max(u-n-n8(a,$6,p)-m,0),u-f-s+t+n8(a,e8,p)+h]}),B3(e=>e!==null),z3(k6)),[0,0])}},A3(s6),{singleton:!0});function NMe(e,t,n){if(P6(t)){let r=L6(e,t);return[{index:f6(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var a8={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function o8(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:c8(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:c8(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function s8(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=q6(t,s);return o8(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function c8(e,t,n){if(e.length===0)return[];if(!P6(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=h6(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function l8(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var u8=X3(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=$([]),g=$(0),_=J3(),v=$(0);F3(a.topItemsIndexes,h);let y=q3(Q(Z3(p,m,Q3(c,k6),Q3(i),Q3(r),Q3(l),u,Q3(h),Q3(t),Q3(n),Q3(v),e),B3(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),V3(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=P3(g);if(n===0)return{...a8,totalCount:n};if(e===0&&t===0)return m===0?{...a8,totalCount:n}:s8(m,i,r,s,c,u||[]);if(u6(p))return m>0?null:o8(NMe(q6(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of h6(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return o8([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=xMe(f,e,t,_);if(v.length===0)return null;let y=n-1,b=k3([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=l8(l,$6),S=l8(l,e8);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=h6(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=h6(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return o8(b,h,n,c,d,s)}),B3(e=>e!==null),z3()),a8);F3(Q(e,B3(D3),V3(e=>e?.length)),i),F3(Q(y,V3(e=>e.topListHeight)),d),F3(d,s),F3(Q(y,V3(e=>[e.top,e.bottom])),o),F3(Q(y,V3(e=>e.items)),_);let b=Y3(Q(y,B3(({items:e})=>e.length>0),K3(i,e),B3(([{items:e},t])=>e[e.length-1].originalIndex===t-1),V3(([,e,t])=>[e-1,t]),z3(k6),V3(([e])=>e))),x=Y3(Q(y,G3(200),B3(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),V3(({items:e})=>e[0].index),z3()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:Y3(Q(y,B3(({items:e})=>e.length>0),V3(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),z3(O6))),startReached:x,topItemsIndexes:h,...f}},A3(V6,H6,i8,J6,G6,Q6,U6,A6),{singleton:!0}),d8=X3(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=J3(),o=q3(Q(Z3(n,e,r,t,i),V3(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return F3(Q3(o),a),{totalListHeight:o,totalListHeightChanged:a}},A3(s6,u8),{singleton:!0}),PMe=X3(([{viewportHeight:e},{totalListHeight:t}])=>{let n=$(!1);return{alignToBottom:n,paddingTopAddition:q3(Q(Z3(n,e,t),B3(([e])=>e),V3(([,e,t])=>Math.max(0,e-t)),G3(0),z3()),0)}},A3(s6,d8),{singleton:!0}),f8=X3(()=>({context:$(null)})),FMe=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,p8=X3(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=J3();return F3(Q(u,K3(t,c,n,a,i,r,s),K3(e),V3(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=FMe,done:d,...f}=e,p=R6(e,t,r-1),m=I6(p,t.offsetTree,l)+i+a,h=m+f6(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&I3(Q(o,B3(e=>!e),W3(P3(o)?1:2)),d),_}),B3(e=>e!==null)),l),{scrollIntoView:u}},A3(V6,s6,G6,u8,t6),{singleton:!0});function m8(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var IMe=(e,t)=>typeof e==`function`?m8(e(t)):t&&m8(e),LMe=X3(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=$(!1),h=J3(),g=null;function _(e){M3(o,{align:`end`,behavior:e,index:`LAST`})}j3(Q(Z3(Q(Q3(t),W3(1)),c),K3(Q3(m),a,s,d),V3(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=IMe(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),B3(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),P3(n)===void 0?g=I3(e,()=>{P3(u)(`following output to `,{totalCount:r},e6.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{P3(u)(`following output to `,{totalCount:r},e6.DEBUG),_(t)})});function v(e){let t=I3(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(P3(u)(`scrolling to bottom due to increased size`,{},e6.DEBUG),_(`auto`))});setTimeout(t,100)}j3(Q(Z3(Q3(m),t,l),B3(([e,,t])=>e!==!1&&t),U3(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),B3(({refreshed:e})=>e),K3(m,t)),([,e])=>{P3(s)&&v(e!==!1)}),j3(h,()=>{v(P3(m)!==!1)}),j3(Z3(Q3(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=$(null),b=J3();return F3($3(Q(Q3(r),V3(e=>e?.length??0)),Q(Q3(t))),b),j3(Q(Z3(Q(b,W3(1)),c),K3(Q3(y),s,d,f),V3(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),B3(e=>!!e),G3(0)),t=>{g!==null&&(g(),g=null),P3(n)===void 0?g=I3(e,()=>{P3(u)(`scrolling into view`,{}),M3(p,t),g=null}):requestAnimationFrame(()=>{P3(u)(`scrolling into view`,{}),M3(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},A3(V6,Q6,G6,J6,U6,t6,s6,f8,p8)),RMe=X3(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(F3(Q(s,K3(a),B3(([,e])=>e!==0),K3(i,r,t,n,e),V3(([[,e],t,n,r,i,a=[]])=>s8(e,t,n,r,i,a))),o),{}),A3(V6,J6,u8,U6),{singleton:!0}),zMe=X3(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=$(0);return j3(Q(e,K3(r),B3(([,e])=>e!==0),V3(([,e])=>({top:e}))),e=>{I3(Q(n,W3(1),B3(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{M3(t,e)})})}),{initialScrollTop:r}},A3(U6,s6,u8),{singleton:!0}),h8=X3(([{scrollVelocity:e}])=>{let t=$(!1),n=J3(),r=$(!1);return F3(Q(e,K3(r,t,n),B3(([e,t])=>t!==!1&&t!==void 0),V3(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),z3()),t),j3(Q(Z3(t,e,n),K3(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},A3(Q6),{singleton:!0}),g8=X3(([{scrollContainerState:e,scrollTo:t}])=>{let n=J3(),r=J3(),i=J3(),a=$(!1),o=$(void 0);return F3(Q(Z3(n,r),V3(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),F3(Q(t,K3(r),V3(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},A3(s6)),BMe=X3(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=J3(),u=$(void 0),d=$(null),f=$(null);return F3(s,d),F3(c,f),j3(Q(l,K3(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=CMe(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),F3(Q(u,B3(D3),V3(VMe)),i),F3(Q(a,K3(u),B3(([,e])=>e!==void 0),z3(),V3(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},A3(V6,s6,J6,U6,g8));function VMe(e){return{align:`start`,index:0,offset:e.scrollTop}}var HMe=X3(([{topItemsIndexes:e}])=>{let t=$(0);return F3(Q(t,B3(e=>e>=0),V3(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},A3(u8));function _8(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var UMe=_8(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),v8=X3(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:k,...A}=b;return F3(k,T.scrollSeekRangeChanged),F3(Q(T.windowViewportRect,V3(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:k,...A,...T,..._,sizes:u,...v}},A3(V6,J6,s6,BMe,LMe,u8,G6,X3(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=Y3(Q(c,K3(o),U3(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),B3(([e])=>e!==0),K3(r,s,n,i,p,m),B3(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===X6),V3(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},e6.DEBUG),e))));function g(n){n>0?(M3(t,{behavior:`auto`,top:-n}),M3(e,0)):(M3(e,0),M3(t,{behavior:`auto`,top:-n}))}return j3(Q(h,K3(e,a)),([t,n,r])=>{r&&UMe()?M3(e,n-t):g(-t)}),j3(Q(Z3(q3(a,!1),e,m),B3(([e,t,n])=>!e&&!n&&t!==0),V3(([e,t])=>t),G3(1)),g),F3(Q(d,V3(e=>({top:-e}))),t),j3(Q(l,K3(f,u),V3(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=d6(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{M3(e,n),requestAnimationFrame(()=>{M3(t,{top:n}),requestAnimationFrame(()=>{M3(e,0),M3(m,!1)})})}),{deviation:e}},A3(s6,Q6,u8,V6,t6,A6)),HMe,H6,X3(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),A3(i8,RMe,U6,h8,d8,zMe,PMe,g8,p8,t6,f8))));function WMe(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var y8=typeof document<`u`?R.useLayoutEffect:R.useEffect;function b8(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=R.createContext({});function c(e,n){e.propsReady!==void 0&&M3(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];M3(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];M3(i,n[r])}e.propsReady!==void 0&&M3(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];M3(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=lMe(e[t.events[r]]),n),{})}return{Component:R.forwardRef(function(t,a){let{children:d,...f}=t,[p]=R.useState(()=>k3(dMe(e),e=>{c(e,f)})),[m]=R.useState(iMe(u,p));y8(()=>{for(let e of o)e in f&&j3(m[e],f[e]);return()=>{Object.values(m).map(N3)}},[f,m,p]),y8(()=>{c(p,f)}),R.useImperativeHandle(a,nMe(l(p)));let h=n;return(0,z.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,z.jsx)(h,{...WMe([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=R.useContext(s)[e];y8(()=>j3(n,t),[t,n])},useEmitterValue:e=>{let t=R.useContext(s)[e],n=R.useCallback(e=>j3(t,e),[t]);return R.useSyncExternalStore(n,()=>P3(t),()=>P3(t))},usePublisher:e=>{let t=R.useContext(s);return R.useCallback(n=>{M3(t[e],n)},[t,e])}}}var x8=R.createContext(void 0),S8=R.createContext(void 0),C8=`-webkit-sticky`,w8=`sticky`,T8=_8(()=>{if(typeof document>`u`)return w8;let e=document.createElement(`div`);return e.style.position=C8,e.style.position===C8?C8:w8}),E8=typeof document<`u`?R.useLayoutEffect:R.useEffect;function D8(e){return`self`in e}function GMe(e){return`body`in e}function O8(e,t,n,r=O3,i,a){let o=R.useRef(null),s=R.useRef(null),c=R.useRef(null),l=R.useCallback(n=>{let r,i,o,l=n.target;if(GMe(l)||D8(l)){let e=D8(l)?l:l.defaultView;o=a===!0?e.scrollX:e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?l.scrollLeft:l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Na.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);R.useEffect(()=>{let e=i||o.current;return r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;D8(r)?(u=Math.max(N6(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?window.scrollX:window.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=N6(r,a===!0?`width`:`height`),d=r[a===!0?`scrollLeft`:`scrollTop`]);let f=u-l;if(n.top=Math.ceil(Math.max(Math.min(f,n.top),0)),Y6(l,u)||n.top===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=n.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:n.top}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:e.top}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function k8(e){return e}var KMe=X3(([e,t])=>({...e,...t}),A3(v8,X3(()=>{let e=$(e=>`Item ${e}`),t=$(e=>`Group ${e}`),n=$({}),r=$(k8),i=$(`div`),a=$(O3),o=(e,t=null)=>q3(Q(n,V3(t=>t[e]),z3()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),qMe=({height:e})=>(0,z.jsx)(`div`,{style:{height:e}}),JMe={overflowAnchor:`none`,position:T8(),zIndex:1},A8={overflowAnchor:`none`},YMe={...A8,display:`inline-block`,height:`100%`},j8=R.memo(function({showTopList:e=!1}){let t=z8(`listState`),n=B8(`sizeRanges`),r=z8(`useWindowScroll`),i=z8(`customScrollParent`),a=B8(`windowScrollContainerState`),o=B8(`scrollContainerState`),s=i||r?a:o,c=z8(`itemContent`),l=z8(`context`),u=z8(`groupContent`),d=z8(`trackItemSizes`),f=z8(`itemSize`),p=z8(`log`),m=B8(`gap`),h=z8(`horizontalDirection`),{callbackRef:g}=i6(n,f,d,e?O3:s,p,m,i,h,z8(`skipAnimationFrameInResizeObserver`)),[_,v]=R.useState(0);R8(`deviation`,e=>{_!==e&&v(e)});let y=z8(`EmptyPlaceholder`),b=z8(`ScrollSeekPlaceholder`)??qMe,x=z8(`ListComponent`),S=z8(`ItemComponent`),C=z8(`GroupComponent`),w=z8(`computeItemKey`),T=z8(`isSeeking`),E=z8(`groupIndices`).length>0,D=z8(`alignToBottom`),O=z8(`initialItemFinalLocationReached`),k=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginLeft:_===0?D?`auto`:0:_,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:`nowrap`}:{marginTop:_===0?D?`auto`:0:_,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...O?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&y!=null?(0,z.jsx)(y,{...P8(y,l)}):(0,z.jsx)(x,{...P8(x,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:k,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=w(n+t.firstItemIndex,e.data,l);return T?(0,R.createElement)(b,{...P8(b,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,R.createElement)(C,{...P8(C,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:JMe},u(e.index,l)):(0,R.createElement)(S,{...P8(S,l),...F8(S,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?YMe:A8},E?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),XMe={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},ZMe={outline:`none`,overflowX:`auto`,position:`relative`},M8=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),N8=(e,t,n=0)=>({...M8(e),position:t?`relative`:`absolute`,top:t?-n:0}),QMe={position:T8(),top:0,width:`100%`,zIndex:1};function P8(e,t){if(typeof e!=`string`)return{context:t}}function F8(e,t){return{item:typeof e==`string`?void 0:t}}var $Me=R.memo(function(){let e=z8(`HeaderComponent`),t=B8(`headerHeight`),n=z8(`HeaderFooterTag`),r=n6(R.useMemo(()=>e=>{t(N6(e,`height`))},[t]),!0,z8(`skipAnimationFrameInResizeObserver`)),i=z8(`context`);return e==null?null:(0,z.jsx)(n,{ref:r,children:(0,z.jsx)(e,{...P8(e,i)})})}),eNe=R.memo(function(){let e=z8(`FooterComponent`),t=B8(`footerHeight`),n=z8(`HeaderFooterTag`),r=n6(R.useMemo(()=>e=>{t(N6(e,`height`))},[t]),!0,z8(`skipAnimationFrameInResizeObserver`)),i=z8(`context`);return e==null?null:(0,z.jsx)(n,{ref:r,children:(0,z.jsx)(e,{...P8(e,i)})})});function I8({useEmitter:e,useEmitterValue:t,usePublisher:n}){return R.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=O8(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,z.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?ZMe:XMe,...i},tabIndex:0,...o,...P8(c,a),children:r})})}function L8({useEmitter:e,useEmitterValue:t,usePublisher:n}){return R.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=R.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=O8(s,l,c,t(`scrollerRef`),f);return E8(()=>(h.current=f||p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,z.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...P8(c,a),children:r})})}var tNe=({children:e})=>{let t=R.useContext(x8),n=B8(`viewportHeight`),r=B8(`fixedItemHeight`),i=z8(`alignToBottom`),a=z8(`horizontalDirection`),o=n6(R.useMemo(()=>E3(n,e=>N6(e,a?`width`:`height`)),[n,a]),!0,z8(`skipAnimationFrameInResizeObserver`));return R.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,z.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:M8(i),children:e})},nNe=({children:e})=>{let t=R.useContext(x8),n=B8(`windowViewportRect`),r=B8(`fixedItemHeight`),i=z8(`customScrollParent`),a=z8(`useWindowScroll`),o=z8(`topListHeight`),s=o6(n,i,z8(`skipAnimationFrameInResizeObserver`)),c=z8(`alignToBottom`);return R.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,z.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:N8(c,a,o),children:e})},rNe=({children:e})=>{let t=z8(`TopItemListComponent`)??`div`,n=z8(`headerHeight`);return(0,z.jsx)(t,{style:{...QMe,marginTop:`${n}px`},...P8(t,z8(`context`)),children:e})},{Component:iNe,useEmitter:R8,useEmitterValue:z8,usePublisher:B8}=b8(KMe,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},R.memo(function(e){let t=z8(`useWindowScroll`),n=z8(`topItemsIndexes`).length>0,r=z8(`customScrollParent`),i=z8(`context`);return(0,z.jsxs)(r||t?oNe:aNe,{...e,context:i,children:[n&&(0,z.jsx)(rNe,{children:(0,z.jsx)(j8,{showTopList:!0})}),(0,z.jsxs)(r||t?nNe:tNe,{children:[(0,z.jsx)($Me,{}),(0,z.jsx)(j8,{}),(0,z.jsx)(eNe,{})]})]})})),aNe=I8({useEmitter:R8,useEmitterValue:z8,usePublisher:B8}),oNe=L8({useEmitter:R8,useEmitterValue:z8,usePublisher:B8}),sNe=iNe,cNe=X3(([e,t])=>({...e,...t}),A3(v8,X3(()=>{let e=$(e=>(0,z.jsxs)(`td`,{children:[`Item $`,e]})),t=$(null),n=$(e=>(0,z.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=$(null),i=$(null),a=$({}),o=$(k8),s=$(O3),c=(e,t=null)=>q3(Q(a,V3(t=>t[e]),z3()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),lNe=({height:e})=>(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{style:{height:e}})}),uNe=({height:e})=>(0,z.jsx)(`tr`,{children:(0,z.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),dNe={overflowAnchor:`none`},V8={position:T8(),zIndex:2,overflowAnchor:`none`},H8=R.memo(function({showTopList:e=!1}){let t=W8(`listState`),n=W8(`computeItemKey`),r=W8(`firstItemIndex`),i=W8(`context`),a=W8(`isSeeking`),o=W8(`fixedHeaderHeight`),s=W8(`groupIndices`).length>0,c=W8(`itemContent`),l=W8(`groupContent`),u=W8(`ScrollSeekPlaceholder`)??lNe,d=W8(`GroupComponent`),f=W8(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,R.createElement)(u,{...P8(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,R.createElement)(d,{...P8(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...V8,top:o}},l(t.index,i)):(0,R.createElement)(f,{...P8(f,i),...F8(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...V8,top:o+g}:dNe},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),fNe=R.memo(function(){let e=W8(`listState`),t=W8(`topItemsIndexes`).length>0,n=G8(`sizeRanges`),r=W8(`useWindowScroll`),i=W8(`customScrollParent`),a=G8(`windowScrollContainerState`),o=G8(`scrollContainerState`),s=i||r?a:o,c=W8(`trackItemSizes`),{callbackRef:l,ref:u}=i6(n,W8(`itemSize`),c,s,W8(`log`),void 0,i,!1,W8(`skipAnimationFrameInResizeObserver`)),[d,f]=R.useState(0);U8(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=W8(`EmptyPlaceholder`),m=W8(`FillerRow`)??uNe,h=W8(`TableBodyComponent`),g=W8(`paddingTopAddition`),_=W8(`statefulTotalCount`),v=W8(`context`);if(_===0&&p!=null)return(0,z.jsx)(p,{...P8(p,v)});let y=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),b=e.offsetTop+g+d-y,x=e.offsetBottom,S=b>0?(0,z.jsx)(m,{context:v,height:b},`padding-top`):null,C=x>0?(0,z.jsx)(m,{context:v,height:x},`padding-bottom`):null;return(0,z.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...P8(h,v),children:[S,t&&(0,z.jsx)(H8,{showTopList:!0}),(0,z.jsx)(H8,{}),C]})}),pNe=({children:e})=>{let t=R.useContext(x8),n=G8(`viewportHeight`),r=G8(`fixedItemHeight`),i=n6(R.useMemo(()=>E3(n,e=>N6(e,`height`)),[n]),!0,W8(`skipAnimationFrameInResizeObserver`));return R.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,z.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:M8(!1),children:e})},mNe=({children:e})=>{let t=R.useContext(x8),n=G8(`windowViewportRect`),r=G8(`fixedItemHeight`),i=W8(`customScrollParent`),a=W8(`useWindowScroll`),o=o6(n,i,W8(`skipAnimationFrameInResizeObserver`));return R.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,z.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:N8(!1,a),children:e})},{Component:hNe,useEmitter:U8,useEmitterValue:W8,usePublisher:G8}=b8(cNe,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},R.memo(function(e){let t=W8(`useWindowScroll`),n=W8(`customScrollParent`),r=G8(`fixedHeaderHeight`),i=G8(`fixedFooterHeight`),a=W8(`fixedHeaderContent`),o=W8(`fixedFooterContent`),s=W8(`context`),c=n6(R.useMemo(()=>E3(r,e=>N6(e,`height`)),[r]),!0,W8(`skipAnimationFrameInResizeObserver`)),l=n6(R.useMemo(()=>E3(i,e=>N6(e,`height`)),[i]),!0,W8(`skipAnimationFrameInResizeObserver`)),u=n||t?_Ne:gNe,d=n||t?mNe:pNe,f=W8(`TableComponent`),p=W8(`TableHeadComponent`),m=W8(`TableFooterComponent`),h=a?(0,z.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...P8(p,s),children:a()},`TableHead`):null,g=o?(0,z.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...P8(m,s),children:o()},`TableFoot`):null;return(0,z.jsx)(u,{...e,...P8(u,s),children:(0,z.jsx)(d,{children:(0,z.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...P8(f,s),children:[h,(0,z.jsx)(fNe,{},`TableBody`),g]})})})})),gNe=I8({useEmitter:U8,useEmitterValue:W8,usePublisher:G8}),_Ne=L8({useEmitter:U8,useEmitterValue:W8,usePublisher:G8}),K8={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},vNe={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:q8,floor:J8,max:Y8,min:X8,round:Z8}=Math;function Q8(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function yNe(e){return{...vNe,items:e}}function $8(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function bNe(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var xNe=X3(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=$(0),C=$(0),w=$(K8),T=$({height:0,width:0}),E=$({height:0,width:0}),D=J3(),O=J3(),k=$(0),A=$(null),j=$({column:0,row:0}),M=J3(),N=J3(),P=$(!1),F=$(0),ee=$(!0),te=$(!1),I=$(!1);j3(Q(m,K3(F),B3(([e,t])=>t!==0)),()=>{M3(ee,!1)}),j3(Q(Z3(m,ee,E,T,F,te),B3(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{M3(te,!0),K6(1,()=>{M3(D,e)}),I3(Q(l),()=>{M3(t,[0,0]),M3(ee,!0)})}),F3(Q(N,B3(e=>e!=null&&e.scrollTop>0),H3(0)),C),j3(Q(m,K3(N),B3(([,e])=>e!=null)),([,e])=>{e&&(M3(T,e.viewport),M3(E,e.item),M3(j,e.gap),e.scrollTop>0&&(M3(P,!0),I3(Q(l,W3(1)),e=>{M3(P,!1)}),M3(c,{top:e.scrollTop})))}),F3(Q(T,V3(({height:e})=>e)),d),F3(Q(Z3(Q3(T,$8),Q3(E,$8),Q3(j,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),Q3(l)),V3(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),M),F3(Q(Z3(Q3(S),r,Q3(j,bNe),Q3(E,$8),Q3(T,$8),Q3(A),Q3(C),Q3(P),Q3(ee),Q3(F)),B3(([,,,,,,,e])=>!e),V3(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return K8;if(p===0){let t=q6(l,e);return yNe(Q8(t,t+Math.max(s-1,0),o))}let h=e5(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*J8((t+d)/(f+d)),_=h*q8((n+d)/(f+d))-1,_=X8(e-1,Y8(_,h-1)),g=X8(_,Y8(0,g))):(g=0,_=-1);let v=Q8(g,_,o),{bottom:y,top:b}=t5(a,r,i,v),x=q8(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),F3(Q(A,B3(e=>e!==null),V3(e=>e.length)),S),F3(Q(Z3(T,E,w,j),B3(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),V3(([e,t,{items:n},r])=>{let{bottom:i,top:a}=t5(e,r,t,n);return[a,i]}),z3(k6)),t);let ne=$(!1);F3(Q(l,K3(ne),V3(([e,t])=>t||e!==0)),ne);let L=Y3(Q(Z3(w,S),B3(([{items:e}])=>e.length>0),K3(ne),B3(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),V3(([[,e]])=>e-1),z3())),re=Y3(Q(Q3(w),B3(({items:e})=>e.length>0&&e[0].index===0),H3(0),z3())),ie=Y3(Q(Q3(w),K3(P),B3(([{items:e},t])=>e.length>0&&!t),V3(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),z3(O6),G3(0)));F3(ie,p.scrollSeekRangeChanged),F3(Q(D,K3(T,E,S,j),V3(([e,t,n,r,i])=>{let a=W6(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Y8(0,l,X8(r-1,l));let u=n5(t,i,n,l);return o===`end`?u=Z8(u-t.height+n.height):o===`center`&&(u=Z8(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let ae=q3(Q(w,V3(e=>e.offsetBottom+e.bottom)),0);return F3(Q(b,V3(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:A,deviation:k,footerHeight:i,gap:j,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:N,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:I,initialTopMostItemIndex:F,totalListHeight:ae,...f,endReached:L,propsReady:h,rangeChanged:ie,startReached:re,stateChanged:M,stateRestoreInProgress:P,...x}},A3(i8,s6,Q6,h8,U6,g8,t6));function e5(e,t,n){return Y8(1,J8((e+n)/(J8(t)+n)))}function t5(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=n5(e,t,n,r[0].index);return{bottom:n5(e,t,n,r[r.length-1].index)+i,top:a}}function n5(e,t,n,r){let i=J8(r/e5(e.width,n.width,t.column)),a=i*n.height+Y8(0,i-1)*t.row;return a>0?a+t.row:a}var SNe=X3(([e,t])=>({...e,...t}),A3(xNe,X3(()=>{let e=$(e=>`Item ${e}`),t=$({}),n=$(null),r=$(`virtuoso-grid-item`),i=$(`virtuoso-grid-list`),a=$(k8),o=$(`div`),s=$(O3),c=(e,n=null)=>q3(Q(t,V3(t=>t[e]),z3()),n),l=$(!1),u=$(!1);return F3(Q3(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),CNe=R.memo(function(){let e=i5(`gridState`),t=i5(`listClassName`),n=i5(`itemClassName`),r=i5(`itemContent`),i=i5(`computeItemKey`),a=i5(`isSeeking`),o=a5(`scrollHeight`),s=i5(`ItemComponent`),c=i5(`ListComponent`),l=i5(`ScrollSeekPlaceholder`),u=i5(`context`),d=a5(`itemDimensions`),f=a5(`gap`),p=i5(`log`),m=i5(`stateRestoreInProgress`),h=a5(`reportReadyState`),g=n6(R.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:o5(`column-gap`,getComputedStyle(e).columnGap,p),row:o5(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return E8(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,z.jsx)(c,{className:t,ref:g,...P8(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,z.jsx)(l,{...P8(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,R.createElement)(s,{...P8(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),wNe=R.memo(function(){let e=i5(`HeaderComponent`),t=a5(`headerHeight`),n=i5(`headerFooterTag`),r=n6(R.useMemo(()=>e=>{t(N6(e,`height`))},[t]),!0,!1),i=i5(`context`);return e==null?null:(0,z.jsx)(n,{ref:r,children:(0,z.jsx)(e,{...P8(e,i)})})}),TNe=R.memo(function(){let e=i5(`FooterComponent`),t=a5(`footerHeight`),n=i5(`headerFooterTag`),r=n6(R.useMemo(()=>e=>{t(N6(e,`height`))},[t]),!0,!1),i=i5(`context`);return e==null?null:(0,z.jsx)(n,{ref:r,children:(0,z.jsx)(e,{...P8(e,i)})})}),ENe=({children:e})=>{let t=R.useContext(S8),n=a5(`itemDimensions`),r=a5(`viewportDimensions`),i=n6(R.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return R.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,z.jsx)(`div`,{ref:i,style:M8(!1),children:e})},DNe=({children:e})=>{let t=R.useContext(S8),n=a5(`windowViewportRect`),r=a5(`itemDimensions`),i=i5(`customScrollParent`),a=i5(`useWindowScroll`),o=o6(n,i,!1);return R.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,z.jsx)(`div`,{ref:o,style:N8(!1,a),children:e})},{Component:ONe,useEmitter:r5,useEmitterValue:i5,usePublisher:a5}=b8(SNe,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},R.memo(function({...e}){let t=i5(`useWindowScroll`),n=i5(`customScrollParent`),r=n||t?ANe:kNe,i=n||t?DNe:ENe,a=i5(`context`);return(0,z.jsx)(r,{...e,...P8(r,a),children:(0,z.jsxs)(i,{children:[(0,z.jsx)(wNe,{}),(0,z.jsx)(CNe,{}),(0,z.jsx)(TNe,{})]})})})),kNe=I8({useEmitter:r5,useEmitterValue:i5,usePublisher:a5}),ANe=L8({useEmitter:r5,useEmitterValue:i5,usePublisher:a5});function o5(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,e6.WARN),t===`normal`?0:parseInt(t??`0`,10)}var jNe=24,MNe=700,NNe=3;function PNe({itemCount:e,resetKey:t,contentKey:n,atBottomThreshold:r=jNe}){let i=(0,R.useRef)(null),a=(0,R.useRef)(e),o=(0,R.useRef)(!0),s=(0,R.useRef)(void 0),c=(0,R.useRef)(!1),l=(0,R.useRef)(void 0),u=(0,R.useRef)(void 0),[d,f]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null);(0,R.useLayoutEffect)(()=>{a.current=e},[e]);let h=(0,R.useCallback)(e=>{o.current=e,f(e)},[]),g=(0,R.useCallback)(()=>{s.current!==void 0&&(cancelAnimationFrame(s.current),s.current=void 0)},[]),_=(0,R.useCallback)((e=`auto`)=>{g(),s.current=requestAnimationFrame(()=>{s.current=void 0;let t=a.current-1;t<0||(i.current?.autoscrollToBottom(),i.current?.scrollToIndex({index:t,align:`end`,behavior:e}),requestAnimationFrame(()=>{o.current&&i.current?.autoscrollToBottom()}))})},[g]),v=(0,R.useCallback)((e=`auto`)=>{h(!0),_(e)},[_,h]),y=(0,R.useCallback)((e,t=`center`,n=`auto`,r={})=>{h(!1),g(),requestAnimationFrame(()=>{if(n!==`fast-smooth`){i.current?.scrollToIndex({index:e,align:t,behavior:n});return}if(r.stagingAlign){i.current?.scrollToIndex({index:e,align:r.stagingAlign,behavior:`auto`}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i.current?.scrollToIndex({index:e,align:t,behavior:`smooth`})})});return}let o=r.fromIndex,s=Math.abs(typeof o==`number`?o-e:0),c=r.stagingDistance??NNe;if(typeof o!=`number`||s<=c){i.current?.scrollToIndex({index:e,align:t,behavior:`smooth`});return}let l=a.current-1,u=e<o?Math.min(l,e+c):Math.max(0,e-c);i.current?.scrollToIndex({index:u,align:t,behavior:`auto`}),requestAnimationFrame(()=>{i.current?.scrollToIndex({index:e,align:t,behavior:`smooth`})})})},[g,h]),b=(0,R.useCallback)(e=>{c.current=!0,(e instanceof WheelEvent&&e.deltaY<0||p&&!s5(p,r))&&h(!1),l.current!==void 0&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{c.current=!1,l.current=void 0},MNe)},[r,p,h]),x=(0,R.useCallback)(()=>{if(!p)return;let e=FNe(p),t=u.current;if(u.current=e,s5(p,r)){h(!0);return}let n=t!==void 0&&e<t-1;(c.current||n)&&h(!1)},[r,p,h]);return(0,R.useEffect)(()=>{if(!p)return;let e=p,t=e=>{let t=e instanceof KeyboardEvent?e.key:``;[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(t)&&b()},n=t=>{t.target===e&&b()};return e.addEventListener(`wheel`,b,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!0}),e.addEventListener(`pointerdown`,n,{passive:!0}),e.addEventListener(`keydown`,t),e.addEventListener(`scroll`,x,{passive:!0}),()=>{e.removeEventListener(`wheel`,b),e.removeEventListener(`touchmove`,b),e.removeEventListener(`pointerdown`,n),e.removeEventListener(`keydown`,t),e.removeEventListener(`scroll`,x)}},[b,p,x]),(0,R.useLayoutEffect)(()=>{u.current=void 0,h(!0),_(`auto`)},[t,_,h]),(0,R.useLayoutEffect)(()=>{o.current&&_(`auto`)},[n,e,_]),(0,R.useEffect)(()=>()=>{g(),l.current!==void 0&&window.clearTimeout(l.current)},[g]),{virtuosoRef:i,isSticky:d,stickToBottom:v,scrollToIndex:y,scrollerRef:m,atBottomStateChange:(0,R.useCallback)(e=>{if(e){h(!0);return}c.current&&h(!1)},[h]),atBottomThreshold:r,followOutput:(0,R.useCallback)(()=>o.current?`auto`:!1,[]),totalListHeightChanged:(0,R.useCallback)(()=>{o.current&&_(`auto`)},[_])}}function s5(e,t){let n=e instanceof Window?document.scrollingElement:e;return n?n.scrollHeight-n.scrollTop-n.clientHeight<=t:!0}function FNe(e){return(e instanceof Window?document.scrollingElement:e)?.scrollTop??0}var c5={"agent.run":{color:`text-[#11a4d4]`,bgColor:`bg-[#11a4d4]/20`,borderColor:`border-[#11a4d4]`,label:`Agent Run`},"tool.call":{color:`text-purple-500`,bgColor:`bg-purple-500/20`,borderColor:`border-purple-500`,label:`Tool Call`},"tool.result":{color:`text-green-500`,bgColor:`bg-green-500/20`,borderColor:`border-green-500`,label:`Tool Result`},"model.request":{color:`text-blue-500`,bgColor:`bg-blue-500/20`,borderColor:`border-blue-500`,label:`Model Request`},"model.response":{color:`text-[#0bda57]`,bgColor:`bg-[#0bda57]/20`,borderColor:`border-[#0bda57]`,label:`Model Response`},"model.reasoning":{color:`text-amber-500`,bgColor:`bg-amber-500/20`,borderColor:`border-amber-500`,label:`Reasoning`},"agent.delegation":{color:`text-orange-500`,bgColor:`bg-orange-500/20`,borderColor:`border-orange-500`,label:`Agent Delegation`},"agent.async":{color:`text-orange-500`,bgColor:`bg-orange-500/20`,borderColor:`border-orange-500`,label:`Async Agent`},"yielded.run":{color:`text-[#11a4d4]`,bgColor:`bg-[#11a4d4]/20`,borderColor:`border-[#11a4d4]`,label:`Yielded Run`},"user.prompt":{color:`text-cyan-500`,bgColor:`bg-cyan-500/20`,borderColor:`border-cyan-500`,label:`User Prompt`},user_input:{color:`text-slate-500`,bgColor:`bg-slate-800`,borderColor:`border-slate-600`,label:`User Input`},"execution.command":{color:`text-yellow-500`,bgColor:`bg-yellow-500/20`,borderColor:`border-yellow-500`,label:`Command`}},l5=12;function u5(e,t){return t===`all`||e<t}(0,R.memo)(function e({span:t,startTime:n,depth:r=0,expansionDepth:i,expansionSignal:a,expandThinking:o,onFork:s,onOpenSession:c}){let[l,u]=(0,R.useState)(()=>u5(r,i)),[d,f]=(0,R.useState)(()=>t.spanType===`model.reasoning`?o:u5(r,i));(0,R.useEffect)(()=>{let e=u5(r,i);u(e),f(t.spanType===`model.reasoning`?o:e)},[r,i,a,o,t.spanType]),c5[t.spanType]||c5[`agent.run`],t.status,t.status,t.spanType===`user.prompt`||t.spanType;let p=!!t.children?.length;return p5(t.startTime,n),t.durationUs?`${(t.durationUs/1e3).toFixed(1)}`:t.endTime&&`${((t.endTime-t.startTime)/1e3).toFixed(1)}`,(0,z.jsx)(INe,{span:t,startTime:n,depth:r,contentExpanded:d,childrenExpanded:l,onToggle:(0,R.useCallback)(()=>{f(e=>!e),p&&u(e=>!e)},[p]),onFork:s,onOpenSession:c,childrenContent:p?t.children?.map(t=>(0,z.jsx)(e,{span:t,startTime:n,depth:r+1,expansionDepth:i,expansionSignal:a,expandThinking:o,onFork:s,onOpenSession:c},t.id)):void 0})});var INe=(0,R.memo)(function({span:e,startTime:t,depth:n=0,contentExpanded:r,childrenExpanded:i,onToggle:a,onFork:o,onOpenSession:s,childrenContent:c}){let l=c5[e.spanType]||c5[`agent.run`],u=e.status===`UNSET`,d=WNe(e.status,u),f=e.spanType===`user.prompt`||e.spanType===`user_input`,p=!!e.children?.length,m=p5(e.startTime,t),h=e.durationUs?`${(e.durationUs/1e3).toFixed(1)}ms`:e.endTime?`${((e.endTime-e.startTime)/1e3).toFixed(1)}ms`:null;return(0,z.jsx)(`div`,{className:`relative mb-4 group`,style:{marginLeft:n>0?l5:0,width:n>0?`calc(100% - ${l5}px)`:`var(--trace-readable-width)`,maxWidth:`100%`},children:(0,z.jsxs)(`div`,{className:`min-w-0 ${f?`bg-[#11a4d4]/10`:`bg-white dark:bg-[#1a262b]`} border ${d.cardClass} rounded-sm shadow-sm transition-all hover:border-opacity-70 focus:outline-none focus:ring-1 focus:ring-[#11a4d4]/50 ${u?d.glowClass:``}`,onDoubleClick:e=>{d5(e)||a()},onKeyDown:e=>{d5(e)||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a())},role:`button`,tabIndex:0,"aria-expanded":r,children:[(0,z.jsx)(LNe,{span:e,config:l,statusStyles:d,isActive:u,contentExpanded:r,duration:h,relativeTime:m,onToggle:a,onFork:o,onOpenSession:s}),r?(0,z.jsx)(BNe,{span:e}):null,p&&i&&r?(0,z.jsx)(`div`,{className:`min-w-0 border-t border-slate-700 bg-slate-900/50 py-4`,children:c}):null]})})});function d5(e){let t=e.target;if(!(t instanceof Element)||t===e.currentTarget)return!1;let n=t.closest(`button, a, input, textarea, select, summary, [role='button'], [tabindex]:not([tabindex='-1'])`);return!!(n&&n!==e.currentTarget)}function LNe({span:e,config:t,statusStyles:n,isActive:r,contentExpanded:i,duration:a,relativeTime:o,onToggle:s,onFork:c,onOpenSession:l}){let u=e.spanType===`user.prompt`||e.spanType===`user_input`?`bg-[#11a4d4]/10`:n.headerClass;return(0,z.jsx)(`div`,{className:`${i?`border-b ${t.borderColor}/20`:``} ${u}`,children:(0,z.jsxs)(`div`,{className:`box-border flex w-full min-w-0 items-center`,style:{maxWidth:`100%`},children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1 px-4 py-2 text-left`,children:(0,z.jsxs)(`span`,{className:`min-w-0 text-xs font-bold ${t.color} uppercase tracking-wider flex items-center gap-2`,children:[i?(0,z.jsx)(zo,{size:12}):(0,z.jsx)(Bo,{size:12}),(0,z.jsx)(RNe,{spanType:e.spanType,config:t,isActive:r}),(0,z.jsx)(`span`,{className:`shrink-0`,children:t.label}),e.name?(0,z.jsxs)(`span`,{className:`min-w-0 truncate font-normal text-slate-500 dark:text-slate-400 normal-case`,children:[`: `,e.name]}):null,r?(0,z.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-[#11a4d4] animate-pulse`}):null]})}),(0,z.jsx)(VNe,{forkEntryId:e.pibo?.traceNodeType===`user.message`?e.pibo.entryId:void 0,linkedPiboSessionId:e.pibo?.linkedPiboSessionId,onFork:c,onOpenSession:l}),(0,z.jsx)(zNe,{duration:a,relativeTime:o})]})})}function RNe({spanType:e,config:t,isActive:n}){return(0,z.jsxs)(`span`,{className:`relative inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full ${t.bgColor} border-2 ${t.borderColor} ${n?`shadow-[0_0_10px_rgba(17,164,212,0.4)]`:``}`,children:[(0,z.jsx)(UNe,{type:e,className:t.color}),n?(0,z.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full bg-[#11a4d4] animate-pulse`}):null]})}function zNe({duration:e,relativeTime:t}){return(0,z.jsxs)(`div`,{className:`ml-2 mr-4 flex w-36 shrink-0 items-center justify-end gap-2 font-mono tabular-nums`,children:[e?(0,z.jsx)(`span`,{className:`text-[10px] text-slate-500 dark:text-slate-400`,children:e}):null,(0,z.jsx)(`span`,{className:`text-xs text-slate-400 dark:text-slate-500`,children:t})]})}var BNe=(0,R.memo)(function({span:e}){let[t,n]=(0,R.useState)(!1),{spanType:r,attributes:i,name:a}=e,o=i.content||i.input||i.output||i.message,s=i.tool_name||i.tool?.name||i[`tool.name`],c=typeof s==`string`?s:null,l=i.output||i.result||i[`tool.result`],u=i.arguments||i.args||i[`tool.arguments`],d=e.status===`ERROR`?(0,z.jsxs)(`div`,{className:`mx-4 mt-4 p-3 bg-red-500/10 border border-red-500/20 rounded-sm text-xs`,children:[(0,z.jsx)(`div`,{className:`flex items-center gap-2 font-semibold text-red-500 mb-1`,children:`Error`}),e.statusMessage?(0,z.jsx)(`div`,{className:`font-mono text-red-400 mb-2`,children:e.statusMessage}):null]}):null;if(r===`user.prompt`||r===`user_input`)return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsx)(`div`,{className:`min-w-0 break-words p-4 font-mono text-sm text-slate-300 whitespace-pre-wrap`,children:typeof o==`string`?o:JSON.stringify(o)})]});if(r===`model.response`)return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsx)(`div`,{className:`model-response-markdown min-w-0 p-4 text-sm text-slate-200 leading-relaxed`,children:typeof o==`string`?(0,z.jsx)(BW,{children:o}):(0,z.jsx)(yq,{value:o})})]});if(r===`tool.result`)return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsxs)(`div`,{className:`p-4 bg-green-500/5 border-t border-green-500/20`,children:[(0,z.jsxs)(`div`,{className:`text-xs font-medium text-green-400 mb-2`,children:[`Returned from `,c||a,`:`]}),(0,z.jsx)(yq,{value:l??o})]})]});if(r===`tool.call`){let e=m5(u)?u:{},r=Object.keys(e).length>0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`p-4 bg-[#0e1116] border-b border-slate-800`,children:(0,z.jsx)(HNe,{name:c??a,args:e})}),l==null?null:(0,z.jsxs)(`div`,{className:`px-4 py-2 bg-[#1a262b] flex items-center gap-2`,children:[(0,z.jsx)(Eo,{size:14,className:`text-slate-400`}),(0,z.jsx)(`span`,{className:`text-xs font-mono text-slate-500`,children:`Output:`}),(0,z.jsx)(`code`,{className:`min-w-0 max-w-md truncate text-xs font-mono text-slate-300`,children:typeof l==`string`?l.slice(0,100):JSON.stringify(l).slice(0,100)})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`w-full px-4 py-1.5 flex items-center gap-1.5 text-[11px] font-medium text-slate-400 hover:text-slate-200 bg-slate-900/40 hover:bg-slate-800/60 border-t border-slate-700/40 transition-colors`,children:[t?(0,z.jsx)(is,{size:12}):(0,z.jsx)(as,{size:12}),t?`Hide Details`:`Show Details`]}),t?(0,z.jsxs)(`div`,{className:`border-t border-slate-700/40 bg-[#0e1116]`,children:[r?(0,z.jsxs)(`div`,{className:`px-4 pt-3 pb-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-blue-400 uppercase tracking-wider mb-1.5`,children:`Input`}),(0,z.jsx)(yq,{value:e})]}):null,l==null?null:(0,z.jsxs)(`div`,{className:`px-4 pt-2 pb-3 border-t border-slate-700/30`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-semibold text-green-400 uppercase tracking-wider mb-1.5`,children:`Output`}),(0,z.jsx)(yq,{value:l})]})]}):null,d]})}if(r===`yielded.run`){let e=m5(l)?l:m5(o)?o:{};return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsxs)(`div`,{className:`p-4 border-b border-[#11a4d4]/20 bg-[#11a4d4]/5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(Oo,{size:14,className:`text-[#11a4d4]`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-[#11a4d4]`,children:`Run notification`}),(0,z.jsx)(`span`,{className:`text-xs font-mono text-slate-400`,children:typeof i.content==`string`?i.content:a})]}),(0,z.jsx)(GNe,{notification:e})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),className:`w-full px-4 py-1.5 flex items-center gap-1.5 text-[11px] font-medium text-slate-400 hover:text-slate-200 bg-slate-900/40 hover:bg-slate-800/60 border-t border-slate-700/40 transition-colors`,children:[t?(0,z.jsx)(is,{size:12}):(0,z.jsx)(as,{size:12}),t?`Hide Details`:`Show Details`]}),t?(0,z.jsx)(`div`,{className:`border-t border-slate-700/40 bg-[#0e1116] px-4 py-3`,children:(0,z.jsx)(yq,{value:e})}):null]})}if(r===`model.reasoning`){let e=i.reasoning||i[`model.reasoning`]||o;return(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsxs)(`div`,{className:`min-w-0 break-words p-4 font-mono text-sm text-slate-300 bg-amber-500/5 leading-relaxed whitespace-pre-wrap`,children:[(0,z.jsx)(`span`,{className:`text-amber-500 opacity-60`,children:`// Model reasoning`}),(0,z.jsx)(`br`,{}),typeof e==`string`?e:JSON.stringify(e,null,2)]})]})}if(r===`agent.delegation`){let e=i[`delegation.target_agent`],t=i[`delegation.query`],n=i[`result.status`];return(0,z.jsxs)(z.Fragment,{children:[d,(0,z.jsxs)(`div`,{className:`p-4 border-b border-orange-500/20 bg-orange-500/5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,z.jsx)(fs,{size:14,className:`text-orange-500`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-orange-500`,children:`Delegated to:`}),(0,z.jsxs)(`span`,{className:`text-sm font-semibold text-slate-200`,children:[e||`unknown`,` agent`]}),n?(0,z.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-[10px] font-bold rounded-sm bg-green-500/20 text-green-500`,children:n.toUpperCase()}):null]}),t?(0,z.jsxs)(`div`,{className:`text-xs text-slate-400 font-mono italic line-clamp-2`,children:[`"`,h5(t),`"`]}):null]})]})}if(r===`agent.async`){let e=i[`async_agent.target_agent`],t=i[`async_agent.query`],n=i[`async_agent.started_by`],r=i.run_id,a=i[`result.status`];return(0,z.jsxs)(z.Fragment,{children:[d,(0,z.jsxs)(`div`,{className:`p-4 border-b border-orange-500/20 bg-orange-500/5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-2`,children:[(0,z.jsx)(fs,{size:14,className:`text-orange-500`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-orange-500`,children:`Async agent started:`}),(0,z.jsxs)(`span`,{className:`text-sm font-semibold text-slate-200`,children:[e||`unknown`,` agent`]}),a?(0,z.jsx)(`span`,{className:`px-2 py-0.5 text-[10px] font-bold rounded-sm bg-orange-500/15 text-orange-400`,children:a.toUpperCase()}):null]}),(0,z.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-x-3 gap-y-1 font-mono text-[11px] text-slate-500`,children:[(0,z.jsxs)(`span`,{children:[`Started by `,n||`pibo_run_start`]}),r?(0,z.jsx)(`span`,{children:r}):null]}),t?(0,z.jsxs)(`div`,{className:`text-xs text-slate-400 font-mono italic line-clamp-2`,children:[`"`,h5(t),`"`]}):null]})]})}return r===`agent.run`?(0,z.jsx)(`div`,{className:`flex flex-col`,children:d}):(0,z.jsxs)(`div`,{className:`flex flex-col`,children:[d,(0,z.jsx)(`div`,{className:`p-4 font-mono text-sm text-slate-300`,children:(0,z.jsx)(yq,{value:i})})]})});function VNe({forkEntryId:e,linkedPiboSessionId:t,onFork:n,onOpenSession:r}){let i=e&&n?e:void 0,a=t&&r?t:void 0;return!i&&!a?null:(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[i?(0,z.jsx)(`button`,{type:`button`,onClick:()=>n?.(i),className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 bg-[#151f24]/80 text-slate-400 transition-colors hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Fork user message`,"aria-label":`Fork user message`,children:(0,z.jsx)(fs,{size:14})}):null,a?(0,z.jsx)(`button`,{type:`button`,onClick:()=>r?.(a),className:`inline-flex h-8 w-8 items-center justify-center rounded-sm border border-slate-700 bg-[#151f24]/80 text-slate-400 transition-colors hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Open child session`,"aria-label":`Open child session`,children:(0,z.jsx)(rs,{size:14})}):null]})}function HNe({name:e,args:t}){return(0,z.jsxs)(`code`,{className:`font-mono text-xs text-green-400`,children:[(0,z.jsx)(`span`,{className:`text-purple-400`,children:`def`}),` `,(0,z.jsx)(`span`,{className:`text-yellow-300`,children:e}),(0,z.jsxs)(`span`,{children:[`(`,Object.entries(t).map(([e,t],n)=>(0,z.jsxs)(`span`,{children:[n>0?`, `:null,(0,z.jsx)(`span`,{className:`text-blue-400`,children:e}),`=`,(0,z.jsx)(`span`,{className:`text-green-300`,children:typeof t==`string`?`'${t.slice(0,50)}${t.length>50?`...`:``}'`:h5(t).slice(0,50)})]},e)),`)`]})]})}function UNe({type:e,className:t}){let n={size:14,className:t};switch(e){case`agent.run`:return(0,z.jsx)(Po,{...n});case`tool.call`:return(0,z.jsx)(ko,{...n});case`tool.result`:return(0,z.jsx)(Eo,{...n});case`model.request`:return(0,z.jsx)(Mo,{...n});case`model.response`:return(0,z.jsx)(Eo,{...n});case`model.reasoning`:return(0,z.jsx)(ys,{...n});case`agent.delegation`:return(0,z.jsx)(fs,{...n});case`agent.async`:return(0,z.jsx)(fs,{...n});case`yielded.run`:return(0,z.jsx)(Oo,{...n});case`user.prompt`:return(0,z.jsx)(Os,{...n});case`user_input`:return(0,z.jsx)(Xs,{...n});case`execution.command`:return(0,z.jsx)(ko,{...n});default:return(0,z.jsx)(Ro,{...n})}}function WNe(e,t){return e===`ERROR`?{cardClass:`border-[#ff6b00]/50`,headerClass:`bg-[#ff6b00]/5`,glowClass:``}:e===`OK`?{cardClass:`border-[#0bda57]/30`,headerClass:`bg-[#0bda57]/5`,glowClass:``}:t?{cardClass:`border-[#11a4d4]/50`,headerClass:`bg-[#11a4d4]/5`,glowClass:`shadow-[0_0_10px_rgba(17,164,212,0.1)]`}:{cardClass:`border-slate-700`,headerClass:`bg-[#151f24]`,glowClass:``}}function GNe({notification:e}){let t=[[`completed`,`text-green-500`,e.completed],[`failed`,`text-red-400`,e.failed],[`cancelled`,`text-slate-400`,e.cancelled],[`running`,`text-[#11a4d4]`,e.running]].map(([e,t,n])=>({name:e,color:t,runs:Array.isArray(n)?n.filter(m5):[]})).filter(e=>e.runs.length>0);return t.length===0?(0,z.jsx)(`div`,{className:`text-xs text-slate-400`,children:`No yielded run updates.`}):(0,z.jsx)(`div`,{className:`grid gap-2`,children:t.map(e=>(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-wider ${e.color}`,children:e.name}),(0,z.jsx)(`div`,{className:`grid gap-1`,children:e.runs.map((t,n)=>(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2 rounded-sm border border-slate-700/60 bg-[#0e1116]/60 px-2 py-1.5`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate font-mono text-xs text-slate-200`,children:f5(t.toolName)||`yielded tool`}),(0,z.jsx)(`div`,{className:`truncate font-mono text-[10px] text-slate-500`,children:f5(t.runId)})]}),(0,z.jsx)(`div`,{className:`font-mono text-[10px] uppercase text-slate-400`,children:f5(t.status)||e.name})]},`${e.name}-${n}`))})]},e.name))})}function f5(e){return typeof e==`string`?e:``}function p5(e,t){let n=(e-t)/1e3,r=Math.floor(n/6e4),i=Math.floor(n%6e4/1e3),a=Math.floor(n%1e3);return`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}.${String(a).padStart(3,`0`)}`}function m5(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function h5(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function g5(e){if(e==null)return{kind:`empty`};let t=_5(e);return t===void 0?{kind:`json`,value:e}:{kind:`text`,text:t}}function _5(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=e.map(_5).filter(e=>e!==void 0);return t.length===e.length&&t.length>0?t.join(``):void 0}if(!v5(e))return;let t=typeof e.type==`string`?e.type:void 0;if(t===`text`&&typeof e.text==`string`)return e.text;if(t===`text`&&typeof e.content==`string`)return e.content;if(t===`output_text`&&typeof e.text==`string`)return e.text;let n=_5(e.content);if(n!==void 0&&KNe(e))return n;let r=v5(e.message)?_5(e.message.content):void 0;if(r!==void 0)return r}function KNe(e){let t=Object.keys(e).filter(t=>e[t]!==void 0);return t.length===1&&t[0]===`content`||t.every(e=>e===`content`||e===`type`)||t.every(e=>e===`content`||e===`details`||e===`type`)?!0:typeof e.type==`string`&&e.type.includes(`text`)}function v5(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function qNe({row:e,onOpenSession:t}){return(0,z.jsx)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-shared-terminal-details":e.kind,children:e.detailItems?.length?(0,z.jsx)(`div`,{className:`space-y-3`,children:e.detailItems.map(e=>(0,z.jsxs)(`div`,{className:`space-y-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`font-semibold text-[#d4d4d4]`,children:e.label}),e.linkedPiboSessionId?(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.linkedPiboSessionId),className:`border border-[#3a3a3a] px-2 py-0.5 text-[#38bdf8] hover:border-[#38bdf8]`,children:`Open Session`}):null]}),(0,z.jsx)(y5,{label:`Input`,value:e.input}),(0,z.jsx)(y5,{label:`Output`,value:e.output}),(0,z.jsx)(b5,{value:e.output}),e.error?(0,z.jsx)(S5,{label:`Error`,value:e.error,tone:`red`}):null]},e.id))}):(0,z.jsxs)(`div`,{className:`space-y-3`,children:[(0,z.jsx)(y5,{label:`Input`,value:e.input}),(0,z.jsx)(y5,{label:`Output`,value:e.output}),(0,z.jsx)(b5,{value:e.output}),e.error?(0,z.jsx)(S5,{label:`Error`,value:e.error,tone:`red`}):null,e.linkedPiboSessionId?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`Child session`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.linkedPiboSessionId),className:`border border-[#3a3a3a] px-2 py-0.5 text-[#38bdf8] hover:border-[#38bdf8]`,children:e.linkedPiboSessionId})]}):null]})})}function y5({label:e,value:t}){let n=g5(t);if(n.kind===`empty`)return null;if(n.kind===`text`){let t=C5(n.text);return t?.kind===`json`?(0,z.jsx)(x5,{label:e,value:t.value,meta:t.meta}):t?.kind===`text`?(0,z.jsx)(S5,{label:e,value:t.text}):(0,z.jsx)(S5,{label:e,value:n.text})}return(0,z.jsx)(x5,{label:e,value:n.value})}function b5({value:e}){let t=JNe(e);return t?(0,z.jsxs)(`details`,{className:`space-y-1 border border-[#2a2a2a] bg-[#0b0b0b] p-2`,children:[(0,z.jsxs)(`summary`,{className:`cursor-pointer text-[11px] font-semibold text-[#38bdf8]`,children:[`Show full output (`,t.originalLines,` lines)`]}),t.fullOutput?(0,z.jsx)(`pre`,{className:`mt-2 max-h-[520px] overflow-auto whitespace-pre-wrap break-words font-mono text-[12px] leading-[1.45] text-[#d4d4d4]`,children:t.fullOutput}):t.fullOutputPath?(0,z.jsxs)(`div`,{className:`mt-2 min-w-0 break-words font-mono text-[12px] text-[#d4d4d4]`,children:[`Full output file: `,t.fullOutputPath]}):null]}):null}function JNe(e){if(!E5(e))return;let t=E5(e.details)?e.details.piboBashOutputCompaction:void 0;if(!E5(t)||t.kind!==`validation-output`)return;let n=typeof t.originalLines==`number`?t.originalLines:void 0;if(n!==void 0)return{originalLines:n,fullOutput:typeof t.fullOutput==`string`?t.fullOutput:void 0,fullOutputPath:typeof t.fullOutputPath==`string`?t.fullOutputPath:void 0}}function x5({label:e,value:t,meta:n}){return(0,z.jsxs)(`div`,{className:`space-y-1`,"data-shared-terminal-detail-json":e,children:[(0,z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-semibold text-[#737373]`,"data-shared-terminal-detail-label":e,children:e}),n?(0,z.jsxs)(`div`,{className:`min-w-0 break-words text-[11px] text-[#737373]`,children:[`Status: `,n]}):null]}),(0,z.jsx)(`div`,{className:`compact-terminal-json border border-[#2a2a2a] bg-[#0b0b0b] p-2`,children:(0,z.jsx)(yq,{value:t,showControls:!1})})]})}function S5({label:e,value:t,tone:n=`default`}){return(0,z.jsxs)(`div`,{className:`space-y-1`,"data-shared-terminal-detail-text":e,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-semibold text-[#737373]`,"data-shared-terminal-detail-label":e,children:e}),(0,z.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words border border-[#2a2a2a] bg-[#0b0b0b] p-2 font-mono text-[12px] leading-[1.45] ${n===`red`?`text-[#ef4444]`:`text-[#d4d4d4]`}`,children:t})]})}function C5(e){let t=e.trim();if(!t)return;let n=T5(t);if(n!==void 0)return w5(n);let r=t.split(/\r?\n/);for(let e=1;e<r.length;e+=1){let t=r.slice(e).join(`
|
|
165
165
|
`).trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))continue;let n=T5(t);if(n!==void 0)return w5(n,r.slice(0,e).join(` `).trim()||void 0)}}function w5(e,t){let n=g5(e);if(n.kind===`text`){let e=C5(n.text);return e?.kind===`json`?{...e,meta:e.meta??t}:{kind:`text`,text:n.text}}return{kind:`json`,value:e,meta:t}}function T5(e){if(!(!e.startsWith(`{`)&&!e.startsWith(`[`)))try{let t=JSON.parse(e);return typeof t==`object`&&t?t:void 0}catch{return}}function E5(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function YNe({name:e,input:t}){return(0,z.jsxs)(`span`,{className:`compact-terminal-function-call`,children:[(0,z.jsx)(`span`,{className:`text-[#facc15] font-semibold`,children:e}),(0,z.jsx)(`span`,{className:`text-[#d4d4d4]`,children:`(`}),t===void 0?null:(0,z.jsx)(XNe,{value:t}),(0,z.jsx)(`span`,{className:`text-[#d4d4d4]`,children:`)`})]})}function XNe({value:e}){let[t,n]=(0,R.useState)(()=>new Set([`$`])),[r,i]=(0,R.useState)(()=>new Set);return(0,z.jsx)(D5,{value:e,path:`$`,expandedPaths:t,expandedStrings:r,onTogglePath:e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},onToggleString:e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}})}function D5({value:e,path:t,expandedPaths:n,expandedStrings:r,onTogglePath:i,onToggleString:a}){if(Array.isArray(e))return(0,z.jsx)(O5,{value:e,path:t,open:`[`,close:`]`,expandedPaths:n,expandedStrings:r,onTogglePath:i,onToggleString:a});if(QNe(e))return(0,z.jsx)(O5,{value:e,path:t,open:`{`,close:`}`,expandedPaths:n,expandedStrings:r,onTogglePath:i,onToggleString:a});if(typeof e==`string`){let n=r.has(t),i=e.length>140&&!n,o=i?`${e.slice(0,140)}...`:e,s=(0,z.jsx)(`span`,{className:`text-[#fb923c]`,children:JSON.stringify(o)});return!i&&e.length<=140?s:(0,z.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a(t)},className:`compact-terminal-json-toggle text-left align-baseline`,title:n?`Collapse string`:`Expand string`,children:s})}return typeof e==`number`||typeof e==`boolean`||e===null?(0,z.jsx)(`span`,{className:`text-[#60a5fa]`,children:String(e)}):(0,z.jsx)(`span`,{className:`text-[#737373]`,children:JSON.stringify(String(e))})}function O5({value:e,path:t,open:n,close:r,expandedPaths:i,expandedStrings:a,onTogglePath:o,onToggleString:s}){let c=Array.isArray(e)?e.map((e,t)=>[String(t),e]):Object.entries(e);return i.has(t)?(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t)},className:`compact-terminal-json-toggle align-baseline text-[#737373]`,title:`Collapse JSON`,"aria-label":`Collapse JSON at ${t}`,"data-inline-json-path":t,children:[(0,z.jsx)(`span`,{className:`compact-terminal-json-caret`,children:`▾`}),n]}),c.map(([n,r],c)=>{let l=`${t}.${ZNe(n)}`;return(0,z.jsxs)(`span`,{children:[c>0?(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`, `}):null,Array.isArray(e)?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{className:`text-[#d4d4d4]`,children:JSON.stringify(n)}),(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`:`})]}),(0,z.jsx)(D5,{value:r,path:l,expandedPaths:i,expandedStrings:a,onTogglePath:o,onToggleString:s})]},l)}),(0,z.jsx)(`span`,{className:`text-[#737373]`,children:r})]}):(0,z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(t)},className:`compact-terminal-json-toggle align-baseline text-[#737373]`,title:`Expand JSON`,"aria-label":`Expand JSON at ${t}`,"data-inline-json-path":t,children:[(0,z.jsx)(`span`,{className:`compact-terminal-json-caret`,children:`▸`}),n,`...`,r]})}function ZNe(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`.`,`\\.`)}function QNe(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $Ne({line:e,status:t,clampLines:n}){let r=`min-w-0 whitespace-pre-wrap break-words ${n?`block overflow-hidden`:``}`;return(0,z.jsxs)(`div`,{className:`grid grid-cols-[1.9rem_minmax(0,1fr)] gap-2 leading-[1.45]`,children:[(0,z.jsx)(`span`,{className:`whitespace-pre ${tPe(e.prefix,t)}`,children:ePe(e.prefix)}),(0,z.jsxs)(`span`,{className:r,style:n?{maxHeight:`${n*1.45}em`}:void 0,children:[e.tokens.map((e,t)=>(0,z.jsx)(`span`,{className:nPe(e),children:e.text},`${t}:${e.text}`)),e.functionCall?(0,z.jsx)(YNe,{name:e.functionCall.name,input:e.functionCall.input}):null]})]})}function ePe(e=`none`){switch(e){case`bullet`:return`•`;case`detail`:return`└`;case`continuation`:return` `;case`prompt`:return`›`;default:return` `}}function tPe(e=`none`,t){if(e===`bullet`){if(t===`running`)return`text-[#38bdf8]`;if(t===`error`)return`text-[#ef4444]`;if(t===`done`)return`text-[#22c55e]`}return`text-[#737373]`}function nPe(e){return`${e.tone===`dim`?`text-[#737373]`:e.tone===`cyan`?`text-[#38bdf8]`:e.tone===`green`?`text-[#22c55e]`:e.tone===`red`?`text-[#ef4444]`:e.tone===`magenta`?`text-[#d946ef]`:e.tone===`yellow`?`text-[#facc15]`:e.tone===`blue`?`text-[#60a5fa]`:e.tone===`amber`?`text-[#f59e0b]`:`text-[#d4d4d4]`} ${e.weight===`bold`?`font-bold`:e.weight===`semibold`?`font-semibold`:`font-normal`} ${e.italic?`italic`:``}`.trim()}async function rPe(){await fetch(`/api/auth/sign-out`,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:`{}`})}async function iPe(){let e=location.pathname.startsWith(`/apps/chat`)?`${location.pathname}${location.search}`:`/apps/chat`,t=await fetch(`/api/auth/sign-in/social`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provider:`google`,callbackURL:e,disableRedirect:!0})}),n=await t.json();if(!t.ok||!n.url)throw Error(n.message||n.error||`Could not start Google sign in.`);location.href=n.url}function aPe(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.action===`show_login_menu`&&Array.isArray(t.providers)}function oPe(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=e;return t.action===`show_model_menu`&&Array.isArray(t.providers)}function k5(e){return sPe(e)?e.result:e}function sPe(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&e.type===`execution_result`}var cPe={device_code:`Device code`,api_key:`API key`,oauth:`Browser OAuth`};function lPe({row:e,piboSessionId:t}){let n=aPe(e.output)?e.output:void 0,r=(0,R.useMemo)(()=>n?.providers??[],[n?.providers]),[i,a]=(0,R.useState)({type:`select_provider`}),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(null),m=(0,R.useCallback)(()=>{a({type:`select_provider`}),l(``),d(``)},[]),h=(0,R.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),p(e),window.setTimeout(()=>p(t=>t===e?null:t),1600)}catch{}},[]),g=(0,R.useCallback)(async e=>{if(!t){a({type:`error`,provider:e,message:`Select a chat session before starting login.`});return}s(!0),a({type:`device_starting`,provider:e});try{let n=k5(await yc(t,`login.start`,{provider:e.id}));if(!n?.url){a({type:`error`,provider:e,message:`No login URL returned.`});return}a({type:`device_flow`,provider:e,url:n.url,state:n.state,userCode:n.userCode,instructions:n.instructions})}catch(t){a({type:`error`,provider:e,message:t instanceof Error?t.message:String(t)})}finally{s(!1)}},[t]),_=(0,R.useCallback)(async(e,n,r)=>{if(t){s(!0);try{await yc(t,`login.complete`,{provider:e.id,state:n??``,...r?{code:r}:{}}),a({type:`success`,provider:e,message:`${e.name} login completed.`})}catch(t){a({type:`error`,provider:e,message:t instanceof Error?t.message:String(t)})}finally{s(!1)}}},[t]),v=(0,R.useCallback)(async e=>{if(!t)return;let n=c.trim();if(n){s(!0);try{await yc(t,`login.apikey`,{provider:e.id,apiKey:n}),l(``),a({type:`success`,provider:e,message:`${e.name} API key saved.`})}catch(t){a({type:`error`,provider:e,message:t instanceof Error?t.message:String(t)})}finally{s(!1)}}},[c,t]);return n?(0,z.jsx)(A5,{title:i.type===`select_provider`?`Login`:dPe(i),tone:i.type===`error`?`red`:i.type===`success`?`green`:`cyan`,action:i.type===`select_provider`?void 0:(0,z.jsx)(uPe,{onClick:m,disabled:o}),children:i.type===`select_provider`?(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`text-[11px] text-[#737373]`,children:[`Choose a provider. Use `,(0,z.jsx)(`span`,{className:`text-[#38bdf8]`,children:`/login`}),` anytime.`]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a({type:`select_method`,provider:e}),className:`inline-flex items-center gap-1 border border-[#3a3a3a] bg-transparent px-2 py-1 text-[11px] text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8]`,children:[(0,z.jsx)(`span`,{children:e.name}),e.configured?(0,z.jsx)(`span`,{className:`text-[#22c55e]`,children:`●`}):null]},e.id))})]}):i.type===`select_method`?(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`Provider:`}),(0,z.jsx)(`span`,{className:`text-[#d4d4d4]`,children:i.provider.name}),i.provider.configured?(0,z.jsx)(j5,{tone:`green`,children:`Configured`}):(0,z.jsx)(j5,{tone:`neutral`,children:`Not configured`})]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.provider.authMethods.map(e=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>e===`api_key`?a({type:`api_key`,provider:i.provider}):void g(i.provider),className:`inline-flex items-center gap-1 border border-[#3a3a3a] bg-transparent px-2 py-1 text-[11px] text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8]`,children:[e===`api_key`?(0,z.jsx)(gs,{size:11}):(0,z.jsx)(Ts,{size:11}),cPe[e]]},e))})]}):i.type===`device_starting`?(0,z.jsxs)(`div`,{className:`inline-flex items-center gap-2 text-[11px] text-[#38bdf8]`,children:[(0,z.jsx)(Cs,{size:13,className:`animate-spin`}),` Starting device login...`]}):i.type===`device_flow`?(0,z.jsxs)(`div`,{className:`grid gap-2 text-[11px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`Open:`}),(0,z.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[#38bdf8] hover:underline`,children:[fPe(i.url),` `,(0,z.jsx)(rs,{size:11})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void h(i.url),className:`inline-flex items-center gap-1 border border-[#3a3a3a] px-1.5 py-0.5 text-[#737373] hover:border-[#38bdf8] hover:text-[#38bdf8]`,children:[f===i.url?(0,z.jsx)(qo,{size:10}):(0,z.jsx)($o,{size:10}),` `,f===i.url?`Copied`:`Copy`]})]}),i.userCode?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`Code:`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void h(i.userCode),className:`border border-[#1f4960] px-2 py-0.5 font-semibold tracking-widest text-[#38bdf8] hover:border-[#38bdf8]`,children:i.userCode}),(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`then`}),(0,z.jsxs)(`button`,{type:`button`,disabled:o,onClick:()=>void _(i.provider,i.state),className:`inline-flex items-center gap-1 border border-[#3a3a3a] px-2 py-0.5 text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8] disabled:opacity-50`,children:[o?(0,z.jsx)(Cs,{size:11,className:`animate-spin`}):(0,z.jsx)(qo,{size:11}),` Complete`]})]}):(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`authorization code`,className:`min-w-0 flex-1 border border-[#2a2a2a] bg-[#0b0b0b] px-2 py-1 text-[11px] text-[#d4d4d4] outline-none focus:border-[#38bdf8]`}),(0,z.jsxs)(`button`,{type:`button`,disabled:o||!u.trim(),onClick:()=>void _(i.provider,i.state,u.trim()),className:`inline-flex items-center gap-1 border border-[#3a3a3a] px-2 py-1 text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8] disabled:opacity-50`,children:[o?(0,z.jsx)(Cs,{size:11,className:`animate-spin`}):(0,z.jsx)(qo,{size:11}),` Complete`]})]}),i.instructions?(0,z.jsx)(`div`,{className:`text-[#737373]`,children:i.instructions}):null]}):i.type===`api_key`?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`API key:`}),(0,z.jsx)(`input`,{type:`password`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v(i.provider)},placeholder:`sk-...`,className:`min-w-[12rem] flex-1 border border-[#2a2a2a] bg-[#0b0b0b] px-2 py-1 text-[11px] text-[#d4d4d4] outline-none focus:border-[#38bdf8]`}),(0,z.jsxs)(`button`,{type:`button`,disabled:o||!c.trim(),onClick:()=>void v(i.provider),className:`inline-flex items-center gap-1 border border-[#3a3a3a] px-2 py-1 text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8] disabled:opacity-50`,children:[o?(0,z.jsx)(Cs,{size:11,className:`animate-spin`}):(0,z.jsx)(qo,{size:11}),` Save`]})]}):i.type===`success`?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-[#22c55e]`,children:[(0,z.jsx)(qo,{size:13}),` `,i.message]}):(0,z.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] text-[#ef4444]`,children:[(0,z.jsx)(Go,{size:13,className:`mt-0.5 shrink-0`}),` `,(0,z.jsx)(`span`,{children:i.message})]})}):(0,z.jsx)(A5,{title:`Login`,tone:`red`,children:`Unparseable login payload.`})}function A5({title:e,tone:t,action:n,children:r}){return(0,z.jsxs)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-shared-terminal-card":`login`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(Ts,{size:14,className:t===`red`?`text-[#ef4444]`:t===`green`?`text-[#22c55e]`:`text-[#38bdf8]`}),(0,z.jsx)(`span`,{className:`font-semibold text-[#d4d4d4]`,children:e}),n?(0,z.jsx)(`div`,{className:`ml-auto`,children:n}):null]}),r]})}function uPe({onClick:e,disabled:t}){return(0,z.jsxs)(`button`,{type:`button`,disabled:t,onClick:e,className:`inline-flex items-center gap-1 border border-[#3a3a3a] bg-transparent px-1.5 py-0.5 text-[11px] text-[#737373] hover:border-[#38bdf8] hover:text-[#38bdf8] disabled:opacity-50`,children:[(0,z.jsx)(Do,{size:10}),` Back`]})}function j5({tone:e,children:t}){return(0,z.jsx)(`span`,{className:`border px-1.5 py-0.5 text-[10px] ${e===`green`?`border-[#14532d] text-[#22c55e]`:`border-[#3a3a3a] text-[#737373]`}`,children:t})}function dPe(e){return`provider`in e&&e.provider?e.provider.name:`Login`}function fPe(e){try{let t=new URL(e);return`${t.host}${t.pathname}`}catch{return e.length>42?`${e.slice(0,39)}...`:e}}function pPe({row:e,piboSessionId:t,onModelChanged:n}){let r=k5(e.output),i=(oPe(r)?r:void 0)?.providers??[],a=(0,R.useMemo)(()=>i.flatMap(e=>e.models.map(t=>({...t,providerLabel:e.label}))),[i]),[o,s]=(0,R.useState)(``),[c,l]=(0,R.useState)(null),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(null),m=(0,R.useMemo)(()=>{let e=o.trim().toLowerCase();return e?a.filter(t=>`${t.providerLabel} ${t.provider} ${t.label} ${t.id}`.toLowerCase().includes(e)):a},[a,o]),h=async e=>{if(!(!t||u)){d(!0),l(e),p(null);try{await gc(t,{activeModel:{provider:e.provider,id:e.id}}),p(`Selected ${e.provider}/${e.id}.`),await n?.()}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}}};return(0,z.jsxs)(`div`,{className:`ml-[1.9rem] max-w-3xl border border-[#3a3a3a] bg-[#111111] text-[12px] shadow-lg`,"data-shared-terminal-card":`model`,children:[(0,z.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[#2a2a2a] px-3 py-2`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[#d4d4d4]`,children:`Model`}),(0,z.jsxs)(`div`,{className:`text-[11px] text-[#737373]`,children:[`Choose a model from authenticated providers. Use `,(0,z.jsx)(`span`,{className:`text-[#38bdf8]`,children:`/login`}),` to add providers.`]})]})}),(0,z.jsxs)(`div`,{className:`space-y-2 p-3`,children:[i.length?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`flex items-center gap-2 border border-[#2a2a2a] bg-[#0b0b0b] px-2 py-1 text-[#737373]`,children:[(0,z.jsx)(Vs,{size:13}),(0,z.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Search models`,className:`min-w-0 flex-1 bg-transparent text-[#d4d4d4] outline-none placeholder:text-[#525252]`})]}),(0,z.jsx)(`div`,{className:`max-h-72 overflow-auto border border-[#2a2a2a]`,children:m.length?m.map(e=>(0,z.jsxs)(`button`,{type:`button`,disabled:u,onClick:()=>void h(e),className:`grid w-full grid-cols-[150px_1fr_auto] gap-2 border-b border-[#1f1f1f] px-3 py-2 text-left hover:bg-[#38bdf8]/10 disabled:opacity-50`,children:[(0,z.jsx)(`span`,{className:`truncate text-[#737373]`,children:e.providerLabel}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block truncate text-[#d4d4d4]`,children:e.label}),(0,z.jsxs)(`span`,{className:`block truncate text-[11px] text-[#737373]`,children:[e.provider,`/`,e.id]})]}),c?.provider===e.provider&&c?.id===e.id?(0,z.jsx)(Ro,{size:14,className:`text-[#22c55e]`}):null]},`${e.provider}:${e.id}`)):(0,z.jsx)(`div`,{className:`px-3 py-2 text-[#737373]`,children:`No matching models.`})})]}):(0,z.jsxs)(`div`,{className:`text-[#737373]`,children:[`No authenticated model providers found. Run `,(0,z.jsx)(`span`,{className:`text-[#38bdf8]`,children:`/login`}),` first.`]}),f?(0,z.jsx)(`div`,{className:`text-[11px] text-[#a3a3a3]`,children:f}):null]})]})}function mPe(e={}){let t=[],n=[],r=P5(e.warnings),i=P5(e.errors);(e.session?.id||e.session?.title)&&t.push({id:`session`,label:`Session`,value:M5([e.session?.title,e.session?.id].filter(Boolean).join(` | `))}),e.session?.profile&&t.push({id:`profile`,label:`Profile`,value:M5(e.session.profile)}),e.session?.status&&t.push({id:`session-status`,label:`Session status`,value:M5(e.session.status),tone:e.session.status===`error`||e.session.status===`disposed`?`red`:`neutral`}),(e.model?.provider||e.model?.id||e.model?.label)&&t.push({id:`model`,label:`Model`,value:M5(e.model.label??[e.model.provider,e.model.id].filter(Boolean).join(`/`))}),e.runtime?.state&&t.push({id:`runtime`,label:`Runtime`,value:M5(e.runtime.state),tone:e.runtime.connected===!1||e.runtime.disposed?`red`:`green`}),e.runtime?.disposed!==void 0&&t.push({id:`disposed`,label:`Disposed`,value:e.runtime.disposed?`yes`:`no`,tone:e.runtime.disposed?`red`:`neutral`}),typeof e.runtime?.queuedMessages==`number`&&t.push({id:`queue`,label:`Queue`,value:String(e.runtime.queuedMessages)}),e.runtime?.processing!==void 0&&t.push({id:`processing`,label:`Processing`,value:e.runtime.processing?`yes`:`no`,tone:e.runtime.processing?`cyan`:`neutral`}),e.runtime?.streaming!==void 0&&t.push({id:`streaming`,label:`Streaming`,value:e.runtime.streaming?`yes`:`no`,tone:e.runtime.streaming?`cyan`:`neutral`}),e.cwd&&t.push({id:`cwd`,label:`CWD`,value:M5(e.cwd)});let a=typeof e.thinking==`string`?{level:e.thinking}:e.thinking;(a?.level||a?.supported!==void 0)&&t.push({id:`thinking`,label:`Thinking`,value:M5(a.level??(a.supported===!1?`unsupported`:`available`)),tone:a.supported===!1?`red`:`yellow`}),e.fastMode!==void 0&&t.push({id:`fast-mode`,label:`Fast mode`,value:typeof e.fastMode==`string`?M5(e.fastMode):e.fastMode?`on`:`off`,tone:e.fastMode?`green`:`neutral`});let o=P5(e.tools?.enabled),s=P5(e.tools?.active);o.length&&t.push({id:`enabled-tools`,label:`Enabled tools`,value:`${o.length}${o.length<=4?` (${o.join(`, `)})`:``}`}),s.length&&t.push({id:`active-tools`,label:`Active tools`,value:`${s.length}${s.length<=4?` (${s.join(`, `)})`:``}`,tone:`cyan`}),e.providerUsage?.planType&&t.push({id:`provider-plan`,label:`Provider plan`,value:M5(e.providerUsage.planType)}),e.providerUsage?.credits&&t.push({id:`provider-credits`,label:`Credits`,value:e.providerUsage.credits.unlimited?`unlimited`:M5(e.providerUsage.credits.balance??`available`)}),e.message&&t.push({id:`message`,label:`Message`,value:M5(e.message)}),n.push(hPe(e.contextUsage));for(let t of gPe(e.providerUsage))n.push(t);return{kind:`status`,title:`Status`,fields:t,progress:n,warnings:r,errors:i}}function M5(e){return e.replace(/\b([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET|PASSWORD)[A-Z0-9_]*)\s*=\s*([^\s]+)/gi,`$1=[redacted]`).replace(/\b(api[_-]?key|token|secret|password)\s*[:=]\s*([^\s]+)/gi,`$1=[redacted]`).replace(/\b(?:sk|pk|pibo|ghp|github_pat)_[A-Za-z0-9_\-]{8,}\b/g,`[redacted]`)}function hPe(e){if(!e||e.tokens===void 0&&e.contextWindow===void 0&&e.percent===void 0)return{id:`context`,label:`Context`,state:`unavailable`,text:`Context usage unavailable`,tone:`neutral`};let t=N5(e.percent??(e.tokens!==void 0&&e.contextWindow?e.tokens/e.contextWindow*100:void 0));return{id:`context`,label:`Context`,state:t===void 0?`unavailable`:`available`,value:e.tokens,max:e.contextWindow,percent:t,text:t===void 0?`Context usage unavailable`:`${e.tokens??`?`}/${e.contextWindow??`?`} tokens (${t.toFixed(1)}%)`,tone:_Pe(t)}}function gPe(e){return e?.limits?.length?e.limits.map((t,n)=>{let r=N5(t.usedPercent),i=N5(t.remainingPercent??(r===void 0?void 0:100-r)),a=e.provider?`${e.provider} `:``,o=[i===void 0?void 0:`${i.toFixed(1)}% remaining`,t.resetsAt?`resets ${M5(t.resetsAt)}`:void 0].filter(Boolean).join(`, `);return{id:`provider-${n}`,label:`${a}${t.label??`quota`}`.trim(),state:i===void 0?`unavailable`:`available`,percent:i,text:i===void 0?`Provider usage unavailable`:o,tone:vPe(i)}}):[{id:`provider`,label:`Provider quota`,state:`unavailable`,text:`Provider usage unavailable`,tone:`neutral`}]}function N5(e){if(!(typeof e!=`number`||!Number.isFinite(e)))return Math.max(0,Math.min(100,e))}function _Pe(e){return e===void 0?`neutral`:e>=80?`red`:e>=50?`yellow`:`green`}function vPe(e){return e===void 0?`neutral`:e<=20?`red`:e<=50?`yellow`:`green`}function P5(e){return(e??[]).map(e=>M5(e)).filter(e=>e.length>0)}function yPe(e){switch(e.kind){case`tool.status`:return bPe(e);case`tool.thinking`:return xPe(e);case`tool.model`:return SPe(e);case`tool.login`:return CPe(e);case`tool.call`:case`tool.image`:case`tool.group.exploring`:case`tool.group.images`:return wPe(e);case`yielded.run`:return F5(e,`yielded-run`,`Yielded run`,e.status===`error`?`red`:e.status===`running`?`cyan`:`green`);case`execution.compaction`:return F5(e,`compaction`,e.status===`error`?`Compaction failed`:e.status===`running`?`Compacting`:`Compaction`,e.status===`error`?`red`:`magenta`);case`execution.command`:return F5(e,`command`,`Command`,e.status===`error`?`red`:`yellow`);case`error`:return F5(e,`error`,`Error`,`red`);default:return}}function bPe(e){let t=I5(e.output),n=L5(t,`activeModel`)??L5(t,`model`),r=mPe({session:{id:B5(t,`piboSessionId`)??B5(t,`sessionId`),title:B5(t,`sessionTitle`)??B5(t,`title`),profile:B5(t,`profile`)??B5(t,`activeAgentId`)??B5(t,`agentId`),status:V5(t,`disposed`)?`disposed`:B5(t,`sessionStatus`)},model:n?{provider:B5(n,`provider`),id:B5(n,`id`),label:B5(n,`label`)}:void 0,runtime:{state:V5(t,`disposed`)?`disposed`:V5(t,`processing`)?`processing`:V5(t,`streaming`)?`streaming`:B5(t,`mode`)??`idle`,connected:V5(t,`connected`),queuedMessages:EPe(t,`queuedMessages`),processing:V5(t,`processing`),streaming:V5(t,`streaming`),disposed:V5(t,`disposed`)},cwd:B5(t,`cwd`),contextUsage:L5(t,`contextUsage`),providerUsage:L5(t,`providerUsage`),tools:{enabled:z5(t,`enabledTools`),active:z5(t,`activeTools`)},thinking:B5(t,`thinkingLevel`)?{level:B5(t,`thinkingLevel`)}:void 0,fastMode:V5(t,`fastMode`),warnings:z5(t,`warnings`),errors:z5(t,`errors`),message:B5(t,`message`)});return{id:e.id,kind:`status`,title:`Status`,status:e.status,tone:e.status===`error`?`red`:`green`,rows:r.fields.map(e=>({label:e.label,value:e.value,tone:e.tone})),statusView:r,sourceRowKind:e.kind}}function xPe(e){let t=I5(e.output),n=B5(t,`level`)??`unknown`,r=t?.supported!==!1,i=z5(t,`availableLevels`);return{id:e.id,kind:`thinking`,title:`Thinking`,status:e.status,tone:r?`yellow`:`red`,rows:[{label:`Current`,value:M5(n)},{label:`Supported`,value:r?`yes`:`no`,tone:r?`green`:`red`}],actions:i.map(e=>({id:`thinking:${e}`,label:e,action:`thinking.set`,value:e,disabled:!r})),sourceRowKind:e.kind}}function SPe(e){let t=R5(I5(e.output),`providers`),n=t.flatMap(e=>{let t=B5(e,`id`)??B5(e,`provider`)??`provider`,n=B5(e,`label`)??B5(e,`name`)??t;return R5(e,`models`).map(e=>{let r=B5(e,`id`)??`model`,i=B5(e,`label`)??r;return{id:`model:${t}:${r}`,label:`${n} / ${i}`,action:`model.select`,value:`${t}/${r}`}})});return{id:e.id,kind:`model`,title:`Model`,status:e.status,tone:n.length?`cyan`:`neutral`,rows:[{label:`Providers`,value:String(t.length)},{label:`Models`,value:String(n.length)}],actions:n,sourceRowKind:e.kind}}function CPe(e){let t=R5(I5(e.output),`providers`),n=t.map(e=>{let t=B5(e,`id`)??`provider`;return{id:`login:${t}`,label:B5(e,`name`)??B5(e,`label`)??t,action:`login.selectProvider`,value:t,description:z5(e,`authMethods`).join(`, `)}});return{id:e.id,kind:`login`,title:`Login`,status:e.status,tone:n.length?`cyan`:`neutral`,rows:[{label:`Providers`,value:String(t.length)}],actions:n,sourceRowKind:e.kind}}function wPe(e){return F5(e,`tool`,e.kind===`tool.group.exploring`?`Exploring`:e.kind===`tool.image`||e.kind===`tool.group.images`?`Image`:`Tool`,e.status===`error`?`red`:e.status===`running`?`cyan`:`green`)}function F5(e,t,n,r){let i=e.lines.flatMap(e=>{let t=`${e.tokens.map(e=>e.text).join(``)}${e.functionCall?`${e.functionCall.name}${e.functionCall.input===void 0?``:` ${TPe(e.functionCall.input)}`}`:``}`.trim();return t?[{value:M5(t)}]:[]}),a=e.lines.length===0&&typeof e.output==`string`&&e.output.trim()?[{value:M5(e.output.trim())}]:[],o=[e.error?{label:`Error`,value:M5(e.error),tone:`red`}:void 0].filter(e=>!!e);return{id:e.id,kind:t,title:n,status:e.status,tone:r,rows:[...i,...a,...o],sourceRowKind:e.kind}}function TPe(e){try{return JSON.stringify(e)}catch{return String(e)}}function I5(e){if(e){if(typeof e==`string`)try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:void 0}catch{return}return typeof e==`object`&&!Array.isArray(e)?e:void 0}}function L5(e,t){let n=e?.[t];return n&&typeof n==`object`&&!Array.isArray(n)?n:void 0}function R5(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):[]}function z5(e,t){let n=e?.[t];return Array.isArray(n)?n.filter(e=>typeof e==`string`):[]}function B5(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function EPe(e,t){let n=e?.[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function V5(e,t){let n=e?.[t];return typeof n==`boolean`?n:void 0}function DPe(e,t){return e?XPe(H5(e.nodes).sort((e,t)=>n4(e.node,t.node)).filter(e=>e.node.type!==`agent.turn`&&(t.showThinking||e.node.type!==`model.reasoning`)).map(e=>OPe(e.node,e.turnId))).map(e=>e.row):[]}function H5(e,t){let n=[];for(let r of e)r.type!==`agent.turn`&&n.push({node:r,turnId:t}),n.push(...H5(r.children,r.type===`agent.turn`?r.id:t));return n}function OPe(e,t){let n;switch(e.type){case`user.message`:n={row:APe(e),turnId:t};break;case`assistant.message`:n={row:jPe(e),turnId:t};break;case`model.reasoning`:n={row:MPe(e),turnId:t};break;case`tool.call`:n=NPe(e,t);break;case`tool.result`:n=PPe(e,t);break;case`agent.delegation`:n={row:IPe(e),turnId:t};break;case`agent.async`:n={row:LPe(e),turnId:t};break;case`yielded.run`:n={row:RPe(e),turnId:t};break;case`execution.command`:n={row:zPe(e),turnId:t};break;case`execution.compaction`:n={row:W5(e),turnId:t};break;case`error`:n={row:JPe(e),turnId:t};break;case`agent.turn`:n={row:{id:e.id,kind:`error`,status:`neutral`,lines:[],sourceNodeIds:[e.id]},turnId:t};break}return{...n,row:{...n.row,...kPe(e)}}}function kPe(e){return{eventId:e.eventId,runId:e.runId,orderSource:e.source,orderStreamId:e.orderKey?.streamId,orderStreamFrameIndex:e.orderKey?.streamFrameIndex}}function APe(e){let t=s7(e.output)||s7(e.summary)||e.title;return{id:e.id,kind:`message.user`,status:i7(e.status),lines:[{prefix:`prompt`,tokens:[o7(t)]}],sourceNodeIds:[e.id],forkEntryId:e.entryId,output:t}}function jPe(e){return{id:e.id,kind:`message.assistant`,status:i7(e.status),lines:[],sourceNodeIds:[e.id],output:s7(e.output)||s7(e.summary)||``,error:e.error}}function MPe(e){let t=t7(e.output??e.summary);return{id:e.id,kind:`reasoning`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(e.status===`running`?`Thinking`:`Thought`,`amber`,`semibold`)]}],sourceNodeIds:[e.id],markdown:t}}function NPe(e,t){let n=r7(e.input);if(n&&nFe(e.title))return{row:qPe(e,n),turnId:t,exploring:void 0};let r=q5(e);if(r)return{row:U5(e,r),turnId:t,image:r.detail};let i=$5(e.error??e.output,5,e.error?`red`:`dim`);return{row:{id:e.id,kind:`tool.call`,status:i7(e.status),errorKind:e.status===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(iFe(e.status),a7(e.status),`semibold`),o7(` `)],functionCall:{name:e.title,input:e.input}},...i.lines],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error,previewOmission:e7(i,e.error?`error`:`output`)},turnId:t,exploring:tFe(e)}}function U5(e,t){let n=i7(e.status),r=t.path?`Path: ${t.path}`:t.query?`Query: ${t.query}`:t.mimeType?`Type: ${t.mimeType}`:`Image content returned`;return{id:e.id,kind:`tool.image`,status:n,errorKind:e.status===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7($Pe(e.status,t.count),a7(e.status),`semibold`)]},{prefix:`detail`,tokens:[o7(r,e.status===`error`?`red`:`cyan`)]}],sourceNodeIds:[e.id],input:Y5(e.input),output:t.summary,error:e.error,expandable:e.input!==void 0||t.summary!==void 0||!!e.error}}function PPe(e,t){let n=q5(e);return n?{row:U5(e,n),turnId:t,image:n.detail}:{row:FPe(e),turnId:t}}function FPe(e){let t=$5(e.error??e.output,5,e.error?`red`:`dim`);return{id:e.id,kind:`tool.call`,status:i7(e.status),errorKind:e.status===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(e.status===`error`?`Tool failed`:`Returned`,a7(e.status),`semibold`),o7(` ${e.title}`)]},...t.lines],sourceNodeIds:[e.id],output:e.output,error:e.error,expandable:e.output!==void 0||!!e.error,previewOmission:e7(t,e.error?`error`:`output`)}}function IPe(e){let t=s7(c7(e.input)?e.input.subagentName:void 0)||e.summary||e.title,n=n7((c7(e.input)?e.input.arguments:void 0)??e.input),r=n?[{prefix:`detail`,tokens:[o7(n,`dim`)]}]:[];return{id:e.id,kind:`agent.delegation`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(aFe(e.status),a7(e.status),`semibold`),o7(` ${t}`,`cyan`)]},...r],sourceNodeIds:[e.id],linkedPiboSessionId:e.linkedPiboSessionId,input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error}}function LPe(e){let t=$5(e.error??e.output,5,e.error?`red`:`dim`);return{id:e.id,kind:`agent.async`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(oFe(e.status),a7(e.status),`semibold`),o7(` ${e.title}`,`cyan`)]},...t.lines],sourceNodeIds:[e.id],linkedPiboSessionId:e.linkedPiboSessionId,input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error,previewOmission:e7(t,e.error?`error`:`output`)}}function RPe(e){let t=$5(e.output,5);return{id:e.id,kind:`yielded.run`,status:i7(e.status),errorKind:e.status===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(e.status===`running`?`Waiting on runs`:`Run update`,a7(e.status),`semibold`),o7(e.summary?` ${e.summary}`:``)]},...t.lines],sourceNodeIds:[e.id],output:e.output,error:e.error,expandable:e.output!==void 0||!!e.error,previewOmission:e7(t,`output`)}}function W5(e){let t=e.status===`running`?`Compacting`:e.status===`error`?`Compaction failed`:s7(e.summary)||`Compacted`;return{id:e.id,kind:`execution.compaction`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(t,a7(e.status),e.status===`error`?`bold`:`semibold`)]}],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error}}function zPe(e){if(e.title===`status`)return BPe(e);if(e.title===`thinking`)return VPe(e);if(e.title===`fast_mode`)return HPe(e);if(e.title===`login`&&GPe(e.output))return UPe(e);if(e.title===`model`&&KPe(e.output))return WPe(e);r7(e.output)??r7(e.input)??e.title;let t=$5(e.error??e.output,5,e.error?`red`:`dim`,180);return{id:e.id,kind:`execution.command`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(`Command`,`yellow`,`semibold`),o7(` /${e.title}`,`yellow`)]},...t.lines],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error,previewOmission:e7(t,e.error?`error`:`output`)}}function BPe(e){return{id:e.id,kind:`tool.status`,status:i7(e.status),lines:[],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:!1}}function VPe(e){return{id:e.id,kind:`tool.thinking`,status:i7(e.status),lines:[],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:!1}}function HPe(e){let t=c7(e.output)?e.output:void 0,n=t?.mode===`fast`?`fast`:t?.mode===`normal`?`normal`:void 0,r=t?.changed!==!1,i=t?.supported!==!1,a=i?n===`fast`?r?`Switched to Fast mode.`:`Fast mode is already on.`:n===`normal`?r?`Switched to Normal mode.`:`Normal mode is already on.`:`Fast mode updated.`:`Fast mode is not supported by this model.`;return{id:e.id,kind:`execution.command`,status:i7(e.status),lines:[{prefix:`bullet`,tokens:[o7(a,i?`green`:`dim`,`semibold`)]}],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:!1}}function UPe(e){return{id:e.id,kind:`tool.login`,status:i7(e.status),lines:[],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:!1}}function WPe(e){return{id:e.id,kind:`tool.model`,status:i7(e.status),lines:[],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:!1}}function GPe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.action===`show_login_menu`&&Array.isArray(t.providers)}function KPe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return t.action===`show_model_menu`&&Array.isArray(t.providers)}function qPe(e,t){let n=$5(e.error??e.output,5,e.error?`red`:`dim`,180);return{id:e.id,kind:`execution.command`,status:i7(e.status),errorKind:e.status===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(e.status===`running`?`Running`:`Ran`,a7(e.status),`semibold`),o7(` `),...rFe(t)]},...n.lines],sourceNodeIds:[e.id],input:e.input,output:e.output,error:e.error,expandable:e.input!==void 0||e.output!==void 0||!!e.error,previewOmission:e7(n,e.error?`error`:`output`)}}function JPe(e){return{id:e.id,kind:`error`,status:`error`,errorKind:`system`,lines:[{prefix:`bullet`,tokens:[o7(e.title||`Error`,`red`,`bold`),o7(e.error?` ${e.error}`:``,`red`)]},...YPe(e.input)],sourceNodeIds:[e.id],input:e.input,error:e.error,output:e.output,expandable:e.input!==void 0||e.output!==void 0||!!e.error}}function YPe(e){return c7(e)?[[`Class`,s7(e.errorClass)??s7(e.category)],[`Code`,s7(e.code)??s7(e.providerCode)],[`Origin`,s7(e.origin)],[`Provider`,[s7(e.api),s7(e.provider),s7(e.model)].filter(Boolean).join(` / `)||void 0],[`Retryable`,typeof e.retryable==`boolean`?e.retryable?`yes`:`no`:void 0]].filter(e=>typeof e[1]==`string`&&e[1].length>0).map(([e,t],n)=>({prefix:n===0?`detail`:`continuation`,tokens:[o7(`${e}: `,`dim`),o7(t,`red`)]})):[]}function XPe(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n],i=G5(r);if(!i){t.push(r);continue}let a=[r],o=n+1;for(;o<e.length&&G5(e[o])===i&&e[o].turnId===r.turnId;)a.push(e[o]),o+=1;if(a.length===1){t.push(r);continue}t.push({row:i===`images`?QPe(a):ZPe(a),turnId:r.turnId}),n=o-1}return t}function G5(e){if(e.image)return`images`;if(e.exploring)return`exploring`}function ZPe(e){let t=K5(e,`exploring`),n=t.slice(0,6),r=Math.max(0,t.length-n.length),i=e[0]?.row,a=i?.id??`exploring`,o=e[e.length-1]?.row.id??a,s=e.some(e=>e.row.status===`running`)?`running`:e.some(e=>e.row.status===`error`)?`error`:`done`;return{id:`group:exploring:${a}:${o}`,kind:`tool.group.exploring`,status:s,errorKind:s===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(s===`running`?`Exploring`:s===`error`?`Exploring failed`:`Explored`,a7(s),`semibold`)]},...n.map((e,t)=>({prefix:t===0?`detail`:`continuation`,tokens:[o7(e.label,e.status===`error`?`red`:`dim`)]})),...r>0?[{prefix:`continuation`,tokens:[o7(`+${r} more explorations`,`dim`,`normal`,!0)]}]:[]],sourceNodeIds:e.flatMap(e=>e.row.sourceNodeIds),eventId:i?.eventId,runId:i?.runId,orderSource:i?.orderSource,orderStreamId:i?.orderStreamId,orderStreamFrameIndex:i?.orderStreamFrameIndex,detailItems:t,expandable:t.some(e=>e.input!==void 0||e.output!==void 0||!!e.error),previewOmission:r>0?{source:`details`,visibleLineCount:n.length,omittedLineCount:r,totalLineCount:t.length,maxVisibleLineCount:6}:void 0}}function QPe(e){let t=K5(e,`images`),n=t.slice(0,6),r=Math.max(0,t.length-n.length),i=e[0]?.row,a=i?.id??`images`,o=e[e.length-1]?.row.id??a,s=e.some(e=>e.row.status===`running`)?`running`:e.some(e=>e.row.status===`error`)?`error`:`done`;return{id:`group:images:${a}:${o}`,kind:`tool.group.images`,status:s,errorKind:s===`error`?`tool`:void 0,lines:[{prefix:`bullet`,tokens:[o7(s===`running`?`Viewing images`:s===`error`?`Image reads failed`:`Viewed images`,a7(s),`semibold`)]},...n.map((e,t)=>({prefix:t===0?`detail`:`continuation`,tokens:[o7(e.label,e.status===`error`?`red`:`cyan`)]})),...r>0?[{prefix:`continuation`,tokens:[o7(`+${r} more image reads`,`dim`,`normal`,!0)]}]:[]],sourceNodeIds:e.flatMap(e=>e.row.sourceNodeIds),eventId:i?.eventId,runId:i?.runId,orderSource:i?.orderSource,orderStreamId:i?.orderStreamId,orderStreamFrameIndex:i?.orderStreamFrameIndex,detailItems:t,expandable:t.some(e=>e.input!==void 0||e.output!==void 0||!!e.error),previewOmission:r>0?{source:`details`,visibleLineCount:n.length,omittedLineCount:r,totalLineCount:t.length,maxVisibleLineCount:6}:void 0}}function K5(e,t){return e.map(e=>{let n=t===`images`?e.image:e.exploring;return{id:e.row.id,label:n?.label??e.row.lines[0]?.tokens.map(e=>e.text).join(``)??e.row.id,status:e.row.status,input:e.row.input,output:e.row.output,error:e.row.error,linkedPiboSessionId:e.row.linkedPiboSessionId,previewOmission:e.row.previewOmission}})}function q5(e){let t=(e.title??``).trim().toLowerCase(),n=c7(e.input)?e.input:void 0,r=Z5(n)??Z5(c7(e.output)?eFe(e.output,`details`):void 0)??Z5(c7(e.output)?e.output:void 0),i=Q5(n),a=J5(e.output),o=X5(t,[`view_image`,`image`,`screenshot`]);if(!a.length&&!o)return;let s=a.map(e=>e.mimeType).find(e=>!!e),c=Math.max(1,a.length),l={type:a.length>1?`images`:a.length===1?`image`:`image_reference`,path:r,query:i,mimeType:s,count:c>1?c:void 0,detail:a.length?`Image data hidden in terminal view.`:`Image path only; binary data is hidden in terminal view.`},u=r??i??s??`image`;return{count:c,path:r,query:i,mimeType:s,summary:l,detail:{id:e.id,label:`${e.status===`error`?`Image failed`:`Viewed image`} ${u}`,status:i7(e.status),input:Y5(e.input),output:l,error:e.error}}}function J5(e,t=0,n=new Set){if(t>5||typeof e!=`object`||!e||n.has(e))return[];if(n.add(e),Array.isArray(e))return e.flatMap(e=>J5(e,t+1,n));let r=e,i=typeof r.type==`string`?r.type.toLowerCase():void 0,a=typeof r.mimeType==`string`?r.mimeType:typeof r.mime_type==`string`?r.mime_type:void 0,o=typeof r.data==`string`||typeof r.image_url==`string`||c7(r.image_url);if((i===`image`||i===`input_image`||i===`output_image`||i===`image_url`)&&(o||a?.startsWith(`image/`))||a?.startsWith(`image/`)&&o)return[{mimeType:a}];let s=[];return`content`in r&&s.push(r.content),`message`in r&&s.push(r.message),`result`in r&&s.push(r.result),`output`in r&&s.push(r.output),s.flatMap(e=>J5(e,t+1,n))}function Y5(e){if(Array.isArray(e))return e.map(Y5);if(!c7(e))return e;let t={};for(let[n,r]of Object.entries(e)){if((n===`data`||n===`image_url`)&&typeof r==`string`&&r.length>120){t[n]=`[hidden ${n}]`;continue}t[n]=Y5(r)}return t}function $Pe(e,t){return e===`running`?t>1?`Viewing images`:`Viewing image`:e===`error`?t>1?`Image reads failed`:`Image read failed`:t>1?`Viewed images`:`Viewed image`}function eFe(e,t){let n=e?.[t];return c7(n)?n:void 0}function tFe(e){let t=(e.title??``).trim().toLowerCase(),n=c7(e.input)?e.input:void 0;if(X5(t,[`read`,`open`]))return{id:e.id,label:`Read ${Z5(n)??n7(e.input)}`,status:i7(e.status),input:e.input,output:e.output,error:e.error};if(X5(t,[`list`,`ls`,`glob`]))return{id:e.id,label:`List ${Z5(n)??n7(e.input)}`,status:i7(e.status),input:e.input,output:e.output,error:e.error};if(X5(t,[`search`,`find`,`grep`,`rg`])){let t=Q5(n),r=Z5(n);return{id:e.id,label:`Search ${t??n7(e.input)}${r?` in ${r}`:``}`,status:i7(e.status),input:e.input,output:e.output,error:e.error}}}function X5(e,t){return t.some(t=>e===t||e.startsWith(`${t}_`)||e.endsWith(`_${t}`)||e.includes(t))}function Z5(e){if(e)for(let t of[`path`,`file`,`filePath`,`filepath`,`url`,`uri`,`cwd`,`pattern`,`glob`]){let n=s7(e[t]);if(n)return n}}function Q5(e){if(e)for(let t of[`query`,`pattern`,`text`,`name`,`q`,`regex`]){let n=s7(e[t]);if(n)return n}}function $5(e,t,n=`dim`,r=160){let i={lines:[],visibleLineCount:0,omittedLineCount:0,totalLineCount:0,maxVisibleLineCount:t},a=t7(e);if(!a)return i;let o=a.split(/\r?\n/).map(e=>e.trimEnd()).filter((e,t,n)=>e.length>0||n.length===1);if(!o.length)return i;let s=o.slice(0,t),c=Math.max(0,o.length-s.length),l=s.map((e,t)=>({prefix:t===0?`detail`:`continuation`,tokens:[o7(e,n)]}));return c>0&&l.push({prefix:`continuation`,tokens:[o7(`+${c} more lines`,`dim`,`normal`,!0)]}),{lines:l,visibleLineCount:s.length,omittedLineCount:c,totalLineCount:o.length,maxVisibleLineCount:t}}function e7(e,t){if(!(e.omittedLineCount<=0))return{source:t,visibleLineCount:e.visibleLineCount,omittedLineCount:e.omittedLineCount,totalLineCount:e.totalLineCount,maxVisibleLineCount:e.maxVisibleLineCount}}function t7(e){let t=_5(e);if(t!==void 0)return t.trim();if(typeof e==`string`)return e.trim();if(e==null)return``;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function n7(e){return(typeof e==`string`?e:t7(e)).replace(/\s+/g,` `).trim()}function nFe(e){let t=(e??``).trim().toLowerCase();return t===`shell`||t===`bash`||t===`terminal`}function r7(e){if(c7(e))for(let t of[`cmd`,`command`,`script`]){let n=s7(e[t]);if(n)return n}}function rFe(e){let t=e.match(/\s+|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s]+/g)??[e],n=!1;return t.map(e=>/^\s+$/.test(e)?o7(e):/^(?:&&|\|\||[|;<>]|2>&1)$/.test(e)?o7(e,`red`,`semibold`):e.startsWith(`-`)?o7(e,`magenta`):e.startsWith(`$`)||e.includes(`=`)?o7(e,`yellow`):/^['"]/.test(e)?o7(e,`green`):n?e.includes(`/`)||e.startsWith(`.`)?o7(e,`cyan`):o7(e,`default`):(n=!0,o7(e,`green`,`semibold`)))}function iFe(e){return e===`running`?`Calling`:e===`error`?`Call failed`:`Called`}function aFe(e){return e===`running`?`Spawning`:e===`error`?`Spawn failed`:`Spawned`}function oFe(e){return e===`running`?`Waiting for`:`Finished waiting for`}function i7(e){return e===`running`?`running`:e===`error`?`error`:`done`}function a7(e){return e===`running`?`cyan`:e===`error`?`red`:e===`done`?`green`:`default`}function o7(e,t=`default`,n=`normal`,r=!1){return{text:e,tone:t,weight:n,italic:r}}function s7(e){return typeof e==`string`&&e.trim().length?e:void 0}function c7(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function sFe(e){if(!e)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else typeof e==`object`&&!Array.isArray(e)&&(t=e);if(!t)return;let n=typeof t.contextUsage==`object`&&t.contextUsage!==null?t.contextUsage:void 0,r=typeof t.providerUsage==`object`&&t.providerUsage!==null?t.providerUsage:void 0,i=Array.isArray(r?.limits)?r.limits.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)).map(e=>{let t=typeof e.usedPercent==`number`?e.usedPercent:void 0,n=typeof e.remainingPercent==`number`?e.remainingPercent:t===void 0?0:Math.max(0,Math.min(100,100-t));return{label:typeof e.label==`string`?e.label:`limit`,usedPercent:t??0,remainingPercent:n,resetsAt:typeof e.resetsAt==`string`?e.resetsAt:void 0}}):[],a=typeof r?.credits==`object`&&r.credits!==null?r.credits:void 0;return{piboSessionId:typeof t.piboSessionId==`string`?t.piboSessionId:void 0,queuedMessages:typeof t.queuedMessages==`number`?t.queuedMessages:void 0,processing:typeof t.processing==`boolean`?t.processing:void 0,streaming:typeof t.streaming==`boolean`?t.streaming:void 0,enabledTools:Array.isArray(t.enabledTools)?t.enabledTools.filter(e=>typeof e==`string`):Array.isArray(t.activeTools)?t.activeTools.filter(e=>typeof e==`string`):void 0,activeTools:Array.isArray(t.activeTools)?t.activeTools.filter(e=>typeof e==`string`):void 0,cwd:typeof t.cwd==`string`?t.cwd:void 0,disposed:typeof t.disposed==`boolean`?t.disposed:void 0,contextUsage:n?{tokens:typeof n.tokens==`number`?n.tokens:void 0,contextWindow:typeof n.contextWindow==`number`?n.contextWindow:void 0,percent:typeof n.percent==`number`?n.percent:void 0}:void 0,providerUsage:r&&(i.length>0||a)?{provider:typeof r.provider==`string`?r.provider:void 0,planType:typeof r.planType==`string`?r.planType:void 0,fetchedAt:typeof r.fetchedAt==`string`?r.fetchedAt:void 0,limits:i,credits:a?{unlimited:a.unlimited===!0,balance:typeof a.balance==`string`?a.balance:void 0}:void 0}:void 0}}function l7(e,t,n){return n?{id:e,label:t,value:n}:void 0}function u7({field:e,icon:t}){let n=t===`session`?ms:us;return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,"data-shared-status-field":e.id,children:[(0,z.jsx)(n,{size:11,className:`shrink-0 text-[#737373]`}),(0,z.jsxs)(`span`,{className:`shrink-0 text-[#737373]`,children:[e.label,`:`]}),(0,z.jsx)(`span`,{className:`truncate font-mono ${e.id===`session`?`text-[#38bdf8]`:`text-[#d4d4d4]`}`,children:e.value})]})}function d7({progress:e,label:t}){let n=e.percent??0,r=e.tone===`red`?`bg-[#ef4444]`:e.tone===`yellow`?`bg-[#facc15]`:e.tone===`cyan`?`bg-[#38bdf8]`:`bg-[#22c55e]`;return(0,z.jsxs)(`div`,{className:`mt-3 space-y-1`,"data-shared-progress":e.id,"data-shared-progress-state":e.state,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:t??e.label}),(0,z.jsx)(`span`,{className:`font-mono text-[#d4d4d4]`,children:e.state===`available`?e.text:`unavailable`})]}),e.state===`available`?(0,z.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-[#2a2a2a]`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full ${r} transition-all`,style:{width:`${Math.min(Math.max(n,0),100)}%`}})}):null]})}function cFe(e){if(!e)return;let t=new Date(e);if(!Number.isNaN(t.getTime()))return t.toLocaleString(void 0,{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}function lFe({row:e}){let t=sFe(e.output),n=yPe(e),r=n?.kind===`status`?n.statusView:void 0,[i,a]=(0,R.useState)(!1);if(!t||!r)return(0,z.jsx)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-pibo-component":`TerminalStatusCard`,"data-pibo-debug":`terminal-status-card`,"data-shared-terminal-card":`status`,children:(0,z.jsx)(`div`,{className:`text-[#737373]`,children:`Status (unparseable)`})});let o=new Map(r.fields.map(e=>[e.id,e])),s=o.get(`session`)??l7(`session`,`Session`,t.piboSessionId),c=o.get(`cwd`)??l7(`cwd`,`CWD`,t.cwd),l=r.progress.find(e=>e.id===`context`),u=r.progress.filter(e=>e.id.startsWith(`provider`)),d=t.providerUsage?.limits.length?t.providerUsage.limits:void 0,f=t.enabledTools??t.activeTools??[],p=r.fields.filter(e=>!new Set([`session`,`cwd`]).has(e.id)),m=t.providerUsage?.provider?`${t.providerUsage.provider} quota`:`Provider quota`;return(0,z.jsxs)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-pibo-component":`TerminalStatusCard`,"data-pibo-debug":`terminal-status-card`,"data-shared-terminal-card":`status`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(Co,{size:14,className:`text-[#22c55e]`}),(0,z.jsx)(`span`,{className:`font-semibold text-[#d4d4d4]`,children:r.title})]}),(0,z.jsxs)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:[s?(0,z.jsx)(u7,{field:s,icon:`session`}):null,c?(0,z.jsx)(u7,{field:c,icon:`cwd`}):null,p.slice(0,8).map(e=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,"data-shared-status-field":e.id,children:[(0,z.jsxs)(`span`,{className:`shrink-0 text-[#737373]`,children:[e.label,`:`]}),(0,z.jsx)(`span`,{className:`truncate font-mono text-[#d4d4d4]`,children:e.value})]},e.id))]}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:[t.processing?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-[#1f4960] px-1.5 py-0.5 text-[11px] text-[#38bdf8]`,children:[(0,z.jsx)(es,{size:10}),` Processing`]}):null,t.streaming?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-[#1f4960] px-1.5 py-0.5 text-[11px] text-[#38bdf8]`,children:[(0,z.jsx)(Co,{size:10}),` Streaming`]}):null,typeof t.queuedMessages==`number`&&t.queuedMessages>0?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 border border-[#3a3a3a] px-1.5 py-0.5 text-[11px] text-[#d4d4d4]`,children:[(0,z.jsx)(vs,{size:10}),` Queued: `,t.queuedMessages]}):null,t.disposed?(0,z.jsx)(`span`,{className:`inline-flex items-center gap-1 border border-[#5f2222] px-1.5 py-0.5 text-[11px] text-[#ef4444]`,children:`Disposed`}):null]}),l?(0,z.jsx)(d7,{progress:l,label:`Context Usage`}):null,u.length?(0,z.jsxs)(`div`,{className:`mt-3 space-y-1.5 border-t border-[#2a2a2a] pt-2`,"data-shared-provider-progress":u.length,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-[#737373]`,"data-shared-status-field":`provider-quota`,children:[(0,z.jsx)(ds,{size:11}),(0,z.jsxs)(`span`,{children:[m,t.providerUsage?.planType?` (${t.providerUsage.planType})`:``]})]}),d?d.map(e=>{let t=cFe(e.resetsAt);return(0,z.jsxs)(`div`,{className:`space-y-1`,"data-shared-progress":`provider-limit:${e.label}`,"data-shared-progress-state":`available`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px]`,children:[(0,z.jsx)(`span`,{className:`text-[#a3a3a3]`,children:e.label}),(0,z.jsxs)(`span`,{className:`shrink-0 font-mono text-[#d4d4d4]`,children:[e.remainingPercent.toFixed(0),`% left`,t?` · resets ${t}`:``]})]}),(0,z.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-[#2a2a2a]`,children:(0,z.jsx)(`div`,{className:`h-full rounded-full bg-[#38bdf8] transition-all`,style:{width:`${Math.min(Math.max(e.remainingPercent,0),100)}%`}})})]},`${e.label}-${e.resetsAt??``}`)}):u.map(e=>(0,z.jsx)(d7,{progress:e},e.id)),t.providerUsage?.credits?(0,z.jsxs)(`div`,{className:`text-[11px] text-[#a3a3a3]`,"data-shared-status-field":`provider-credits`,children:[`Credits: `,t.providerUsage.credits.unlimited?`unlimited`:t.providerUsage.credits.balance??`available`]}):null]}):null,r.warnings.length||r.errors.length?(0,z.jsxs)(`div`,{className:`mt-3 space-y-1 border-t border-[#2a2a2a] pt-2`,children:[r.warnings.map((e,t)=>(0,z.jsxs)(`div`,{"data-shared-status-warning":!0,className:`text-[11px] text-[#facc15]`,children:[`⚠ `,e]},`warning-${t}`)),r.errors.map((e,t)=>(0,z.jsxs)(`div`,{"data-shared-status-error":!0,className:`text-[11px] text-[#ef4444]`,children:[`✕ `,e]},`error-${t}`))]}):null,f.length>0?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex items-center gap-1.5 text-[11px] text-[#737373] hover:text-[#d4d4d4]`,children:[(0,z.jsx)(`span`,{className:`text-[#d4d4d4]`,children:i?`▾`:`▸`}),(0,z.jsxs)(`span`,{children:[`Enabled tools (`,f.length,`)`]})]}),i?(0,z.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:f.map(e=>(0,z.jsx)(`span`,{className:`inline-block rounded-sm border border-[#2a2a2a] bg-[#0b0b0b] px-1.5 py-0.5 font-mono text-[11px] text-[#a3a3a3]`,children:e},e))}):null]}):null]})}function uFe(e){let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else e&&typeof e==`object`&&!Array.isArray(e)&&(t=e);if(t)return{level:typeof t.level==`string`?t.level:void 0,availableLevels:Array.isArray(t.availableLevels)?t.availableLevels.filter(e=>typeof e==`string`):[],supported:typeof t.supported==`boolean`?t.supported:void 0}}function dFe(e){return Zq.includes(e)?e:void 0}function fFe({row:e,onLevelSelect:t}){let n=uFe(e.output);return n?(0,z.jsxs)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-shared-terminal-card":`thinking`,children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,z.jsx)(Po,{size:14,className:`text-[#f59e0b]`}),(0,z.jsx)(`span`,{className:`font-semibold text-[#d4d4d4]`,children:`Thinking`}),n.supported===!1?(0,z.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 border border-[#5f2222] px-1.5 py-0.5 text-[11px] text-[#ef4444]`,children:[(0,z.jsx)(Qs,{size:10}),` Unsupported`]}):(0,z.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 border border-[#1f4960] px-1.5 py-0.5 text-[11px] text-[#38bdf8]`,children:[(0,z.jsx)(Ro,{size:10}),` Supported`]})]}),(0,z.jsxs)(`div`,{className:`grid gap-1.5 text-[11px]`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-[#737373]`,children:`Current:`}),(0,z.jsx)(`span`,{className:`font-mono font-semibold text-[#f59e0b]`,children:n.level??`unknown`})]}),n.availableLevels.length?(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`mr-1 text-[#737373]`,children:`Available:`}),n.availableLevels.map(e=>{let r=dFe(e),i=n.supported===!1||!r||!t;return(0,z.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>{r&&t?.(r)},className:`border bg-transparent px-1.5 py-0.5 ${e===n.level?`border-[#f59e0b] text-[#f59e0b]`:`border-[#3a3a3a] text-[#d4d4d4]`} ${i?`cursor-default`:`cursor-pointer`}`,children:e},e)})]}):null,(0,z.jsxs)(`div`,{className:`text-[#737373]`,children:[`Click a level or use `,(0,z.jsx)(`span`,{className:`text-[#f59e0b]`,children:`/thinking <level>`}),`.`]})]})]}):(0,z.jsx)(`div`,{className:`mt-2 border border-[#2a2a2a] bg-[#111111] px-3 py-2 text-[12px] text-[#d4d4d4]`,"data-shared-terminal-card":`thinking`,children:(0,z.jsx)(`div`,{className:`text-[#737373]`,children:`Thinking (unparseable)`})})}var pFe=180,mFe={index:`LAST`,align:`end`},hFe={top:2400,bottom:2400},gFe=84,_Fe=6;function vFe({traceView:e,selectedTrace:t,isLoading:n,showThinking:r,expandThinking:i,sessionAgentProfile:a,sessionActiveModel:o,selectedSessionStatus:s,selectedSessionSignal:c,sessionBreadcrumbs:l,originSession:u,derivedSessions:d,agentProfiles:f,sessionProfileChangeDisabled:p,onSessionAgentProfileChange:m,onFork:h,onOpenSession:g,onThinkingLevelChange:_,onModelChanged:v}){let y=(0,R.useMemo)(()=>DPe(e,{showThinking:r}),[r,e]),[b,x]=(0,R.useState)(new Set),[S,C]=(0,R.useState)(null),w=(0,R.useRef)({}),T=y.filter(e=>e.status===`running`).length,E=y.filter(e=>m7(e,`user`)).length,D=y.filter(e=>m7(e,`tool`)).length,O=y.filter(e=>m7(e,`system`)).length,k=c?c.isTreeActive:s===`running`||T>0||t?.status===`UNSET`,A=PNe({itemCount:y.length,resetKey:e?.piboSessionId,contentKey:y,atBottomThreshold:pFe});(0,R.useEffect)(()=>{x(e=>wFe(e,y,i))},[i,y]),(0,R.useEffect)(()=>{let e=new Set(y.map(e=>e.id));C(t=>t&&e.has(t)?t:null);for(let t of[`system`,`tool`,`user`]){let n=w.current[t];n&&!e.has(n)&&delete w.current[t]}},[y]);let j=(0,R.useCallback)(e=>{let t=TFe(y,e,w.current[e]);t&&(w.current[e]=t.row.id,C(t.row.id),A.scrollToIndex(t.index,`start`,`fast-smooth`,{fromIndex:t.fromIndex,stagingAlign:e===`tool`?`end`:void 0}),EFe(t.row.id))},[y,A]),M=e=>{e.expandable&&x(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})},N=(0,R.useCallback)((t,n)=>(0,z.jsx)(`div`,{className:`px-4`,children:(0,z.jsx)(bFe,{row:n,expanded:b.has(n.id),focused:S===n.id,piboSessionId:e?.piboSessionId??``,onToggle:()=>M(n),onFork:h,onOpenSession:g,onThinkingLevelChange:_,onModelChanged:v})}),[b,S,h,v,g,_,e?.piboSessionId]),P=(0,R.useMemo)(()=>({Footer:k?jFe:void 0}),[k]);return(0,z.jsxs)(`section`,{className:`relative min-w-0 flex-1 flex flex-col overflow-hidden bg-[#0b0b0b] text-[#d4d4d4]`,"data-pibo-component":`CompactTerminalSessionView`,"data-pibo-debug":`compact-terminal-session-view`,"data-pibo-session-id":e?.piboSessionId??void 0,children:[(0,z.jsx)(yFe,{errorCount:O,toolErrorCount:D,userMessageCount:E,onNavigate:j,sessionAgentProfile:a,sessionActiveModel:o,sessionBreadcrumbs:l,originSession:u,derivedSessions:d,onOpenSession:g}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:e?y.length?(0,z.jsx)(sNe,{ref:A.virtuosoRef,data:y,initialTopMostItemIndex:mFe,increaseViewportBy:hFe,defaultItemHeight:gFe,className:`min-h-0 h-full overflow-x-hidden font-mono text-[12px] leading-[1.45]`,computeItemKey:(e,t)=>t.id,scrollerRef:A.scrollerRef,atBottomStateChange:A.atBottomStateChange,atBottomThreshold:A.atBottomThreshold,followOutput:A.followOutput,totalListHeightChanged:A.totalListHeightChanged,alignToBottom:!0,components:P,itemContent:N},e.piboSessionId):(0,z.jsx)(C7,{isLoading:n,agentProfiles:f,disabled:p,onSelectAgentProfile:m,message:`No visible trace rows yet.`}):(0,z.jsx)(C7,{isLoading:n,agentProfiles:f,disabled:p,onSelectAgentProfile:m})}),A.isSticky?null:(0,z.jsx)(`button`,{type:`button`,onClick:()=>A.stickToBottom(`auto`),title:`Scroll to latest`,"aria-label":`Scroll to latest`,className:`absolute right-4 bottom-4 z-30 inline-flex h-9 w-9 items-center justify-center rounded-sm border border-[#38bdf8] bg-[#111111]/95 text-[#38bdf8] shadow-lg shadow-black/30 hover:bg-[#161616]`,children:(0,z.jsx)(zo,{size:18})})]})}function yFe({errorCount:e,toolErrorCount:t,userMessageCount:n,onNavigate:r,sessionAgentProfile:i,sessionActiveModel:a,sessionBreadcrumbs:o,originSession:s,derivedSessions:c,onOpenSession:l}){return(0,z.jsxs)(`div`,{className:`border-b border-[#2a2a2a] bg-[#111111] px-4 py-2 text-[11px]`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,z.jsx)(x7,{tone:`neutral`,children:i}):null,a?(0,z.jsx)(x7,{tone:`purple`,children:a}):null,n>0?(0,z.jsxs)(x7,{tone:`cyan`,label:`${n} user messages · jump to previous user message`,onClick:()=>r(`user`),children:[n,(0,z.jsx)(Os,{size:12})]}):null,e>0?(0,z.jsxs)(x7,{tone:`red`,label:`${e} errors · jump to previous error`,onClick:()=>r(`system`),children:[e,(0,z.jsx)(Jo,{size:12})]}):null,t>0?(0,z.jsxs)(x7,{tone:`amber`,label:`${t} tool call errors · jump to previous tool error`,onClick:()=>r(`tool`),children:[t,(0,z.jsx)(ps,{size:12})]}):null,s?(0,z.jsxs)(f7,{onClick:()=>l(s.piboSessionId),children:[`Origin `,s.label]}):null,c.map(e=>(0,z.jsxs)(f7,{onClick:()=>l(e.piboSessionId),children:[`Derived `,e.label]},e.piboSessionId))]}),o.length?(0,z.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 text-[#737373]`,children:o.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0?(0,z.jsx)(Bo,{size:12,className:`text-[#525252]`}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>l(e.piboSessionId),className:`hover:text-[#38bdf8]`,children:e.label})]},e.piboSessionId))}):null]})}function f7({children:e,onClick:t}){return(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`border border-[#3a3a3a] px-2 py-0.5 text-[#38bdf8] hover:border-[#38bdf8]`,children:e})}function bFe({row:e,expanded:t,focused:n,piboSessionId:r,onToggle:i,onFork:a,onOpenSession:o,onThinkingLevelChange:s,onModelChanged:c}){let l=!t&&OFe(e),u=l?DFe(e):e.lines;return(0,z.jsxs)(`div`,{className:CFe(e,n),"data-pibo-component":`TerminalRow`,"data-pibo-debug":`terminal-row`,"data-pibo-terminal-row":`true`,"data-row-id":e.id,"data-row-kind":e.kind,"data-row-status":e.status,"data-trace-node-id":e.sourceNodeIds.join(` `),"data-event-id":e.eventId,"data-run-id":e.runId,"data-order-source":e.orderSource,"data-order-stream-id":e.orderStreamId,"data-order-frame-index":e.orderStreamFrameIndex,onDoubleClick:e.expandable?t=>{!e.expandable||h7(t)||i()}:void 0,onKeyDown:e.expandable?t=>{!e.expandable||h7(t)||(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),i())}:void 0,role:e.expandable?`button`:void 0,tabIndex:e.expandable||n?0:void 0,"aria-expanded":e.expandable?t:void 0,"aria-current":n?`true`:void 0,children:[(0,z.jsxs)(`div`,{className:`flex gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,z.jsx)(xFe,{row:e,visibleLines:u,collapseToolCallPreview:l,piboSessionId:r,onThinkingLevelChange:s,onModelChanged:c})}),(0,z.jsx)(SFe,{row:e,onFork:a,onOpenSession:o})]}),t?(0,z.jsx)(qNe,{row:e,onOpenSession:o}):null]})}function xFe({row:e,visibleLines:t,collapseToolCallPreview:n,piboSessionId:r,onThinkingLevelChange:i,onModelChanged:a}){return e.kind===`message.assistant`?(0,z.jsx)(`div`,{className:`ml-[1.9rem] min-w-0`,"data-pibo-component":`TerminalAssistantMessage`,children:(0,z.jsx)(`div`,{className:`compact-terminal-markdown`,"data-pibo-component":`MarkdownRendererHost`,"data-pibo-markdown-kind":`assistant-message`,children:(0,z.jsx)(BW,{streaming:e.status===`running`,children:typeof e.output==`string`?e.output:``})})}):e.kind===`tool.status`?(0,z.jsx)(lFe,{row:e}):e.kind===`tool.thinking`?(0,z.jsx)(fFe,{row:e,onLevelSelect:i}):e.kind===`tool.login`?(0,z.jsx)(lPe,{row:e,piboSessionId:r}):e.kind===`tool.model`?(0,z.jsx)(pPe,{row:e,piboSessionId:r,onModelChanged:a}):e.kind===`execution.compaction`&&e.status===`running`?(0,z.jsx)(NFe,{}):e.kind===`reasoning`&&e.markdown?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(p7,{lines:t,status:e.status,clampPreview:n}),(0,z.jsx)(`div`,{className:`ml-[1.9rem] min-w-0`,"data-pibo-component":`TerminalReasoningMarkdown`,children:(0,z.jsx)(`div`,{className:`compact-terminal-markdown compact-terminal-reasoning`,"data-pibo-component":`MarkdownRendererHost`,"data-pibo-markdown-kind":`reasoning`,children:(0,z.jsx)(BW,{streaming:e.status===`running`,children:e.markdown})})})]}):(0,z.jsx)(p7,{lines:t,status:e.status,clampPreview:n})}function p7({lines:e,status:t,clampPreview:n}){return e.map((e,r)=>(0,z.jsx)($Ne,{line:e,status:t,clampLines:n&&r===0?5:void 0},r))}function SFe({row:e,onFork:t,onOpenSession:n}){return(0,z.jsxs)(`div`,{className:`flex shrink-0 items-start gap-1 transition-opacity ${e.forkEntryId?`opacity-100`:`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`}`,children:[e.linkedPiboSessionId?(0,z.jsx)(S7,{label:`Open linked session`,onClick:()=>n(e.linkedPiboSessionId),children:`Open`}):null,e.forkEntryId?(0,z.jsxs)(S7,{label:`Fork from this user message`,onClick:()=>t(e.forkEntryId),children:[(0,z.jsx)(fs,{size:13}),`Fork`]}):null]})}function CFe(e,t=!1){let n=e.kind===`message.user`?`group border-b border-[#141414] bg-[#11a4d4]/10 py-2 last:border-b-0 hover:bg-[#11a4d4]/15`:e.kind===`execution.command`?`group border-b border-[#141414] bg-[#f59e0b]/5 py-2 last:border-b-0 hover:bg-[#f59e0b]/10`:`group border-b border-[#141414] py-2 last:border-b-0 hover:bg-[#161616]`,r=e.expandable||t?` focus:outline-none focus:ring-1 focus:ring-[#38bdf8]/50`:``;return t?`${n}${r} ring-1 ring-[#38bdf8] bg-[#123040]`:`${n}${r}`}function wFe(e,t,n){let r=new Set;for(let i of t)e.has(i.id)&&r.add(i.id),n&&i.kind===`reasoning`&&i.expandable&&r.add(i.id);return FFe(e,r)?e:r}function m7(e,t){return t===`user`?e.kind===`message.user`:e.status===`error`?t===`tool`?e.errorKind===`tool`:e.errorKind!==`tool`:!1}function TFe(e,t,n){let r=e.map((e,t)=>({row:e,index:t})).filter(({row:e})=>m7(e,t));if(!r.length)return;let i=n?e.findIndex(e=>e.id===n):-1,a=i>=0?i:e.length;return{...r.filter(e=>e.index<a).at(-1)??r[r.length-1],fromIndex:a}}function EFe(e){let t=0,n=()=>{let r=Array.from(document.querySelectorAll(`[data-pibo-component="TerminalRow"]`)).find(t=>t.dataset.rowId===e);if(r){r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`smooth`}),r.focus({preventScroll:!0});return}t+=1,t<8&&requestAnimationFrame(n)};requestAnimationFrame(()=>requestAnimationFrame(n))}function DFe(e){return e.kind===`tool.group.exploring`||e.kind===`tool.group.images`?e.lines.slice(0,_Fe):e.lines}function OFe(e){return!!e.expandable&&(e.kind===`tool.call`||e.kind===`tool.image`||e.kind===`tool.group.exploring`||e.kind===`tool.group.images`||e.kind===`agent.delegation`||e.kind===`agent.async`||e.kind===`yielded.run`||e.kind===`execution.command`||e.kind===`execution.compaction`)}function h7(e){let t=e.target;if(!(t instanceof Element)||t===e.currentTarget)return!1;let n=t.closest(`button, a, input, textarea, select, summary, [role='button'], [tabindex]:not([tabindex='-1'])`);return!!(n&&n!==e.currentTarget)}var kFe=`Working...`,g7=33,AFe=126;function jFe(){let{chars:e,activeIndex:t}=MFe(kFe);return(0,z.jsx)(`div`,{className:`border-t border-[#141414] px-4 py-2`,role:`status`,"aria-live":`polite`,"aria-label":`Working`,children:(0,z.jsxs)(`div`,{className:`grid grid-cols-[1.9rem_minmax(0,1fr)] gap-2 whitespace-pre-wrap break-words`,children:[(0,z.jsx)(`span`,{className:`whitespace-pre text-[#737373]`,children:`•`}),(0,z.jsx)(`span`,{className:`compact-terminal-working-scramble`,"aria-hidden":`true`,children:e.map((e,n)=>(0,z.jsx)(`span`,{className:n===t?`compact-terminal-working-scramble-active`:void 0,children:e},n))})]})})}function MFe(e){let t=(0,R.useMemo)(()=>Array.from(e),[e]),[n,r]=(0,R.useState)(()=>v7(t)),[i,a]=(0,R.useState)(0);return(0,R.useEffect)(()=>{let e=0,n=0,i=b7(),o=0;r(v7(t));let s=window.setInterval(()=>{if(o>0){o--;return}if(e>=t.length){e=0,n=0,i=b7(),r(v7(t)),a(0);return}let s=e,c=t[s]??` `;if(a(s),n++,n<i){r(e=>_7(e,s,y7(c)));return}r(e=>_7(e,s,c)),e++,n=0,i=b7(),e>=t.length&&(r(t),a(-1),o=18)},55);return()=>window.clearInterval(s)},[t]),{chars:n,activeIndex:i}}function _7(e,t,n){let r=[...e];return r[t]=n,r}function v7(e){return e.map(e=>y7(e))}function y7(e){let t=``;do{let e=g7+Math.floor(Math.random()*(AFe-g7+1));t=String.fromCharCode(e)}while(t===e);return t}function b7(){return 2+Math.floor(Math.random()*11)}function NFe(){let e=PFe();return(0,z.jsxs)(`div`,{className:`grid grid-cols-[1.9rem_minmax(0,1fr)] gap-2 whitespace-pre-wrap break-words`,children:[(0,z.jsx)(`span`,{className:`whitespace-pre text-[#38bdf8]`,children:`•`}),(0,z.jsxs)(`span`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`font-semibold text-[#38bdf8]`,children:`Compacting`}),(0,z.jsx)(`span`,{className:`text-[#38bdf8]`,children:e})]})]})}function PFe(){let[e,t]=(0,R.useState)(0);return(0,R.useEffect)(()=>{let e=window.setInterval(()=>t(e=>(e+1)%4),400);return()=>window.clearInterval(e)},[]),`.`.repeat(e)}function x7({tone:e,label:t,onClick:n,children:r}){let i=`inline-flex items-center gap-1 border px-2 py-0.5 ${e===`cyan`?`border-[#1f4960] text-[#38bdf8]`:e===`red`?`border-[#5f2222] text-[#ef4444]`:e===`amber`?`border-[#6b4e16] text-[#f59e0b]`:e===`purple`?`border-purple-500/40 text-purple-300`:`border-[#3a3a3a] text-[#d4d4d4]`}`;return n?(0,z.jsx)(`button`,{type:`button`,onClick:n,className:`${i} hover:bg-white/5 focus:outline-none focus:ring-1 focus:ring-[#38bdf8]`,title:t,"aria-label":t,children:r}):(0,z.jsx)(`span`,{className:i,title:t,"aria-label":t,children:r})}function S7({label:e,onClick:t,children:n}){return(0,z.jsx)(`button`,{type:`button`,onClick:t,"aria-label":e,title:e,className:`inline-flex min-h-7 min-w-7 items-center gap-1 border border-[#3a3a3a] px-2 text-[11px] text-[#737373] hover:border-[#38bdf8] hover:text-[#38bdf8]`,children:n})}function C7({isLoading:e,agentProfiles:t,disabled:n,onSelectAgentProfile:r,message:i}){return(0,z.jsxs)(`div`,{className:`flex min-h-full flex-col items-center justify-center gap-4 px-6 py-10 text-center text-[12px] text-[#737373]`,children:[(0,z.jsx)(`div`,{children:e?`Loading trace…`:i??`No trace selected.`}),t.length?(0,z.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:t.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>r(e.name),className:`border border-[#3a3a3a] px-2 py-1 text-[#d4d4d4] hover:border-[#38bdf8] hover:text-[#38bdf8] disabled:opacity-50`,children:e.name},e.name))}):null]})}function FFe(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function IFe({traceView:e,isLoading:t,selectedSessionStatus:n,selectedSessionSignal:r,workflowProjectSession:i,workflowLifecycleEvents:a,sessionNodes:o,onOpenSession:s,onRefreshBootstrap:c,onError:l}){let u=i?JFe(i,e,n,r,a??[],o):null;return u?(0,z.jsx)(`section`,{className:`min-w-0 flex-1 overflow-auto bg-[#0b0f14] p-4 text-slate-300`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-6xl flex-col gap-4`,children:[(0,z.jsx)(LFe,{model:u}),(0,z.jsx)(w7,{}),(0,z.jsx)(RFe,{model:u,onRefreshBootstrap:c,onError:l}),(0,z.jsx)(BFe,{model:u}),(0,z.jsx)(VFe,{model:u,onOpenSession:s}),(0,z.jsx)(HFe,{nodes:u.nodes,edges:u.edges}),(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,z.jsx)(WFe,{model:u}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,z.jsx)(GFe,{model:u}),(0,z.jsx)(KFe,{model:u}),(0,z.jsx)(qFe,{model:u})]})]})]})}):(0,z.jsx)(`section`,{className:`min-w-0 flex-1 overflow-auto bg-[#0b0f14] p-4 text-slate-300`,children:(0,z.jsxs)(`div`,{className:`mx-auto flex max-w-4xl flex-col gap-4`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-slate-100`,children:[(0,z.jsx)(vs,{size:16,className:`text-[#11a4d4]`}),`Workflow / XState`]}),(0,z.jsx)(`p`,{className:`mt-2 text-sm text-slate-400`,children:t?`Loading session trace…`:`This session is not linked to a workflow run, so no Workflow/XState projection is available.`})]}),(0,z.jsx)(w7,{})]})})}function LFe({model:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-slate-100`,children:[(0,z.jsx)(vs,{size:16,className:`text-[#11a4d4]`}),`Workflow / XState Projection`]}),(0,z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[(0,z.jsx)(q7,{tone:`blue`,children:e.workflowId}),e.workflowRunId?(0,z.jsxs)(q7,{tone:`slate`,children:[`run `,X7(e.workflowRunId)]}):null,(0,z.jsx)(q7,{tone:hIe(e.status),children:e.state})]})]}),(0,z.jsxs)(`div`,{className:`min-w-0 text-right font-mono text-[11px] text-slate-500`,children:[(0,z.jsxs)(`div`,{className:`truncate`,children:[`session `,X7(e.piboSessionId)]}),e.latestStreamId===void 0?null:(0,z.jsxs)(`div`,{children:[`stream `,e.latestStreamId]})]})]}),(0,z.jsx)(`p`,{className:`mt-3 text-sm text-slate-400`,children:`Dedicated Project workflow execution surface. This view derives the current XState-style UI snapshot from project-session workflow linkage and live session state while keeping kernel records as durable truth.`})]})}function w7(){return(0,z.jsx)(`div`,{className:`rounded-sm border border-amber-500/30 bg-amber-500/10 p-4 text-sm`,children:(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-amber-200`,children:[(0,z.jsx)(Js,{size:14}),`Workflow IR source-of-truth boundary`]}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-xs leading-5 text-amber-100/80`,children:`Projects inspect configured sessions, workflow runs, and the XState-style projection derived from Pibo Workflow IR. Authoring stays in the Workflows tab; raw XState editing and inline executable code are not exposed here.`})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,z.jsx)(`span`,{className:`rounded border border-amber-500/40 bg-[#0b0f14]/50 px-2 py-1 text-[10px] uppercase tracking-wide text-amber-100/80`,children:`IR: source of truth`}),(0,z.jsx)(`span`,{className:`rounded border border-amber-500/40 bg-[#0b0f14]/50 px-2 py-1 text-[10px] uppercase tracking-wide text-amber-100/80`,children:`XState: projection only`})]})]})})}function RFe({model:e,onRefreshBootstrap:t,onError:n}){let r=e.workflowRunId?A7(e):void 0,i=`${e.workflowId}${e.workflowVersion?`@${e.workflowVersion}`:``}`;return(0,z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,"aria-label":`Projects workflow execution shell`,children:[(0,z.jsx)(O7,{title:`Workflow configured-session view`,icon:(0,z.jsx)(xs,{size:14}),children:(0,z.jsxs)(`div`,{className:`space-y-3 text-xs text-slate-400`,children:[(0,z.jsx)(k7,{label:`selected workflow`,value:i}),(0,z.jsx)(k7,{label:`session state`,value:e.workflowRunId?`started`:`configured/not-started`}),(0,z.jsx)(k7,{label:`input keys`,value:String(e.configuration.inputKeys.length)}),(0,z.jsx)(k7,{label:`prompt overrides`,value:String(e.configuration.promptOverrideNodeIds.length)}),(0,z.jsx)(`p`,{className:`leading-5 text-slate-500`,children:`Saved configuration is reviewed here before Start. Workflow selection and session overrides remain immutable for this configured Project session.`})]})}),(0,z.jsx)(O7,{title:`Workflow run view`,icon:(0,z.jsx)(Co,{size:14}),children:(0,z.jsxs)(`div`,{className:`space-y-3 text-xs text-slate-400`,children:[(0,z.jsx)(k7,{label:`run id`,value:e.workflowRunId?X7(e.workflowRunId):`not started`}),(0,z.jsx)(k7,{label:`status`,value:e.state}),(0,z.jsx)(k7,{label:`current node`,value:r?.label??`none`}),(0,z.jsx)(k7,{label:`output`,value:e.finalOutput?`available`:`empty`}),(0,z.jsx)(k7,{label:`error`,value:e.runtimeErrors.length?`${e.runtimeErrors.length} runtime errors`:e.validationErrors.length?`${e.validationErrors.length} validation diagnostics`:`none`}),(0,z.jsx)(`p`,{className:`leading-5 text-slate-500`,children:`This workflow run view container is the stable Project home for status, current node, output, and error sections.`})]})}),(0,z.jsx)(O7,{title:`Human action area`,icon:(0,z.jsx)(Xo,{size:14}),children:(0,z.jsx)(zFe,{model:e,onRefreshBootstrap:t,onError:n})})]})}function zFe({model:e,onRefreshBootstrap:t,onError:n}){let[r,i]=(0,R.useState)({}),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)({}),[l,u]=(0,R.useState)({}),d=(e,t)=>{i(n=>({...n,[e]:t}))},f=async(i,a)=>{if(!i.waitTokenId||!a.registered)return;let s=`${i.waitTokenId}:${a.id}`,l=a.kind??`resume`,d;if(l===`resume`){let e=r[i.waitTokenId]??(i.payloadRequirements?.required?`{}`:``);if(e.trim())try{d=JSON.parse(e)}catch{let e=[{code:`WorkflowRuntimeError.invalidHumanActionPayload`,message:`Resume payload must be valid JSON before it can be submitted.`,severity:`error`,path:`$.payload`,hint:`Enter JSON such as {"comment":"Approved"}.`}];c(t=>({...t,[i.waitTokenId]:e})),n?.(`Resume payload must be valid JSON.`);return}}o(s),c(e=>({...e,[i.waitTokenId]:[]}));try{await Mye(e.projectId,e.piboSessionId,{waitTokenId:i.waitTokenId,actionId:a.id,...a.kind?{kind:a.kind}:{},...d===void 0?{}:{payload:d}}),u(e=>({...e,[i.waitTokenId]:`${a.displayName} submitted.`})),n?.(null),await t?.()}catch(e){let t=lIe(e);c(e=>({...e,[i.waitTokenId]:t})),n?.(t[0]?.message??V7(e))}finally{o(null)}};return(0,z.jsxs)(`div`,{className:`space-y-3 text-xs text-slate-400`,children:[e.pendingHumanActions.length?(0,z.jsx)(`div`,{className:`space-y-3`,children:e.pendingHumanActions.map(e=>{let t=[...e.diagnostics,...e.waitTokenId?s[e.waitTokenId]??[]:[]];return(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/10 p-3 text-amber-100`,"aria-label":`Pending workflow human action wait token`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:e.label}),(0,z.jsx)(`div`,{className:`mt-1 break-words text-[11px] leading-5 text-amber-100/80`,children:e.prompt})]}),(0,z.jsx)(`span`,{className:`shrink-0 rounded border border-amber-400/40 bg-[#0b0f14]/40 px-1.5 py-0.5 font-mono text-[10px] text-amber-100/70`,children:e.waitTokenId?X7(e.waitTokenId):e.source})]}),(0,z.jsxs)(`div`,{className:`mt-2 grid gap-2 text-[11px] text-amber-100/75`,children:[(0,z.jsx)(k7,{label:`human node`,value:e.humanNodeId??`unspecified`}),(0,z.jsx)(k7,{label:`payload`,value:e.payloadRequirements?.description??`No persisted payload schema.`}),e.expiresAt?(0,z.jsx)(k7,{label:`expires`,value:e.expiresAt}):null]}),e.payloadRequirements?.schema?(0,z.jsxs)(`div`,{className:`mt-2 rounded-sm border border-amber-400/25 bg-[#0b0f14]/50 p-2`,children:[(0,z.jsx)(`div`,{className:`mb-1 text-[10px] font-bold uppercase tracking-wider text-amber-100/70`,children:`Resume payload schema`}),(0,z.jsx)(yq,{value:e.payloadRequirements.schema,defaultExpandLevel:1,maxHeight:`10rem`,showControls:!1})]}):null,e.availableActions.some(e=>e.kind===`resume`)?(0,z.jsxs)(`label`,{className:`mt-3 block text-[11px] text-amber-100/80`,children:[(0,z.jsx)(`span`,{className:`mb-1 block font-semibold`,children:`Resume payload JSON`}),(0,z.jsx)(`textarea`,{className:`min-h-20 w-full rounded-sm border border-amber-500/30 bg-[#0b0f14] px-2 py-1.5 font-mono text-[11px] text-amber-50 outline-none focus:border-[#11a4d4]`,value:r[e.waitTokenId??e.id]??(e.payloadRequirements?.required?`{}`:``),onChange:t=>d(e.waitTokenId??e.id,t.target.value),placeholder:`{"comment":"Approved"}`})]}):null,(0,z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,"aria-label":`Workflow wait token actions`,children:e.availableActions.length?e.availableActions.map(t=>{let n=`${e.waitTokenId}:${t.id}`;return(0,z.jsx)(`button`,{type:`button`,disabled:!e.waitTokenId||!t.registered||a!==null,onClick:()=>void f(e,t),className:`rounded-sm border border-amber-400/40 bg-[#0b0f14]/70 px-2.5 py-1 text-[11px] font-semibold text-amber-100 transition hover:border-[#11a4d4] hover:text-[#8bdcf4] disabled:cursor-not-allowed disabled:opacity-50`,title:t.description??t.id,children:a===n?`Submitting…`:t.displayName},t.id)}):(0,z.jsx)(`span`,{className:`text-amber-100/60`,children:`No registered human actions are available for this wait token.`})}),e.waitTokenId&&l[e.waitTokenId]?(0,z.jsx)(`div`,{className:`mt-2 text-[11px] text-emerald-200`,children:l[e.waitTokenId]}):null,t.length?(0,z.jsx)(`div`,{className:`mt-2 space-y-1`,"aria-label":`Human action diagnostics`,children:t.map((e,t)=>(0,z.jsxs)(`div`,{className:`rounded border border-red-400/35 bg-red-500/15 p-2 text-[11px] leading-5 text-red-100`,children:[(0,z.jsx)(`div`,{children:e.message}),(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-red-100/70`,children:[e.code,e.path?` · ${e.path}`:``]})]},`${e.code}:${t}`))}):null]},e.id)})}):(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-3 text-slate-500`,children:`No pending human action. Approval, rejection, resume, and cancel controls render here when a persisted workflow wait token exists.`}),(0,z.jsx)(`p`,{className:`leading-5 text-slate-500`,children:`This human action area lives inside the workflow run context, validates wait-token state and resume payloads, and stays separate from normal Terminal chat controls.`})]})}function BFe({model:e}){let t=e.workflowRunId?A7(e):void 0,n=[...e.runtimeErrors.map(e=>({...e,source:e.source??`runtime`})),...e.validationErrors.map(e=>({...e,source:e.source??`validation`}))].slice(0,8);return(0,z.jsxs)(`section`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4 text-sm`,"aria-label":`Workflow run inspection panel`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(ts,{size:14}),`Workflow run inspection`]}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-xs leading-5 text-slate-500`,children:`Status, current node, history, attempts, transfers, output, and errors are rendered from Project session and workflow run facts when a run is linked. The XState graph remains a visualization projection only.`})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2 text-[10px] uppercase tracking-wide`,children:[(0,z.jsx)(`span`,{className:`rounded border border-emerald-500/40 bg-emerald-500/10 px-2 py-1 text-emerald-200`,children:`kernel/run records: truth`}),(0,z.jsx)(`span`,{className:`rounded border border-amber-500/40 bg-amber-500/10 px-2 py-1 text-amber-100`,children:`XState projection only`})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,z.jsxs)(T7,{title:`Status`,badge:e.state,icon:(0,z.jsx)(Co,{size:14}),children:[(0,z.jsx)(E7,{label:`run id`,value:e.workflowRunId?X7(e.workflowRunId):`not started`}),(0,z.jsx)(E7,{label:`status`,value:e.state}),(0,z.jsx)(E7,{label:`record source`,value:e.workflowRunId?`Project workflow run id`:`no run record yet`})]}),(0,z.jsxs)(T7,{title:`Current node`,badge:t?.status??`none`,icon:(0,z.jsx)(Rs,{size:14}),children:[(0,z.jsx)(E7,{label:`node`,value:t?.label??`none`}),(0,z.jsx)(E7,{label:`node id`,value:t?.id??`none`}),(0,z.jsx)(E7,{label:`source`,value:`project/session run cursor`})]}),(0,z.jsx)(T7,{title:`Run history`,badge:`${e.runHistory.length}`,icon:(0,z.jsx)(hs,{size:14}),children:e.runHistory.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:e.runHistory.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-mono text-xs text-slate-200`,children:X7(e.id)}),(0,z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${Y7(e.status)}`,children:e.status})]}),(0,z.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-500`,children:[e.currentNodeId?`current ${e.currentNodeId}`:`no current node`,` · `,e.source]}),(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-slate-600`,children:[`updated `,e.updatedAt]})]},e.id))}):(0,z.jsx)(D7,{children:e.workflowRunId?`No workflow run history for this selected Project session yet.`:`No current run attempts; this configured Project session has not been started.`})})]}),(0,z.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[(0,z.jsx)(T7,{title:`Node attempts`,badge:`${e.nodeAttempts.length}`,icon:(0,z.jsx)(xs,{size:14}),children:e.nodeAttempts.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:e.nodeAttempts.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-xs font-semibold text-slate-200`,children:e.label}),(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-slate-500`,children:[e.nodeId,` · attempt `,e.attempt]})]}),(0,z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${Y7(e.status)}`,children:e.status})]}),(0,z.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-500`,children:[e.kind,` · `,e.source]})]},e.id))}):(0,z.jsx)(D7,{children:e.workflowRunId?`No node attempts recorded for this workflow run yet.`:`No current node attempts; Start has not created a workflow run.`})}),(0,z.jsx)(T7,{title:`Edge transfers`,badge:`${e.edgeTransfers.length}`,icon:(0,z.jsx)(fs,{size:14}),children:e.edgeTransfers.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:e.edgeTransfers.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsx)(`div`,{className:`min-w-0 truncate font-mono text-xs text-slate-200`,children:e.edgeId}),(0,z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${Y7(e.status)}`,children:e.status})]}),(0,z.jsxs)(`div`,{className:`mt-1 text-[11px] text-slate-500`,children:[e.source,e.createdAt?` · ${e.createdAt}`:``]})]},e.id))}):(0,z.jsx)(D7,{children:`No edge transfers recorded for this workflow run yet.`})}),(0,z.jsx)(T7,{title:`Output`,badge:e.finalOutput?`available`:`empty`,icon:(0,z.jsx)(Ko,{size:14}),children:e.finalOutput?(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-2`,children:[(0,z.jsx)(`div`,{className:`mb-2 font-mono text-[10px] text-slate-500`,children:e.finalOutput.source}),(0,z.jsx)(yq,{value:e.finalOutput.value,defaultExpandLevel:1,maxHeight:`12rem`,showControls:!1})]}):(0,z.jsx)(D7,{children:`No workflow output has been recorded for this run yet.`})}),(0,z.jsx)(T7,{title:`Error`,badge:n.length?`${n.length}`:`none`,icon:(0,z.jsx)(Js,{size:14}),children:n.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-500/35 bg-red-500/10 p-2 text-xs text-red-100`,children:[(0,z.jsx)(`div`,{className:`break-words`,children:e.message}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1 font-mono text-[10px] text-red-200/70`,children:[e.code?(0,z.jsx)(`span`,{children:e.code}):null,e.source?(0,z.jsx)(`span`,{children:e.source}):null]})]},e.id))}):(0,z.jsx)(D7,{children:`No workflow run errors are recorded.`})})]})]})}function VFe({model:e,onOpenSession:t}){let n=N7(e.definitionLink);return(0,z.jsxs)(`section`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4 text-sm`,"aria-label":`Workflow navigation links`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(rs,{size:14}),`Workflow navigation links`]}),(0,z.jsx)(`p`,{className:`mt-2 max-w-3xl text-xs leading-5 text-slate-500`,children:`Use these run-view links to move between real nested workflow sessions and the Workflows tab definition. Snapshot-only history is shown when the live definition is deleted or unavailable.`})]}),e.definitionLink.status===`live`&&n?(0,z.jsxs)(`a`,{className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm border border-[#11a4d4]/50 px-3 py-1.5 text-xs font-semibold text-[#8bdcf4] transition hover:border-[#11a4d4] hover:text-slate-100`,href:n,children:[(0,z.jsx)(rs,{size:13}),`Open live workflow definition`]}):null]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-2`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0f171e] p-3`,"aria-label":`Nested workflow child session links`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-bold uppercase tracking-wider text-slate-500`,children:`Nested workflow child sessions`}),(0,z.jsx)(`span`,{className:`rounded border border-slate-700 bg-[#0b0f14] px-1.5 py-0.5 font-mono text-[10px] text-slate-400`,children:e.nestedSessionLinks.length})]}),e.nestedSessionLinks.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:e.nestedSessionLinks.map(e=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>t(e.piboSessionId),className:`w-full rounded-sm border border-slate-800 bg-[#0b0f14] p-2 text-left transition hover:border-[#11a4d4]/60 hover:bg-[#102331]`,children:(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-xs font-semibold text-slate-200`,children:e.title}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[10px] text-slate-500`,children:X7(e.piboSessionId)})]}),(0,z.jsx)(`span`,{className:`rounded border border-[#11a4d4]/40 bg-[#11a4d4]/10 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-[#8bdcf4]`,children:`open session`})]})},e.piboSessionId))}):(0,z.jsx)(D7,{children:`No nested workflow child sessions are linked under this selected Project session yet.`})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0f171e] p-3`,"aria-label":`Workflow definition link state`,children:[(0,z.jsx)(`div`,{className:`mb-3 text-xs font-bold uppercase tracking-wider text-slate-500`,children:`Workflow definition link`}),e.definitionLink.status===`live`&&n?(0,z.jsxs)(`div`,{className:`rounded-sm border border-emerald-500/35 bg-emerald-500/10 p-3 text-xs leading-5 text-emerald-100`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:`Live workflow definition exists`}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-emerald-100/80`,children:F7(e.definitionLink)}),e.definitionLink.definitionHash?(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-emerald-100/60`,children:[`snapshot `,X7(e.definitionLink.definitionHash)]}):null]}):(0,z.jsxs)(`div`,{className:`rounded-sm border border-amber-500/40 bg-amber-500/10 p-3 text-xs leading-5 text-amber-100`,children:[(0,z.jsx)(`div`,{className:`font-semibold`,children:`Definition deleted — snapshot-only definition-deleted state`}),(0,z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-amber-100/80`,children:F7(e.definitionLink)}),(0,z.jsx)(`div`,{className:`mt-1 text-amber-100/80`,children:e.definitionLink.tombstoneLabel??`Historical run inspection uses the immutable Project session snapshot instead of a broken live definition link.`}),e.definitionLink.definitionHash?(0,z.jsxs)(`div`,{className:`mt-1 font-mono text-[10px] text-amber-100/60`,children:[`snapshot `,X7(e.definitionLink.definitionHash)]}):null]})]})]})]})}function T7({title:e,badge:t,icon:n,children:r}){return(0,z.jsxs)(`section`,{className:`min-w-0 rounded-sm border border-slate-800 bg-[#0f171e] p-3`,"aria-label":e,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:n}),e]}),(0,z.jsx)(`span`,{className:`shrink-0 rounded border border-slate-700 bg-[#0b0f14] px-1.5 py-0.5 font-mono text-[10px] text-slate-400`,children:t})]}),r]})}function E7({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-slate-800/70 py-2 first:pt-0 last:border-b-0 last:pb-0`,children:[(0,z.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-slate-500`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 max-w-[14rem] truncate text-right font-mono text-xs text-slate-300`,title:t,children:t})]})}function D7({children:e}){return(0,z.jsx)(`div`,{className:`rounded-sm border border-dashed border-slate-800 bg-[#0b0f14] p-3 text-xs leading-5 text-slate-500`,children:e})}function O7({title:e,icon:t,children:n}){return(0,z.jsxs)(`section`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4`,"aria-label":e,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(`span`,{className:`text-[#11a4d4]`,children:t}),e]}),n]})}function k7({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-slate-800/70 pb-2 last:border-b-0 last:pb-0`,children:[(0,z.jsx)(`span`,{className:`uppercase tracking-wide text-slate-500`,children:e}),(0,z.jsx)(`span`,{className:`min-w-0 max-w-[12rem] truncate text-right font-mono text-slate-300`,title:t,children:t})]})}function A7(e){return e.nodes.find(e=>e.status===`active`||e.status===`waiting`)??e.nodes[0]}function HFe({nodes:e,edges:t}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0f171e] p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(Rs,{size:14}),`Visual State Flow`]}),(0,z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_auto_1fr_auto_1fr]`,children:e.map((e,n)=>(0,z.jsx)(UFe,{node:e,edge:t[n]},e.id))})]})}function UFe({node:e,edge:t}){return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`rounded-sm border p-3 ${J7(e.status)}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(K7,{status:e.status}),(0,z.jsx)(`div`,{className:`min-w-0 truncate text-sm font-semibold text-slate-100`,children:e.label})]}),(0,z.jsx)(`span`,{className:`rounded border border-slate-700 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-slate-400`,children:e.kind})]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-slate-400`,children:e.description})]}),t?(0,z.jsx)(`div`,{className:`hidden items-center justify-center text-center text-[10px] uppercase tracking-wide text-slate-500 md:flex`,children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(fs,{size:14,className:`mx-auto mb-1 text-[#11a4d4]`}),t.label]})}):null]})}function WFe({model:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(Co,{size:14}),`Current UI Snapshot`]}),(0,z.jsx)(yq,{value:e.snapshot,showControls:!1})]})}function GFe({model:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4 text-sm`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(xs,{size:14}),`Node Statuses`]}),(0,z.jsxs)(`span`,{className:`font-mono text-[11px] text-slate-500`,children:[e.nodes.length,` nodes`]})]}),(0,z.jsx)(`div`,{className:`space-y-2`,children:e.nodes.map(e=>(0,z.jsxs)(`div`,{className:`rounded-sm border px-3 py-2 ${J7(e.status)}`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,z.jsx)(K7,{status:e.status})}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`truncate text-sm font-semibold text-slate-100`,children:e.label}),(0,z.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-slate-500`,children:e.id})]})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] uppercase tracking-wide ${gIe(e.status)}`,children:e.status}),(0,z.jsx)(`span`,{className:`rounded border border-slate-700 px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-slate-400`,children:e.kind})]})]}),(0,z.jsx)(`p`,{className:`mt-2 text-xs text-slate-400`,children:e.description})]},e.id))}),(0,z.jsx)(`p`,{className:`mt-3 text-xs text-slate-500`,children:`Node status is reconstructed from the workflow run linkage and live session state; persisted kernel records remain the durable source of truth.`})]})}function KFe({model:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4 text-sm`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(Ko,{size:14}),`Final Output & Validation`]}),(0,z.jsxs)(`div`,{className:`space-y-4`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-slate-400`,children:`Final output`}),e.finalOutput?(0,z.jsx)(`span`,{className:`rounded border border-slate-700 px-1.5 py-0.5 font-mono text-[10px] text-slate-500`,children:e.finalOutput.source}):null]}),e.finalOutput?(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-2`,children:(0,z.jsx)(yq,{value:e.finalOutput.value,defaultExpandLevel:1,maxHeight:`14rem`,showControls:!1})}):(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-3 text-xs text-slate-500`,children:`No final workflow output is available yet. Completed workflow-backed sessions show the final assistant output here.`})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,z.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-slate-400`,children:`Validation errors`}),(0,z.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 font-mono text-[10px] ${e.validationErrors.length?`border-red-500/40 bg-red-500/10 text-red-300`:`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`}`,children:e.validationErrors.length?`${e.validationErrors.length} found`:`none`})]}),e.validationErrors.length?(0,z.jsx)(`div`,{className:`space-y-2`,children:e.validationErrors.map(e=>(0,z.jsx)(`div`,{className:`rounded-sm border border-red-500/35 bg-red-500/10 p-2`,children:(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 text-xs text-red-200`,children:[(0,z.jsx)(Js,{size:14,className:`mt-0.5 shrink-0 text-red-300`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`break-words`,children:e.message}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1 font-mono text-[10px] text-red-200/70`,children:[e.code?(0,z.jsx)(`span`,{children:e.code}):null,e.path?(0,z.jsx)(`span`,{children:e.path}):null,e.source?(0,z.jsx)(`span`,{children:e.source}):null]})]})]})},e.id))}):(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-800 bg-[#0b0f14] p-3 text-xs text-slate-500`,children:`No workflow validation diagnostics were found in the current session trace.`})]})]})]})}function qFe({model:e}){return(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#111820] p-4 text-sm`,children:[(0,z.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-slate-500`,children:[(0,z.jsx)(Yo,{size:14}),`Projection Facts`]}),(0,z.jsxs)(`dl`,{className:`space-y-3`,children:[(0,z.jsx)(j7,{label:`projection kind`,value:`pibo.workflow.xstateUiModel`}),(0,z.jsx)(j7,{label:`schema`,value:`v1`}),(0,z.jsx)(j7,{label:`durable truth`,value:`kernel`}),(0,z.jsx)(j7,{label:`private payloads`,value:`not exposed`}),(0,z.jsx)(j7,{label:`states`,value:String(e.nodes.length)}),(0,z.jsx)(j7,{label:`transitions`,value:String(e.edges.length)}),(0,z.jsx)(j7,{label:`trace`,value:e.traceVersion??`pending`})]})]})}function j7({label:e,value:t}){return(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-slate-800/70 pb-2 last:border-b-0 last:pb-0`,children:[(0,z.jsx)(`dt`,{className:`text-xs uppercase tracking-wide text-slate-500`,children:e}),(0,z.jsx)(`dd`,{className:`min-w-0 truncate text-right font-mono text-xs text-slate-300`,children:t})]})}function JFe(e,t,n,r,i,a){if(!uIe(e))return null;let o=W7(e,n),s=dIe(e,n),c=fIe(s),l=oIe(t,s),u=[...cIe(t),...sIe(e,i)],d=$Fe(e,o,c),f=eIe(t,e.workflowRunId),p=rIe(t,e.workflowRunId),m=iIe(t,r),h=YFe(e),g=XFe(a,e.piboSessionId),_=[{id:`workflow.entry`,label:`workflow entry`,kind:`initial`,status:s===`idle`?`active`:`completed`,description:`Project session is linked to a workflow-capable route.`},{id:`node.session`,label:t?.title??`pibo session actor`,kind:`agent`,status:c===`node.session`?s:s===`completed`?`completed`:`idle`,description:`Normal Pibo routed session used as the visible workflow actor.`},{id:G7(s),label:pIe(s),kind:`terminal`,status:c.startsWith(`workflow.`)?s:`idle`,description:`Terminal state projected from the current workflow/session state.`}];return{projectId:e.projectId,workflowId:e.workflowId,...e.workflowVersion?{workflowVersion:e.workflowVersion}:{},...e.workflowRunId?{workflowRunId:e.workflowRunId}:{},piboSessionId:e.piboSessionId,state:o,status:s,traceTitle:t?.title,traceVersion:t?.version,latestStreamId:t?.latestStreamId,nodes:_,edges:[{id:`workflow.transition.entry.session`,source:`workflow.entry`,target:`node.session`,label:`WORKFLOW.START`},{id:`workflow.transition.session.terminal`,source:`node.session`,target:G7(s),label:mIe(s)}],configuration:ZFe(e),definitionLink:h,nestedSessionLinks:g,pendingHumanActions:QFe(e,r),runHistory:d,nodeAttempts:f,edgeTransfers:p,runtimeErrors:m,...l?{finalOutput:l}:{},validationErrors:u,snapshot:{kind:`pibo.workflow.xstateUiModel`,schemaVersion:1,projection:{workflowId:e.workflowId,initialStateId:`workflow.entry`,durableTruth:`kernel`,exposesPrivatePayloads:!1},authoring:{location:`workflows_tab`,rawXStateEditingUi:`not_exposed`,inlineExecutableCodeUi:`not_exposed`},current:{snapshotKind:`ui`,...e.workflowRunId?{runId:e.workflowRunId}:{},status:o,stateIds:[c],nodeId:c===`node.session`?`session`:void 0},nodeStatuses:_.map(e=>({id:e.id,kind:e.kind,status:e.status})),runInspection:{durableTruth:`kernel_run_records`,xstateProjectionOnly:!0,runHistoryCount:d.length,nodeAttemptCount:f.length,edgeTransferCount:p.length,runtimeErrorCount:m.length},result:{hasFinalOutput:!!l,validationErrorCount:u.length},actors:[{id:`workflow.actor.session`,kind:`agent`,piboSessionId:e.piboSessionId}],definitionLink:{status:h.status,workflowId:h.workflowId,workflowVersion:h.workflowVersion,hasLiveLink:h.status===`live`&&!!N7(h)},nestedWorkflowSessionCount:g.length}}}function YFe(e){return e.workflowDefinitionLink?e.workflowDefinitionLink:e.workflowVersion?{status:`live`,workflowId:e.workflowId,workflowVersion:e.workflowVersion,title:e.title??e.workflowId,href:P7(e.workflowId,e.workflowVersion)}:{status:`snapshot_only_definition_deleted`,workflowId:e.workflowId,title:e.title??e.workflowId,tombstoneLabel:`Historical run inspection uses the immutable Project session snapshot instead of a broken live definition link.`}}function XFe(e,t){let n=M7(e,t);if(!n)return[];let r=[],i=e=>{for(let t of e)t.workflowSessionKind===`nested_workflow`&&r.push({piboSessionId:t.piboSessionId,title:t.title,kind:t.workflowSessionKind??t.profile??`workflow`,...t.workflowSessionKind?{workflowSessionKind:t.workflowSessionKind}:{}}),i(t.children)};return i(n.children),r}function M7(e,t){for(let n of e){if(n.piboSessionId===t)return n;let e=M7(n.children,t);if(e)return e}}function N7(e){if(e.status===`live`){if(e.href)return e.href;if(e.workflowVersion)return P7(e.workflowId,e.workflowVersion)}}function P7(e,t){return`/apps/chat/workflows/view/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function F7(e){return`${e.workflowId}${e.workflowVersion?`@${e.workflowVersion}`:``}`}function ZFe(e){let t=e.configuration;return{inputKeys:Object.keys(t?.inputValues??{}).sort(),promptOverrideNodeIds:Object.keys(t?.promptOverrides??{}).sort()}}function QFe(e,t){if(e.pendingHumanActions?.length)return e.pendingHumanActions.map(e=>({id:`wait-token:${e.waitTokenId}`,waitTokenId:e.waitTokenId,workflowRunId:e.workflowRunId,...e.nodeAttemptId?{nodeAttemptId:e.nodeAttemptId}:{},...e.humanNodeId?{humanNodeId:e.humanNodeId}:{},prompt:e.prompt,label:`Pending registered human action`,source:`persisted wait token`,...e.schema?{schema:e.schema}:{},payloadRequirements:e.payloadRequirements,availableActions:e.availableActions,diagnostics:e.diagnostics,createdAt:e.createdAt,...e.expiresAt?{expiresAt:e.expiresAt}:{}}));let n=W7(e,void 0).toLowerCase(),r=[t?.aggregateStatus,t?.localStatus].filter(e=>typeof e==`string`).join(` `).toLowerCase();return n.includes(`waiting`)||n.includes(`blocked`)||r.includes(`waiting`)||r.includes(`blocked`)||t?.hasBlockedDescendant?[{id:`human-action:${e.piboSessionId}`,prompt:`Session signal indicates a wait, but no persisted workflow wait token is available in the Project run store.`,label:`Awaiting human action`,source:t?`session signal`:`project session state`,availableActions:[],diagnostics:[]}]:[]}function $Fe(e,t,n){return e.workflowRunId?[{id:e.workflowRunId,status:t,currentNodeId:n,updatedAt:e.updatedAt,source:`project session run record`}]:[]}function eIe(e,t){return!t||!e?[]:I7(e.nodes).filter(tIe).slice(0,8).map((e,t)=>({id:e.id,nodeId:e.stableKey??e.entryId??e.type,label:e.title||e.type,kind:e.type,status:nIe(e.status),attempt:t+1,source:`session trace fact`,...e.startedAt?{startedAt:e.startedAt}:{},...e.completedAt?{completedAt:e.completedAt}:{}}))}function tIe(e){return e.type===`agent.turn`||e.type===`tool.call`||e.type===`execution.command`||e.type===`agent.delegation`||e.type===`agent.async`||e.type===`yielded.run`||e.type===`error`}function nIe(e){return e===`done`?`completed`:e===`error`?`failed`:`running`}function rIe(e,t){if(!t||!e)return[];let n=[];for(let r of e.rawEvents){if(!U7(r.payload))continue;let e=H7(r.payload.type),i=H7(r.payload.runId);if(e!==`edge.transferred`||i&&i!==t)continue;let a=H7(r.payload.edgeId);a&&n.push({id:H7(r.payload.edgeTransferId)??r.id,edgeId:a,status:`transferred`,source:r.type,createdAt:r.createdAt})}return n.slice(0,8)}function iIe(e,t){let n=[];for(let e of t?.errors??[])n.push({id:`signal:${n.length}`,message:e.message,...e.code?{code:e.code}:{},source:e.source??`session signal`});if(e){for(let t of I7(e.nodes)){let e=t.error??(t.status===`error`?R7(t.output)??R7(t.summary):void 0);e&&n.push({id:`node:${t.id}`,message:e,source:t.type})}for(let t of e.rawEvents){if(!U7(t.payload))continue;let e=t.payload.error,r=U7(e)?H7(e.message):H7(e),i=U7(e)?H7(e.code):void 0;r&&n.push({id:`event:${t.id}`,message:r,...i?{code:i}:{},source:t.type})}}return aIe(n).slice(0,8)}function aIe(e){let t=new Set;return e.filter(e=>{let n=`${e.code??``}:${e.message}:${e.source??``}`;return t.has(n)?!1:(t.add(n),!0)})}function oIe(e,t){if(t!==`completed`||!e)return;let n=I7(e.nodes),r=[...n].reverse().find(e=>e.type===`assistant.message`&&e.status===`done`&&(e.output!==void 0||e.summary));if(r)return{value:r.output??r.summary??``,source:`assistant.message`};let i=[...n].reverse().find(e=>e.status===`done`&&e.type!==`user.message`&&e.type!==`model.reasoning`&&e.output!==void 0);return i?{value:i.output,source:i.type}:void 0}function sIe(e,t){let n=[];for(let r of t)if(r.piboSessionId===e.piboSessionId&&!(r.type!==`project.workflow_start.blocked`&&r.validation?.trigger!==`before_workflow_start`))for(let e of r.diagnostics)e.severity===`error`&&n.push({id:`lifecycle:${r.id}:${n.length}`,message:e.message,code:e.code,path:e.path,source:`start lifecycle event`});return B7(n).slice(0,8)}function cIe(e){if(!e)return[];let t=[];for(let n of I7(e.nodes)){let e=n.error??R7(n.output)??R7(n.summary);e&&(!z7([n.title,n.summary,n.error,n.type].filter(e=>typeof e==`string`).join(` `))&&!z7(e)||t.push({id:`node:${n.id}`,message:e,...n.type?{source:n.type}:{}}))}for(let n of e.rawEvents)L7(n.payload,`event:${n.id}`,t);return B7(t).slice(0,8)}function I7(e){let t=[],n=e=>{for(let r of e)t.push(r),n(r.children)};return n(e),t}function L7(e,t,n,r=0){if(r>4||!U7(e))return;let i=Array.isArray(e.diagnostics)?e.diagnostics:void 0;if(i)for(let e of i){if(!U7(e))continue;let r=H7(e.message)??R7(e);r&&n.push({id:`${t}:diagnostic:${n.length}`,message:r,...H7(e.code)?{code:H7(e.code)}:{},...H7(e.path)?{path:H7(e.path)}:{},source:`workflow.diagnostic`})}let a=e.error;if(U7(a)){let e=H7(a.code),r=H7(a.message)??R7(a);r&&z7([e,r].filter(Boolean).join(` `))&&n.push({id:`${t}:error:${n.length}`,message:r,...e?{code:e}:{},source:`workflow.error`})}else typeof a==`string`&&z7(a)&&n.push({id:`${t}:error:${n.length}`,message:a,source:`workflow.error`});for(let[i,a]of Object.entries(e))i===`diagnostics`||i===`error`||i!==`payload`&&i!==`output`&&i!==`result`&&i!==`data`||L7(a,`${t}:${i}`,n,r+1)}function R7(e){if(typeof e==`string`)return e;if(U7(e))return H7(e.message)??H7(e.error)??H7(e.summary)}function z7(e){let t=e.toLowerCase();return t.includes(`validation`)||t.includes(`validate`)||t.includes(`diagnostic`)||t.includes(`workflowinterfaceerror`)||t.includes(`workflowruntimeerror.validation`)}function B7(e){let t=new Set;return e.filter(e=>{let n=`${e.code??``}:${e.path??``}:${e.message}`;return t.has(n)?!1:(t.add(n),!0)})}function lIe(e){return U7(e)&&U7(e.data)&&Array.isArray(e.data.diagnostics)?e.data.diagnostics.filter(U7).map(t=>({code:H7(t.code)??`WorkflowRuntimeError.humanActionRejected`,message:H7(t.message)??V7(e),severity:t.severity===`info`||t.severity===`warning`||t.severity===`error`?t.severity:`error`,...H7(t.path)?{path:H7(t.path)}:{},...H7(t.registryRef)?{registryRef:H7(t.registryRef)}:{},...H7(t.hint)?{hint:H7(t.hint)}:{}})):[{code:`WorkflowRuntimeError.humanActionRejected`,message:V7(e),severity:`error`}]}function V7(e){return e instanceof Error?e.message:String(e)}function H7(e){return typeof e==`string`&&e.trim()?e:void 0}function U7(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function uIe(e){return!!e.workflowRunId||e.state===`workflow`||e.workflowId!==`simple-chat`}function W7(e,t){return e.archived?`archived`:e.state&&e.state!==`workflow`?e.state.replace(/_/g,` `):t===`running`?`running`:t===`error`?`failed`:e.workflowRunId?`workflow`:e.kind}function dIe(e,t){let n=W7(e,t).toLowerCase();return e.archived?`cancelled`:n.includes(`complete`)||n.includes(`done`)?`completed`:n.includes(`fail`)||n.includes(`error`)?`failed`:n.includes(`cancel`)?`cancelled`:n.includes(`wait`)||n.includes(`blocked`)?`waiting`:!e.workflowRunId&&n.includes(`configured`)?`idle`:`active`}function fIe(e){return e===`completed`?`workflow.completed`:e===`failed`?`workflow.failed`:e===`cancelled`?`workflow.cancelled`:`node.session`}function G7(e){return e===`failed`?`workflow.failed`:e===`cancelled`?`workflow.cancelled`:`workflow.completed`}function pIe(e){return e===`failed`?`failed`:e===`cancelled`?`cancelled`:`completed`}function mIe(e){return e===`failed`?`WORKFLOW.FAIL`:e===`cancelled`?`WORKFLOW.CANCEL`:`WORKFLOW.NODE.DONE`}function K7({status:e}){return e===`completed`?(0,z.jsx)(Ko,{size:16,className:`text-emerald-300`}):e===`failed`?(0,z.jsx)(Jo,{size:16,className:`text-red-300`}):e===`cancelled`?(0,z.jsx)(Js,{size:16,className:`text-slate-400`}):e===`waiting`?(0,z.jsx)(Xo,{size:16,className:`text-amber-300`}):e===`active`?(0,z.jsx)(Co,{size:16,className:`text-[#11a4d4]`}):(0,z.jsx)(Yo,{size:16,className:`text-slate-500`})}function q7({tone:e,children:t}){return(0,z.jsx)(`span`,{className:`rounded border px-2 py-1 font-mono ${{blue:`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-[#11a4d4]`,slate:`border-slate-700 bg-slate-900/50 text-slate-300`,green:`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`,amber:`border-amber-500/40 bg-amber-500/10 text-amber-300`,red:`border-red-500/40 bg-red-500/10 text-red-300`}[e]}`,children:t})}function hIe(e){return e===`completed`?`green`:e===`failed`||e===`cancelled`?`red`:e===`waiting`?`amber`:`blue`}function J7(e){return e===`completed`?`border-emerald-500/40 bg-emerald-500/10`:e===`failed`?`border-red-500/40 bg-red-500/10`:e===`cancelled`?`border-slate-600 bg-slate-800/40`:e===`waiting`?`border-amber-500/40 bg-amber-500/10`:e===`active`?`border-[#11a4d4]/50 bg-[#11a4d4]/10 shadow-[0_0_0_1px_rgba(17,164,212,0.18)]`:`border-slate-800 bg-[#111820]`}function gIe(e){return e===`completed`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`:e===`failed`||e===`cancelled`?`border-red-500/40 bg-red-500/10 text-red-300`:e===`waiting`?`border-amber-500/40 bg-amber-500/10 text-amber-300`:e===`active`?`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-[#11a4d4]`:`border-slate-700 bg-slate-900/50 text-slate-400`}function Y7(e){let t=e.toLowerCase();return t.includes(`complete`)||t.includes(`done`)||t.includes(`transferred`)?`border-emerald-500/40 bg-emerald-500/10 text-emerald-300`:t.includes(`fail`)||t.includes(`error`)||t.includes(`cancel`)?`border-red-500/40 bg-red-500/10 text-red-300`:t.includes(`wait`)||t.includes(`blocked`)?`border-amber-500/40 bg-amber-500/10 text-amber-300`:t.includes(`run`)||t.includes(`active`)||t.includes(`workflow`)?`border-[#11a4d4]/40 bg-[#11a4d4]/10 text-[#11a4d4]`:`border-slate-700 bg-slate-900/50 text-slate-400`}function X7(e){return e.length>18?`${e.slice(0,10)}…${e.slice(-6)}`:e}var Z7=[{id:`terminal`,label:`Terminal`,description:`Compact Codex-style terminal transcript.`,render:e=>(0,z.jsx)(vFe,{...e})},{id:`workflow`,label:`Workflow`,description:`Workflow/XState visualization for workflow-backed project sessions.`,render:e=>(0,z.jsx)(IFe,{...e})}],Q7=new Map(Z7.map(e=>[e.id,e]));function _Ie(){return Z7}function $7(e){return Q7.get(e)??Q7.get(`terminal`)}function e9(e,t){return{localBootstrap:t,queryData:e.getQueriesData({queryKey:[`chat`,`bootstrap`]})}}function t9(e,t){return p9(e.sessions,t.piboSessionId)?e:{...e,sessions:[t,...e.sessions]}}function vIe(e,t){let n=n9(e.sessions,t),r=t.has(e.selectedPiboSessionId);return{...e,selectedPiboSessionId:r?``:e.selectedPiboSessionId,sessions:n}}function n9(e,t){let n=!1,r=[];for(let i of e){if(t.has(i.piboSessionId)){n=!0;continue}let e=n9(i.children,t);e===i.children?r.push(i):(n=!0,r.push({...i,children:e}))}return n?r:e}function r9(e){let t=new Set([e.piboSessionId]);for(let n of e.children)for(let e of r9(n))t.add(e);return t}function yIe(e,t,n){if(!t)return t9(e,n);let r=!1,i=u9(e.sessions,t,()=>(r=!0,n));return{...e,selectedPiboSessionId:e.selectedPiboSessionId===t?n.piboSessionId:e.selectedPiboSessionId,session:e.session.id===t?f9(n,e.session):e.session,sessions:r?i:[n,...i]}}function i9(e,t){let n=typeof t.metadata?.chatWebArchivedAt==`string`;return{...e,session:e.session.id===t.id?t:e.session,sessions:u9(e.sessions,t.id,e=>({...e,profile:t.profile,activeModel:t.activeModel,title:t.title||e.title||`Untitled Session`,archived:n}))}}function a9(e,t,n){let r=e.session.id===t?f9(n(d9(e.session)),e.session):e.session;return{...e,session:r,sessions:u9(e.sessions,t,n)}}function bIe(e,t){return f3(e.rooms,t.id)?e:{...e,room:t,selectedRoomId:t.id,selectedPiboSessionId:``,rooms:[t,...e.rooms]}}function xIe(e,t,n){return{...e,room:e.room?.id===t?n:e.room,selectedRoomId:e.selectedRoomId===t?n.id:e.selectedRoomId,rooms:s9(e.rooms,t,()=>n)}}function o9(e,t,n){return{...e,room:e.room?.id===t?n(e.room):e.room,rooms:s9(e.rooms,t,n)}}function SIe(e,t){let n=t.has(e.selectedRoomId);return{...e,room:e.room&&t.has(e.room.id)?void 0:e.room,selectedRoomId:n?``:e.selectedRoomId,selectedPiboSessionId:n?``:e.selectedPiboSessionId,rooms:c9(e.rooms,t)}}function s9(e,t,n){let r=!1,i=e.map(e=>{if(e.id===t)return r=!0,n(e);let i=e.children??[],a=s9(i,t,n);return a===i?e:(r=!0,{...e,children:a})});return r?i:e}function c9(e,t){let n=!1,r=[];for(let i of e){if(t.has(i.id)){n=!0;continue}let e=i.children??[],a=c9(e,t);a===e?r.push(i):(n=!0,r.push({...i,children:a}))}return n?r:e}function CIe(e,t){let n=new Date().toISOString();return{id:e,name:t,type:`chat`,createdAt:n,updatedAt:n,metadata:{},children:[]}}function wIe(e,t){let n={...e.metadata};return t?n.chatRoomArchivedAt=new Date().toISOString():delete n.chatRoomArchivedAt,{...e,metadata:n,updatedAt:new Date().toISOString()}}function l9(e){let t=new Set([e.id]);for(let n of e.children??[])for(let e of l9(n))t.add(e);return t}function u9(e,t,n){let r=!1,i=e.map(e=>{if(e.piboSessionId===t)return r=!0,n(e);let i=u9(e.children,t,n);return i===e.children?e:(r=!0,{...e,children:i})});return r?i:e}function TIe(e,t){return{piboSessionId:e,piSessionId:`pending`,profile:t,title:`New Session`,status:`idle`,lastActivityAt:new Date().toISOString(),derivedSessions:[],children:[]}}function d9(e){return{piboSessionId:e.id,piSessionId:e.piSessionId,profile:e.profile,activeModel:e.activeModel,title:e.title||`Untitled Session`,archived:typeof e.metadata?.chatWebArchivedAt==`string`,status:`idle`,lastActivityAt:e.updatedAt,derivedSessions:[],children:[]}}function f9(e,t){return{...t,id:e.piboSessionId,piSessionId:e.piSessionId,profile:e.profile,activeModel:e.activeModel,title:c3(e),updatedAt:e.lastActivityAt??t.updatedAt}}function p9(e,t){for(let n of e){if(n.piboSessionId===t)return n;let e=p9(n.children,t);if(e)return e}}function EIe(e){let t=e.trim();if(t.length>=2){let e=t[0],n=t[t.length-1];if(e===`"`&&n===`"`||e===`'`&&n===`'`)return t.slice(1,-1).trim()}return t}function DIe(e,t){if(e===`thinking`&&t)return{level:t.split(/\s+/,1)[0]};if(e===`compact`&&t)return{customInstructions:t}}function OIe(e){return!m9(e)||!m9(e.result)?null:e}function kIe(e){if(!(!m9(e)||!m9(e.result)))return typeof e.result.piboSessionId==`string`?e.result.piboSessionId:void 0}function m9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function AIe(e){let t=e.flatMap(e=>e.slashCommands.filter(e=>e!==`tree`).map(t=>({slash:`/${t}`,action:e.name,description:e.name===`thinking`&&t===`thinking`?`Show thinking level or use /thinking <level>.`:e.description??e.name})));return t.push({slash:`/download`,action:`download`,description:`Download a file by absolute path or relative to the current working directory.`},{slash:`/upload`,action:`upload`,description:`Upload one or more files to ~/.pibo/uploads.`},{slash:`/thinking-show`,action:`thinking-show`,description:`Toggle historical thinking display in this browser.`}),t}function jIe(e,t){if(!e)return[];let n=e.agentCatalog?.skills??[],r=e.agentCatalog?.userSkills??[],i=[...n,...r],a=Q4(e),o=t?e3(e.sessions,t)?.profile??a:a,s=[...e.agents.map(e=>({name:e.name,skills:e.skills})),...e.customAgents.map(e=>({name:e.profileName,skills:e.skills}))].find(e=>e.name===o),c=new Set(s?.skills??[]);return i.filter(e=>c.has(e.name))}function MIe(e,t){let n=e.area===`sessions`?e.roomId:void 0,r=e.area===`sessions`||e.area===`projects`||e.area===`context`?e.piboSessionId:void 0,i=n?t.sessionsByRoom?.[n]:t.piboSessionId;return{requestedRoomId:e.area===`sessions`?n??(r?void 0:t.roomId):e.area===`context`&&r?void 0:t.roomId,requestedPiboSessionId:e.area===`sessions`?r??(r?void 0:i):e.area===`context`?r:t.piboSessionId}}function NIe(e){let{bootstrap:t,creatingSession:n,route:r}=e,i=r.area===`sessions`||r.area===`projects`||r.area===`context`?r.piboSessionId:void 0;return t&&r.area!==`sessions`&&(r.area!==`context`||!i||t.selectedPiboSessionId===i)||n?!0:!!(t&&r.area===`sessions`&&r.piboSessionId&&t.selectedPiboSessionId===r.piboSessionId&&t.selectedRoomId===r.roomId)}function PIe(e,t){if(e.area===`sessions`&&t.selectedPiboSessionId&&!(e.roomId===t.selectedRoomId&&e.piboSessionId===t.selectedPiboSessionId))return t}function FIe(e){return e.area===`sessions`&&!!(e.roomId||e.piboSessionId)}function IIe({activePanel:e,onSelect:t,piPackageCount:n,userSkillCount:r}){return(0,z.jsx)(`div`,{className:`p-2`,children:(0,z.jsxs)(`div`,{className:`mb-4`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Settings`}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(`general`),className:`mb-1 flex w-full items-center gap-2 border p-2 text-left ${e===`general`?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(Ws,{size:13,className:`text-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm text-slate-200`,children:`General`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`browser + runtime`})]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(`shortcuts`),className:`mb-1 flex w-full items-center gap-2 border p-2 text-left ${e===`shortcuts`?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(_s,{size:13,className:`text-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm text-slate-200`,children:`Shortcuts`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`keyboard`})]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(`pi-packages`),className:`mb-1 flex w-full items-center gap-2 border p-2 text-left ${e===`pi-packages`?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(vs,{size:13,className:`text-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm text-slate-200`,children:`Pi Packages`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`runtime-packages`})]}),(0,z.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center border border-slate-700 bg-[#101d22] px-1.5 py-0.5 text-[10px] font-mono text-slate-400`,children:n})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(`skills`),className:`mb-1 flex w-full items-center gap-2 border p-2 text-left ${e===`skills`?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(Zs,{size:13,className:`text-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm text-slate-200`,children:`Skills`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`user-managed`})]}),(0,z.jsx)(`span`,{className:`inline-flex min-w-6 items-center justify-center border border-slate-700 bg-[#101d22] px-1.5 py-0.5 text-[10px] font-mono text-slate-400`,children:r})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>t(`providers`),className:`flex w-full items-center gap-2 border p-2 text-left ${e===`providers`?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 bg-[#151f24] hover:border-slate-700`}`,children:[(0,z.jsx)(gs,{size:13,className:`text-[#11a4d4]`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`block truncate text-sm text-slate-200`,children:`Providers`}),(0,z.jsx)(`span`,{className:`block truncate font-mono text-[10px] text-slate-500`,children:`auth + api keys`})]})]})]})})}var h9=[{id:`openai-codex`,name:`OpenAI (ChatGPT Plus/Pro)`,authMethod:`oauth`},{id:`openai`,name:`OpenAI (API Key)`,authMethod:`api_key`},{id:`anthropic`,name:`Anthropic (Claude)`,authMethod:`oauth`},{id:`github-copilot`,name:`GitHub Copilot`,authMethod:`oauth`},{id:`kimi-coding`,name:`Kimi for Coding`,authMethod:`api_key`},{id:`google`,name:`Google (Gemini)`,authMethod:`api_key`},{id:`groq`,name:`Groq`,authMethod:`api_key`},{id:`ollama`,name:`Ollama`,authMethod:`api_key`},{id:`minimax`,name:`MiniMax`,authMethod:`api_key`},{id:`minimax-cn`,name:`MiniMax (China)`,authMethod:`api_key`}];function LIe({piboSessionId:e,onProviderAuthChanged:t}){let[n,r]=(0,R.useState)({}),[i,a]=(0,R.useState)(!1),[o,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(null),[u,d]=(0,R.useState)({}),[f,p]=(0,R.useState)({}),[m,h]=(0,R.useState)({}),[g,_]=(0,R.useState)({}),[v,y]=(0,R.useState)(null),[b,x]=(0,R.useState)({}),S=(0,R.useCallback)(async()=>{if(e){a(!0),s(null);try{let t=g9(await yc(e,`login.status`,{})),n={};if(Array.isArray(t?.providers))for(let e of t.providers){let t=e.id??e.provider;t&&(n[t]=e.configured)}r(n)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}},[e]);(0,R.useEffect)(()=>{S()},[S]);let C=(0,R.useCallback)(async t=>{if(e){x(e=>({...e,[t]:!0})),s(null),l(null),d(e=>({...e,[t]:{type:`oauth_starting`}}));try{let n=g9(await yc(e,`login.start`,{provider:t})),r=n.url,i=n.state;r?d(e=>({...e,[t]:{type:`oauth_flow`,url:r,state:i,userCode:n.userCode,instructions:n.instructions,flow:n.type}})):(s(`No URL returned from login start.`),d(e=>({...e,[t]:{type:`collapsed`}})))}catch(e){s(e instanceof Error?e.message:String(e)),d(e=>({...e,[t]:{type:`collapsed`}}))}finally{x(e=>({...e,[t]:!1}))}}},[e]),w=(0,R.useCallback)(async(n,i,a)=>{if(e){x(e=>({...e,[n]:!0})),s(null),l(null);try{await yc(e,`login.complete`,{provider:n,...i?{code:i}:{},state:a??``});let o=_9(n);l(`${o} login completed.`),r(e=>({...e,[n]:!0})),d(e=>({...e,[n]:{type:`collapsed`}})),p(e=>({...e,[n]:``})),await t?.(),window.setTimeout(()=>l(e=>e===`${o} login completed.`?null:e),5e3)}catch(e){s(e instanceof Error?e.message:String(e))}finally{x(e=>({...e,[n]:!1}))}}},[t,e]),T=(0,R.useCallback)(async(n,i)=>{if(e){x(e=>({...e,[n]:!0})),s(null),l(null);try{await yc(e,`login.apikey`,{provider:n,apiKey:i});let a=_9(n);l(`${a} API key saved.`),r(e=>({...e,[n]:!0})),d(e=>({...e,[n]:{type:`collapsed`}})),h(e=>({...e,[n]:``})),await t?.(),window.setTimeout(()=>l(e=>e===`${a} API key saved.`?null:e),5e3)}catch(e){s(e instanceof Error?e.message:String(e))}finally{x(e=>({...e,[n]:!1}))}}},[t,e]),E=(0,R.useCallback)(async n=>{if(e){x(e=>({...e,[n]:!0})),s(null),l(null);try{await yc(e,`logout`,{provider:n}),r(e=>({...e,[n]:!1})),await t?.()}catch(e){s(e instanceof Error?e.message:String(e))}finally{x(e=>({...e,[n]:!1}))}}},[t,e]),D=async e=>{try{await navigator.clipboard.writeText(e),y(e),setTimeout(()=>y(null),2e3)}catch{}};return e?(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[o?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-red-500/30 bg-red-500/10 px-3 py-2 text-xs text-red-300`,children:[(0,z.jsx)(Go,{size:14}),o]}):null,c?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-sm border border-[#0bda57]/30 bg-[#0bda57]/10 px-3 py-2 text-xs text-[#7cf2a2]`,children:[(0,z.jsx)(qo,{size:14}),c]}):null,i?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[#11a4d4]`,children:[(0,z.jsx)(Cs,{size:14,className:`animate-spin`}),`Loading provider status...`]}):null,h9.map(e=>{let t=n[e.id]??!1,r=u[e.id]??{type:`collapsed`},i=b[e.id]??!1;return(0,z.jsxs)(`div`,{className:`border rounded-sm ${r.type===`collapsed`?t?`border-[#0bda57]/20 bg-[#151f24]`:`border-[#334155] bg-[#151f24] hover:border-slate-600`:`border-[#11a4d4]/50 bg-[#151f24]`}`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 p-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`text-sm font-medium text-slate-200`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 text-[10px] font-mono uppercase tracking-wider ${e.authMethod===`oauth`?`border-purple-500/40 text-purple-300`:`border-amber-500/40 text-amber-300`}`,children:e.authMethod===`oauth`?`OAuth`:`API Key`})]}),(0,z.jsx)(`div`,{className:`mt-1 flex items-center gap-1.5 text-xs`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(qo,{size:12,className:`text-[#0bda57]`}),(0,z.jsx)(`span`,{className:`text-[#0bda57]`,children:`Configured`})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(Ts,{size:12,className:`text-slate-500`}),(0,z.jsx)(`span`,{className:`text-slate-500`,children:`Not configured`})]})})]}),(0,z.jsx)(`div`,{className:`flex items-center gap-2`,children:t?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>d(t=>({...t,[e.id]:t[e.id]?.type===`collapsed`?e.authMethod===`oauth`?{type:`oauth_starting`}:{type:`api_key`}:{type:`collapsed`}})),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-2.5 py-1.5 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[i?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(gs,{size:12}),`Reconfigure`]}),(0,z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>void E(e.id),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-2.5 py-1.5 text-[11px] text-slate-300 hover:border-red-500 hover:text-red-300 disabled:opacity-50`,children:[(0,z.jsx)(qs,{size:12}),`Remove`]})]}):(0,z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>e.authMethod===`oauth`?void C(e.id):d(t=>({...t,[e.id]:{type:`api_key`}})),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-2.5 py-1.5 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[i?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(gs,{size:12}),`Configure`]})})]}),r.type===`collapsed`?null:(0,z.jsx)(`div`,{className:`border-t border-slate-800 p-3`,children:r.type===`oauth_starting`?(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[#11a4d4]`,children:[(0,z.jsx)(Cs,{size:14,className:`animate-spin`}),`Starting OAuth flow...`]}):r.type===`oauth_flow`?(0,z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Step 1: Open URL`}),(0,z.jsx)(`div`,{className:`break-all rounded-sm border border-slate-700 bg-[#0e1116] p-2 font-mono text-[11px] text-slate-300`,children:r.url}),(0,z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void D(r.url),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-2 py-1 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:[v===r.url?(0,z.jsx)(qo,{size:12}):(0,z.jsx)($o,{size:12}),v===r.url?`Copied`:`Copy URL`]}),(0,z.jsxs)(`a`,{href:r.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-2 py-1 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:[(0,z.jsx)(rs,{size:12}),`Open in Browser`]})]})]}),r.userCode?(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Step 2: Enter Code`}),(0,z.jsx)(`div`,{className:`rounded-sm border border-slate-700 bg-[#0e1116] p-3 text-center font-mono text-[20px] font-bold tracking-widest text-[#11a4d4]`,children:r.userCode}),r.instructions?(0,z.jsx)(`div`,{className:`text-[11px] leading-relaxed text-slate-500`,children:r.instructions}):null,(0,z.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>void w(e.id,void 0,r.state),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-3 py-1.5 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[i?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ts,{size:12}),`Complete Login`]})]}):(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Step 2: Paste Code`}),(0,z.jsx)(`input`,{type:`text`,value:f[e.id]??``,onChange:t=>p(n=>({...n,[e.id]:t.target.value})),onKeyDown:t=>{t.key===`Enter`&&(f[e.id]??``).trim()&&w(e.id,f[e.id].trim(),r.state)},placeholder:`Paste authorization code...`,className:`w-full rounded-sm border border-slate-700 bg-[#0e1116] px-2 py-1.5 font-mono text-[12px] text-slate-300 placeholder-slate-600 outline-none focus:border-[#11a4d4]`}),(0,z.jsxs)(`button`,{type:`button`,disabled:i||!(f[e.id]??``).trim(),onClick:()=>void w(e.id,f[e.id].trim(),r.state),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-3 py-1.5 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[i?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ts,{size:12}),`Complete Login`]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.id]:{type:`collapsed`}})),className:`text-[11px] text-slate-500 hover:text-[#11a4d4]`,children:`← Cancel`})]}):r.type===`api_key`?(0,z.jsxs)(`div`,{className:`grid gap-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Enter API Key`}),(0,z.jsxs)(`div`,{className:`relative`,children:[(0,z.jsx)(`input`,{type:g[e.id]?`text`:`password`,value:m[e.id]??``,onChange:t=>h(n=>({...n,[e.id]:t.target.value})),onKeyDown:t=>{t.key===`Enter`&&(m[e.id]??``).trim()&&T(e.id,m[e.id].trim())},placeholder:`sk-...`,className:`w-full rounded-sm border border-slate-700 bg-[#0e1116] px-2 py-1.5 pr-8 font-mono text-[12px] text-slate-300 placeholder-slate-600 outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>_(t=>({...t,[e.id]:!t[e.id]})),className:`absolute right-2 top-1/2 -translate-y-1/2 text-slate-500 hover:text-[#11a4d4]`,title:g[e.id]?`Hide`:`Show`,children:g[e.id]?(0,z.jsx)(is,{size:14}):(0,z.jsx)(as,{size:14})})]}),(0,z.jsxs)(`button`,{type:`button`,disabled:i||!(m[e.id]??``).trim(),onClick:()=>void T(e.id,m[e.id].trim()),className:`inline-flex items-center gap-1 rounded-sm border border-slate-700 bg-[#0e1116] px-3 py-1.5 text-[11px] text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[i?(0,z.jsx)(Cs,{size:12,className:`animate-spin`}):(0,z.jsx)(Ts,{size:12}),`Save API Key`]}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>d(t=>({...t,[e.id]:{type:`collapsed`}})),className:`text-[11px] text-slate-500 hover:text-[#11a4d4]`,children:`← Cancel`})]}):null})]},e.id)})]}):(0,z.jsx)(`div`,{className:`border border-slate-700 bg-[#1a262b] rounded-sm p-4 text-sm text-slate-400`,children:`Select a chat session to manage provider authentication.`})}function g9(e){return RIe(e)?e.result:e}function RIe(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&e.type===`execution_result`}function _9(e){return h9.find(t=>t.id===e)?.name??e}function zIe({activePanel:e,showThinking:t,setShowThinking:n,expandThinking:r,setExpandThinking:i,modelDefaults:a,modelCatalog:o,onModelDefaultsChanged:s,piPackages:c,onPiPackageChanged:l,onPiPackageRemoved:u,userSkills:d,onUserSkillChanged:f,onUserSkillRemoved:p,piboSessionId:m,onProviderAuthChanged:h}){return e===`pi-packages`?(0,z.jsxs)(`div`,{className:`p-6 overflow-auto`,children:[(0,z.jsxs)(`h1`,{className:`text-sm font-bold uppercase tracking-wider mb-4 flex items-center gap-2`,children:[(0,z.jsx)(vs,{size:16}),`Pi Packages`]}),(0,z.jsx)(JIe,{packages:c,onPackageChanged:l,onPackageRemoved:u})]}):e===`skills`?(0,z.jsxs)(`div`,{className:`overflow-auto p-6 max-[640px]:p-3`,children:[(0,z.jsxs)(`h1`,{className:`mb-4 flex items-center gap-2 text-sm font-bold uppercase tracking-wider`,children:[(0,z.jsx)(Zs,{size:16}),`Skills`]}),(0,z.jsx)(YIe,{skills:d,onSkillChanged:f,onSkillRemoved:p})]}):e===`providers`?(0,z.jsxs)(`div`,{className:`p-6 overflow-auto`,children:[(0,z.jsxs)(`h1`,{className:`text-sm font-bold uppercase tracking-wider mb-4 flex items-center gap-2`,children:[(0,z.jsx)(gs,{size:16}),`Providers`]}),(0,z.jsx)(LIe,{piboSessionId:m,onProviderAuthChanged:h})]}):e===`shortcuts`?(0,z.jsxs)(`div`,{className:`p-6 overflow-auto`,children:[(0,z.jsxs)(`h1`,{className:`text-sm font-bold uppercase tracking-wider mb-4 flex items-center gap-2`,children:[(0,z.jsx)(_s,{size:16}),`Shortcuts`]}),(0,z.jsx)(HIe,{})]}):(0,z.jsxs)(`div`,{className:`p-6 overflow-auto`,children:[(0,z.jsxs)(`h1`,{className:`text-sm font-bold uppercase tracking-wider mb-4 flex items-center gap-2`,children:[(0,z.jsx)(Ws,{size:16}),`General`]}),(0,z.jsxs)(k0,{title:`General`,children:[(0,z.jsx)(VIe,{}),(0,z.jsx)(P0,{checked:t,title:`Show thinking blocks`,onToggle:()=>{let e=!t;n(e),r2(e)}}),(0,z.jsx)(P0,{checked:r,disabled:!t,title:`Expand thinking blocks`,onToggle:()=>{let e=!r;i(e),i2(e)}}),(0,z.jsx)(qIe,{modelDefaults:a,modelCatalog:o,onChanged:s})]})]})}var BIe=`UTC.Europe/Berlin.Europe/London.Europe/Paris.Europe/Madrid.Europe/Rome.Europe/Amsterdam.Europe/Vienna.Europe/Zurich.Europe/Warsaw.Europe/Istanbul.America/New_York.America/Chicago.America/Denver.America/Los_Angeles.America/Toronto.America/Sao_Paulo.America/Mexico_City.Asia/Dubai.Asia/Jerusalem.Asia/Kolkata.Asia/Bangkok.Asia/Singapore.Asia/Shanghai.Asia/Tokyo.Asia/Seoul.Australia/Sydney.Australia/Melbourne.Pacific/Auckland`.split(`.`);function VIe(){let e=Yt(),{data:t,isLoading:n}=dn({queryKey:[`user-settings`],queryFn:Zz}),r=(0,R.useMemo)(()=>WIe(t?.timezone),[t?.timezone]),[i,a]=(0,R.useState)(`UTC`),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(null);(0,R.useEffect)(()=>{t?.timezone&&a(t.timezone)},[t?.timezone]);let u=async(t=i)=>{s(!0),l(null);try{let n=await Qz({timezone:t});a(n.timezone),e.setQueryData([`user-settings`],n)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,z.jsxs)(`div`,{className:`border-b border-slate-800 pb-4 mb-4`,children:[(0,z.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-slate-400`,children:`App timezone`}),(0,z.jsx)(`div`,{className:`max-w-xl`,children:(0,z.jsx)(`select`,{value:i,disabled:n||o,onChange:e=>{let t=e.target.value;a(t),u(t)},className:`w-full min-w-0 rounded-sm border border-slate-700 bg-[#0e1116] px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,children:r.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),(0,z.jsx)(`div`,{className:`mt-2 text-[11px] text-slate-500`,children:`Choose a city-based timezone. Changes are saved automatically and loaded into every runtime context together with the current Pibo Session ID.`}),o?(0,z.jsx)(`div`,{className:`mt-2 text-xs text-slate-400`,children:`Saving…`}):null,c?(0,z.jsx)(`div`,{className:`mt-2 text-xs text-red-300`,children:c}):null]})}function HIe(){let e=Yt(),{data:t,isLoading:n}=dn({queryKey:[`user-settings`],queryFn:Zz}),[r,i]=(0,R.useState)(C2),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(!1),[l,u]=(0,R.useState)(null);(0,R.useEffect)(()=>{let e=t?.shortcuts?.webAnnotationsToggle||w2();i(e),T2(e),E2(e)},[t?.shortcuts?.webAnnotationsToggle]);let d=async t=>{let n=D2(t)||`Alt+Shift+A`;i(n),c(!0),u(null);try{let t=await Qz({shortcuts:{webAnnotationsToggle:n}});e.setQueryData([`user-settings`],t),T2(t.shortcuts.webAnnotationsToggle),E2(t.shortcuts.webAnnotationsToggle)}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}};return(0,z.jsx)(k0,{title:`Shortcuts`,children:(0,z.jsxs)(`div`,{className:`grid max-w-2xl gap-3 rounded-sm border border-slate-800 bg-[#151f24] p-3`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-slate-200`,children:[(0,z.jsx)(Ao,{size:15}),` Toggle annotation mode`]}),(0,z.jsx)(`div`,{className:`mt-1 text-xs text-slate-500`,children:`Toggles the Web Annotation element mode with the pencil button.`})]}),(0,z.jsx)(`kbd`,{className:`rounded-sm border border-slate-700 bg-[#0e1116] px-2 py-1 font-mono text-xs text-[#7dd3fc]`,children:r})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:n||s,"aria-pressed":a,onClick:()=>o(e=>!e),onKeyDown:e=>{if(!a)return;let t=UIe(e);t&&(e.preventDefault(),e.stopPropagation(),o(!1),d(t))},className:`rounded-sm border px-3 py-2 text-xs font-medium ${a?`border-[#11a4d4] bg-[#11a4d4]/10 text-sky-100`:`border-slate-700 text-slate-300 hover:border-[#11a4d4] hover:text-[#7dd3fc]`} disabled:opacity-50`,children:a?`Press shortcut…`:`Record shortcut`}),(0,z.jsx)(`button`,{type:`button`,disabled:s||r===`Alt+Shift+A`,onClick:()=>void d(C2),className:`rounded-sm border border-slate-700 px-3 py-2 text-xs text-slate-300 hover:border-[#11a4d4] hover:text-[#7dd3fc] disabled:opacity-50`,children:`Reset`}),s?(0,z.jsx)(`span`,{className:`text-xs text-slate-400`,children:`Saving…`}):null]}),(0,z.jsxs)(`div`,{className:`text-[11px] text-slate-500`,children:[`Default: `,C2,`. Use a modifier combination to avoid conflicts with normal typing.`]}),l?(0,z.jsx)(`div`,{className:`text-xs text-red-300`,children:l}):null]})})}function UIe(e){if([`Alt`,`Control`,`Meta`,`Shift`].includes(e.key))return null;let t=e.code?.match(/^Key[A-Z]$/)?e.code.slice(3):e.key===` `?`Space`:e.key.length===1?e.key.toUpperCase():e.key,n=[];return e.ctrlKey&&n.push(`Ctrl`),e.altKey&&n.push(`Alt`),e.shiftKey&&n.push(`Shift`),e.metaKey&&n.push(`Meta`),n.push(t),n.join(`+`)}function WIe(e){let t=new Set([`UTC`,...Intl.supportedValuesOf?.(`timeZone`)??BIe]);return e&&t.add(e),[...t].map(e=>({value:e,label:GIe(e),offset:KIe(e)})).sort((e,t)=>e.offset-t.offset||e.label.localeCompare(t.label)).map(({value:e,label:t})=>({value:e,label:t}))}function GIe(e){let t=e===`UTC`?`UTC`:e.split(`/`).pop()?.replaceAll(`_`,` `)??e,n=e.includes(`/`)?e.split(`/`)[0].replaceAll(`_`,` `):void 0,r=v9(e);return`${t}${n?` (${n})`:``} — ${r}`}function v9(e){try{return new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`shortOffset`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value.replace(`GMT`,`UTC`)??e}catch{return e}}function KIe(e){let t=v9(e),n=/^UTC(?:(?<sign>[+-])(?<hours>\d{1,2})(?::(?<minutes>\d{2}))?)?$/.exec(t);return n?.groups?.sign?(n.groups.sign===`-`?-1:1)*(Number(n.groups.hours)*60+Number(n.groups.minutes??0)):0}function qIe({modelDefaults:e,modelCatalog:t,onChanged:n}){let[r,i]=(0,R.useState)(e??{}),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null);(0,R.useEffect)(()=>{i(e??{})},[e]);let l=async e=>{i(e),o(!0);try{n(await Vge(e)),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,z.jsxs)(`div`,{className:`grid gap-3 border-t border-slate-800 pt-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Runtime Model Defaults`}),(0,z.jsx)(L0,{title:`Main Agent`,modelTitle:`Main Agent Default`,model:r.main,thinking:r.mainThinking,fast:r.mainFast??!1,modelCatalog:t,readOnly:a,modelHint:`Unset to use provider fallback.`,configuredProvidersOnly:!0,onModelChange:e=>void l({...r,main:e}),onThinkingChange:e=>void l({...r,mainThinking:e}),onFastChange:e=>void l({...r,mainFast:e})}),(0,z.jsx)(L0,{title:`Subagent`,modelTitle:`Subagent Default`,model:r.subagent,thinking:r.subagentThinking,fast:r.subagentFast??!1,modelCatalog:t,readOnly:a,modelHint:`Unset to use provider fallback.`,configuredProvidersOnly:!0,onModelChange:e=>void l({...r,subagent:e}),onThinkingChange:e=>void l({...r,subagentThinking:e}),onFastChange:e=>void l({...r,subagentFast:e})}),s?(0,z.jsx)(`div`,{className:`text-xs text-amber-100`,children:s}):null]})}function JIe({packages:e,onPackageChanged:t,onPackageRemoved:n}){let[r,i]=(0,R.useState)(``),[a,o]=(0,R.useState)(null),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(()=>new Set),d=e??[],f=d.filter(e=>e.installStatus===`installed`).length,p=d.filter(e=>e.enabled).length,m=async()=>{if(!a){o(`add`);try{let e=await qW(r);t(e),i(``),u(t=>new Set(t).add(e.id)),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(null)}}},h=async e=>{if(!a){o(`${e.id}:enabled`);try{t(await JW(e.id,{enabled:!e.enabled})),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(null)}}},g=async e=>{if(!a&&window.confirm(`Unregister Pi package "${e.name}"?`)){o(`${e.id}:delete`);try{n(await YW(e.id)),u(t=>{let n=new Set(t);return n.delete(e.id),n}),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(null)}}},_=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,z.jsxs)(k0,{title:`Pi Package Management`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,z.jsx)(`input`,{value:r,disabled:!e||a===`add`,onChange:e=>i(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] disabled:opacity-60`,placeholder:`https://pi.dev/packages/package-name`}),(0,z.jsx)(`button`,{type:`button`,disabled:!e||a===`add`||!r.trim(),onClick:()=>void m(),title:`Add Pi Package`,"aria-label":`Add Pi Package`,className:`h-9 w-9 inline-flex items-center justify-center border border-[#11a4d4] rounded-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})})]}),(0,z.jsx)(`div`,{className:`text-[11px] text-slate-500`,children:`Extensions execute code in the Pi runtime. Review package source before adding it.`}),s?(0,z.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-200 px-3 py-2 text-sm rounded-sm`,children:s}):null,(0,z.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:[d.length,` registered / `,f,` installed / `,p,` enabled`]})]}),e?d.length?(0,z.jsx)(`div`,{className:`grid gap-2`,children:d.map(e=>(0,z.jsx)(ZIe,{pkg:e,expanded:l.has(e.id),busy:a?.startsWith(`${e.id}:`)??!1,onToggleExpanded:()=>_(e.id),onToggleEnabled:()=>void h(e),onUnregister:()=>void g(e)},e.id))}):(0,z.jsx)(I0,{message:`No Pi packages registered`}):(0,z.jsx)(I0,{})]})}function YIe({skills:e,onSkillChanged:t,onSkillRemoved:n}){let[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(``),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),h=e??[],g=h.filter(e=>e.enabled).length,_=async e=>{if(!d){f(`${e.id}:enabled`);try{t(await QW(e.id,{enabled:!e.enabled})),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}}},v=async e=>{if(!d&&window.confirm(`Delete skill "${e.name}"?`)){f(`${e.id}:delete`);try{await $W(e.id),n(e.id),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}}},y=async e=>{f(`create`);try{t(await ZW(e)),i(!1),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}},b=async e=>{f(`install`);try{t(await eG(e)),o(!1),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}},x=async(e,n)=>{f(`edit`);try{t(await QW(e,n)),c(null),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(k0,{title:`Skill Management`,children:[(0,z.jsxs)(`div`,{className:`grid gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsxs)(`button`,{type:`button`,disabled:d===`create`,onClick:()=>i(!0),className:`inline-flex items-center gap-2 border border-[#11a4d4] rounded-sm px-3 py-2 text-sm text-[#11a4d4] bg-[#11a4d4]/10 disabled:opacity-50`,children:[(0,z.jsx)(Ps,{size:14}),`Create Skill`]}),(0,z.jsxs)(`button`,{type:`button`,disabled:d===`install`,onClick:()=>o(!0),className:`inline-flex items-center gap-2 border border-slate-700 rounded-sm px-3 py-2 text-sm text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:[(0,z.jsx)(rs,{size:14}),`Install from URL`]})]}),p?(0,z.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-200 px-3 py-2 text-sm rounded-sm`,children:p}):null,(0,z.jsxs)(`div`,{className:`font-mono text-[10px] uppercase tracking-wider text-slate-500`,children:[h.length,` skills / `,g,` enabled`]})]}),e?h.length?(0,z.jsx)(`div`,{className:`grid gap-2`,children:h.map(e=>(0,z.jsx)(`div`,{className:`border rounded-sm p-2 ${e.enabled?`border-slate-800 bg-[#151f24]`:`border-slate-800 bg-[#151f24] opacity-75`}`,children:(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 max-[640px]:items-start`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-slate-200`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${e.enabled?`border-[#11a4d4]/60 text-[#7dd3fc]`:`border-slate-700 text-slate-500`}`,children:e.enabled?`enabled`:`disabled`}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider border-slate-700 text-slate-500`,children:e.source})]}),(0,z.jsx)(`div`,{className:`truncate text-xs text-slate-500`,children:e.description||e.path})]}),(0,z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:d?.startsWith(`${e.id}:`)??!1,onClick:()=>void _(e),className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:e.enabled?(0,z.jsx)(Fs,{size:13}):(0,z.jsx)(Is,{size:13})}),(0,z.jsx)(`button`,{type:`button`,disabled:d?.startsWith(`${e.id}:`)??!1,onClick:async()=>{try{let t=await XW(e.id);c(e),u(t.markdown)}catch{c(e),u(``)}},className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ms,{size:13})}),(0,z.jsx)(`button`,{type:`button`,disabled:d?.startsWith(`${e.id}:`)??!1,onClick:()=>void v(e),className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-500 hover:text-red-400 disabled:opacity-50`,children:(0,z.jsx)(qs,{size:13})})]})]})},e.id))}):(0,z.jsx)(I0,{message:`No user skills`}):(0,z.jsx)(I0,{})]}),r?(0,z.jsx)(b9,{title:`Create Skill`,onSave:y,onClose:()=>i(!1),busy:d===`create`}):null,a?(0,z.jsx)(XIe,{onInstall:b,onClose:()=>o(!1),busy:d===`install`}):null,s?(0,z.jsx)(b9,{title:`Edit Skill`,initialName:s.name,initialDescription:s.description,initialMarkdown:l,onSave:e=>void x(s.id,e),onClose:()=>c(null),busy:d===`edit`}):null]})}function y9({children:e,onClose:t}){return(0,z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:[(0,z.jsx)(`div`,{className:`w-full max-w-2xl rounded-sm border border-slate-700 bg-[#151f24] shadow-2xl`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`absolute inset-0 -z-10`,onClick:t,"aria-label":`Close modal`})]})}function b9({title:e,initialName:t=``,initialDescription:n=``,initialMarkdown:r=``,onSave:i,onClose:a,busy:o}){let[s,c]=(0,R.useState)(t),[l,u]=(0,R.useState)(n),[d,f]=(0,R.useState)(r);return(0,z.jsxs)(y9,{onClose:a,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 border-b border-slate-800 px-4 py-3 text-sm font-bold uppercase tracking-wider`,children:[(0,z.jsx)(Ms,{size:16}),e]}),(0,z.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,z.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Skill name (kebab-case)`,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`Short description`,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),placeholder:`Markdown instructions...`,rows:10,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4] resize-vertical`}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`px-3 py-2 text-sm border border-slate-700 rounded-sm hover:border-slate-500`,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,disabled:o||!s.trim(),onClick:()=>i({name:s,description:l,markdown:d}),className:`px-3 py-2 text-sm border border-[#11a4d4] rounded-sm bg-[#11a4d4]/10 text-[#11a4d4] disabled:opacity-50`,children:o?`Saving...`:`Save`})]})]})]})}function XIe({onInstall:e,onClose:t,busy:n}){let[r,i]=(0,R.useState)(``);return(0,z.jsxs)(y9,{onClose:t,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 border-b border-slate-800 px-4 py-3 text-sm font-bold uppercase tracking-wider`,children:[(0,z.jsx)(rs,{size:16}),`Install Skill`]}),(0,z.jsxs)(`div`,{className:`grid gap-3 p-4`,children:[(0,z.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`https://skills.sh/account/skills/skill-name`,className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`div`,{className:`text-[11px] text-slate-500`,children:`Supports skills.sh URLs, GitHub tree URLs, or account/repo shorthand.`}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`px-3 py-2 text-sm border border-slate-700 rounded-sm hover:border-slate-500`,children:`Cancel`}),(0,z.jsx)(`button`,{type:`button`,disabled:n||!r.trim(),onClick:()=>e(r),className:`px-3 py-2 text-sm border border-[#11a4d4] rounded-sm bg-[#11a4d4]/10 text-[#11a4d4] disabled:opacity-50`,children:n?`Installing...`:`Install`})]})]})]})}function ZIe({pkg:e,expanded:t,busy:n,onToggleExpanded:r,onToggleEnabled:i,onUnregister:a}){let o=e.diagnostics.some(e=>e.type===`error`);return(0,z.jsxs)(`div`,{className:`border rounded-sm ${e.enabled?`border-slate-800 bg-[#151f24]`:`border-slate-800 bg-[#151f24] opacity-75`}`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] gap-2 p-2`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 truncate text-sm text-slate-200`,children:e.name}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${e.enabled?`border-[#11a4d4]/60 text-[#7dd3fc]`:`border-slate-700 text-slate-500`}`,children:e.enabled?`enabled`:`disabled`}),(0,z.jsx)(`span`,{className:`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider ${e.installStatus===`installed`?`border-[#0bda57]/50 text-green-300`:`border-[#f59e0b]/50 text-amber-100`}`,children:e.installStatus})]}),(0,z.jsx)(`div`,{className:`truncate text-xs text-slate-500`,children:e.description??e.source}),(0,z.jsx)(`div`,{className:`font-mono text-[10px] mt-1 ${o?`text-[#f59e0b]`:`text-[#11a4d4]`}`,children:D0(e)})]}),(0,z.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:r,title:t?`Hide Details`:`Show Details`,"aria-label":t?`Hide Details`:`Show Details`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:t?(0,z.jsx)(zo,{size:13}):(0,z.jsx)(Bo,{size:13})}),(0,z.jsx)(`button`,{type:`button`,disabled:n,onClick:i,title:e.enabled?`Disable Package`:`Enable Package`,"aria-label":e.enabled?`Disable Package`:`Enable Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:e.enabled?(0,z.jsx)(Fs,{size:13}):(0,z.jsx)(Is,{size:13})}),(0,z.jsx)(`button`,{type:`button`,disabled:n,onClick:a,title:`Unregister Package`,"aria-label":`Unregister Package`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-red-400 hover:text-red-300 disabled:opacity-50`,children:(0,z.jsx)(qs,{size:13})})]})]}),t?(0,z.jsx)(M0,{pkg:e}):null]})}function QIe({data:e,selectedProject:t,selectedPiboSessionId:n,selectedProjectSession:r,workflowProjectSessions:i,activeProjects:a,archivedProjects:o,sessionGroups:s,selectedSessionPathIds:c,autoRenameSessionId:l,creatingSession:u,showArchivedProjects:d,showArchivedSessions:f,mobileSidebarOpen:p,onRefresh:m,onCloseMobileSidebar:h,onCreateProject:g,onToggleArchivedProjects:_,onSelectProject:v,onRenameProject:y,onSetProjectArchived:b,onDeleteArchivedProject:x,onCreateProjectSession:S,onToggleArchivedSessions:C,onSelectSession:w,onRenameSession:T,onArchiveSession:E,onDeleteSession:D,onViewContext:O,onAutoRenameConsumed:k}){let A=Date.now();return(0,z.jsxs)(`aside`,{className:`min-h-0 overflow-auto bg-[#1a262b] border-r border-slate-800 max-[980px]:fixed max-[980px]:left-0 max-[980px]:top-0 max-[980px]:bottom-0 max-[980px]:z-40 max-[980px]:w-[280px] max-[980px]:transition-transform max-[980px]:duration-200 ${p?`max-[980px]:translate-x-0`:`max-[980px]:-translate-x-full`}`,children:[(0,z.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider max-[980px]:h-auto max-[980px]:py-2`,children:[(0,z.jsx)(`span`,{children:`projects`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:m,title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ls,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:h,title:`Close sidebar`,"aria-label":`Close sidebar`,className:`min-[981px]:hidden p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qs,{size:13})})]})]}),(0,z.jsxs)(`div`,{className:`p-2 space-y-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Shared Chat`}),(0,z.jsx)(S9,{project:e.sharedDefaultProject,selected:t?.id===e.sharedDefaultProject.id,onSelect:()=>v(e.sharedDefaultProject.id)})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Projects`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:g,title:`New Project`,"aria-label":`New Project`,className:`h-6 w-6 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ps,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:_,title:`Archived Projects`,"aria-label":`Archived Projects`,className:`h-6 w-6 inline-flex items-center justify-center border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${d?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:d?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})})]})]}),a.map(e=>(0,z.jsx)(S9,{project:e,selected:t?.id===e.id,onSelect:()=>v(e.id),onRename:t=>y(e,t),onArchive:()=>b(e,!0)},e.id)),a.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No projects`}):null,d?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Archived Projects`}),o.map(e=>(0,z.jsx)(S9,{project:e,selected:t?.id===e.id,onSelect:()=>v(e.id),onRename:t=>y(e,t),onArchive:()=>b(e,!1),onDelete:()=>x(e),archived:!0},e.id))]}):null]}),i.length>0?(0,z.jsx)($Ie,{projectSessions:i,sessionNodes:e.sessions,selectedPiboSessionId:n,onSelect:w}):null,(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-1`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Project Sessions`}),(0,z.jsx)(`div`,{className:`text-[10px] text-slate-500`,children:r?Wke(r):`Workflow: simple-chat`})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:S,disabled:u||!t,title:`New Project Session`,"aria-label":`New Project Session`,className:`h-6 w-6 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Ps,{size:14})}),(0,z.jsx)(`button`,{type:`button`,onClick:C,title:f?`Hide Archived Project Sessions`:`Show Archived Project Sessions`,"aria-label":f?`Hide Archived Project Sessions`:`Show Archived Project Sessions`,className:`h-6 w-6 inline-flex items-center justify-center border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${f?`border-[#11a4d4] text-[#11a4d4]`:`border-slate-700 text-slate-400`}`,children:f?(0,z.jsx)(wo,{size:14}):(0,z.jsx)(To,{size:14})})]})]}),s.active.map(e=>(0,z.jsx)(g3,{node:e,signalNow:A,selectedPiboSessionId:n,selectedSessionPathIds:c,onSelect:w,onRename:T,onArchive:E,onDelete:D,onViewContext:O,loadingPiboSessionId:null,autoRename:l===e.piboSessionId,onAutoRenameConsumed:k,showWorkflowSessionKindMarkers:!0},e.piboSessionId)),s.active.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No active project sessions`}):null,f?(0,z.jsxs)(`div`,{className:`mt-3`,children:[(0,z.jsx)(`div`,{className:`px-1 pb-1 text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Archived Project Sessions`}),s.archived.map(e=>(0,z.jsx)(g3,{node:e,signalNow:A,selectedPiboSessionId:n,selectedSessionPathIds:c,onSelect:w,onRename:T,onArchive:E,onDelete:D,onViewContext:O,loadingPiboSessionId:null,showWorkflowSessionKindMarkers:!0},e.piboSessionId)),s.archived.length===0?(0,z.jsx)(`div`,{className:`px-2 py-3 text-xs text-slate-500 border border-dashed border-slate-700 rounded-sm`,children:`No archived project sessions`}):null]}):null]})]})]})}function x9(e,t){for(let n of e){if(n.piboSessionId===t)return n;let e=x9(n.children,t);if(e)return e}}function $Ie({projectSessions:e,sessionNodes:t,selectedPiboSessionId:n,onSelect:r}){return(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pb-1`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wider text-slate-500`,children:`Workflow Runs`}),(0,z.jsx)(`div`,{className:`text-[10px] text-slate-500`,children:e.length})]}),(0,z.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>{let i=x9(t,e.piboSessionId),a=i?c3(i):e.title??e.piboSessionId,o=e.piboSessionId===n,s=H2(e,i?.status);return(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(e.piboSessionId),className:`w-full text-left rounded-sm border px-2 py-2 transition-colors ${o?`border-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-800 hover:border-slate-700 hover:bg-slate-800/40`}`,title:e.workflowRunId??e.workflowId,children:[(0,z.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-slate-200 truncate`,children:a}),(0,z.jsx)(`span`,{className:qke(e,i?.status),children:s})]}),(0,z.jsx)(`span`,{className:`mt-1 block text-[10px] text-slate-500 truncate`,children:e.workflowId}),e.workflowRunId?(0,z.jsxs)(`span`,{className:`block text-[10px] font-mono text-slate-500 truncate`,children:[`run `,W2(e.workflowRunId)]}):null]},`${e.workflowRunId??e.piboSessionId}:${e.piboSessionId}`)})})]})}function S9({project:e,selected:t,archived:n,onSelect:r,onRename:i,onArchive:a,onDelete:o}){let s=e.metadata?.default===!0||e.metadata?.personal===!0,[c,l]=(0,R.useState)(!1),[u,d]=(0,R.useState)(e.name),[f,p]=(0,R.useState)(!1),m=(0,R.useRef)(null),h=(0,R.useRef)(null);(0,R.useEffect)(()=>{c||d(e.name)},[c,e.name]),(0,R.useEffect)(()=>{if(!f)return;let e=e=>{h.current&&!h.current.contains(e.target)&&p(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]),(0,R.useLayoutEffect)(()=>{c&&(m.current?.focus(),m.current?.select())},[c]);let g=()=>{let t=u.trim();t&&t!==e.name&&i?.(t),l(!1)};return(0,z.jsxs)(`div`,{className:`group flex items-center gap-2 rounded-sm border px-2 py-2 text-sm ${s?t?`border-[#0bda57] bg-[#0bda57]/10 text-green-100`:`border-[#0bda57]/50 bg-[#0bda57]/5 text-slate-300 hover:border-[#0bda57]`:t?`border-[#11a4d4] bg-[#11a4d4]/10 text-sky-100`:`border-transparent text-slate-300 hover:border-slate-700 hover:bg-slate-900/40`}`,children:[(0,z.jsx)(`span`,{className:`h-6 w-6 shrink-0 inline-flex items-center justify-center rounded-sm ${s?`bg-[#0bda57]/15 text-[#0bda57]`:n?`bg-[#f59e0b]/15 text-[#f59e0b]`:`bg-[#151f24] text-slate-500`}`,children:s?(0,z.jsx)(Ts,{size:13}):n?(0,z.jsx)(To,{size:13}):(0,z.jsx)(ls,{size:13})}),c?(0,z.jsxs)(`form`,{className:`min-w-0 flex-1 grid grid-cols-[1fr_auto_auto] gap-1`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,z.jsx)(`input`,{ref:m,value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Escape`&&(t.preventDefault(),l(!1),d(e.name))},className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-2 py-1 text-sm outline-none focus:border-[#11a4d4]`}),(0,z.jsx)(`button`,{type:`submit`,title:`Save Project Name`,"aria-label":`Save Project Name`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ro,{size:13})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>{l(!1),d(e.name)},title:`Cancel Rename`,"aria-label":`Cancel Rename`,className:`h-7 w-7 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Qs,{size:13})})]}):(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`min-w-0 flex-1 text-left`,children:[(0,z.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,z.jsx)(`span`,{className:`block truncate text-[11px] text-slate-500`,children:s?`shared default project chat`:e.projectFolder})]}),s?(0,z.jsx)(`span`,{title:`Shared Chat is locked`,"aria-label":`Shared Chat is locked`,className:`h-7 w-7 max-[980px]:h-9 max-[980px]:w-9 inline-flex items-center justify-center border border-[#0bda57]/50 rounded-sm text-[#0bda57]`,children:(0,z.jsx)(Ts,{size:24,className:`w-3.5 h-3.5 max-[980px]:w-5 max-[980px]:h-5`})}):c?null:(0,z.jsxs)(`div`,{className:`relative opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity max-[980px]:opacity-100`,ref:h,children:[(0,z.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),title:`Project actions`,"aria-label":`Project actions`,className:`h-7 w-7 max-[980px]:h-9 max-[980px]:w-9 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(ns,{size:24,className:`w-3.5 h-3.5 max-[980px]:w-5 max-[980px]:h-5`})}),f?(0,z.jsxs)(`div`,{className:`absolute right-0 top-full z-50 mt-1 w-48 bg-[#1a262b] border border-slate-700 rounded-sm shadow-lg py-1`,children:[i?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{p(!1),l(!0)},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[(0,z.jsx)(Ms,{size:16}),` Rename Project`]}):null,a?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{p(!1),a()},className:`w-full text-left px-3 py-2.5 text-sm text-slate-300 hover:bg-[#11a4d4]/10 hover:text-[#11a4d4] flex items-center gap-2`,children:[n?(0,z.jsx)(wo,{size:16}):(0,z.jsx)(To,{size:16}),` `,n?`Restore Project`:`Archive Project`]}):null,o?(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{p(!1),o()},className:`w-full text-left px-3 py-2.5 text-sm text-red-300 hover:bg-red-500/10 flex items-center gap-2`,children:[(0,z.jsx)(qs,{size:16}),` Delete Project`]}):null]}):null]})]})}function eLe({project:e,options:t,selectedOptionKey:n,titleValue:r,loadState:i,errorMessage:a,creating:o,diagnostics:s,onSelectedOptionChange:c,onTitleChange:l,onCreate:u}){let d=t.find(e=>T9(e)===n),f=o||i!==`loaded`||!d||!!e.archivedAt;return(0,z.jsxs)(`section`,{className:`rounded-sm border border-slate-800 bg-[#151f24] p-4 shadow-lg shadow-black/10`,"aria-labelledby":`project-workflow-create-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 max-w-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(vs,{size:13}),`Workflow-backed session`]}),(0,z.jsx)(`h2`,{id:`project-workflow-create-title`,className:`mt-1 text-sm font-bold text-slate-100`,children:`Create workflow Project session`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-slate-500`,children:`Choose a published workflow version from the global catalog and save a configured Project session. Creation does not start a workflow run.`})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/80 px-2 py-1 text-[11px] uppercase tracking-wide text-slate-500`,children:[`Project: `,(0,z.jsx)(`span`,{className:`text-slate-300`,children:e.name})]})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)_auto] md:items-end`,children:[(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Workflow version`}),(0,z.jsxs)(`select`,{"aria-label":`Workflow version`,className:`rounded-sm border border-slate-700 bg-[#101d22] px-3 py-2 text-sm text-slate-100 outline-none transition focus:border-[#11a4d4] disabled:opacity-60`,value:n,onChange:e=>c(e.target.value),disabled:o||i!==`loaded`,children:[(0,z.jsx)(`option`,{value:``,children:`Select a workflow version`}),t.map(e=>(0,z.jsx)(`option`,{value:T9(e),children:lLe(e)},T9(e)))]})]}),(0,z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-semibold text-slate-300`,children:[(0,z.jsx)(`span`,{children:`Session name`}),(0,z.jsx)(`input`,{"aria-label":`Workflow session name`,className:`rounded-sm border border-slate-700 bg-[#101d22] px-3 py-2 text-sm text-slate-100 outline-none transition placeholder:text-slate-600 focus:border-[#11a4d4] disabled:opacity-60`,value:r,onChange:e=>l(e.target.value),placeholder:`Optional`,disabled:o})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:u,disabled:f,className:`inline-flex min-h-10 items-center justify-center gap-2 rounded-sm border border-[#11a4d4]/60 bg-[#11a4d4]/10 px-3 py-2 text-xs font-bold uppercase tracking-wide text-[#11a4d4] transition hover:bg-[#11a4d4]/15 disabled:cursor-not-allowed disabled:border-slate-700 disabled:bg-slate-900/40 disabled:text-slate-500`,children:[o?(0,z.jsx)(Cs,{size:14,className:`animate-spin`}):(0,z.jsx)(Bs,{size:14}),`Save configured session`]})]}),d?(0,z.jsxs)(`div`,{className:`mt-3 rounded-sm border border-slate-800 bg-[#101d22]/70 p-3 text-xs leading-5 text-slate-500`,children:[(0,z.jsx)(`span`,{className:`font-semibold text-slate-300`,children:d.title}),` `,(0,z.jsxs)(`span`,{className:`font-mono text-slate-400`,children:[d.id,`@`,d.version]}),d.description?(0,z.jsxs)(`span`,{children:[` — `,d.description]}):null]}):null,(0,z.jsx)(nLe,{}),i===`loading`?(0,z.jsx)(`div`,{className:`mt-3 text-xs text-slate-500`,children:`Loading workflow catalog…`}):null,i===`error`?(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border border-red-900/70 bg-red-950/40 p-3 text-xs text-red-200`,role:`alert`,children:a??`Failed to load workflow catalog.`}):null,s.length?(0,z.jsx)(tLe,{label:`Create-blocking diagnostics`,diagnostics:s}):null]})}function tLe({label:e,diagnostics:t}){return(0,z.jsxs)(`div`,{className:`mt-3 rounded-sm border border-red-500/40 bg-red-500/10 p-3 text-xs text-red-100`,role:`alert`,"aria-label":e,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-red-200`,children:[(0,z.jsx)(Js,{size:12}),e]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-2`,children:t.map((e,t)=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-[#0b0f14]/60 p-2`,children:[(0,z.jsx)(`div`,{className:`break-words text-red-100`,children:e.message??e.code??`Workflow validation blocked this action.`}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1 font-mono text-[10px] text-red-200/70`,children:[e.code?(0,z.jsx)(`span`,{children:e.code}):null,e.path?(0,z.jsx)(`span`,{children:e.path}):null,e.nodeId?(0,z.jsxs)(`span`,{children:[`node:`,e.nodeId]}):null,e.edgeId?(0,z.jsxs)(`span`,{children:[`edge:`,e.edgeId]}):null,e.registryRef?(0,z.jsx)(`span`,{children:e.registryRef}):null]}),e.hint?(0,z.jsx)(`div`,{className:`mt-1 text-[11px] text-red-100/75`,children:e.hint}):null]},`${e.code??`diagnostic`}:${e.path??e.registryRef??e.nodeId??e.edgeId??t}`))})]})}function nLe(){return(0,z.jsxs)(`div`,{className:`mt-3 rounded-sm border border-amber-700/60 bg-amber-950/15 p-3 text-[11px] leading-5 text-amber-100/80`,"aria-label":`Project workflow V2 explicit non-goals`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-amber-200`,children:[(0,z.jsx)(Ts,{size:12}),`V2 scope boundary`]}),(0,z.jsx)(`p`,{className:`mt-2`,children:`Project workflow sessions select published catalog versions and save configured sessions only. They do not expose workflow templates, workflow slash commands, workflow tools for agents, inline TypeScript/JavaScript/shell/eval code, raw XState editing, TypeScript export, YAML/JSON product import/export, or Zod schema authoring.`})]})}function rLe({projectSession:e,lifecycleEvents:t,starting:n,message:r,onStart:i}){let a=iLe(e),o=sLe(aLe(e.piboSessionId,t)),s=oLe(e.piboSessionId,t),c=cLe(r);return(0,z.jsxs)(`section`,{className:`rounded-sm border border-[#11a4d4]/35 bg-[#111820] p-4 shadow-lg shadow-black/10`,"aria-labelledby":`project-workflow-start-title`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 max-w-2xl`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-[#11a4d4]`,children:[(0,z.jsx)(Is,{size:13}),`Configured/not-started`]}),(0,z.jsx)(`h2`,{id:`project-workflow-start-title`,className:`mt-1 text-sm font-bold text-slate-100`,children:`Ready to start workflow`}),(0,z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-slate-500`,children:`This Project session is saved for review. Start explicitly when the configuration is ready.`})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:`inline-flex min-h-10 items-center justify-center gap-2 rounded-sm border border-emerald-500/60 bg-emerald-500/10 px-3 py-2 text-xs font-bold uppercase tracking-wide text-emerald-300 transition hover:bg-emerald-500/15 disabled:cursor-not-allowed disabled:border-slate-700 disabled:bg-slate-900/40 disabled:text-slate-500`,children:[n?(0,z.jsx)(Cs,{size:14,className:`animate-spin`}):(0,z.jsx)(Is,{size:14}),`Start workflow`]})]}),(0,z.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs md:grid-cols-2 xl:grid-cols-4`,children:[(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wide text-slate-500`,children:`Workflow`}),(0,z.jsx)(`div`,{className:`mt-1 truncate font-mono text-slate-300`,title:e.workflowId,children:e.workflowId}),e.workflowVersion?(0,z.jsxs)(`div`,{className:`mt-1 text-slate-500`,children:[`version `,e.workflowVersion]}):null]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wide text-slate-500`,children:`Configuration summary`}),(0,z.jsx)(`div`,{className:`mt-1 text-slate-300`,children:a.primary}),(0,z.jsx)(`div`,{className:`mt-1 text-slate-500`,children:a.secondary})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wide text-slate-500`,children:`Validation state`}),(0,z.jsx)(`div`,{className:o.className,children:o.label}),(0,z.jsx)(`div`,{className:`mt-1 text-slate-500`,children:o.description})]}),(0,z.jsxs)(`div`,{className:`rounded-sm border border-slate-800 bg-[#101d22]/70 p-3`,children:[(0,z.jsx)(`div`,{className:`text-[10px] font-bold uppercase tracking-wide text-slate-500`,children:`Run history`}),(0,z.jsx)(`div`,{className:`mt-1 text-slate-300`,children:`No current run attempts`}),(0,z.jsx)(`div`,{className:`mt-1 text-slate-500`,children:`No workflow run record exists until Start succeeds.`})]})]}),s.length?(0,z.jsxs)(`div`,{className:`mt-3 rounded-sm border border-red-500/40 bg-red-500/10 p-3 text-xs text-red-100`,role:`alert`,"aria-label":`Start-blocking diagnostics`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold uppercase tracking-[0.16em] text-red-200`,children:[(0,z.jsx)(Js,{size:12}),`Start-blocking diagnostics`]}),(0,z.jsx)(`div`,{className:`mt-2 space-y-2`,children:s.map((e,t)=>(0,z.jsxs)(`div`,{className:`rounded-sm border border-red-500/25 bg-[#0b0f14]/60 p-2`,children:[(0,z.jsx)(`div`,{className:`break-words text-red-100`,children:e.message}),(0,z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1 font-mono text-[10px] text-red-200/70`,children:[(0,z.jsx)(`span`,{children:e.code}),e.path?(0,z.jsx)(`span`,{children:e.path}):null,e.registryRef?(0,z.jsx)(`span`,{children:e.registryRef}):null]}),e.hint?(0,z.jsx)(`div`,{className:`mt-1 text-[11px] text-red-100/75`,children:e.hint}):null]},`${e.code}:${e.path??e.registryRef??t}`))})]}):null,r?(0,z.jsx)(`div`,{className:`mt-3 rounded-sm border p-3 text-xs ${c}`,role:`status`,children:r}):null]})}function iLe(e){let t=e.configuration,n=Object.keys(t?.inputValues??{}).length,r=Object.keys(t?.promptOverrides??{}).length,i=t?.model?`${t.model.provider}/${t.model.id}`:`default model`,a=t?.thinkingLevel?`${t.thinkingLevel} thinking`:`default thinking`,o=t?.fastMode===!0?`fast mode on`:t?.fastMode===!1?`fast mode off`:`default speed`;return{primary:`${n} input ${n===1?`value`:`values`} · ${r} prompt ${r===1?`override`:`overrides`}`,secondary:`${i} · ${a} · ${o}`}}function aLe(e,t){return C9(t.filter(t=>t.piboSessionId===e&&!!t.validation))}function oLe(e,t){return(C9(t.filter(t=>t.piboSessionId===e&&t.type===`project.workflow_start.blocked`))?.diagnostics??[]).filter(e=>e.severity===`error`)}function C9(e){return e.reduce((e,t)=>e?t.createdAt>e.createdAt?t:e:t,void 0)}function sLe(e){if(!e?.validation)return{label:`not checked yet`,description:`Validation runs before Start creates a workflow run.`,className:`mt-1 text-slate-300`};let t=e.validation,n=`${t.errorCount} errors · ${t.warningCount} warnings`;return t.blocksRun||t.validationState===`error`?{label:`blocked · ${n}`,description:`Last checked ${w9(t.checkedAt)} at ${t.trigger}.`,className:`mt-1 text-red-200`}:t.validationState===`warning`?{label:`warnings · ${n}`,description:`Last checked ${w9(t.checkedAt)} at ${t.trigger}.`,className:`mt-1 text-amber-200`}:{label:`valid · ${n}`,description:`Last checked ${w9(t.checkedAt)} at ${t.trigger}.`,className:`mt-1 text-emerald-200`}}function cLe(e){return e?.toLowerCase().includes(`blocked`)?`border-red-500/40 bg-red-500/10 text-red-200`:`border-emerald-500/40 bg-emerald-500/10 text-emerald-200`}function w9(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:`short`,timeStyle:`short`})}function T9(e){return`${e.id}@${e.version}`}function lLe(e){return`${e.title} (${e.id}@${e.version})`}function E9(e){if(!e||typeof e!=`object`||!(`data`in e))return[];let t=e.data;if(!t||typeof t!=`object`||!(`diagnostics`in t))return[];let n=t.diagnostics;return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`):[]}function uLe(e){let t=[],n=[];for(let r of e??[])r.archivedAt?n.push(r):t.push(r);return{active:t,archived:n}}function dLe(e,t){return t?e.find(e=>e.piboSessionId===t):void 0}function fLe(e){return e.filter(z2)}function pLe(e,t){return{...e,...t?.session?{session:t.session}:{},agents:t?.agents??e.agents,customAgents:t?.customAgents??e.customAgents,modelDefaults:t?.modelDefaults??e.modelDefaults,modelCatalog:t?.modelCatalog??e.modelCatalog,agentCatalog:t?.agentCatalog??e.agentCatalog,capabilities:t?.capabilities??e.capabilities,sessions:t?.sessions??[]}}function mLe(e,t,n){return e.find(e=>e.id===t&&e.version===n)??e[0]}function hLe(){return[{code:`ProjectWorkflowSessionCreate.missingWorkflowVersion`,message:`Select a workflow version before creating the Project session.`,severity:`error`}]}function gLe(e){return e?`Workflow run started.`:`Start accepted after validation. No workflow run record exists yet.`}function _Le(e){return`Start blocked: ${e.map(e=>e.code).filter(Boolean).slice(0,3).join(`, `)||`validation diagnostics`}`}var vLe=new Set;function yLe({baseBootstrap:e,routeProjectId:t,routePiboSessionId:n,sessionViews:r,showRawEvents:i,showThinking:a,expandThinking:o,commands:s,skills:c,onNavigate:l,onViewContext:u,onSelectSessionView:d,onToggleRawEvents:f,onToggleThinking:p,onToggleExpandThinking:m,onThinkingLevelChange:h,mobileSidebarOpen:g,onCloseMobileSidebar:_,onError:v}){let[y,b]=(0,R.useState)(null),[x,S]=(0,R.useState)(!0),[C,w]=(0,R.useState)(()=>localStorage.getItem(`pibo.chat.projects.showArchivedProjects`)===`true`),[T,E]=(0,R.useState)(()=>localStorage.getItem(`pibo.chat.projects.showArchivedSessions`)===`true`),[D,O]=(0,R.useState)(!1),[k,A]=(0,R.useState)(!1),[j,M]=(0,R.useState)(`loading`),[N,P]=(0,R.useState)(null),[F,ee]=(0,R.useState)([]),[te,I]=(0,R.useState)(``),[ne,L]=(0,R.useState)(``),[re,ie]=(0,R.useState)(null),[ae,oe]=(0,R.useState)({}),[se,ce]=(0,R.useState)([]),[le,ue]=(0,R.useState)(null),[de,fe]=(0,R.useState)(()=>n?$0(n):``),[pe,me]=(0,R.useState)(0),he=(0,R.useCallback)(async(e={})=>{S(!0);try{let r=await nc({projectId:e.projectId??t,piboSessionId:e.piboSessionId??n,includeArchived:C||T});return b(r),(!t||r.selectedProjectId!==t||r.selectedPiboSessionId&&r.selectedPiboSessionId!==n)&&l(r.selectedProjectId,r.selectedPiboSessionId,!0,{closeMobileSidebar:!1}),v(null),r}catch(e){throw v(a3(e)),e}finally{S(!1)}},[v,l,n,t,C,T]);(0,R.useEffect)(()=>{he()},[he]),(0,R.useEffect)(()=>{let e=!1;return M(`loading`),P(null),lJ().then(t=>{if(e)return;ee(t.options);let n=mLe(t.options,t.selectedWorkflowId,t.selectedWorkflowVersion);I(e=>e||(n?T9(n):``)),M(`loaded`)}).catch(t=>{e||(P(a3(t)),M(`error`))}),()=>{e=!0}},[]),(0,R.useEffect)(()=>{fe(n?$0(n):``)},[n]);let ge=y?.project,_e=y?.selectedPiboSessionId??null,ve=_e&&y?e3(y.sessions,_e):void 0,ye=ve?.profile??Q4(e),be=y?.projectSessions??[],xe=dLe(be,_e),Se=fLe(be),Ce=uLe(y?.projects),we=Ce.active,Te=Ce.archived,Ee=(0,R.useMemo)(()=>y?u3(y.sessions,T):{active:[],archived:[]},[y,T]),De=(0,R.useMemo)(()=>_e&&y?new Set(t3(y.sessions,_e).map(e=>e.piboSessionId)):vLe,[y,_e]),Oe=(0,R.useMemo)(()=>pLe(e,y),[e,y]),ke=(0,R.useMemo)(()=>Bke({selectedSessionNode:ve,selectedProjectSession:xe,selectedSession:y?.session,selectedProject:ge}),[y?.session,ge,xe,ve]),Ae=(0,R.useMemo)(()=>$7(ke.viewId),[ke.viewId]),je=async()=>{let e=window.prompt(`Project name`);if(!e)return;let t=window.prompt(`Project folder path (absolute path, e.g. ~/code/my-project or /home/me/code/my-project)`);if(!t)return;let n=window.prompt(`Description (optional)`)??void 0;try{let{project:r}=await rc({name:e,projectFolder:t,createFolder:!0,...n?{description:n}:{}});await he({projectId:r.id}),l(r.id,void 0)}catch(e){v(a3(e))}},Me=async()=>{if(ge){O(!0);try{let e=await oc(ge.id,{profile:ye,workflowId:`simple-chat`});ue(e.session.id),l(ge.id,e.session.id,!1,{closeMobileSidebar:!1}),await he({projectId:ge.id,piboSessionId:e.session.id})}catch(e){v(a3(e))}finally{O(!1)}}},Ne=async()=>{if(!ge)return;let e=F.find(e=>T9(e)===te);if(!e){let e=hLe();ce(e),v(e[0]?.message??`Select a workflow version before creating the Project session.`);return}A(!0),ce([]);try{let t=ne.trim(),n=await Eye(ge.id,{profile:ye,workflowId:e.id,workflowVersion:e.version,...t?{title:t}:{}});L(``),ce([]),l(ge.id,n.session.id,!1,{closeMobileSidebar:!1}),await he({projectId:ge.id,piboSessionId:n.session.id})}catch(e){ce(E9(e)),v(a3(e))}finally{A(!1)}},Pe=async e=>{if(ge){ie(e.piboSessionId);try{let t=gLe((await jye(ge.id,e.piboSessionId)).projectSession.workflowRunId);oe(n=>({...n,[e.piboSessionId]:t})),v(null),await he({projectId:ge.id,piboSessionId:e.piboSessionId})}catch(t){let n=E9(t);n.length&&oe(t=>({...t,[e.piboSessionId]:_Le(n)})),v(a3(t)),await he({projectId:ge.id,piboSessionId:e.piboSessionId})}finally{ie(null)}}},Fe=async(e,t)=>{try{await sc(e,{title:t}),await he({projectId:ge?.id,piboSessionId:e})}catch(e){v(a3(e))}},Ie=async(e,t)=>{try{await ic(e.id,{name:t}),await he({projectId:ge?.id,piboSessionId:_e??void 0})}catch(e){v(a3(e))}},Le=async(e,t)=>{try{await ic(e.id,{archived:t});let n=await he({projectId:t?void 0:e.id});t&&ge?.id===e.id&&l(n.selectedProjectId,n.selectedPiboSessionId)}catch(e){v(a3(e))}},Re=async e=>{let t=window.prompt(`Type the project name to permanently delete "${e.name}".`);if(t===null)return;let n=window.confirm(`Also delete the real project folder?\n\n${e.projectFolder}`);try{await ac(e.id,{confirmName:t,deleteFiles:n});let r=await he({projectId:ge?.id===e.id?void 0:ge?.id});ge?.id===e.id&&l(r.selectedProjectId,r.selectedPiboSessionId)}catch(e){v(a3(e))}},ze=async e=>{if(!_e)return!1;let t=e.trim().split(/\s+/)[0],n=s.find(e=>e.slash===t);return n?(await yc(_e,n.action),await he({projectId:ge?.id,piboSessionId:_e}),!0):!1},Be=ge&&xe&&zke(xe)?(0,z.jsx)(rLe,{projectSession:xe,lifecycleEvents:y?.workflowLifecycleEvents??[],starting:re===xe.piboSessionId,message:ae[xe.piboSessionId]??null,onStart:()=>void Pe(xe)}):null;return x&&!y?(0,z.jsx)(`main`,{className:`min-h-0 grid place-items-center text-slate-400`,children:`Loading Projects...`}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/60 min-[981px]:hidden transition-opacity duration-200 ${g?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,onClick:_}),(0,z.jsx)(QIe,{data:y,selectedProject:ge,selectedPiboSessionId:_e,selectedProjectSession:xe,workflowProjectSessions:Se,activeProjects:we,archivedProjects:Te,sessionGroups:Ee,selectedSessionPathIds:De,autoRenameSessionId:le,creatingSession:D,showArchivedProjects:C,showArchivedSessions:T,mobileSidebarOpen:g,onRefresh:()=>void he(),onCloseMobileSidebar:_,onCreateProject:()=>void je(),onToggleArchivedProjects:()=>{let e=!C;w(e),localStorage.setItem(`pibo.chat.projects.showArchivedProjects`,String(e))},onSelectProject:e=>l(e,void 0),onRenameProject:(e,t)=>void Ie(e,t),onSetProjectArchived:(e,t)=>void Le(e,t),onDeleteArchivedProject:e=>void Re(e),onCreateProjectSession:()=>void Me(),onToggleArchivedSessions:()=>{let e=!T;E(e),localStorage.setItem(`pibo.chat.projects.showArchivedSessions`,String(e))},onSelectSession:e=>l(ge?.id,e),onRenameSession:(e,t)=>void Fe(e,t),onArchiveSession:(e,t)=>void sc(e,{archived:t}).then(()=>he({projectId:ge?.id})),onDeleteSession:e=>void sc(e.piboSessionId,{archived:!0}).then(()=>he({projectId:ge?.id})),onViewContext:u,onAutoRenameConsumed:()=>ue(null)}),(0,z.jsx)(o3,{bootstrap:Oe,selectedPiboSessionId:_e,selectedRoomId:null,selectedRoomArchived:!!ge?.archivedAt,workflowProjectSession:ke.workflowProjectSession,workflowLifecycleEvents:y?.workflowLifecycleEvents??[],projectSessionCreatePanel:ge?(0,z.jsx)(eLe,{project:ge,options:F,selectedOptionKey:te,titleValue:ne,loadState:j,errorMessage:N,creating:k,diagnostics:se,onSelectedOptionChange:e=>{I(e),ce([])},onTitleChange:L,onCreate:()=>void Ne()}):null,workflowStartPanel:Be,selectedSessionProfile:ye,selectedSessionActiveModel:$4(Oe,ve??{profile:ye}),selectedSessionStatus:ve?.status,sessionViewId:ke.viewId,sessionViews:r,currentSessionView:Ae,allowedSessionViewIds:Rke[ke.viewId],creatingSession:D||k,showRawEvents:i,showThinking:a,expandThinking:o,commands:s,skills:c,composerText:de,composerFocusSignal:pe,onComposerTextChange:e=>fe(t=>typeof e==`function`?e(t):e),onToggleRawEvents:f,onToggleThinking:p,onToggleExpandThinking:m,onSessionAgentProfileChange:async e=>{_e&&await gc(_e,{profile:e})},onFork:()=>void 0,onOpenSession:e=>l(ge?.id,e),onSelectSessionView:d,onCommand:ze,onThinkingLevelChange:h,onRefreshTrace:async()=>void 0,onRefreshBootstrap:async()=>{await he({projectId:ge?.id,piboSessionId:_e??void 0})},onSend:async e=>{_e&&(await cc(_e,e,n3()),await he({projectId:ge?.id,piboSessionId:_e}))},onError:v})]})}var D9=`Delete this session`;function bLe({session:e,confirmText:t,deleting:n,onConfirmTextChange:r,onCancel:i,onDelete:a}){return(0,z.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/70 grid place-items-center p-4`,children:(0,z.jsxs)(`div`,{className:`w-full max-w-lg border border-red-500/70 bg-[#1a262b] rounded-sm shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 border-b border-red-500/50 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-wider text-red-200`,children:`Delete Session`}),(0,z.jsx)(`div`,{className:`font-mono text-[11px] text-slate-500 truncate`,children:e.piboSessionId})]}),(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:n,title:`Cancel`,"aria-label":`Cancel`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Qs,{size:14})})]}),(0,z.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,z.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived session, its child sessions, and their Chat events. This cannot be undone.`}),(0,z.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,z.jsx)(`span`,{className:`font-mono text-red-200`,children:D9}),` to confirm.`]}),(0,z.jsx)(`input`,{value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:D9,autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,z.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==D9,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,z.jsx)(qs,{size:14}),`Delete permanently`]})]})]})]})})}function xLe({room:e,confirmName:t,deleting:n,onConfirmNameChange:r,onCancel:i,onDelete:a}){return(0,z.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/70 grid place-items-center p-4`,children:(0,z.jsxs)(`div`,{className:`w-full max-w-lg border border-red-500/70 bg-[#1a262b] rounded-sm shadow-xl`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-3 border-b border-red-500/50 flex items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-wider text-red-200`,children:`Delete Room`}),(0,z.jsx)(`div`,{className:`font-mono text-[11px] text-slate-500 truncate`,children:e.id})]}),(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:n,title:`Cancel`,"aria-label":`Cancel`,className:`h-8 w-8 inline-flex items-center justify-center border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:(0,z.jsx)(Qs,{size:14})})]}),(0,z.jsxs)(`div`,{className:`p-4 grid gap-3`,children:[(0,z.jsx)(`div`,{className:`border border-red-500/60 bg-red-500/10 text-red-100 rounded-sm p-3 text-sm`,children:`This permanently deletes the archived room, child rooms, all contained sessions, subagent sessions, and their Chat events. This cannot be undone.`}),(0,z.jsxs)(`div`,{className:`text-sm text-slate-300`,children:[`Type `,(0,z.jsx)(`span`,{className:`font-mono text-red-200`,children:e.name}),` to confirm.`]}),(0,z.jsx)(`input`,{value:t,onChange:e=>r(e.target.value),className:`min-w-0 bg-[#0e1116] border border-slate-700 rounded-sm px-3 py-2 text-sm outline-none focus:border-red-500`,placeholder:e.name,autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:i,disabled:n,className:`h-8 inline-flex items-center border border-slate-700 rounded-sm px-3 text-slate-300 hover:border-[#11a4d4] hover:text-[#11a4d4] disabled:opacity-50`,children:`Cancel`}),(0,z.jsxs)(`button`,{type:`button`,onClick:a,disabled:n||t!==e.name,className:`h-8 inline-flex items-center gap-2 border border-red-500 rounded-sm px-3 text-red-200 bg-red-500/10 disabled:opacity-50`,children:[(0,z.jsx)(qs,{size:14}),`Delete permanently`]})]})]})]})})}var O9=[`sessions`,`projects`,`workflows`,`cron`,`ralph`,`agents`,`context`,`settings`];function SLe(){return(0,z.jsxs)(`div`,{className:`fixed top-0 left-0 right-0 z-50 bg-red-600 text-white text-center text-sm font-bold py-1.5 px-4 flex items-center justify-center gap-2 shadow-lg`,children:[(0,z.jsx)(Js,{size:16}),`Recovery Mode: Main gateway is down. You are connected to a fallback instance.`]})}function CLe({area:e,identity:t,mobileAreaMenuOpen:n,mobileAreaMenuRef:r,totalRoomUnreadCount:i,onOpenMobileSidebar:a,onSelectMainNavArea:o,onToggleMobileAreaMenu:s}){let c=t.email||t.name||t.userId;return(0,z.jsxs)(`header`,{className:`relative flex items-center gap-3 px-4 bg-[#1a262b] border-b border-slate-800 min-h-14 max-[980px]:px-3`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:a,className:`min-[981px]:hidden shrink-0 p-1.5 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Open sidebar`,"aria-label":`Open sidebar`,children:(0,z.jsx)(Es,{size:16})}),(0,z.jsx)(`img`,{src:`/apps/chat/assets/pwa-images/android/launchericon-512x512.png`,alt:`Logo`,className:`h-5 w-auto shrink-0`}),(0,z.jsx)(`div`,{className:`truncate font-extrabold tracking-[0.08em] uppercase text-lg max-[420px]:text-base`,children:`Pibo Chat`})]}),(0,z.jsx)(`nav`,{className:`flex gap-1 max-[1200px]:hidden min-[1201px]:absolute min-[1201px]:left-1/2 min-[1201px]:-translate-x-1/2`,children:O9.map(t=>(0,z.jsx)(`button`,{type:`button`,onClick:()=>o(t),className:`h-8 px-3 border rounded-sm text-xs uppercase tracking-wider ${e===t?`border-[#11a4d4] text-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-700 text-slate-400`}`,children:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{children:t}),t===`sessions`?(0,z.jsx)(k9,{count:i}):null]})},t))}),(0,z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center justify-end gap-2 text-xs text-slate-400 min-[1201px]:ml-0`,children:[(0,z.jsx)(Ys,{size:14}),(0,z.jsx)(`span`,{className:`truncate max-[600px]:hidden`,children:c}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void rPe().then(()=>location.reload()),className:`p-1 border border-slate-700 rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Sign out`,"aria-label":`Sign out`,children:(0,z.jsx)(ws,{size:14})}),(0,z.jsxs)(`div`,{className:`relative min-[1201px]:hidden`,ref:r,children:[(0,z.jsx)(`button`,{type:`button`,onClick:s,className:`p-1 border rounded-sm hover:border-[#11a4d4] hover:text-[#11a4d4] ${n?`border-[#11a4d4] text-[#11a4d4] bg-[#11a4d4]/10`:`border-slate-700 text-slate-400`}`,title:`Open navigation menu`,"aria-label":`Open navigation menu`,"aria-expanded":n,children:(0,z.jsx)(Ss,{size:14})}),n?(0,z.jsx)(`div`,{className:`absolute right-0 top-full z-50 mt-2 w-52 rounded-sm border border-slate-700 bg-[#1a262b] p-1 shadow-xl`,role:`menu`,"aria-label":`Main navigation`,children:O9.map(t=>(0,z.jsxs)(`button`,{type:`button`,onClick:()=>o(t),className:`flex w-full items-center justify-between gap-2 rounded-sm px-3 py-2 text-left text-xs uppercase tracking-wider ${e===t?`bg-[#11a4d4]/10 text-[#11a4d4]`:`text-slate-300 hover:bg-slate-800/80 hover:text-[#11a4d4]`}`,role:`menuitem`,children:[(0,z.jsx)(`span`,{children:t}),t===`sessions`?(0,z.jsx)(k9,{count:i}):null]},t))}):null]})]})]})}function wLe({message:e,onDismiss:t}){return(0,z.jsxs)(`div`,{className:`border-b border-red-500/40 bg-red-500/10 px-4 py-2 text-sm text-red-100 flex items-start justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0 flex items-start gap-2`,children:[(0,z.jsx)(Js,{size:16,className:`mt-0.5 shrink-0 text-red-300`}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-red-300`,children:`Session Error`}),(0,z.jsx)(`div`,{className:`break-words`,children:e})]})]}),(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`shrink-0 rounded-sm border border-red-500/40 px-2 py-1 text-[11px] uppercase tracking-wider text-red-200 hover:border-red-300 hover:text-red-100`,children:`Dismiss`})]})}function TLe({message:e}){return(0,z.jsx)(`div`,{className:`min-h-screen bg-[#101d22] text-slate-300 grid place-items-center`,children:(0,z.jsxs)(`div`,{className:`border border-slate-700 bg-[#1a262b] p-5 rounded-sm`,children:[(0,z.jsx)(`div`,{className:`mb-4 text-sm text-slate-400`,children:e}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void iPe(),className:`px-3 py-2 bg-[#11a4d4] rounded-sm`,children:`Sign in with Google`})]})})}function ELe(e){return e>99?`99+`:String(e)}function k9({count:e}){return!e||e<=0?null:(0,z.jsx)(`span`,{className:`min-w-5 h-5 px-1.5 inline-flex items-center justify-center rounded-full bg-[#38bdf8] text-[#0e1116] text-[10px] font-bold tabular-nums leading-none`,"aria-label":`${e} unread messages across all rooms`,title:`${e} unread messages across all rooms`,children:ELe(e)})}function A9(e,t){return j9(e,e=>F9(t.sessions[e]))}function DLe(e,t){let n=new Map(t.sessionSnapshots.map(e=>[e.piboSessionId,F9(e)]));return j9(e,e=>n.get(e))}function j9(e,t){return{...e,sessions:e.sessions.map(e=>M9(e,t))}}function M9(e,t){let n=t(e.piboSessionId),r=P9(n,N9(e)),i=r&&r!==e.status?L9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):L9(e.lastActivityAt,n?.updatedAt);return{...e,status:r??e.status,lastActivityAt:i,children:e.children.map(e=>M9(e,t)),derivedSessions:e.derivedSessions.map(e=>{let n=t(e.piboSessionId),r=P9(n,0),i=!!(r&&r!==e.status);return{...e,status:r??e.status,lastActivityAt:i?L9(e.lastActivityAt,n?.updatedAt,new Date().toISOString()):L9(e.lastActivityAt,n?.updatedAt)}})}}function N9(e){return(e.unreadCount??0)+e.children.reduce((e,t)=>e+N9(t),0)}function P9(e,t){return e?.status===`error`?t>0?`error`:e.isTreeActive?`running`:`idle`:e?.status}function F9(e){let t=I9(e);if(!(!e&&!t))return{status:t,updatedAt:e?.updatedAt,isTreeActive:e?.isTreeActive}}function I9(e){if(e)return e.hasError||e.hasErrorDescendant||e.aggregateStatus===`error`?`error`:e.isTreeActive?`running`:`idle`}function L9(...e){let t,n=-1/0;for(let r of e){if(!r)continue;let e=Date.parse(r);!Number.isFinite(e)||e<n||(t=r,n=e)}return t}function OLe(e,t){if(!e||e.rootPiboSessionId!==t.rootPiboSessionId||e.version!==t.fromVersion)return e;let n={...e.nodes};for(let e of t.removes)delete n[e];for(let e of t.upserts)n[e.id]=e;let r={...e.sessions};for(let e of t.sessionSnapshots)r[e.piboSessionId]=e;return{...e,version:t.toVersion,generatedAt:t.generatedAt,nodes:n,sessions:r}}function R9(e,t,n={}){let r=n.readSessionId?kLe(e.sessions,n.readSessionId):new Set,i=new Map;z9(e.sessions,i);let a=[...r].reduce((e,t)=>e+(i.get(t)??0),0);return{...e,identity:t.identity,session:t.session,room:t.room,selectedRoomId:t.selectedRoomId,selectedPiboSessionId:t.selectedPiboSessionId,latestRoomStreamId:t.latestRoomStreamId,rooms:ALe(e.rooms,t.rooms,t.selectedRoomId,a),sessions:V9(t.sessions,r,i)}}function z9(e,t){for(let n of e)t.set(n.piboSessionId,n.unreadCount??0),z9(n.children,t)}function kLe(e,t){let n=new Set,r=e=>e.piboSessionId===t?(B9(e,n),!0):e.children.some(e=>r(e));for(let t of e)r(t);return n}function B9(e,t){t.add(e.piboSessionId);for(let n of e.children)B9(n,t)}function V9(e,t,n){return e.map(e=>{let r=n.get(e.piboSessionId),i=t.has(e.piboSessionId)?0:e.unreadCount??r??0;return{...e,...i>0?{unreadCount:i}:{unreadCount:void 0},children:V9(e.children,t,n)}})}function ALe(e,t,n,r){let i=new Map;return H9(e,i),U9(t,i,n,r).rooms}function H9(e,t){for(let n of e)t.set(n.id,n.unreadCount??0),H9(n.children??[],t)}function U9(e,t,n,r){let i=!1;return{rooms:e.map(e=>{let a=U9(e.children??[],t,n,r),o=e.id===n||a.selectedRoomFound;i||=o;let s=e.unreadCount??t.get(e.id)??0,c=o&&r>0?Math.max(0,s-r):s;return{...e,...c>0?{unreadCount:c}:{unreadCount:void 0},...e.children?{children:a.rooms}:{}}}),selectedRoomFound:i}}function jLe(e,t){if(!t.length)return e;let n=new Set(e.map(e=>e.piboSessionId)),r=t.filter(e=>!n.has(e.piboSessionId));return r.length?[...e,...r]:e}function MLe(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,mcpServers:e.agentCatalog.mcpServers.map(e=>e.name===t.name?t:e)}}:e}function W9(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.piPackages.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,piPackages:J9([...n,t])}}}function G9(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,piPackages:e.agentCatalog.piPackages.filter(e=>e.id!==t)}}:e}function K9(e,t){if(!e.agentCatalog)return e;let n=e.agentCatalog.userSkills.filter(e=>e.id!==t.id);return{...e,agentCatalog:{...e.agentCatalog,userSkills:J9([...n,t])}}}function q9(e,t){return e.agentCatalog?{...e,agentCatalog:{...e.agentCatalog,userSkills:e.agentCatalog.userSkills.filter(e=>e.id!==t)}}:e}function J9(e){return e.sort((e,t)=>e.name.localeCompare(t.name))}function NLe(e,t){let n=r9(e);return{deletedSessionIds:n,selectedSessionDeleted:t?n.has(t):!1,restoreSelectedPiboSessionId:t}}function PLe(e,t,n){return t?e.includes(t):n}function FLe(e,t){return t?void 0:e??void 0}function ILe(e,t,n){let r=l9(e);return{deletedRoomIds:r,selectedRoomDeleted:t?r.has(t):!1,restoreSelectedRoomId:t,restoreSelectedPiboSessionId:n}}function LLe(e,t){return t===e}function RLe({queryClient:e,bootstrap:t,selectedPiboSessionId:n,selectedRoomId:r,showArchivedRef:i,isSessionsArea:a,loadBootstrap:o,navigateToSelectedSession:s,updateBootstrapCache:c,restoreBootstrapSnapshot:l,setSelectedPiboSessionId:u,setSelectedRoomId:d,setError:f}){let[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(``),[_,v]=(0,R.useState)(!1),[y,b]=(0,R.useState)(null),[x,S]=(0,R.useState)(``),[C,w]=(0,R.useState)(!1),T=e=>{b(e),S(``)},E=()=>{b(null),S(``)},D=async()=>{if(!y)return;w(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let d=e9(e,t),p=NLe(y,n);p.selectedSessionDeleted&&u(null),c(e=>vIe(e,p.deletedSessionIds));try{let e=PLe((await _c(y.piboSessionId,x)).deletedSessionIds,n,p.selectedSessionDeleted);e&&u(null);let t=await o(FLe(n,e),i.current,r??void 0,{force:!0});a&&s(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),E(),f(null)}catch(e){l(d),p.selectedSessionDeleted&&u(p.restoreSelectedPiboSessionId),f(e instanceof Error?e.message:String(e))}finally{w(!1)}},O=e=>{m(e),g(``)},k=()=>{m(null),g(``)};return{deleteRoomTarget:p,deleteRoomConfirmName:h,deletingRoom:_,setDeleteRoomConfirmName:g,requestRoomDelete:O,cancelRoomDelete:k,permanentlyDeleteRoom:async()=>{if(!p)return;v(!0),await e.cancelQueries({queryKey:[`chat`,`bootstrap`]});let m=e9(e,t),g=ILe(p,r,n);g.selectedRoomDeleted&&(d(null),u(null)),c(e=>SIe(e,g.deletedRoomIds));try{await hc(p.id,h),LLe(p.id,r)&&(d(null),u(null));let e=await o(void 0,i.current,void 0,{force:!0});a&&s(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),k(),f(null)}catch(e){l(m),g.selectedRoomDeleted&&(d(g.restoreSelectedRoomId),u(g.restoreSelectedPiboSessionId)),f(e instanceof Error?e.message:String(e))}finally{v(!1)}},deleteSessionTarget:y,deleteSessionConfirmText:x,deletingSession:C,setDeleteSessionConfirmText:S,requestSessionDelete:T,cancelSessionDelete:E,permanentlyDeleteSession:D}}var zLe=750,Y9=120,X9=60,BLe=new Set;async function VLe(e,t){let n=eje(t.piboSessionId,t.includeArchived,t.roomId);return await e.removeQueries({queryKey:n,exact:!0}),ec(t.piboSessionId,t.includeArchived,t.roomId,!!t.markRead)}async function Z9(e,t){let n=tje(t.includeArchived,t.roomId,t.piboSessionId);return await e.removeQueries({queryKey:n,exact:!0}),tc(t.piboSessionId,t.includeArchived,t.roomId)}function HLe({route:e}){let t=ja(),n=Yt(),r=e.area,i=e.area===`sessions`?e.roomId:void 0,a=e.area===`projects`?e.projectId:void 0,o=e.area===`sessions`||e.area===`projects`||e.area===`context`?e.piboSessionId:void 0,s=e.area===`sessions`||e.area===`projects`?e.sessionViewId:void 0,c=e.area===`settings`?e.panel??`general`:`general`,[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(null),[_,v]=(0,R.useState)(oke),[y,b]=(0,R.useState)(ske),[x,S]=(0,R.useState)(cke),[C,w]=(0,R.useState)(lke),[T,E]=(0,R.useState)(dke),[D,O]=(0,R.useState)(fke),[k,A]=(0,R.useState)(()=>s??n2()),[j,M]=(0,R.useState)(``),[N,P]=(0,R.useState)(0),[F,ee]=(0,R.useState)(!1),te=(0,R.useRef)(!1),[I,ne]=(0,R.useState)(!1),[L,re]=(0,R.useState)(!1),[ie,ae]=(0,R.useState)(Y9),[oe,se]=(0,R.useState)(X9),[ce,le]=(0,R.useState)(null),[ue,de]=(0,R.useState)(null),[fe,pe]=(0,R.useState)(`build-context`),[me,he]=(0,R.useState)(null),[ge,_e]=(0,R.useState)(null),[ve,ye]=(0,R.useState)(!1),[be,xe]=(0,R.useState)(!1),[Se,Ce]=(0,R.useState)(!1),we=(0,R.useRef)(null),[Te,Ee]=(0,R.useState)(null),[De,Oe]=(0,R.useState)(null),[ke,Ae]=(0,R.useState)(()=>Date.now()),je=(0,R.useRef)(C),Me=(0,R.useRef)(null),Ne=(0,R.useRef)(null),Pe=(0,R.useRef)(0),Fe=p??l?.selectedRoomId??null,Ie=Fe&&l?f3(l.rooms,Fe)??l.room:void 0,Le=Ie?h3(Ie):!1;(0,R.useEffect)(()=>{je.current=C},[C]),(0,R.useEffect)(()=>{if(!Se)return;let e=e=>{we.current&&!we.current.contains(e.target)&&Ce(!1)},t=e=>{e.key===`Escape`&&Ce(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[Se]),(0,R.useEffect)(()=>{Ne.current=l},[l]),(0,R.useEffect)(()=>{ae(Y9),se(X9)},[p,C]),(0,R.useEffect)(()=>{Ae(Date.now())},[l]),(0,R.useEffect)(()=>{if(r!==`sessions`||!d){Oe(null);return}let e,t=t=>{e&&clearTimeout(e),e=setTimeout(()=>{e=void 0,Rc(d).then(e=>{Oe(e),u(t=>t&&A9(t,e))}).catch(()=>void 0)},t)},n=zc(d,{onSnapshot:t=>{e&&=(clearTimeout(e),void 0),Oe(t),u(e=>e&&A9(e,t))},onPatch:e=>{Oe(n=>{let r=OLe(n,e);return n&&r===n&&t(0),r}),u(t=>t&&DLe(t,e))},onError:()=>t(zLe)});return()=>{e&&clearTimeout(e),n()}},[r,d]),(0,R.useEffect)(()=>{let e=l?Gje(l.sessions,ke):void 0;if(e===void 0)return;let t=setTimeout(()=>Ae(Date.now()),Math.max(50,e));return()=>clearTimeout(t)},[l,ke]),(0,R.useEffect)(()=>{let e=async()=>{try{let e=await fetch(`/health`,{signal:AbortSignal.timeout(3e3)});e.ok?Ee((await e.json()).mode===`fallback`?`fallback`:`main`):Ee(null)}catch{Ee(null)}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[]),(0,R.useEffect)(()=>{if(r!==`sessions`&&r!==`projects`)return;let e=s??n2();A(t=>t===e?t:e)},[r,s]),(0,R.useEffect)(()=>{ake(k)},[k]);let Re=(0,R.useCallback)((e,n=!1,r=k,i={})=>{i.closeMobileSidebar!==!1&&xe(!1),kc(t,e,n,r)},[t,k]),ze=(0,R.useCallback)((e,t,n=!1,r={})=>{if(!t){Re({area:`sessions`,...e?{roomId:e}:{}},n,k,r);return}Re({area:`sessions`,...e?{roomId:e}:{},piboSessionId:t},n,k,r)},[Re,k]),Be=(0,R.useCallback)((e,t,n=!1,r={})=>{if(!t){Re({area:`projects`,...e?{projectId:e}:{}},n,k,r);return}Re({area:`projects`,...e?{projectId:e}:{},piboSessionId:t},n,k,r)},[Re,k]),Ve=(0,R.useCallback)(e=>{pe(`build-context`),Re({area:`context`,piboSessionId:e})},[Re]),He=(0,R.useCallback)(e=>{he(e),pe(`context-files`),Re({area:`context`})},[Re]),Ue=(0,R.useCallback)(e=>{_e(e),pe(`mcp-tools`),Re({area:`context`})},[Re]),We=(0,R.useCallback)(e=>{u(t=>t&&MLe(t,e))},[]),Ge=(0,R.useCallback)(e=>{u(t=>t&&W9(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&W9(t,e))},[n]),Ke=(0,R.useCallback)(e=>{u(t=>t&&G9(t,e.id)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&G9(t,e.id))},[n]),qe=(0,R.useCallback)(e=>{u(t=>t&&K9(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&K9(t,e))},[n]),Je=(0,R.useCallback)(e=>{u(t=>t&&q9(t,e)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&q9(t,e))},[n]),Ye=(0,R.useCallback)(async(e,t=je.current,r,i={})=>{let a=Ne.current;if(a&&i.selectSession!==!1&&!i.force){e&&await dc(e);let i=Pe.current+1;Pe.current=i;let o=R9(a,await Z9(n,{piboSessionId:e,includeArchived:t,roomId:r}),{readSessionId:e});return i===Pe.current?(u(o),f(o.selectedPiboSessionId),m(o.selectedRoomId),o):o}let o=Pe.current+1;Pe.current=o;let s=await VLe(n,{piboSessionId:e,includeArchived:t,roomId:r,markRead:i.selectSession!==!1,force:i.force});return o===Pe.current?(u(s),i.selectSession!==!1&&f(s.selectedPiboSessionId),m(s.selectedRoomId),s):s},[n]),Xe=(0,R.useCallback)(async(e,t=je.current,r,i={})=>{let a=Ne.current;if(!a)return Ye(e,t,r,{force:i.force});let o=Pe.current+1;Pe.current=o;let s=R9(a,await Z9(n,{piboSessionId:e,includeArchived:t,roomId:r,force:i.force}),{readSessionId:i.readSessionId});return o===Pe.current?(u(s),f(s.selectedPiboSessionId),m(s.selectedRoomId),s):s},[Ye,n]);(0,R.useEffect)(()=>{if(r!==`sessions`)return;let e=!1,t=window.setInterval(()=>{e||document.hidden||!Ne.current||Xe(d??void 0,je.current,Fe??void 0,{force:!0}).catch(()=>void 0)},2500);return()=>{e=!0,window.clearInterval(t)}},[Fe,r,Xe,d]),(0,R.useEffect)(()=>{let{requestedRoomId:t,requestedPiboSessionId:n}=MIe(e,Z0()),r=(t,n=!0)=>{let r=PIe(e,t);r&&ze(r.selectedRoomId,r.selectedPiboSessionId,n)};if(NIe({bootstrap:l,creatingSession:te.current,route:e}))return;let a=l?Xe:Ye;a(n,je.current,t).then(e=>{r(e),g(null)}).catch(s=>{if(e.area===`sessions`&&i&&!o&&n){Q0(i),a(void 0,je.current,i).then(e=>{r(e),g(null)}).catch(e=>g(e instanceof Error?e.message:String(e)));return}if(FIe(e)||!n&&!t){g(s instanceof Error?s.message:String(s));return}pke(),a().then(e=>{r(e),g(null)}).catch(e=>g(e instanceof Error?e.message:String(e)))})},[l,Ye,Xe,ze,e.area,o,i]),(0,R.useEffect)(()=>{!p&&!d||rke({roomId:p??void 0,piboSessionId:d??void 0})},[d,p]),(0,R.useEffect)(()=>{M(d?$0(d):``)},[d]);let Ze=(0,R.useCallback)(e=>{M(t=>{let n=typeof e==`function`?e(t):e;return d&&e2(d,n),n})},[d]),Qe=(0,R.useMemo)(()=>_Ie(),[]),$e=(0,R.useMemo)(()=>$7(k),[k]);(0,R.useEffect)(()=>{if(!l?.agents.length)return;let e=Q4(l),t=D||e,n=Q9(l.agents,t);if(n){D!==n.name&&(O(n.name),s2(n.name));return}let r=Q9(l.agents,e)?.name??l.agents[0].name;O(r),s2(r)},[l,D]);let et=(0,R.useCallback)(e=>{O(e),s2(e)},[]),tt=(0,R.useCallback)(async e=>{let t=YU(e),r=!1;try{await Promise.all([n.invalidateQueries({queryKey:B4(e),refetchType:`none`}),n.invalidateQueries({queryKey:V4(e),refetchType:`none`})]),await Promise.all([n.refetchQueries({queryKey:B4(e),type:`active`}),n.refetchQueries({queryKey:V4(e),type:`active`})])}catch(e){throw r=!0,e}finally{XU(e,t,r)}},[n]),nt=(0,R.useCallback)(()=>d?tt(d):Promise.resolve(),[tt,d]),rt=(0,R.useCallback)(()=>Xe(d??void 0,je.current,p??void 0,{force:!0}),[Xe,d,p]),it=(0,R.useCallback)(async()=>{g(null);let e=d??void 0;await Ye(e,je.current,p??void 0,{force:!0,selectSession:!1}),e&&await tt(e)},[Ye,tt,d,p]),at=(0,R.useCallback)(e=>{u(t=>t&&e(t)),n.setQueriesData({queryKey:[`chat`,`bootstrap`]},t=>t&&e(t))},[n]),ot=l?.latestRoomStreamId;(0,R.useEffect)(()=>{if(r!==`sessions`||!Fe)return;let e=new URLSearchParams({roomId:Fe});e.set(`mode`,`summary`),e.set(`since`,`${ot??0}:999999`);let t=new EventSource(`/api/chat/events?${e.toString()}`),n,i=()=>{n&&clearTimeout(n),n=setTimeout(()=>{n=void 0,Ye(d??void 0,je.current,Fe,{force:!0,selectSession:!1}).catch(e=>g(a3(e)))},900)};return t.addEventListener(`pibo`,e=>{let t=Yc(e);if(!t||t.type===`ready`)return;let n=t.piboSessionId,r=ol(t);if(n&&r){let e=new Date().toISOString();at(t=>a9(t,n,t=>({...t,status:r,lastActivityAt:e})))}el(t)&&i()}),()=>{n&&clearTimeout(n),t.close()}},[Fe,r,ot,Ye,d,at]);let st=(0,R.useCallback)(e=>{if(e){u(e.localBootstrap);for(let[t,r]of e.queryData)n.setQueryData(t,r)}},[n]),{deleteRoomTarget:ct,deleteRoomConfirmName:lt,deletingRoom:ut,setDeleteRoomConfirmName:dt,requestRoomDelete:ft,cancelRoomDelete:pt,permanentlyDeleteRoom:mt,deleteSessionTarget:ht,deleteSessionConfirmText:gt,deletingSession:_t,setDeleteSessionConfirmText:vt,requestSessionDelete:yt,cancelSessionDelete:bt,permanentlyDeleteSession:xt}=RLe({queryClient:n,bootstrap:l,selectedPiboSessionId:d,selectedRoomId:p,showArchivedRef:je,isSessionsArea:r===`sessions`,loadBootstrap:Ye,navigateToSelectedSession:ze,updateBootstrapCache:at,restoreBootstrapSnapshot:st,setSelectedPiboSessionId:f,setSelectedRoomId:m,setError:g}),St=fn({mutationFn:({profile:e,roomId:t})=>uc(e||void 0,t),onMutate:async({profile:e})=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let t=e9(n,l),r=d,i=`optimistic-session-${n3()}`;return f(i),at(t=>({...t9(t,TIe(i,e||Q4(t))),selectedPiboSessionId:i})),{snapshot:t,tempId:i,previousSelectedPiboSessionId:r}},onError:(e,t,n)=>{st(n?.snapshot),f(n?.previousSelectedPiboSessionId??null)},onSuccess:(e,t,n)=>{f(e.session.id),at(t=>yIe(t,n?.tempId,d9(e.session)))}}),Ct=fn({mutationFn:({piboSessionId:e,title:t})=>gc(e,{title:t}),onMutate:async({piboSessionId:e,title:t})=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=e9(n,l);return at(n=>a9(n,e,e=>({...e,title:t||`Untitled Session`}))),{snapshot:r}},onError:(e,t,n)=>st(n?.snapshot),onSuccess:({session:e})=>at(t=>i9(t,e))}),wt=fn({mutationFn:({piboSessionId:e,archived:t})=>gc(e,{archived:t}),onMutate:async({piboSessionId:e,archived:t})=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let r=e9(n,l);return at(n=>a9(n,e,e=>({...e,archived:t,unreadCount:t?0:e.unreadCount}))),{snapshot:r}},onError:(e,t,n)=>st(n?.snapshot),onSuccess:({session:e})=>at(t=>i9(t,e))}),Tt=fn({mutationFn:({piboSessionId:e,text:t,clientTxnId:n,roomId:r,webAnnotationIds:i,fileAttachmentPaths:a})=>vc(e,t,n,r,i,a),onMutate:async({piboSessionId:e})=>{await n.cancelQueries({queryKey:V4(e)}),at(t=>a9(t,e,e=>({...e,status:`running`,lastActivityAt:new Date().toISOString()})))},onError:(e,t)=>{at(e=>a9(e,t.piboSessionId,e=>({...e,status:`error`})))}}),Et=(0,R.useCallback)(async e=>{if(!(!d||!l||e===Q4(l)))try{await gc(d,{profile:e}),et(e);let t=await Ye(d,je.current,p??void 0);r===`sessions`&&ze(t.selectedRoomId,t.selectedPiboSessionId),await tt(d),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}},[r,l,Ye,ze,tt,d,p,et]),Dt=(0,R.useMemo)(()=>AIe(l?.capabilities.actions??[]),[l]),Ot=(0,R.useMemo)(()=>jIe(l,d),[l,d]),kt=(0,R.useCallback)(async e=>{(0,Na.flushSync)(()=>{f(e),le(e),xe(!1)}),ze(p??l?.selectedRoomId,e,!1,{closeMobileSidebar:!1});try{await dc(e);let t=await Xe(e,je.current,p??l?.selectedRoomId,{readSessionId:e});ze(t.selectedRoomId,t.selectedPiboSessionId,!0,{closeMobileSidebar:!1})}finally{le(t=>t===e?null:t)}},[l?.selectedRoomId,Xe,ze,p]),At=(0,R.useCallback)(async(e,t={})=>{let n={...t,closeMobileSidebar:!1},r=Z0().sessionsByRoom?.[e];m(e),f(r??null);try{let t=await Xe(r,je.current,e);ze(t.selectedRoomId,t.selectedPiboSessionId,!1,n)}catch(t){if(!r)throw t;Q0(e),f(null);let i=await Xe(void 0,je.current,e);ze(i.selectedRoomId,i.selectedPiboSessionId,!1,n)}},[Xe,ze]),jt=async(e=D)=>{if(!(F||Le)){te.current=!0,ee(!0);try{let t=await St.mutateAsync({profile:e,roomId:p??void 0});f(t.session.id),de(t.session.id),ze(p??l?.selectedRoomId??void 0,t.session.id,!1,{closeMobileSidebar:!1});let n=await Ye(t.session.id,je.current,p??void 0,{force:!0});ze(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}finally{te.current=!1,ee(!1)}}},Mt=async()=>{let e=!C;if(w(e),uke(e),!e){re(!1),g(null);return}re(!0);try{let e=await Xe(d??void 0,!0,p??void 0);r===`sessions`&&ze(e.selectedRoomId,e.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}finally{re(!1)}},Nt=async(e,t)=>{try{await Ct.mutateAsync({piboSessionId:e,title:t});let n=await Ye(d??void 0,je.current,p??void 0,{force:!0});r===`sessions`&&await tt(n.selectedPiboSessionId),r===`sessions`&&ze(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}},Pt=async(e,t)=>{try{await wt.mutateAsync({piboSessionId:e,archived:t});let n=await Ye(t&&!C&&d===e?void 0:d??void 0,je.current,p??void 0,{force:!0});r===`sessions`&&ze(n.selectedRoomId,n.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}},Ft=async()=>{if(ve)return;ye(!0),await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let e=e9(n,l),t=`optimistic-room-${n3()}`,r=CIe(t,`New Chat`);m(t),f(null),at(e=>bIe(e,r));try{let e=await pc({name:`New Chat`});at(n=>xIe(n,t,e.room)),await At(e.room.id,{closeMobileSidebar:!1}),g(null)}catch(t){st(e),m(p),f(d),g(t instanceof Error?t.message:String(t))}finally{ye(!1)}},It=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let i=e9(n,l);at(n=>o9(n,e,e=>({...e,...t.name===void 0?{}:{name:t.name},...t.topic===void 0?{}:{topic:t.topic??void 0},...t.workspace===void 0?{}:{workspace:t.workspace??void 0},updatedAt:new Date().toISOString()})));try{let{room:n}=await mc(e,t);at(t=>o9(t,e,()=>n));let i=await Ye(d??void 0,je.current,e,{force:!0});r===`sessions`&&ze(i.selectedRoomId,i.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){st(i),g(e instanceof Error?e.message:String(e))}},Lt=async e=>{try{await fc(e);let t=await Ye(d??void 0,je.current,p??void 0,{force:!0,selectSession:!1});r===`sessions`&&ze(t.selectedRoomId,t.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}},Rt=async(e,t)=>{await n.cancelQueries({queryKey:[`chat`,`bootstrap`]});let i=e9(n,l);t&&(E(!0),o2(!0)),at(n=>o9(n,e,e=>wIe(e,t)));try{let{room:n}=await mc(e,{archived:t});at(t=>o9(t,e,()=>n));let i=await Ye(d??void 0,je.current,p??void 0,{force:!0});r===`sessions`&&ze(i.selectedRoomId,i.selectedPiboSessionId,!1,{closeMobileSidebar:!1}),g(null)}catch(e){st(i),g(e instanceof Error?e.message:String(e))}},zt=(0,R.useCallback)(async e=>{if(!d||Le)return!1;let t=e.trim().split(/\s+/)[0],n=Dt.find(e=>e.slash===t);if(!n)return!1;if(n.action===`thinking-show`){let e=!_;return v(e),r2(e),!0}if(n.action===`download`){let n=EIe(e.slice(t.length));if(!n)return g(`Usage: /download <path>`),!0;try{await Pc(n,{piboSessionId:d,roomId:p??void 0}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}return!0}let i=DIe(n.action,e.slice(t.length).trim()),a=kIe(await yc(d,n.action,i));if((n.action===`session.clone`||n.action===`session.fork`)&&a)await kt(a);else{let e=await Ye(d,je.current,p??void 0);r===`sessions`&&ze(e.selectedRoomId,e.selectedPiboSessionId),await tt(d)}return!0},[r,Ye,ze,tt,kt,d,Le,p,_,Dt]),Bt=(0,R.useCallback)(async e=>{if(!d||Le)return;let t=OIe(await yc(d,`session.fork`,{entryId:e}));if(t?.result.cancelled)return;if(!t)throw Error(`Unexpected fork action response`);let n=typeof t.result.selectedText==`string`?t.result.selectedText:void 0;n!==void 0&&t.result.piboSessionId&&e2(t.result.piboSessionId,n),t.result.piboSessionId&&await kt(t.result.piboSessionId),n!==void 0&&(M(n),P(e=>e+1))},[kt,d,Le]),Vt=(0,R.useCallback)(e=>void kt(e),[kt]),Ht=(0,R.useCallback)(e=>{if(A(e),r===`projects`){Re({area:`projects`,...a?{projectId:a}:{},...o?{piboSessionId:o}:{}},!1,e);return}r===`sessions`&&Re({area:`sessions`,...p?{roomId:p}:{},...d?{piboSessionId:d}:{}},!1,e)},[r,Re,o,a,d,p]),Ut=(0,R.useMemo)(()=>l?u3(l.sessions,C):{active:[],archived:[]},[l?.sessions,C]),Wt=(0,R.useMemo)(()=>Kje(Ut.active,ie,d),[Ut.active,d,ie]),Gt=(0,R.useMemo)(()=>C?Ut.archived.slice(0,oe):[],[Ut.archived,C,oe]),Kt=Ut.active.length>Wt.length,qt=C&&Ut.archived.length>Gt.length,Jt=(0,R.useMemo)(()=>d?new Set(t3(l?.sessions??[],d).map(e=>e.piboSessionId)):BLe,[l?.sessions,d]),Xt=(0,R.useCallback)(async e=>{if(!Fe)return;let t=(e?Gt:Wt).at(-1)?.piboSessionId;e?re(!0):ne(!0);try{let r=e?X9:Y9,i=await n.fetchQuery({queryKey:rje(Fe,e,t,r),queryFn:()=>lc({roomId:Fe,piboSessionId:d??void 0,archived:e,cursor:t,limit:r}),staleTime:3e4,gcTime:30*6e4});u(e=>e&&{...e,sessions:jLe(e.sessions,i.sessions)}),e?se(e=>e+r):ae(e=>e+r)}finally{e?re(!1):ne(!1)}},[Fe,n,d,Wt,Gt]);if(h&&!l)return(0,z.jsx)(TLe,{message:h});if(!l)return(0,z.jsx)(`div`,{className:`min-h-screen bg-[#101d22] text-slate-300 grid place-items-center`,children:`Loading Pibo Chat...`});let Zt=d?e3(l.sessions,d):void 0,Qt=d?De?.sessions[d]:void 0,$t=De?.rootPiboSessionId?De.sessions[De.rootPiboSessionId]:void 0,en=$4(l,Zt??{profile:Q4(l),parentId:l.session?.parentId}),tn=qje(l.rooms),nn=[...new Set([...l.agents.map(e=>e.name),...l.customAgents.map(e=>e.profileName)])],rn=wje(l);return(0,z.jsxs)(z.Fragment,{children:[Te===`fallback`?(0,z.jsx)(SLe,{}):null,(0,z.jsxs)(`div`,{"data-pibo-debug":`chat-app`,"data-pibo-area":r,"data-pibo-room-id":p??l.selectedRoomId??void 0,"data-pibo-selected-session-id":d??l.selectedPiboSessionId??void 0,className:`h-dvh overflow-hidden bg-[#101d22] text-slate-200 grid grid-rows-[auto_auto_1fr]`,children:[(0,z.jsx)(CLe,{area:r,identity:rn,mobileAreaMenuOpen:Se,mobileAreaMenuRef:we,totalRoomUnreadCount:tn,onOpenMobileSidebar:()=>xe(!0),onSelectMainNavArea:e=>{if(Ce(!1),e===`sessions`){ze(p??l.selectedRoomId,d??l.selectedPiboSessionId);return}if(e===`projects`){Re({area:`projects`});return}Re({area:e})},onToggleMobileAreaMenu:()=>Ce(e=>!e)}),(0,z.jsx)(`div`,{children:h?(0,z.jsx)(wLe,{message:h,onDismiss:()=>g(null)}):null}),(0,z.jsx)(`div`,{"data-pibo-debug":`route-shell`,"data-pibo-area":r,"data-pibo-room-id":p??l.selectedRoomId??void 0,"data-pibo-selected-session-id":d??void 0,className:`min-h-0 ${r===`agents`||r===`workflows`||r===`cron`||r===`ralph`?`h-full overflow-hidden`:`grid ${(r===`sessions`||r===`projects`)&&x?`grid-cols-[300px_minmax(0,1fr)_320px] max-[980px]:grid-cols-1`:`grid-cols-[300px_minmax(0,1fr)] max-[980px]:grid-cols-1`}`}`,children:r===`cron`?(0,z.jsx)(Rve,{bootstrap:l,mobileSidebarOpen:be,onCloseMobileSidebar:()=>xe(!1)}):r===`ralph`?(0,z.jsx)(dye,{bootstrap:l,mobileSidebarOpen:be,onCloseMobileSidebar:()=>xe(!1)}):r===`agents`?(0,z.jsx)(ZOe,{agents:l.agents,initialCustomAgents:l.customAgents,initialCatalog:l.agentCatalog,modelCatalog:l.modelCatalog,onSelect:et,onCreateSession:e=>void jt(e),onEditContextFile:He,onEditMcpServer:Ue,onAgentsChanged:()=>void Ye(d??void 0,je.current,p??void 0,{selectSession:!1}),creatingSession:F||Le}):r===`workflows`?(0,z.jsx)(xOe,{draftId:e.area===`workflows`?e.draftId:void 0,viewWorkflowId:e.area===`workflows`?e.viewWorkflowId:void 0,viewWorkflowVersion:e.area===`workflows`?e.viewWorkflowVersion:void 0}):r===`projects`?(0,z.jsx)(yLe,{baseBootstrap:l,routeProjectId:a,routePiboSessionId:o,sessionViews:Qe,showRawEvents:x,showThinking:_,expandThinking:y,commands:Dt,skills:Ot,mobileSidebarOpen:be,onCloseMobileSidebar:()=>xe(!1),onNavigate:Be,onViewContext:Ve,onSelectSessionView:Ht,onToggleRawEvents:()=>{let e=!x;S(e),a2(e)},onToggleThinking:()=>{let e=!_;v(e),r2(e)},onToggleExpandThinking:()=>{let e=!y;b(e),i2(e)},onThinkingLevelChange:e=>void yc(o??``,`thinking`,{level:e}),onError:g}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`fixed inset-0 z-30 bg-black/60 min-[981px]:hidden transition-opacity duration-200 ${be?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,onClick:()=>xe(!1)}),(0,z.jsxs)(`aside`,{"data-pibo-debug":`sidebar-shell`,"data-pibo-area":r,"data-pibo-room-id":p??l.selectedRoomId??void 0,"data-pibo-selected-session-id":d??void 0,"data-pibo-state":be?`open`:`closed`,className:`min-h-0 overflow-hidden flex flex-col bg-[#1a262b] border-r border-slate-800 max-[980px]:fixed max-[980px]:left-0 max-[980px]:top-0 max-[980px]:bottom-0 max-[980px]:z-40 max-[980px]:w-[280px] max-[980px]:transition-transform max-[980px]:duration-200 ${be?`max-[980px]:translate-x-0`:`max-[980px]:-translate-x-full`}`,children:[(0,z.jsxs)(`div`,{className:`h-11 px-3 border-b border-slate-800 flex items-center justify-between text-xs font-bold uppercase tracking-wider max-[980px]:h-auto max-[980px]:py-2 max-[980px]:flex-wrap`,children:[(0,z.jsx)(`span`,{children:r}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[r===`sessions`?(0,z.jsx)(`button`,{type:`button`,onClick:()=>void Ye(d??void 0,je.current,p??void 0,{force:!0}).then(e=>{d&&tt(d),r===`sessions`&&ze(e.selectedRoomId,e.selectedPiboSessionId)}),title:`Refresh`,"aria-label":`Refresh`,className:`p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,children:(0,z.jsx)(Ls,{size:13})}):null,(0,z.jsx)(`button`,{type:`button`,onClick:()=>xe(!1),className:`min-[981px]:hidden p-1 border border-slate-700 rounded-sm text-slate-400 hover:border-[#11a4d4] hover:text-[#11a4d4]`,title:`Close sidebar`,"aria-label":`Close sidebar`,children:(0,z.jsx)(Qs,{size:13})})]})]}),r===`sessions`?(0,z.jsx)($je,{bootstrap:l,selectedRoomId:p,selectedPiboSessionId:d,showArchivedRooms:T,onToggleArchivedRooms:()=>{let e=!T;E(e),o2(e)},creatingRoom:ve,onCreateRoom:()=>Ft(),onSelectRoom:At,onUpdateRoom:It,onArchiveRoom:Rt,onReadAllRoom:Lt,onDeleteRoom:ft,newSessionProfile:D,onNewSessionProfileChange:et,selectedRoomArchived:Le,creatingSession:F,onCreateSession:()=>jt(),showArchived:C,onToggleArchivedSessions:Mt,loadingArchivedSessions:L,visibleActiveSessions:Wt,visibleArchivedSessions:Gt,totalActiveSessionCount:Ut.active.length,totalArchivedSessionCount:Ut.archived.length,hasMoreActiveSessions:Kt,hasMoreArchivedSessions:qt,loadingActiveSessions:I,sessionListScrollRef:Me,onLoadMoreSessions:Xt,signalNow:ke,selectedSessionPathIds:Jt,onSelectSession:kt,onRenameSession:Nt,onArchiveSession:Pt,onDeleteSession:yt,onViewContext:Ve,loadingPiboSessionId:ce,autoRenameSessionId:ue,onAutoRenameConsumed:()=>de(null)}):r===`context`?(0,z.jsx)(Ave,{activePanel:fe,onSelect:pe,toolCount:l.agentCatalog?.piboTools.length??0,mcpServerCount:l.agentCatalog?.mcpServers.length??0}):(0,z.jsx)(IIe,{activePanel:c,onSelect:e=>Re({area:`settings`,panel:e}),piPackageCount:l.agentCatalog?.piPackages.length??0,userSkillCount:l.agentCatalog?.userSkills.length??0})]}),r===`sessions`?(0,z.jsx)(o3,{bootstrap:l,selectedPiboSessionId:d,selectedRoomId:p,selectedRoomArchived:Le,selectedSessionProfile:Zt?.profile??Q4(l),selectedSessionActiveModel:en,selectedSessionStatus:I9(Qt??$t)??Zt?.status,selectedSessionSignal:Qt,sessionViewId:k,sessionViews:Qe,currentSessionView:$e,creatingSession:F,showRawEvents:x,showThinking:_,expandThinking:y,commands:Dt,skills:Ot,composerText:j,composerFocusSignal:N,onComposerTextChange:Ze,onToggleRawEvents:()=>{let e=!x;S(e),a2(e)},onToggleThinking:()=>{let e=!_;v(e),r2(e)},onToggleExpandThinking:()=>{let e=!y;b(e),i2(e)},onSessionAgentProfileChange:e=>void Et(e),onFork:Bt,onOpenSession:Vt,onSelectSessionView:Ht,onCommand:zt,onThinkingLevelChange:e=>void zt(`/thinking ${e}`),onRefreshTrace:nt,onRefreshBootstrap:rt,onSend:async(e,t,n,r)=>{if(!(!d||Le))try{await Tt.mutateAsync({piboSessionId:d,text:e,clientTxnId:r??n3(),roomId:p??void 0,webAnnotationIds:t,fileAttachmentPaths:n}),await Ye(d,je.current,p??void 0,{force:!0}),g(null)}catch(e){g(e instanceof Error?e.message:String(e))}},onError:g}):(0,z.jsx)(`main`,{className:`min-h-0 flex flex-col`,children:r===`context`?fe===`pibo-tools`?(0,z.jsx)(VW,{tools:l.agentCatalog?.piboTools??[]}):fe===`mcp-tools`?(0,z.jsx)(tG,{servers:l.agentCatalog?.mcpServers??[],selectedServerName:ge,onServerSaved:We}):fe===`build-context`?(0,z.jsx)(yve,{piboSessionId:o??null}):fe===`base-prompt`?(0,z.jsx)(Hge,{}):fe===`compaction-prompt`?(0,z.jsx)(Gge,{}):(0,z.jsx)(Tge,{agentProfiles:nn,selectedFileKey:me}):(0,z.jsx)(zIe,{activePanel:c,showThinking:_,setShowThinking:v,expandThinking:y,setExpandThinking:b,modelDefaults:l.modelDefaults,modelCatalog:l.modelCatalog,onModelDefaultsChanged:e=>{u(t=>t&&{...t,modelDefaults:e})},piPackages:l.agentCatalog?.piPackages,onPiPackageChanged:Ge,onPiPackageRemoved:Ke,userSkills:l.agentCatalog?.userSkills,onUserSkillChanged:qe,onUserSkillRemoved:Je,piboSessionId:d,onProviderAuthChanged:it})}),ct?(0,z.jsx)(xLe,{room:ct,confirmName:lt,deleting:ut,onConfirmNameChange:dt,onCancel:pt,onDelete:()=>void mt()}):null,ht?(0,z.jsx)(bLe,{session:ht,confirmText:gt,deleting:_t,onConfirmTextChange:vt,onCancel:bt,onDelete:()=>void xt()}):null]})})]})]})}function Q9(e,t){return e.find(e=>e.name===t||e.aliases.includes(t))}var ULe=new Gt({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});function WLe(){let e=ho({select:e=>({pathname:e.location.pathname,search:e.location.search})});return(0,z.jsx)(HLe,{route:Dc(e.pathname,e.search)})}var $9=Xa({component:WLe}),GLe=Ja({getParentRoute:()=>$9,path:`/`}),KLe=Ja({getParentRoute:()=>$9,path:`sessions/$piboSessionId`}),qLe=Ja({getParentRoute:()=>$9,path:`rooms/$roomId`}),JLe=Ja({getParentRoute:()=>$9,path:`rooms/$roomId/sessions/$piboSessionId`}),YLe=Ja({getParentRoute:()=>$9,path:`projects`}),XLe=Ja({getParentRoute:()=>$9,path:`projects/$projectId`}),ZLe=Ja({getParentRoute:()=>$9,path:`projects/$projectId/sessions/$piboSessionId`}),QLe=Ja({getParentRoute:()=>$9,path:`workflows`}),$Le=Ja({getParentRoute:()=>$9,path:`workflows/drafts/$draftId`}),eRe=Ja({getParentRoute:()=>$9,path:`workflows/view/$workflowId/$workflowVersion`}),tRe=Ja({getParentRoute:()=>$9,path:`agents`}),nRe=Ja({getParentRoute:()=>$9,path:`cron`}),rRe=Ja({getParentRoute:()=>$9,path:`ralph`}),iRe=Ja({getParentRoute:()=>$9,path:`context`}),aRe=Ja({getParentRoute:()=>$9,path:`settings`}),oRe=Ja({getParentRoute:()=>$9,path:`settings/shortcuts`}),sRe=Ja({getParentRoute:()=>$9,path:`settings/pi-packages`}),cRe=Ja({getParentRoute:()=>$9,path:`settings/skills`}),lRe=Ja({getParentRoute:()=>$9,path:`settings/providers`}),uRe=uo({routeTree:$9.addChildren([GLe,KLe,qLe,JLe,YLe,XLe,ZLe,QLe,$Le,eRe,tRe,nRe,rRe,iRe,aRe,oRe,sRe,cRe,lRe]),basepath:`/apps/chat`});`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`/apps/chat/sw.js`).catch(()=>{})}),(0,$s.createRoot)(document.getElementById(`root`)).render((0,z.jsx)(R.StrictMode,{children:(0,z.jsx)(Xt,{client:ULe,children:(0,z.jsx)(mo,{router:uRe})})}));export{rfe as i,tP as n,xde as r,$N as t};
|