modular-studio 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +261 -0
- package/dist/assets/graphPopulator-C6jg83nL.js +1 -0
- package/dist/assets/index-CXhIX28x.js +634 -0
- package/dist/assets/index-CeNF0r-K.css +1 -0
- package/dist/assets/jszip.min-BlpRodxc.js +2 -0
- package/dist/index.html +16 -0
- package/dist/vite.svg +1 -0
- package/dist-server/bin/modular-mcp.d.ts +8 -0
- package/dist-server/bin/modular-mcp.d.ts.map +1 -0
- package/dist-server/bin/modular-mcp.js +158 -0
- package/dist-server/bin/modular-mcp.js.map +1 -0
- package/dist-server/bin/modular-studio.d.ts +3 -0
- package/dist-server/bin/modular-studio.d.ts.map +1 -0
- package/dist-server/bin/modular-studio.js +63 -0
- package/dist-server/bin/modular-studio.js.map +1 -0
- package/dist-server/server/config.d.ts +4 -0
- package/dist-server/server/config.d.ts.map +1 -0
- package/dist-server/server/config.js +33 -0
- package/dist-server/server/config.js.map +1 -0
- package/dist-server/server/data/mcp-clients.json +5 -0
- package/dist-server/server/index.d.ts +3 -0
- package/dist-server/server/index.d.ts.map +1 -0
- package/dist-server/server/index.js +174 -0
- package/dist-server/server/index.js.map +1 -0
- package/dist-server/server/mcp/manager.d.ts +47 -0
- package/dist-server/server/mcp/manager.d.ts.map +1 -0
- package/dist-server/server/mcp/manager.js +203 -0
- package/dist-server/server/mcp/manager.js.map +1 -0
- package/dist-server/server/mcp/modular-server.d.ts +55 -0
- package/dist-server/server/mcp/modular-server.d.ts.map +1 -0
- package/dist-server/server/mcp/modular-server.js +492 -0
- package/dist-server/server/mcp/modular-server.js.map +1 -0
- package/dist-server/server/mcp/transport.d.ts +29 -0
- package/dist-server/server/mcp/transport.d.ts.map +1 -0
- package/dist-server/server/mcp/transport.js +61 -0
- package/dist-server/server/mcp/transport.js.map +1 -0
- package/dist-server/server/routes/agent-sdk.d.ts +3 -0
- package/dist-server/server/routes/agent-sdk.d.ts.map +1 -0
- package/dist-server/server/routes/agent-sdk.js +99 -0
- package/dist-server/server/routes/agent-sdk.js.map +1 -0
- package/dist-server/server/routes/agents.d.ts +10 -0
- package/dist-server/server/routes/agents.d.ts.map +1 -0
- package/dist-server/server/routes/agents.js +61 -0
- package/dist-server/server/routes/agents.js.map +1 -0
- package/dist-server/server/routes/auth-codex.d.ts +3 -0
- package/dist-server/server/routes/auth-codex.d.ts.map +1 -0
- package/dist-server/server/routes/auth-codex.js +51 -0
- package/dist-server/server/routes/auth-codex.js.map +1 -0
- package/dist-server/server/routes/capabilities.d.ts +3 -0
- package/dist-server/server/routes/capabilities.d.ts.map +1 -0
- package/dist-server/server/routes/capabilities.js +32 -0
- package/dist-server/server/routes/capabilities.js.map +1 -0
- package/dist-server/server/routes/claude-config.d.ts +3 -0
- package/dist-server/server/routes/claude-config.d.ts.map +1 -0
- package/dist-server/server/routes/claude-config.js +146 -0
- package/dist-server/server/routes/claude-config.js.map +1 -0
- package/dist-server/server/routes/connectors.d.ts +12 -0
- package/dist-server/server/routes/connectors.d.ts.map +1 -0
- package/dist-server/server/routes/connectors.js +325 -0
- package/dist-server/server/routes/connectors.js.map +1 -0
- package/dist-server/server/routes/embeddings.d.ts +6 -0
- package/dist-server/server/routes/embeddings.d.ts.map +1 -0
- package/dist-server/server/routes/embeddings.js +130 -0
- package/dist-server/server/routes/embeddings.js.map +1 -0
- package/dist-server/server/routes/health.d.ts +9 -0
- package/dist-server/server/routes/health.d.ts.map +1 -0
- package/dist-server/server/routes/health.js +284 -0
- package/dist-server/server/routes/health.js.map +1 -0
- package/dist-server/server/routes/knowledge.d.ts +3 -0
- package/dist-server/server/routes/knowledge.d.ts.map +1 -0
- package/dist-server/server/routes/knowledge.js +534 -0
- package/dist-server/server/routes/knowledge.js.map +1 -0
- package/dist-server/server/routes/llm.d.ts +3 -0
- package/dist-server/server/routes/llm.d.ts.map +1 -0
- package/dist-server/server/routes/llm.js +200 -0
- package/dist-server/server/routes/llm.js.map +1 -0
- package/dist-server/server/routes/mcp-oauth.d.ts +12 -0
- package/dist-server/server/routes/mcp-oauth.d.ts.map +1 -0
- package/dist-server/server/routes/mcp-oauth.js +137 -0
- package/dist-server/server/routes/mcp-oauth.js.map +1 -0
- package/dist-server/server/routes/mcp.d.ts +3 -0
- package/dist-server/server/routes/mcp.d.ts.map +1 -0
- package/dist-server/server/routes/mcp.js +177 -0
- package/dist-server/server/routes/mcp.js.map +1 -0
- package/dist-server/server/routes/pipeline.d.ts +45 -0
- package/dist-server/server/routes/pipeline.d.ts.map +1 -0
- package/dist-server/server/routes/pipeline.js +483 -0
- package/dist-server/server/routes/pipeline.js.map +1 -0
- package/dist-server/server/routes/providers.d.ts +3 -0
- package/dist-server/server/routes/providers.d.ts.map +1 -0
- package/dist-server/server/routes/providers.js +204 -0
- package/dist-server/server/routes/providers.js.map +1 -0
- package/dist-server/server/routes/qualification.d.ts +3 -0
- package/dist-server/server/routes/qualification.d.ts.map +1 -0
- package/dist-server/server/routes/qualification.js +105 -0
- package/dist-server/server/routes/qualification.js.map +1 -0
- package/dist-server/server/routes/repo-index.d.ts +4 -0
- package/dist-server/server/routes/repo-index.d.ts.map +1 -0
- package/dist-server/server/routes/repo-index.js +318 -0
- package/dist-server/server/routes/repo-index.js.map +1 -0
- package/dist-server/server/routes/runtime.d.ts +3 -0
- package/dist-server/server/routes/runtime.d.ts.map +1 -0
- package/dist-server/server/routes/runtime.js +122 -0
- package/dist-server/server/routes/runtime.js.map +1 -0
- package/dist-server/server/routes/skills-search.d.ts +3 -0
- package/dist-server/server/routes/skills-search.d.ts.map +1 -0
- package/dist-server/server/routes/skills-search.js +198 -0
- package/dist-server/server/routes/skills-search.js.map +1 -0
- package/dist-server/server/routes/worktrees.d.ts +3 -0
- package/dist-server/server/routes/worktrees.d.ts.map +1 -0
- package/dist-server/server/routes/worktrees.js +70 -0
- package/dist-server/server/routes/worktrees.js.map +1 -0
- package/dist-server/server/services/__tests__/embeddingService.test.d.ts +5 -0
- package/dist-server/server/services/__tests__/embeddingService.test.d.ts.map +1 -0
- package/dist-server/server/services/__tests__/embeddingService.test.js +233 -0
- package/dist-server/server/services/__tests__/embeddingService.test.js.map +1 -0
- package/dist-server/server/services/agentRunner.d.ts +46 -0
- package/dist-server/server/services/agentRunner.d.ts.map +1 -0
- package/dist-server/server/services/agentRunner.js +295 -0
- package/dist-server/server/services/agentRunner.js.map +1 -0
- package/dist-server/server/services/agentStore.d.ts +40 -0
- package/dist-server/server/services/agentStore.d.ts.map +1 -0
- package/dist-server/server/services/agentStore.js +62 -0
- package/dist-server/server/services/agentStore.js.map +1 -0
- package/dist-server/server/services/contentStore.d.ts +32 -0
- package/dist-server/server/services/contentStore.d.ts.map +1 -0
- package/dist-server/server/services/contentStore.js +68 -0
- package/dist-server/server/services/contentStore.js.map +1 -0
- package/dist-server/server/services/embeddingService.d.ts +53 -0
- package/dist-server/server/services/embeddingService.d.ts.map +1 -0
- package/dist-server/server/services/embeddingService.js +199 -0
- package/dist-server/server/services/embeddingService.js.map +1 -0
- package/dist-server/server/services/factExtractor.d.ts +14 -0
- package/dist-server/server/services/factExtractor.d.ts.map +1 -0
- package/dist-server/server/services/factExtractor.js +126 -0
- package/dist-server/server/services/factExtractor.js.map +1 -0
- package/dist-server/server/services/githubIndexer.d.ts +59 -0
- package/dist-server/server/services/githubIndexer.d.ts.map +1 -0
- package/dist-server/server/services/githubIndexer.js +183 -0
- package/dist-server/server/services/githubIndexer.js.map +1 -0
- package/dist-server/server/services/mcpOAuth.d.ts +32 -0
- package/dist-server/server/services/mcpOAuth.d.ts.map +1 -0
- package/dist-server/server/services/mcpOAuth.js +264 -0
- package/dist-server/server/services/mcpOAuth.js.map +1 -0
- package/dist-server/server/services/memoryScorer.d.ts +19 -0
- package/dist-server/server/services/memoryScorer.d.ts.map +1 -0
- package/dist-server/server/services/memoryScorer.js +147 -0
- package/dist-server/server/services/memoryScorer.js.map +1 -0
- package/dist-server/server/services/repoIndexer.d.ts +91 -0
- package/dist-server/server/services/repoIndexer.d.ts.map +1 -0
- package/dist-server/server/services/repoIndexer.js +512 -0
- package/dist-server/server/services/repoIndexer.js.map +1 -0
- package/dist-server/server/services/teamRunner.d.ts +39 -0
- package/dist-server/server/services/teamRunner.d.ts.map +1 -0
- package/dist-server/server/services/teamRunner.js +76 -0
- package/dist-server/server/services/teamRunner.js.map +1 -0
- package/dist-server/server/services/worktreeManager.d.ts +27 -0
- package/dist-server/server/services/worktreeManager.d.ts.map +1 -0
- package/dist-server/server/services/worktreeManager.js +107 -0
- package/dist-server/server/services/worktreeManager.js.map +1 -0
- package/dist-server/server/types.d.ts +30 -0
- package/dist-server/server/types.d.ts.map +1 -0
- package/dist-server/server/types.js +2 -0
- package/dist-server/server/types.js.map +1 -0
- package/dist-server/server/utils/pathSecurity.d.ts +34 -0
- package/dist-server/server/utils/pathSecurity.d.ts.map +1 -0
- package/dist-server/server/utils/pathSecurity.js +78 -0
- package/dist-server/server/utils/pathSecurity.js.map +1 -0
- package/dist-server/src/services/budgetAllocator.d.ts +37 -0
- package/dist-server/src/services/budgetAllocator.d.ts.map +1 -0
- package/dist-server/src/services/budgetAllocator.js +120 -0
- package/dist-server/src/services/budgetAllocator.js.map +1 -0
- package/dist-server/src/services/contradictionDetector.d.ts +18 -0
- package/dist-server/src/services/contradictionDetector.d.ts.map +1 -0
- package/dist-server/src/services/contradictionDetector.js +111 -0
- package/dist-server/src/services/contradictionDetector.js.map +1 -0
- package/dist-server/src/services/treeIndexer.d.ts +91 -0
- package/dist-server/src/services/treeIndexer.d.ts.map +1 -0
- package/dist-server/src/services/treeIndexer.js +289 -0
- package/dist-server/src/services/treeIndexer.js.map +1 -0
- package/dist-server/src/store/knowledgeBase.d.ts +130 -0
- package/dist-server/src/store/knowledgeBase.d.ts.map +1 -0
- package/dist-server/src/store/knowledgeBase.js +299 -0
- package/dist-server/src/store/knowledgeBase.js.map +1 -0
- package/dist-server/tsconfig.server.tsbuildinfo +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function a(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(i){if(i.ep)return;i.ep=!0;const l=a(i);fetch(i.href,l)}})();var c8=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ob(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rp={exports:{}},Gr={};var n0;function aS(){if(n0)return Gr;n0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(s,i,l){var d=null;if(l!==void 0&&(d=""+l),i.key!==void 0&&(d=""+i.key),"key"in i){l={};for(var p in i)p!=="key"&&(l[p]=i[p])}else l=i;return i=l.ref,{$$typeof:e,type:s,key:d,ref:i!==void 0?i:null,props:l}}return Gr.Fragment=n,Gr.jsx=a,Gr.jsxs=a,Gr}var o0;function sS(){return o0||(o0=1,Rp.exports=aS()),Rp.exports}var c=sS(),Op={exports:{}},je={};var a0;function rS(){if(a0)return je;a0=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),d=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function v(I){return I===null||typeof I!="object"?null:(I=b&&I[b]||I["@@iterator"],typeof I=="function"?I:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,j={};function T(I,L,Z){this.props=I,this.context=L,this.refs=j,this.updater=Z||k}T.prototype.isReactComponent={},T.prototype.setState=function(I,L){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,L,"setState")},T.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function E(){}E.prototype=T.prototype;function S(I,L,Z){this.props=I,this.context=L,this.refs=j,this.updater=Z||k}var M=S.prototype=new E;M.constructor=S,w(M,T.prototype),M.isPureReactComponent=!0;var $=Array.isArray;function A(){}var _={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function B(I,L,Z){var ae=Z.ref;return{$$typeof:e,type:I,key:L,ref:ae!==void 0?ae:null,props:Z}}function G(I,L){return B(I.type,L,I.props)}function O(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function K(I){var L={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(Z){return L[Z]})}var V=/\/+/g;function P(I,L){return typeof I=="object"&&I!==null&&I.key!=null?K(""+I.key):L.toString(36)}function N(I){switch(I.status){case"fulfilled":return I.value;case"rejected":throw I.reason;default:switch(typeof I.status=="string"?I.then(A,A):(I.status="pending",I.then(function(L){I.status==="pending"&&(I.status="fulfilled",I.value=L)},function(L){I.status==="pending"&&(I.status="rejected",I.reason=L)})),I.status){case"fulfilled":return I.value;case"rejected":throw I.reason}}throw I}function D(I,L,Z,ae,pe){var me=typeof I;(me==="undefined"||me==="boolean")&&(I=null);var he=!1;if(I===null)he=!0;else switch(me){case"bigint":case"string":case"number":he=!0;break;case"object":switch(I.$$typeof){case e:case n:he=!0;break;case g:return he=I._init,D(he(I._payload),L,Z,ae,pe)}}if(he)return pe=pe(I),he=ae===""?"."+P(I,0):ae,$(pe)?(Z="",he!=null&&(Z=he.replace(V,"$&/")+"/"),D(pe,L,Z,"",function(Q){return Q})):pe!=null&&(O(pe)&&(pe=G(pe,Z+(pe.key==null||I&&I.key===pe.key?"":(""+pe.key).replace(V,"$&/")+"/")+he)),L.push(pe)),1;he=0;var H=ae===""?".":ae+":";if($(I))for(var ce=0;ce<I.length;ce++)ae=I[ce],me=H+P(ae,ce),he+=D(ae,L,Z,me,pe);else if(ce=v(I),typeof ce=="function")for(I=ce.call(I),ce=0;!(ae=I.next()).done;)ae=ae.value,me=H+P(ae,ce++),he+=D(ae,L,Z,me,pe);else if(me==="object"){if(typeof I.then=="function")return D(N(I),L,Z,ae,pe);throw L=String(I),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.")}return he}function U(I,L,Z){if(I==null)return I;var ae=[],pe=0;return D(I,ae,"","",function(me){return L.call(Z,me,pe++)}),ae}function q(I){if(I._status===-1){var L=I._result;L=L(),L.then(function(Z){(I._status===0||I._status===-1)&&(I._status=1,I._result=Z)},function(Z){(I._status===0||I._status===-1)&&(I._status=2,I._result=Z)}),I._status===-1&&(I._status=0,I._result=L)}if(I._status===1)return I._result.default;throw I._result}var W=typeof reportError=="function"?reportError:function(I){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var L=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof I=="object"&&I!==null&&typeof I.message=="string"?String(I.message):String(I),error:I});if(!window.dispatchEvent(L))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",I);return}console.error(I)},oe={map:U,forEach:function(I,L,Z){U(I,function(){L.apply(this,arguments)},Z)},count:function(I){var L=0;return U(I,function(){L++}),L},toArray:function(I){return U(I,function(L){return L})||[]},only:function(I){if(!O(I))throw Error("React.Children.only expected to receive a single React element child.");return I}};return je.Activity=x,je.Children=oe,je.Component=T,je.Fragment=a,je.Profiler=i,je.PureComponent=S,je.StrictMode=s,je.Suspense=f,je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,je.__COMPILER_RUNTIME={__proto__:null,c:function(I){return _.H.useMemoCache(I)}},je.cache=function(I){return function(){return I.apply(null,arguments)}},je.cacheSignal=function(){return null},je.cloneElement=function(I,L,Z){if(I==null)throw Error("The argument must be a React element, but you passed "+I+".");var ae=w({},I.props),pe=I.key;if(L!=null)for(me in L.key!==void 0&&(pe=""+L.key),L)!F.call(L,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&L.ref===void 0||(ae[me]=L[me]);var me=arguments.length-2;if(me===1)ae.children=Z;else if(1<me){for(var he=Array(me),H=0;H<me;H++)he[H]=arguments[H+2];ae.children=he}return B(I.type,pe,ae)},je.createContext=function(I){return I={$$typeof:d,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null},I.Provider=I,I.Consumer={$$typeof:l,_context:I},I},je.createElement=function(I,L,Z){var ae,pe={},me=null;if(L!=null)for(ae in L.key!==void 0&&(me=""+L.key),L)F.call(L,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(pe[ae]=L[ae]);var he=arguments.length-2;if(he===1)pe.children=Z;else if(1<he){for(var H=Array(he),ce=0;ce<he;ce++)H[ce]=arguments[ce+2];pe.children=H}if(I&&I.defaultProps)for(ae in he=I.defaultProps,he)pe[ae]===void 0&&(pe[ae]=he[ae]);return B(I,me,pe)},je.createRef=function(){return{current:null}},je.forwardRef=function(I){return{$$typeof:p,render:I}},je.isValidElement=O,je.lazy=function(I){return{$$typeof:g,_payload:{_status:-1,_result:I},_init:q}},je.memo=function(I,L){return{$$typeof:h,type:I,compare:L===void 0?null:L}},je.startTransition=function(I){var L=_.T,Z={};_.T=Z;try{var ae=I(),pe=_.S;pe!==null&&pe(Z,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(A,W)}catch(me){W(me)}finally{L!==null&&Z.types!==null&&(L.types=Z.types),_.T=L}},je.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},je.use=function(I){return _.H.use(I)},je.useActionState=function(I,L,Z){return _.H.useActionState(I,L,Z)},je.useCallback=function(I,L){return _.H.useCallback(I,L)},je.useContext=function(I){return _.H.useContext(I)},je.useDebugValue=function(){},je.useDeferredValue=function(I,L){return _.H.useDeferredValue(I,L)},je.useEffect=function(I,L){return _.H.useEffect(I,L)},je.useEffectEvent=function(I){return _.H.useEffectEvent(I)},je.useId=function(){return _.H.useId()},je.useImperativeHandle=function(I,L,Z){return _.H.useImperativeHandle(I,L,Z)},je.useInsertionEffect=function(I,L){return _.H.useInsertionEffect(I,L)},je.useLayoutEffect=function(I,L){return _.H.useLayoutEffect(I,L)},je.useMemo=function(I,L){return _.H.useMemo(I,L)},je.useOptimistic=function(I,L){return _.H.useOptimistic(I,L)},je.useReducer=function(I,L,Z){return _.H.useReducer(I,L,Z)},je.useRef=function(I){return _.H.useRef(I)},je.useState=function(I){return _.H.useState(I)},je.useSyncExternalStore=function(I,L,Z){return _.H.useSyncExternalStore(I,L,Z)},je.useTransition=function(){return _.H.useTransition()},je.version="19.2.4",je}var s0;function Mi(){return s0||(s0=1,Op.exports=rS()),Op.exports}var z=Mi();const Qr=ob(z);var $p={exports:{}},qr={},Fp={exports:{}},Ip={};var r0;function iS(){return r0||(r0=1,(function(e){function n(D,U){var q=D.length;D.push(U);e:for(;0<q;){var W=q-1>>>1,oe=D[W];if(0<i(oe,U))D[W]=U,D[q]=oe,q=W;else break e}}function a(D){return D.length===0?null:D[0]}function s(D){if(D.length===0)return null;var U=D[0],q=D.pop();if(q!==U){D[0]=q;e:for(var W=0,oe=D.length,I=oe>>>1;W<I;){var L=2*(W+1)-1,Z=D[L],ae=L+1,pe=D[ae];if(0>i(Z,q))ae<oe&&0>i(pe,Z)?(D[W]=pe,D[ae]=q,W=ae):(D[W]=Z,D[L]=q,W=L);else if(ae<oe&&0>i(pe,q))D[W]=pe,D[ae]=q,W=ae;else break e}}return U}function i(D,U){var q=D.sortIndex-U.sortIndex;return q!==0?q:D.id-U.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var d=Date,p=d.now();e.unstable_now=function(){return d.now()-p}}var f=[],h=[],g=1,x=null,b=3,v=!1,k=!1,w=!1,j=!1,T=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function M(D){for(var U=a(h);U!==null;){if(U.callback===null)s(h);else if(U.startTime<=D)s(h),U.sortIndex=U.expirationTime,n(f,U);else break;U=a(h)}}function $(D){if(w=!1,M(D),!k)if(a(f)!==null)k=!0,A||(A=!0,K());else{var U=a(h);U!==null&&N($,U.startTime-D)}}var A=!1,_=-1,F=5,B=-1;function G(){return j?!0:!(e.unstable_now()-B<F)}function O(){if(j=!1,A){var D=e.unstable_now();B=D;var U=!0;try{e:{k=!1,w&&(w=!1,E(_),_=-1),v=!0;var q=b;try{t:{for(M(D),x=a(f);x!==null&&!(x.expirationTime>D&&G());){var W=x.callback;if(typeof W=="function"){x.callback=null,b=x.priorityLevel;var oe=W(x.expirationTime<=D);if(D=e.unstable_now(),typeof oe=="function"){x.callback=oe,M(D),U=!0;break t}x===a(f)&&s(f),M(D)}else s(f);x=a(f)}if(x!==null)U=!0;else{var I=a(h);I!==null&&N($,I.startTime-D),U=!1}}break e}finally{x=null,b=q,v=!1}U=void 0}}finally{U?K():A=!1}}}var K;if(typeof S=="function")K=function(){S(O)};else if(typeof MessageChannel<"u"){var V=new MessageChannel,P=V.port2;V.port1.onmessage=O,K=function(){P.postMessage(null)}}else K=function(){T(O,0)};function N(D,U){_=T(function(){D(e.unstable_now())},U)}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(D){D.callback=null},e.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<D?Math.floor(1e3/D):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(D){switch(b){case 1:case 2:case 3:var U=3;break;default:U=b}var q=b;b=U;try{return D()}finally{b=q}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function(D,U){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var q=b;b=D;try{return U()}finally{b=q}},e.unstable_scheduleCallback=function(D,U,q){var W=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?W+q:W):q=W,D){case 1:var oe=-1;break;case 2:oe=250;break;case 5:oe=1073741823;break;case 4:oe=1e4;break;default:oe=5e3}return oe=q+oe,D={id:g++,callback:U,priorityLevel:D,startTime:q,expirationTime:oe,sortIndex:-1},q>W?(D.sortIndex=q,n(h,D),a(f)===null&&D===a(h)&&(w?(E(_),_=-1):w=!0,N($,q-W))):(D.sortIndex=oe,n(f,D),k||v||(k=!0,A||(A=!0,K()))),D},e.unstable_shouldYield=G,e.unstable_wrapCallback=function(D){var U=b;return function(){var q=b;b=U;try{return D.apply(this,arguments)}finally{b=q}}}})(Ip)),Ip}var i0;function lS(){return i0||(i0=1,Fp.exports=iS()),Fp.exports}var Lp={exports:{}},_t={};var l0;function cS(){if(l0)return _t;l0=1;var e=Mi();function n(f){var h="https://react.dev/errors/"+f;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+f+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var s={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},i=Symbol.for("react.portal");function l(f,h,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:x==null?null:""+x,children:f,containerInfo:h,implementation:g}}var d=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(f,h){if(f==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return _t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,_t.createPortal=function(f,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(n(299));return l(f,h,null,g)},_t.flushSync=function(f){var h=d.T,g=s.p;try{if(d.T=null,s.p=2,f)return f()}finally{d.T=h,s.p=g,s.d.f()}},_t.preconnect=function(f,h){typeof f=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,s.d.C(f,h))},_t.prefetchDNS=function(f){typeof f=="string"&&s.d.D(f)},_t.preinit=function(f,h){if(typeof f=="string"&&h&&typeof h.as=="string"){var g=h.as,x=p(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,v=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?s.d.S(f,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:x,integrity:b,fetchPriority:v}):g==="script"&&s.d.X(f,{crossOrigin:x,integrity:b,fetchPriority:v,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},_t.preinitModule=function(f,h){if(typeof f=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=p(h.as,h.crossOrigin);s.d.M(f,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&s.d.M(f)},_t.preload=function(f,h){if(typeof f=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,x=p(g,h.crossOrigin);s.d.L(f,g,{crossOrigin:x,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},_t.preloadModule=function(f,h){if(typeof f=="string")if(h){var g=p(h.as,h.crossOrigin);s.d.m(f,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else s.d.m(f)},_t.requestFormReset=function(f){s.d.r(f)},_t.unstable_batchedUpdates=function(f,h){return f(h)},_t.useFormState=function(f,h,g){return d.H.useFormState(f,h,g)},_t.useFormStatus=function(){return d.H.useHostTransitionStatus()},_t.version="19.2.4",_t}var c0;function ab(){if(c0)return Lp.exports;c0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Lp.exports=cS(),Lp.exports}var u0;function uS(){if(u0)return qr;u0=1;var e=lS(),n=Mi(),a=ab();function s(t){var o="https://react.dev/errors/"+t;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)o+="&args[]="+encodeURIComponent(arguments[r])}return"Minified React error #"+t+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function l(t){var o=t,r=t;if(t.alternate)for(;o.return;)o=o.return;else{t=o;do o=t,(o.flags&4098)!==0&&(r=o.return),t=o.return;while(t)}return o.tag===3?r:null}function d(t){if(t.tag===13){var o=t.memoizedState;if(o===null&&(t=t.alternate,t!==null&&(o=t.memoizedState)),o!==null)return o.dehydrated}return null}function p(t){if(t.tag===31){var o=t.memoizedState;if(o===null&&(t=t.alternate,t!==null&&(o=t.memoizedState)),o!==null)return o.dehydrated}return null}function f(t){if(l(t)!==t)throw Error(s(188))}function h(t){var o=t.alternate;if(!o){if(o=l(t),o===null)throw Error(s(188));return o!==t?null:t}for(var r=t,u=o;;){var m=r.return;if(m===null)break;var y=m.alternate;if(y===null){if(u=m.return,u!==null){r=u;continue}break}if(m.child===y.child){for(y=m.child;y;){if(y===r)return f(m),t;if(y===u)return f(m),o;y=y.sibling}throw Error(s(188))}if(r.return!==u.return)r=m,u=y;else{for(var C=!1,R=m.child;R;){if(R===r){C=!0,r=m,u=y;break}if(R===u){C=!0,u=m,r=y;break}R=R.sibling}if(!C){for(R=y.child;R;){if(R===r){C=!0,r=y,u=m;break}if(R===u){C=!0,u=y,r=m;break}R=R.sibling}if(!C)throw Error(s(189))}}if(r.alternate!==u)throw Error(s(190))}if(r.tag!==3)throw Error(s(188));return r.stateNode.current===r?t:o}function g(t){var o=t.tag;if(o===5||o===26||o===27||o===6)return t;for(t=t.child;t!==null;){if(o=g(t),o!==null)return o;t=t.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),T=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),S=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),B=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),O=Symbol.iterator;function K(t){return t===null||typeof t!="object"?null:(t=O&&t[O]||t["@@iterator"],typeof t=="function"?t:null)}var V=Symbol.for("react.client.reference");function P(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===V?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case w:return"Fragment";case T:return"Profiler";case j:return"StrictMode";case $:return"Suspense";case A:return"SuspenseList";case B:return"Activity"}if(typeof t=="object")switch(t.$$typeof){case k:return"Portal";case S:return t.displayName||"Context";case E:return(t._context.displayName||"Context")+".Consumer";case M:var o=t.render;return t=t.displayName,t||(t=o.displayName||o.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case _:return o=t.displayName||null,o!==null?o:P(t.type)||"Memo";case F:o=t._payload,t=t._init;try{return P(t(o))}catch{}}return null}var N=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q={pending:!1,data:null,method:null,action:null},W=[],oe=-1;function I(t){return{current:t}}function L(t){0>oe||(t.current=W[oe],W[oe]=null,oe--)}function Z(t,o){oe++,W[oe]=t.current,t.current=o}var ae=I(null),pe=I(null),me=I(null),he=I(null);function H(t,o){switch(Z(me,o),Z(pe,t),Z(ae,null),o.nodeType){case 9:case 11:t=(t=o.documentElement)&&(t=t.namespaceURI)?Cy(t):0;break;default:if(t=o.tagName,o=o.namespaceURI)o=Cy(o),t=Ey(o,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}L(ae),Z(ae,t)}function ce(){L(ae),L(pe),L(me)}function Q(t){t.memoizedState!==null&&Z(he,t);var o=ae.current,r=Ey(o,t.type);o!==r&&(Z(pe,t),Z(ae,r))}function ge(t){pe.current===t&&(L(ae),L(pe)),he.current===t&&(L(he),Br._currentValue=q)}var xe,J;function ye(t){if(xe===void 0)try{throw Error()}catch(r){var o=r.stack.trim().match(/\n( *(at )?)/);xe=o&&o[1]||"",J=-1<r.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+xe+t+J}var Ee=!1;function Ie(t,o){if(!t||Ee)return"";Ee=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(o){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(ie){var se=ie}Reflect.construct(t,[],de)}else{try{de.call()}catch(ie){se=ie}t.call(de.prototype)}}else{try{throw Error()}catch(ie){se=ie}(de=t())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(ie){if(ie&&se&&typeof ie.stack=="string")return[ie.stack,se.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var y=u.DetermineComponentFrameRoot(),C=y[0],R=y[1];if(C&&R){var Y=C.split(`
|
|
4
|
+
`),ne=R.split(`
|
|
5
|
+
`);for(m=u=0;u<Y.length&&!Y[u].includes("DetermineComponentFrameRoot");)u++;for(;m<ne.length&&!ne[m].includes("DetermineComponentFrameRoot");)m++;if(u===Y.length||m===ne.length)for(u=Y.length-1,m=ne.length-1;1<=u&&0<=m&&Y[u]!==ne[m];)m--;for(;1<=u&&0<=m;u--,m--)if(Y[u]!==ne[m]){if(u!==1||m!==1)do if(u--,m--,0>m||Y[u]!==ne[m]){var le=`
|
|
6
|
+
`+Y[u].replace(" at new "," at ");return t.displayName&&le.includes("<anonymous>")&&(le=le.replace("<anonymous>",t.displayName)),le}while(1<=u&&0<=m);break}}}finally{Ee=!1,Error.prepareStackTrace=r}return(r=t?t.displayName||t.name:"")?ye(r):""}function ze(t,o){switch(t.tag){case 26:case 27:case 5:return ye(t.type);case 16:return ye("Lazy");case 13:return t.child!==o&&o!==null?ye("Suspense Fallback"):ye("Suspense");case 19:return ye("SuspenseList");case 0:case 15:return Ie(t.type,!1);case 11:return Ie(t.type.render,!1);case 1:return Ie(t.type,!0);case 31:return ye("Activity");default:return""}}function Nt(t){try{var o="",r=null;do o+=ze(t,r),r=t,t=t.return;while(t);return o}catch(u){return`
|
|
7
|
+
Error generating stack: `+u.message+`
|
|
8
|
+
`+u.stack}}var mt=Object.prototype.hasOwnProperty,vt=e.unstable_scheduleCallback,mn=e.unstable_cancelCallback,tn=e.unstable_shouldYield,hn=e.unstable_requestPaint,kt=e.unstable_now,Ha=e.unstable_getCurrentPriorityLevel,Pn=e.unstable_ImmediatePriority,yo=e.unstable_UserBlockingPriority,oa=e.unstable_NormalPriority,yu=e.unstable_LowPriority,Ua=e.unstable_IdlePriority,xu=e.log,bu=e.unstable_setDisableYieldValue,aa=null,Dt=null;function En(t){if(typeof xu=="function"&&bu(t),Dt&&typeof Dt.setStrictMode=="function")try{Dt.setStrictMode(aa,t)}catch{}}var zt=Math.clz32?Math.clz32:wu,vu=Math.log,ku=Math.LN2;function wu(t){return t>>>=0,t===0?32:31-(vu(t)/ku|0)|0}var Ga=256,qa=262144,Ka=4194304;function Hn(t){var o=t&42;if(o!==0)return o;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Ya(t,o,r){var u=t.pendingLanes;if(u===0)return 0;var m=0,y=t.suspendedLanes,C=t.pingedLanes;t=t.warmLanes;var R=u&134217727;return R!==0?(u=R&~y,u!==0?m=Hn(u):(C&=R,C!==0?m=Hn(C):r||(r=R&~t,r!==0&&(m=Hn(r))))):(R=u&~y,R!==0?m=Hn(R):C!==0?m=Hn(C):r||(r=u&~t,r!==0&&(m=Hn(r)))),m===0?0:o!==0&&o!==m&&(o&y)===0&&(y=m&-m,r=o&-o,y>=r||y===32&&(r&4194048)!==0)?o:m}function sa(t,o){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&o)===0}function Su(t,o){switch(t){case 1:case 2:case 4:case 8:case 64:return o+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $i(){var t=Ka;return Ka<<=1,(Ka&62914560)===0&&(Ka=4194304),t}function Zs(t){for(var o=[],r=0;31>r;r++)o.push(t);return o}function ra(t,o){t.pendingLanes|=o,o!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Mu(t,o,r,u,m,y){var C=t.pendingLanes;t.pendingLanes=r,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=r,t.entangledLanes&=r,t.errorRecoveryDisabledLanes&=r,t.shellSuspendCounter=0;var R=t.entanglements,Y=t.expirationTimes,ne=t.hiddenUpdates;for(r=C&~r;0<r;){var le=31-zt(r),de=1<<le;R[le]=0,Y[le]=-1;var se=ne[le];if(se!==null)for(ne[le]=null,le=0;le<se.length;le++){var ie=se[le];ie!==null&&(ie.lane&=-536870913)}r&=~de}u!==0&&Fi(t,u,0),y!==0&&m===0&&t.tag!==0&&(t.suspendedLanes|=y&~(C&~o))}function Fi(t,o,r){t.pendingLanes|=o,t.suspendedLanes&=~o;var u=31-zt(o);t.entangledLanes|=o,t.entanglements[u]=t.entanglements[u]|1073741824|r&261930}function Ii(t,o){var r=t.entangledLanes|=o;for(t=t.entanglements;r;){var u=31-zt(r),m=1<<u;m&o|t[u]&o&&(t[u]|=o),r&=~m}}function Li(t,o){var r=o&-o;return r=(r&42)!==0?1:Qs(r),(r&(t.suspendedLanes|o))!==0?0:r}function Qs(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Js(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Bi(){var t=U.p;return t!==0?t:(t=window.event,t===void 0?32:Wy(t.type))}function Pi(t,o){var r=U.p;try{return U.p=t,o()}finally{U.p=r}}var jn=Math.random().toString(36).slice(2),ht="__reactFiber$"+jn,At="__reactProps$"+jn,Un="__reactContainer$"+jn,Va="__reactEvents$"+jn,Hi="__reactListeners$"+jn,Cu="__reactHandles$"+jn,Ui="__reactResources$"+jn,ia="__reactMarker$"+jn;function er(t){delete t[ht],delete t[At],delete t[Va],delete t[Hi],delete t[Cu]}function xo(t){var o=t[ht];if(o)return o;for(var r=t.parentNode;r;){if(o=r[Un]||r[ht]){if(r=o.alternate,o.child!==null||r!==null&&r.child!==null)for(t=zy(t);t!==null;){if(r=t[ht])return r;t=zy(t)}return o}t=r,r=t.parentNode}return null}function bo(t){if(t=t[ht]||t[Un]){var o=t.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return t}return null}function vo(t){var o=t.tag;if(o===5||o===26||o===27||o===6)return t.stateNode;throw Error(s(33))}function ko(t){var o=t[Ui];return o||(o=t[Ui]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function it(t){t[ia]=!0}var Gi=new Set,qi={};function Gn(t,o){wo(t,o),wo(t+"Capture",o)}function wo(t,o){for(qi[t]=o,t=0;t<o.length;t++)Gi.add(o[t])}var Eu=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),tr={},Ki={};function ju(t){return mt.call(Ki,t)?!0:mt.call(tr,t)?!1:Eu.test(t)?Ki[t]=!0:(tr[t]=!0,!1)}function Wa(t,o,r){if(ju(o))if(r===null)t.removeAttribute(o);else{switch(typeof r){case"undefined":case"function":case"symbol":t.removeAttribute(o);return;case"boolean":var u=o.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){t.removeAttribute(o);return}}t.setAttribute(o,""+r)}}function Xa(t,o,r){if(r===null)t.removeAttribute(o);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(o);return}t.setAttribute(o,""+r)}}function gn(t,o,r,u){if(u===null)t.removeAttribute(r);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(r);return}t.setAttributeNS(o,r,""+u)}}function Ot(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Yi(t){var o=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function Tu(t,o,r){var u=Object.getOwnPropertyDescriptor(t.constructor.prototype,o);if(!t.hasOwnProperty(o)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var m=u.get,y=u.set;return Object.defineProperty(t,o,{configurable:!0,get:function(){return m.call(this)},set:function(C){r=""+C,y.call(this,C)}}),Object.defineProperty(t,o,{enumerable:u.enumerable}),{getValue:function(){return r},setValue:function(C){r=""+C},stopTracking:function(){t._valueTracker=null,delete t[o]}}}}function Za(t){if(!t._valueTracker){var o=Yi(t)?"checked":"value";t._valueTracker=Tu(t,o,""+t[o])}}function Vi(t){if(!t)return!1;var o=t._valueTracker;if(!o)return!0;var r=o.getValue(),u="";return t&&(u=Yi(t)?t.checked?"true":"false":t.value),t=u,t!==r?(o.setValue(t),!0):!1}function la(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Nu=/[\n"\\]/g;function $t(t){return t.replace(Nu,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function ca(t,o,r,u,m,y,C,R){t.name="",C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?t.type=C:t.removeAttribute("type"),o!=null?C==="number"?(o===0&&t.value===""||t.value!=o)&&(t.value=""+Ot(o)):t.value!==""+Ot(o)&&(t.value=""+Ot(o)):C!=="submit"&&C!=="reset"||t.removeAttribute("value"),o!=null?nr(t,C,Ot(o)):r!=null?nr(t,C,Ot(r)):u!=null&&t.removeAttribute("value"),m==null&&y!=null&&(t.defaultChecked=!!y),m!=null&&(t.checked=m&&typeof m!="function"&&typeof m!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?t.name=""+Ot(R):t.removeAttribute("name")}function Wi(t,o,r,u,m,y,C,R){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(t.type=y),o!=null||r!=null){if(!(y!=="submit"&&y!=="reset"||o!=null)){Za(t);return}r=r!=null?""+Ot(r):"",o=o!=null?""+Ot(o):r,R||o===t.value||(t.value=o),t.defaultValue=o}u=u??m,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=R?t.checked:!!u,t.defaultChecked=!!u,C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(t.name=C),Za(t)}function nr(t,o,r){o==="number"&&la(t.ownerDocument)===t||t.defaultValue===""+r||(t.defaultValue=""+r)}function qn(t,o,r,u){if(t=t.options,o){o={};for(var m=0;m<r.length;m++)o["$"+r[m]]=!0;for(r=0;r<t.length;r++)m=o.hasOwnProperty("$"+t[r].value),t[r].selected!==m&&(t[r].selected=m),m&&u&&(t[r].defaultSelected=!0)}else{for(r=""+Ot(r),o=null,m=0;m<t.length;m++){if(t[m].value===r){t[m].selected=!0,u&&(t[m].defaultSelected=!0);return}o!==null||t[m].disabled||(o=t[m])}o!==null&&(o.selected=!0)}}function vm(t,o,r){if(o!=null&&(o=""+Ot(o),o!==t.value&&(t.value=o),r==null)){t.defaultValue!==o&&(t.defaultValue=o);return}t.defaultValue=r!=null?""+Ot(r):""}function km(t,o,r,u){if(o==null){if(u!=null){if(r!=null)throw Error(s(92));if(N(u)){if(1<u.length)throw Error(s(93));u=u[0]}r=u}r==null&&(r=""),o=r}r=Ot(o),t.defaultValue=r,u=t.textContent,u===r&&u!==""&&u!==null&&(t.value=u),Za(t)}function Qa(t,o){if(o){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=o;return}}t.textContent=o}var Jv=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function wm(t,o,r){var u=o.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?u?t.setProperty(o,""):o==="float"?t.cssFloat="":t[o]="":u?t.setProperty(o,r):typeof r!="number"||r===0||Jv.has(o)?o==="float"?t.cssFloat=r:t[o]=(""+r).trim():t[o]=r+"px"}function Sm(t,o,r){if(o!=null&&typeof o!="object")throw Error(s(62));if(t=t.style,r!=null){for(var u in r)!r.hasOwnProperty(u)||o!=null&&o.hasOwnProperty(u)||(u.indexOf("--")===0?t.setProperty(u,""):u==="float"?t.cssFloat="":t[u]="");for(var m in o)u=o[m],o.hasOwnProperty(m)&&r[m]!==u&&wm(t,m,u)}else for(var y in o)o.hasOwnProperty(y)&&wm(t,y,o[y])}function Au(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ek=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),tk=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Xi(t){return tk.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function Kn(){}var _u=null;function Du(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Ja=null,es=null;function Mm(t){var o=bo(t);if(o&&(t=o.stateNode)){var r=t[At]||null;e:switch(t=o.stateNode,o.type){case"input":if(ca(t,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),o=r.name,r.type==="radio"&&o!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+$t(""+o)+'"][type="radio"]'),o=0;o<r.length;o++){var u=r[o];if(u!==t&&u.form===t.form){var m=u[At]||null;if(!m)throw Error(s(90));ca(u,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(o=0;o<r.length;o++)u=r[o],u.form===t.form&&Vi(u)}break e;case"textarea":vm(t,r.value,r.defaultValue);break e;case"select":o=r.value,o!=null&&qn(t,!!r.multiple,o,!1)}}}var zu=!1;function Cm(t,o,r){if(zu)return t(o,r);zu=!0;try{var u=t(o);return u}finally{if(zu=!1,(Ja!==null||es!==null)&&(Fl(),Ja&&(o=Ja,t=es,es=Ja=null,Mm(o),t)))for(o=0;o<t.length;o++)Mm(t[o])}}function or(t,o){var r=t.stateNode;if(r===null)return null;var u=r[At]||null;if(u===null)return null;r=u[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(t=t.type,u=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!u;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(s(231,o,typeof r));return r}var Yn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ru=!1;if(Yn)try{var ar={};Object.defineProperty(ar,"passive",{get:function(){Ru=!0}}),window.addEventListener("test",ar,ar),window.removeEventListener("test",ar,ar)}catch{Ru=!1}var So=null,Ou=null,Zi=null;function Em(){if(Zi)return Zi;var t,o=Ou,r=o.length,u,m="value"in So?So.value:So.textContent,y=m.length;for(t=0;t<r&&o[t]===m[t];t++);var C=r-t;for(u=1;u<=C&&o[r-u]===m[y-u];u++);return Zi=m.slice(t,1<u?1-u:void 0)}function Qi(t){var o=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&o===13&&(t=13)):t=o,t===10&&(t=13),32<=t||t===13?t:0}function Ji(){return!0}function jm(){return!1}function Ft(t){function o(r,u,m,y,C){this._reactName=r,this._targetInst=m,this.type=u,this.nativeEvent=y,this.target=C,this.currentTarget=null;for(var R in t)t.hasOwnProperty(R)&&(r=t[R],this[R]=r?r(y):y[R]);return this.isDefaultPrevented=(y.defaultPrevented!=null?y.defaultPrevented:y.returnValue===!1)?Ji:jm,this.isPropagationStopped=jm,this}return x(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Ji)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Ji)},persist:function(){},isPersistent:Ji}),o}var ua={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},el=Ft(ua),sr=x({},ua,{view:0,detail:0}),nk=Ft(sr),$u,Fu,rr,tl=x({},sr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Lu,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==rr&&(rr&&t.type==="mousemove"?($u=t.screenX-rr.screenX,Fu=t.screenY-rr.screenY):Fu=$u=0,rr=t),$u)},movementY:function(t){return"movementY"in t?t.movementY:Fu}}),Tm=Ft(tl),ok=x({},tl,{dataTransfer:0}),ak=Ft(ok),sk=x({},sr,{relatedTarget:0}),Iu=Ft(sk),rk=x({},ua,{animationName:0,elapsedTime:0,pseudoElement:0}),ik=Ft(rk),lk=x({},ua,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),ck=Ft(lk),uk=x({},ua,{data:0}),Nm=Ft(uk),dk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},pk={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},fk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mk(t){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(t):(t=fk[t])?!!o[t]:!1}function Lu(){return mk}var hk=x({},sr,{key:function(t){if(t.key){var o=dk[t.key]||t.key;if(o!=="Unidentified")return o}return t.type==="keypress"?(t=Qi(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?pk[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Lu,charCode:function(t){return t.type==="keypress"?Qi(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Qi(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),gk=Ft(hk),yk=x({},tl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Am=Ft(yk),xk=x({},sr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Lu}),bk=Ft(xk),vk=x({},ua,{propertyName:0,elapsedTime:0,pseudoElement:0}),kk=Ft(vk),wk=x({},tl,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),Sk=Ft(wk),Mk=x({},ua,{newState:0,oldState:0}),Ck=Ft(Mk),Ek=[9,13,27,32],Bu=Yn&&"CompositionEvent"in window,ir=null;Yn&&"documentMode"in document&&(ir=document.documentMode);var jk=Yn&&"TextEvent"in window&&!ir,_m=Yn&&(!Bu||ir&&8<ir&&11>=ir),Dm=" ",zm=!1;function Rm(t,o){switch(t){case"keyup":return Ek.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Om(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ts=!1;function Tk(t,o){switch(t){case"compositionend":return Om(o);case"keypress":return o.which!==32?null:(zm=!0,Dm);case"textInput":return t=o.data,t===Dm&&zm?null:t;default:return null}}function Nk(t,o){if(ts)return t==="compositionend"||!Bu&&Rm(t,o)?(t=Em(),Zi=Ou=So=null,ts=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return _m&&o.locale!=="ko"?null:o.data;default:return null}}var Ak={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function $m(t){var o=t&&t.nodeName&&t.nodeName.toLowerCase();return o==="input"?!!Ak[t.type]:o==="textarea"}function Fm(t,o,r,u){Ja?es?es.push(u):es=[u]:Ja=u,o=Gl(o,"onChange"),0<o.length&&(r=new el("onChange","change",null,r,u),t.push({event:r,listeners:o}))}var lr=null,cr=null;function _k(t){by(t,0)}function nl(t){var o=vo(t);if(Vi(o))return t}function Im(t,o){if(t==="change")return o}var Lm=!1;if(Yn){var Pu;if(Yn){var Hu="oninput"in document;if(!Hu){var Bm=document.createElement("div");Bm.setAttribute("oninput","return;"),Hu=typeof Bm.oninput=="function"}Pu=Hu}else Pu=!1;Lm=Pu&&(!document.documentMode||9<document.documentMode)}function Pm(){lr&&(lr.detachEvent("onpropertychange",Hm),cr=lr=null)}function Hm(t){if(t.propertyName==="value"&&nl(cr)){var o=[];Fm(o,cr,t,Du(t)),Cm(_k,o)}}function Dk(t,o,r){t==="focusin"?(Pm(),lr=o,cr=r,lr.attachEvent("onpropertychange",Hm)):t==="focusout"&&Pm()}function zk(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return nl(cr)}function Rk(t,o){if(t==="click")return nl(o)}function Ok(t,o){if(t==="input"||t==="change")return nl(o)}function $k(t,o){return t===o&&(t!==0||1/t===1/o)||t!==t&&o!==o}var Kt=typeof Object.is=="function"?Object.is:$k;function ur(t,o){if(Kt(t,o))return!0;if(typeof t!="object"||t===null||typeof o!="object"||o===null)return!1;var r=Object.keys(t),u=Object.keys(o);if(r.length!==u.length)return!1;for(u=0;u<r.length;u++){var m=r[u];if(!mt.call(o,m)||!Kt(t[m],o[m]))return!1}return!0}function Um(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Gm(t,o){var r=Um(t);t=0;for(var u;r;){if(r.nodeType===3){if(u=t+r.textContent.length,t<=o&&u>=o)return{node:r,offset:o-t};t=u}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Um(r)}}function qm(t,o){return t&&o?t===o?!0:t&&t.nodeType===3?!1:o&&o.nodeType===3?qm(t,o.parentNode):"contains"in t?t.contains(o):t.compareDocumentPosition?!!(t.compareDocumentPosition(o)&16):!1:!1}function Km(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var o=la(t.document);o instanceof t.HTMLIFrameElement;){try{var r=typeof o.contentWindow.location.href=="string"}catch{r=!1}if(r)t=o.contentWindow;else break;o=la(t.document)}return o}function Uu(t){var o=t&&t.nodeName&&t.nodeName.toLowerCase();return o&&(o==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||o==="textarea"||t.contentEditable==="true")}var Fk=Yn&&"documentMode"in document&&11>=document.documentMode,ns=null,Gu=null,dr=null,qu=!1;function Ym(t,o,r){var u=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;qu||ns==null||ns!==la(u)||(u=ns,"selectionStart"in u&&Uu(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),dr&&ur(dr,u)||(dr=u,u=Gl(Gu,"onSelect"),0<u.length&&(o=new el("onSelect","select",null,o,r),t.push({event:o,listeners:u}),o.target=ns)))}function da(t,o){var r={};return r[t.toLowerCase()]=o.toLowerCase(),r["Webkit"+t]="webkit"+o,r["Moz"+t]="moz"+o,r}var os={animationend:da("Animation","AnimationEnd"),animationiteration:da("Animation","AnimationIteration"),animationstart:da("Animation","AnimationStart"),transitionrun:da("Transition","TransitionRun"),transitionstart:da("Transition","TransitionStart"),transitioncancel:da("Transition","TransitionCancel"),transitionend:da("Transition","TransitionEnd")},Ku={},Vm={};Yn&&(Vm=document.createElement("div").style,"AnimationEvent"in window||(delete os.animationend.animation,delete os.animationiteration.animation,delete os.animationstart.animation),"TransitionEvent"in window||delete os.transitionend.transition);function pa(t){if(Ku[t])return Ku[t];if(!os[t])return t;var o=os[t],r;for(r in o)if(o.hasOwnProperty(r)&&r in Vm)return Ku[t]=o[r];return t}var Wm=pa("animationend"),Xm=pa("animationiteration"),Zm=pa("animationstart"),Ik=pa("transitionrun"),Lk=pa("transitionstart"),Bk=pa("transitioncancel"),Qm=pa("transitionend"),Jm=new Map,Yu="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Yu.push("scrollEnd");function yn(t,o){Jm.set(t,o),Gn(o,[t])}var ol=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},nn=[],as=0,Vu=0;function al(){for(var t=as,o=Vu=as=0;o<t;){var r=nn[o];nn[o++]=null;var u=nn[o];nn[o++]=null;var m=nn[o];nn[o++]=null;var y=nn[o];if(nn[o++]=null,u!==null&&m!==null){var C=u.pending;C===null?m.next=m:(m.next=C.next,C.next=m),u.pending=m}y!==0&&eh(r,m,y)}}function sl(t,o,r,u){nn[as++]=t,nn[as++]=o,nn[as++]=r,nn[as++]=u,Vu|=u,t.lanes|=u,t=t.alternate,t!==null&&(t.lanes|=u)}function Wu(t,o,r,u){return sl(t,o,r,u),rl(t)}function fa(t,o){return sl(t,null,null,o),rl(t)}function eh(t,o,r){t.lanes|=r;var u=t.alternate;u!==null&&(u.lanes|=r);for(var m=!1,y=t.return;y!==null;)y.childLanes|=r,u=y.alternate,u!==null&&(u.childLanes|=r),y.tag===22&&(t=y.stateNode,t===null||t._visibility&1||(m=!0)),t=y,y=y.return;return t.tag===3?(y=t.stateNode,m&&o!==null&&(m=31-zt(r),t=y.hiddenUpdates,u=t[m],u===null?t[m]=[o]:u.push(o),o.lane=r|536870912),y):null}function rl(t){if(50<zr)throw zr=0,ap=null,Error(s(185));for(var o=t.return;o!==null;)t=o,o=t.return;return t.tag===3?t.stateNode:null}var ss={};function Pk(t,o,r,u){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yt(t,o,r,u){return new Pk(t,o,r,u)}function Xu(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Vn(t,o){var r=t.alternate;return r===null?(r=Yt(t.tag,o,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=o,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&65011712,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,o=t.dependencies,r.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r.refCleanup=t.refCleanup,r}function th(t,o){t.flags&=65011714;var r=t.alternate;return r===null?(t.childLanes=0,t.lanes=o,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=r.childLanes,t.lanes=r.lanes,t.child=r.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=r.memoizedProps,t.memoizedState=r.memoizedState,t.updateQueue=r.updateQueue,t.type=r.type,o=r.dependencies,t.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),t}function il(t,o,r,u,m,y){var C=0;if(u=t,typeof t=="function")Xu(t)&&(C=1);else if(typeof t=="string")C=Kw(t,r,ae.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case B:return t=Yt(31,r,o,m),t.elementType=B,t.lanes=y,t;case w:return ma(r.children,m,y,o);case j:C=8,m|=24;break;case T:return t=Yt(12,r,o,m|2),t.elementType=T,t.lanes=y,t;case $:return t=Yt(13,r,o,m),t.elementType=$,t.lanes=y,t;case A:return t=Yt(19,r,o,m),t.elementType=A,t.lanes=y,t;default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case S:C=10;break e;case E:C=9;break e;case M:C=11;break e;case _:C=14;break e;case F:C=16,u=null;break e}C=29,r=Error(s(130,t===null?"null":typeof t,"")),u=null}return o=Yt(C,r,o,m),o.elementType=t,o.type=u,o.lanes=y,o}function ma(t,o,r,u){return t=Yt(7,t,u,o),t.lanes=r,t}function Zu(t,o,r){return t=Yt(6,t,null,o),t.lanes=r,t}function nh(t){var o=Yt(18,null,null,0);return o.stateNode=t,o}function Qu(t,o,r){return o=Yt(4,t.children!==null?t.children:[],t.key,o),o.lanes=r,o.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},o}var oh=new WeakMap;function on(t,o){if(typeof t=="object"&&t!==null){var r=oh.get(t);return r!==void 0?r:(o={value:t,source:o,stack:Nt(o)},oh.set(t,o),o)}return{value:t,source:o,stack:Nt(o)}}var rs=[],is=0,ll=null,pr=0,an=[],sn=0,Mo=null,Tn=1,Nn="";function Wn(t,o){rs[is++]=pr,rs[is++]=ll,ll=t,pr=o}function ah(t,o,r){an[sn++]=Tn,an[sn++]=Nn,an[sn++]=Mo,Mo=t;var u=Tn;t=Nn;var m=32-zt(u)-1;u&=~(1<<m),r+=1;var y=32-zt(o)+m;if(30<y){var C=m-m%5;y=(u&(1<<C)-1).toString(32),u>>=C,m-=C,Tn=1<<32-zt(o)+m|r<<m|u,Nn=y+t}else Tn=1<<y|r<<m|u,Nn=t}function Ju(t){t.return!==null&&(Wn(t,1),ah(t,1,0))}function ed(t){for(;t===ll;)ll=rs[--is],rs[is]=null,pr=rs[--is],rs[is]=null;for(;t===Mo;)Mo=an[--sn],an[sn]=null,Nn=an[--sn],an[sn]=null,Tn=an[--sn],an[sn]=null}function sh(t,o){an[sn++]=Tn,an[sn++]=Nn,an[sn++]=Mo,Tn=o.id,Nn=o.overflow,Mo=t}var wt=null,Ze=null,$e=!1,Co=null,rn=!1,td=Error(s(519));function Eo(t){var o=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw fr(on(o,t)),td}function rh(t){var o=t.stateNode,r=t.type,u=t.memoizedProps;switch(o[ht]=t,o[At]=u,r){case"dialog":De("cancel",o),De("close",o);break;case"iframe":case"object":case"embed":De("load",o);break;case"video":case"audio":for(r=0;r<Or.length;r++)De(Or[r],o);break;case"source":De("error",o);break;case"img":case"image":case"link":De("error",o),De("load",o);break;case"details":De("toggle",o);break;case"input":De("invalid",o),Wi(o,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":De("invalid",o);break;case"textarea":De("invalid",o),km(o,u.value,u.defaultValue,u.children)}r=u.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||o.textContent===""+r||u.suppressHydrationWarning===!0||Sy(o.textContent,r)?(u.popover!=null&&(De("beforetoggle",o),De("toggle",o)),u.onScroll!=null&&De("scroll",o),u.onScrollEnd!=null&&De("scrollend",o),u.onClick!=null&&(o.onclick=Kn),o=!0):o=!1,o||Eo(t,!0)}function ih(t){for(wt=t.return;wt;)switch(wt.tag){case 5:case 31:case 13:rn=!1;return;case 27:case 3:rn=!0;return;default:wt=wt.return}}function ls(t){if(t!==wt)return!1;if(!$e)return ih(t),$e=!0,!1;var o=t.tag,r;if((r=o!==3&&o!==27)&&((r=o===5)&&(r=t.type,r=!(r!=="form"&&r!=="button")||bp(t.type,t.memoizedProps)),r=!r),r&&Ze&&Eo(t),ih(t),o===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Ze=Dy(t)}else if(o===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Ze=Dy(t)}else o===27?(o=Ze,Bo(t.type)?(t=Mp,Mp=null,Ze=t):Ze=o):Ze=wt?cn(t.stateNode.nextSibling):null;return!0}function ha(){Ze=wt=null,$e=!1}function nd(){var t=Co;return t!==null&&(Pt===null?Pt=t:Pt.push.apply(Pt,t),Co=null),t}function fr(t){Co===null?Co=[t]:Co.push(t)}var od=I(null),ga=null,Xn=null;function jo(t,o,r){Z(od,o._currentValue),o._currentValue=r}function Zn(t){t._currentValue=od.current,L(od)}function ad(t,o,r){for(;t!==null;){var u=t.alternate;if((t.childLanes&o)!==o?(t.childLanes|=o,u!==null&&(u.childLanes|=o)):u!==null&&(u.childLanes&o)!==o&&(u.childLanes|=o),t===r)break;t=t.return}}function sd(t,o,r,u){var m=t.child;for(m!==null&&(m.return=t);m!==null;){var y=m.dependencies;if(y!==null){var C=m.child;y=y.firstContext;e:for(;y!==null;){var R=y;y=m;for(var Y=0;Y<o.length;Y++)if(R.context===o[Y]){y.lanes|=r,R=y.alternate,R!==null&&(R.lanes|=r),ad(y.return,r,t),u||(C=null);break e}y=R.next}}else if(m.tag===18){if(C=m.return,C===null)throw Error(s(341));C.lanes|=r,y=C.alternate,y!==null&&(y.lanes|=r),ad(C,r,t),C=null}else C=m.child;if(C!==null)C.return=m;else for(C=m;C!==null;){if(C===t){C=null;break}if(m=C.sibling,m!==null){m.return=C.return,C=m;break}C=C.return}m=C}}function cs(t,o,r,u){t=null;for(var m=o,y=!1;m!==null;){if(!y){if((m.flags&524288)!==0)y=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var C=m.alternate;if(C===null)throw Error(s(387));if(C=C.memoizedProps,C!==null){var R=m.type;Kt(m.pendingProps.value,C.value)||(t!==null?t.push(R):t=[R])}}else if(m===he.current){if(C=m.alternate,C===null)throw Error(s(387));C.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(t!==null?t.push(Br):t=[Br])}m=m.return}t!==null&&sd(o,t,r,u),o.flags|=262144}function cl(t){for(t=t.firstContext;t!==null;){if(!Kt(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function ya(t){ga=t,Xn=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function St(t){return lh(ga,t)}function ul(t,o){return ga===null&&ya(t),lh(t,o)}function lh(t,o){var r=o._currentValue;if(o={context:o,memoizedValue:r,next:null},Xn===null){if(t===null)throw Error(s(308));Xn=o,t.dependencies={lanes:0,firstContext:o},t.flags|=524288}else Xn=Xn.next=o;return r}var Hk=typeof AbortController<"u"?AbortController:function(){var t=[],o=this.signal={aborted:!1,addEventListener:function(r,u){t.push(u)}};this.abort=function(){o.aborted=!0,t.forEach(function(r){return r()})}},Uk=e.unstable_scheduleCallback,Gk=e.unstable_NormalPriority,lt={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function rd(){return{controller:new Hk,data:new Map,refCount:0}}function mr(t){t.refCount--,t.refCount===0&&Uk(Gk,function(){t.controller.abort()})}var hr=null,id=0,us=0,ds=null;function qk(t,o){if(hr===null){var r=hr=[];id=0,us=up(),ds={status:"pending",value:void 0,then:function(u){r.push(u)}}}return id++,o.then(ch,ch),o}function ch(){if(--id===0&&hr!==null){ds!==null&&(ds.status="fulfilled");var t=hr;hr=null,us=0,ds=null;for(var o=0;o<t.length;o++)(0,t[o])()}}function Kk(t,o){var r=[],u={status:"pending",value:null,reason:null,then:function(m){r.push(m)}};return t.then(function(){u.status="fulfilled",u.value=o;for(var m=0;m<r.length;m++)(0,r[m])(o)},function(m){for(u.status="rejected",u.reason=m,m=0;m<r.length;m++)(0,r[m])(void 0)}),u}var uh=D.S;D.S=function(t,o){Yg=kt(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&qk(t,o),uh!==null&&uh(t,o)};var xa=I(null);function ld(){var t=xa.current;return t!==null?t:Ve.pooledCache}function dl(t,o){o===null?Z(xa,xa.current):Z(xa,o.pool)}function dh(){var t=ld();return t===null?null:{parent:lt._currentValue,pool:t}}var ps=Error(s(460)),cd=Error(s(474)),pl=Error(s(542)),fl={then:function(){}};function ph(t){return t=t.status,t==="fulfilled"||t==="rejected"}function fh(t,o,r){switch(r=t[r],r===void 0?t.push(o):r!==o&&(o.then(Kn,Kn),o=r),o.status){case"fulfilled":return o.value;case"rejected":throw t=o.reason,hh(t),t;default:if(typeof o.status=="string")o.then(Kn,Kn);else{if(t=Ve,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=o,t.status="pending",t.then(function(u){if(o.status==="pending"){var m=o;m.status="fulfilled",m.value=u}},function(u){if(o.status==="pending"){var m=o;m.status="rejected",m.reason=u}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw t=o.reason,hh(t),t}throw va=o,ps}}function ba(t){try{var o=t._init;return o(t._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(va=r,ps):r}}var va=null;function mh(){if(va===null)throw Error(s(459));var t=va;return va=null,t}function hh(t){if(t===ps||t===pl)throw Error(s(483))}var fs=null,gr=0;function ml(t){var o=gr;return gr+=1,fs===null&&(fs=[]),fh(fs,t,o)}function yr(t,o){o=o.props.ref,t.ref=o!==void 0?o:null}function hl(t,o){throw o.$$typeof===b?Error(s(525)):(t=Object.prototype.toString.call(o),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":t)))}function gh(t){function o(ee,X){if(t){var te=ee.deletions;te===null?(ee.deletions=[X],ee.flags|=16):te.push(X)}}function r(ee,X){if(!t)return null;for(;X!==null;)o(ee,X),X=X.sibling;return null}function u(ee){for(var X=new Map;ee!==null;)ee.key!==null?X.set(ee.key,ee):X.set(ee.index,ee),ee=ee.sibling;return X}function m(ee,X){return ee=Vn(ee,X),ee.index=0,ee.sibling=null,ee}function y(ee,X,te){return ee.index=te,t?(te=ee.alternate,te!==null?(te=te.index,te<X?(ee.flags|=67108866,X):te):(ee.flags|=67108866,X)):(ee.flags|=1048576,X)}function C(ee){return t&&ee.alternate===null&&(ee.flags|=67108866),ee}function R(ee,X,te,ue){return X===null||X.tag!==6?(X=Zu(te,ee.mode,ue),X.return=ee,X):(X=m(X,te),X.return=ee,X)}function Y(ee,X,te,ue){var Me=te.type;return Me===w?le(ee,X,te.props.children,ue,te.key):X!==null&&(X.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===F&&ba(Me)===X.type)?(X=m(X,te.props),yr(X,te),X.return=ee,X):(X=il(te.type,te.key,te.props,null,ee.mode,ue),yr(X,te),X.return=ee,X)}function ne(ee,X,te,ue){return X===null||X.tag!==4||X.stateNode.containerInfo!==te.containerInfo||X.stateNode.implementation!==te.implementation?(X=Qu(te,ee.mode,ue),X.return=ee,X):(X=m(X,te.children||[]),X.return=ee,X)}function le(ee,X,te,ue,Me){return X===null||X.tag!==7?(X=ma(te,ee.mode,ue,Me),X.return=ee,X):(X=m(X,te),X.return=ee,X)}function de(ee,X,te){if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return X=Zu(""+X,ee.mode,te),X.return=ee,X;if(typeof X=="object"&&X!==null){switch(X.$$typeof){case v:return te=il(X.type,X.key,X.props,null,ee.mode,te),yr(te,X),te.return=ee,te;case k:return X=Qu(X,ee.mode,te),X.return=ee,X;case F:return X=ba(X),de(ee,X,te)}if(N(X)||K(X))return X=ma(X,ee.mode,te,null),X.return=ee,X;if(typeof X.then=="function")return de(ee,ml(X),te);if(X.$$typeof===S)return de(ee,ul(ee,X),te);hl(ee,X)}return null}function se(ee,X,te,ue){var Me=X!==null?X.key:null;if(typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint")return Me!==null?null:R(ee,X,""+te,ue);if(typeof te=="object"&&te!==null){switch(te.$$typeof){case v:return te.key===Me?Y(ee,X,te,ue):null;case k:return te.key===Me?ne(ee,X,te,ue):null;case F:return te=ba(te),se(ee,X,te,ue)}if(N(te)||K(te))return Me!==null?null:le(ee,X,te,ue,null);if(typeof te.then=="function")return se(ee,X,ml(te),ue);if(te.$$typeof===S)return se(ee,X,ul(ee,te),ue);hl(ee,te)}return null}function ie(ee,X,te,ue,Me){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return ee=ee.get(te)||null,R(X,ee,""+ue,Me);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case v:return ee=ee.get(ue.key===null?te:ue.key)||null,Y(X,ee,ue,Me);case k:return ee=ee.get(ue.key===null?te:ue.key)||null,ne(X,ee,ue,Me);case F:return ue=ba(ue),ie(ee,X,te,ue,Me)}if(N(ue)||K(ue))return ee=ee.get(te)||null,le(X,ee,ue,Me,null);if(typeof ue.then=="function")return ie(ee,X,te,ml(ue),Me);if(ue.$$typeof===S)return ie(ee,X,te,ul(X,ue),Me);hl(X,ue)}return null}function be(ee,X,te,ue){for(var Me=null,Le=null,ve=X,Ne=X=0,Oe=null;ve!==null&&Ne<te.length;Ne++){ve.index>Ne?(Oe=ve,ve=null):Oe=ve.sibling;var Be=se(ee,ve,te[Ne],ue);if(Be===null){ve===null&&(ve=Oe);break}t&&ve&&Be.alternate===null&&o(ee,ve),X=y(Be,X,Ne),Le===null?Me=Be:Le.sibling=Be,Le=Be,ve=Oe}if(Ne===te.length)return r(ee,ve),$e&&Wn(ee,Ne),Me;if(ve===null){for(;Ne<te.length;Ne++)ve=de(ee,te[Ne],ue),ve!==null&&(X=y(ve,X,Ne),Le===null?Me=ve:Le.sibling=ve,Le=ve);return $e&&Wn(ee,Ne),Me}for(ve=u(ve);Ne<te.length;Ne++)Oe=ie(ve,ee,Ne,te[Ne],ue),Oe!==null&&(t&&Oe.alternate!==null&&ve.delete(Oe.key===null?Ne:Oe.key),X=y(Oe,X,Ne),Le===null?Me=Oe:Le.sibling=Oe,Le=Oe);return t&&ve.forEach(function(qo){return o(ee,qo)}),$e&&Wn(ee,Ne),Me}function Ce(ee,X,te,ue){if(te==null)throw Error(s(151));for(var Me=null,Le=null,ve=X,Ne=X=0,Oe=null,Be=te.next();ve!==null&&!Be.done;Ne++,Be=te.next()){ve.index>Ne?(Oe=ve,ve=null):Oe=ve.sibling;var qo=se(ee,ve,Be.value,ue);if(qo===null){ve===null&&(ve=Oe);break}t&&ve&&qo.alternate===null&&o(ee,ve),X=y(qo,X,Ne),Le===null?Me=qo:Le.sibling=qo,Le=qo,ve=Oe}if(Be.done)return r(ee,ve),$e&&Wn(ee,Ne),Me;if(ve===null){for(;!Be.done;Ne++,Be=te.next())Be=de(ee,Be.value,ue),Be!==null&&(X=y(Be,X,Ne),Le===null?Me=Be:Le.sibling=Be,Le=Be);return $e&&Wn(ee,Ne),Me}for(ve=u(ve);!Be.done;Ne++,Be=te.next())Be=ie(ve,ee,Ne,Be.value,ue),Be!==null&&(t&&Be.alternate!==null&&ve.delete(Be.key===null?Ne:Be.key),X=y(Be,X,Ne),Le===null?Me=Be:Le.sibling=Be,Le=Be);return t&&ve.forEach(function(oS){return o(ee,oS)}),$e&&Wn(ee,Ne),Me}function Ke(ee,X,te,ue){if(typeof te=="object"&&te!==null&&te.type===w&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case v:e:{for(var Me=te.key;X!==null;){if(X.key===Me){if(Me=te.type,Me===w){if(X.tag===7){r(ee,X.sibling),ue=m(X,te.props.children),ue.return=ee,ee=ue;break e}}else if(X.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===F&&ba(Me)===X.type){r(ee,X.sibling),ue=m(X,te.props),yr(ue,te),ue.return=ee,ee=ue;break e}r(ee,X);break}else o(ee,X);X=X.sibling}te.type===w?(ue=ma(te.props.children,ee.mode,ue,te.key),ue.return=ee,ee=ue):(ue=il(te.type,te.key,te.props,null,ee.mode,ue),yr(ue,te),ue.return=ee,ee=ue)}return C(ee);case k:e:{for(Me=te.key;X!==null;){if(X.key===Me)if(X.tag===4&&X.stateNode.containerInfo===te.containerInfo&&X.stateNode.implementation===te.implementation){r(ee,X.sibling),ue=m(X,te.children||[]),ue.return=ee,ee=ue;break e}else{r(ee,X);break}else o(ee,X);X=X.sibling}ue=Qu(te,ee.mode,ue),ue.return=ee,ee=ue}return C(ee);case F:return te=ba(te),Ke(ee,X,te,ue)}if(N(te))return be(ee,X,te,ue);if(K(te)){if(Me=K(te),typeof Me!="function")throw Error(s(150));return te=Me.call(te),Ce(ee,X,te,ue)}if(typeof te.then=="function")return Ke(ee,X,ml(te),ue);if(te.$$typeof===S)return Ke(ee,X,ul(ee,te),ue);hl(ee,te)}return typeof te=="string"&&te!==""||typeof te=="number"||typeof te=="bigint"?(te=""+te,X!==null&&X.tag===6?(r(ee,X.sibling),ue=m(X,te),ue.return=ee,ee=ue):(r(ee,X),ue=Zu(te,ee.mode,ue),ue.return=ee,ee=ue),C(ee)):r(ee,X)}return function(ee,X,te,ue){try{gr=0;var Me=Ke(ee,X,te,ue);return fs=null,Me}catch(ve){if(ve===ps||ve===pl)throw ve;var Le=Yt(29,ve,null,ee.mode);return Le.lanes=ue,Le.return=ee,Le}}}var ka=gh(!0),yh=gh(!1),To=!1;function ud(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function dd(t,o){t=t.updateQueue,o.updateQueue===t&&(o.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function No(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Ao(t,o,r){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(Pe&2)!==0){var m=u.pending;return m===null?o.next=o:(o.next=m.next,m.next=o),u.pending=o,o=rl(t),eh(t,null,r),o}return sl(t,u,o,r),rl(t)}function xr(t,o,r){if(o=o.updateQueue,o!==null&&(o=o.shared,(r&4194048)!==0)){var u=o.lanes;u&=t.pendingLanes,r|=u,o.lanes=r,Ii(t,r)}}function pd(t,o){var r=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,r===u)){var m=null,y=null;if(r=r.firstBaseUpdate,r!==null){do{var C={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};y===null?m=y=C:y=y.next=C,r=r.next}while(r!==null);y===null?m=y=o:y=y.next=o}else m=y=o;r={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:u.shared,callbacks:u.callbacks},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=o:t.next=o,r.lastBaseUpdate=o}var fd=!1;function br(){if(fd){var t=ds;if(t!==null)throw t}}function vr(t,o,r,u){fd=!1;var m=t.updateQueue;To=!1;var y=m.firstBaseUpdate,C=m.lastBaseUpdate,R=m.shared.pending;if(R!==null){m.shared.pending=null;var Y=R,ne=Y.next;Y.next=null,C===null?y=ne:C.next=ne,C=Y;var le=t.alternate;le!==null&&(le=le.updateQueue,R=le.lastBaseUpdate,R!==C&&(R===null?le.firstBaseUpdate=ne:R.next=ne,le.lastBaseUpdate=Y))}if(y!==null){var de=m.baseState;C=0,le=ne=Y=null,R=y;do{var se=R.lane&-536870913,ie=se!==R.lane;if(ie?(Re&se)===se:(u&se)===se){se!==0&&se===us&&(fd=!0),le!==null&&(le=le.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var be=t,Ce=R;se=o;var Ke=r;switch(Ce.tag){case 1:if(be=Ce.payload,typeof be=="function"){de=be.call(Ke,de,se);break e}de=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Ce.payload,se=typeof be=="function"?be.call(Ke,de,se):be,se==null)break e;de=x({},de,se);break e;case 2:To=!0}}se=R.callback,se!==null&&(t.flags|=64,ie&&(t.flags|=8192),ie=m.callbacks,ie===null?m.callbacks=[se]:ie.push(se))}else ie={lane:se,tag:R.tag,payload:R.payload,callback:R.callback,next:null},le===null?(ne=le=ie,Y=de):le=le.next=ie,C|=se;if(R=R.next,R===null){if(R=m.shared.pending,R===null)break;ie=R,R=ie.next,ie.next=null,m.lastBaseUpdate=ie,m.shared.pending=null}}while(!0);le===null&&(Y=de),m.baseState=Y,m.firstBaseUpdate=ne,m.lastBaseUpdate=le,y===null&&(m.shared.lanes=0),Oo|=C,t.lanes=C,t.memoizedState=de}}function xh(t,o){if(typeof t!="function")throw Error(s(191,t));t.call(o)}function bh(t,o){var r=t.callbacks;if(r!==null)for(t.callbacks=null,t=0;t<r.length;t++)xh(r[t],o)}var ms=I(null),gl=I(0);function vh(t,o){t=ro,Z(gl,t),Z(ms,o),ro=t|o.baseLanes}function md(){Z(gl,ro),Z(ms,ms.current)}function hd(){ro=gl.current,L(ms),L(gl)}var Vt=I(null),ln=null;function _o(t){var o=t.alternate;Z(st,st.current&1),Z(Vt,t),ln===null&&(o===null||ms.current!==null||o.memoizedState!==null)&&(ln=t)}function gd(t){Z(st,st.current),Z(Vt,t),ln===null&&(ln=t)}function kh(t){t.tag===22?(Z(st,st.current),Z(Vt,t),ln===null&&(ln=t)):Do()}function Do(){Z(st,st.current),Z(Vt,Vt.current)}function Wt(t){L(Vt),ln===t&&(ln=null),L(st)}var st=I(0);function yl(t){for(var o=t;o!==null;){if(o.tag===13){var r=o.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||wp(r)||Sp(r)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break;for(;o.sibling===null;){if(o.return===null||o.return===t)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var Qn=0,Te=null,Ge=null,ct=null,xl=!1,hs=!1,wa=!1,bl=0,kr=0,gs=null,Yk=0;function ot(){throw Error(s(321))}function yd(t,o){if(o===null)return!1;for(var r=0;r<o.length&&r<t.length;r++)if(!Kt(t[r],o[r]))return!1;return!0}function xd(t,o,r,u,m,y){return Qn=y,Te=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,D.H=t===null||t.memoizedState===null?ag:zd,wa=!1,y=r(u,m),wa=!1,hs&&(y=Sh(o,r,u,m)),wh(t),y}function wh(t){D.H=Mr;var o=Ge!==null&&Ge.next!==null;if(Qn=0,ct=Ge=Te=null,xl=!1,kr=0,gs=null,o)throw Error(s(300));t===null||ut||(t=t.dependencies,t!==null&&cl(t)&&(ut=!0))}function Sh(t,o,r,u){Te=t;var m=0;do{if(hs&&(gs=null),kr=0,hs=!1,25<=m)throw Error(s(301));if(m+=1,ct=Ge=null,t.updateQueue!=null){var y=t.updateQueue;y.lastEffect=null,y.events=null,y.stores=null,y.memoCache!=null&&(y.memoCache.index=0)}D.H=sg,y=o(r,u)}while(hs);return y}function Vk(){var t=D.H,o=t.useState()[0];return o=typeof o.then=="function"?wr(o):o,t=t.useState()[0],(Ge!==null?Ge.memoizedState:null)!==t&&(Te.flags|=1024),o}function bd(){var t=bl!==0;return bl=0,t}function vd(t,o,r){o.updateQueue=t.updateQueue,o.flags&=-2053,t.lanes&=~r}function kd(t){if(xl){for(t=t.memoizedState;t!==null;){var o=t.queue;o!==null&&(o.pending=null),t=t.next}xl=!1}Qn=0,ct=Ge=Te=null,hs=!1,kr=bl=0,gs=null}function Rt(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ct===null?Te.memoizedState=ct=t:ct=ct.next=t,ct}function rt(){if(Ge===null){var t=Te.alternate;t=t!==null?t.memoizedState:null}else t=Ge.next;var o=ct===null?Te.memoizedState:ct.next;if(o!==null)ct=o,Ge=t;else{if(t===null)throw Te.alternate===null?Error(s(467)):Error(s(310));Ge=t,t={memoizedState:Ge.memoizedState,baseState:Ge.baseState,baseQueue:Ge.baseQueue,queue:Ge.queue,next:null},ct===null?Te.memoizedState=ct=t:ct=ct.next=t}return ct}function vl(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wr(t){var o=kr;return kr+=1,gs===null&&(gs=[]),t=fh(gs,t,o),o=Te,(ct===null?o.memoizedState:ct.next)===null&&(o=o.alternate,D.H=o===null||o.memoizedState===null?ag:zd),t}function kl(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return wr(t);if(t.$$typeof===S)return St(t)}throw Error(s(438,String(t)))}function wd(t){var o=null,r=Te.updateQueue;if(r!==null&&(o=r.memoCache),o==null){var u=Te.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(o={data:u.data.map(function(m){return m.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),r===null&&(r=vl(),Te.updateQueue=r),r.memoCache=o,r=o.data[o.index],r===void 0)for(r=o.data[o.index]=Array(t),u=0;u<t;u++)r[u]=G;return o.index++,r}function Jn(t,o){return typeof o=="function"?o(t):o}function wl(t){var o=rt();return Sd(o,Ge,t)}function Sd(t,o,r){var u=t.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=r;var m=t.baseQueue,y=u.pending;if(y!==null){if(m!==null){var C=m.next;m.next=y.next,y.next=C}o.baseQueue=m=y,u.pending=null}if(y=t.baseState,m===null)t.memoizedState=y;else{o=m.next;var R=C=null,Y=null,ne=o,le=!1;do{var de=ne.lane&-536870913;if(de!==ne.lane?(Re&de)===de:(Qn&de)===de){var se=ne.revertLane;if(se===0)Y!==null&&(Y=Y.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),de===us&&(le=!0);else if((Qn&se)===se){ne=ne.next,se===us&&(le=!0);continue}else de={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Y===null?(R=Y=de,C=y):Y=Y.next=de,Te.lanes|=se,Oo|=se;de=ne.action,wa&&r(y,de),y=ne.hasEagerState?ne.eagerState:r(y,de)}else se={lane:de,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},Y===null?(R=Y=se,C=y):Y=Y.next=se,Te.lanes|=de,Oo|=de;ne=ne.next}while(ne!==null&&ne!==o);if(Y===null?C=y:Y.next=R,!Kt(y,t.memoizedState)&&(ut=!0,le&&(r=ds,r!==null)))throw r;t.memoizedState=y,t.baseState=C,t.baseQueue=Y,u.lastRenderedState=y}return m===null&&(u.lanes=0),[t.memoizedState,u.dispatch]}function Md(t){var o=rt(),r=o.queue;if(r===null)throw Error(s(311));r.lastRenderedReducer=t;var u=r.dispatch,m=r.pending,y=o.memoizedState;if(m!==null){r.pending=null;var C=m=m.next;do y=t(y,C.action),C=C.next;while(C!==m);Kt(y,o.memoizedState)||(ut=!0),o.memoizedState=y,o.baseQueue===null&&(o.baseState=y),r.lastRenderedState=y}return[y,u]}function Mh(t,o,r){var u=Te,m=rt(),y=$e;if(y){if(r===void 0)throw Error(s(407));r=r()}else r=o();var C=!Kt((Ge||m).memoizedState,r);if(C&&(m.memoizedState=r,ut=!0),m=m.queue,jd(jh.bind(null,u,m,t),[t]),m.getSnapshot!==o||C||ct!==null&&ct.memoizedState.tag&1){if(u.flags|=2048,ys(9,{destroy:void 0},Eh.bind(null,u,m,r,o),null),Ve===null)throw Error(s(349));y||(Qn&127)!==0||Ch(u,o,r)}return r}function Ch(t,o,r){t.flags|=16384,t={getSnapshot:o,value:r},o=Te.updateQueue,o===null?(o=vl(),Te.updateQueue=o,o.stores=[t]):(r=o.stores,r===null?o.stores=[t]:r.push(t))}function Eh(t,o,r,u){o.value=r,o.getSnapshot=u,Th(o)&&Nh(t)}function jh(t,o,r){return r(function(){Th(o)&&Nh(t)})}function Th(t){var o=t.getSnapshot;t=t.value;try{var r=o();return!Kt(t,r)}catch{return!0}}function Nh(t){var o=fa(t,2);o!==null&&Ht(o,t,2)}function Cd(t){var o=Rt();if(typeof t=="function"){var r=t;if(t=r(),wa){En(!0);try{r()}finally{En(!1)}}}return o.memoizedState=o.baseState=t,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jn,lastRenderedState:t},o}function Ah(t,o,r,u){return t.baseState=r,Sd(t,Ge,typeof u=="function"?u:Jn)}function Wk(t,o,r,u,m){if(Cl(t))throw Error(s(485));if(t=o.action,t!==null){var y={payload:m,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(C){y.listeners.push(C)}};D.T!==null?r(!0):y.isTransition=!1,u(y),r=o.pending,r===null?(y.next=o.pending=y,_h(o,y)):(y.next=r.next,o.pending=r.next=y)}}function _h(t,o){var r=o.action,u=o.payload,m=t.state;if(o.isTransition){var y=D.T,C={};D.T=C;try{var R=r(m,u),Y=D.S;Y!==null&&Y(C,R),Dh(t,o,R)}catch(ne){Ed(t,o,ne)}finally{y!==null&&C.types!==null&&(y.types=C.types),D.T=y}}else try{y=r(m,u),Dh(t,o,y)}catch(ne){Ed(t,o,ne)}}function Dh(t,o,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(u){zh(t,o,u)},function(u){return Ed(t,o,u)}):zh(t,o,r)}function zh(t,o,r){o.status="fulfilled",o.value=r,Rh(o),t.state=r,o=t.pending,o!==null&&(r=o.next,r===o?t.pending=null:(r=r.next,o.next=r,_h(t,r)))}function Ed(t,o,r){var u=t.pending;if(t.pending=null,u!==null){u=u.next;do o.status="rejected",o.reason=r,Rh(o),o=o.next;while(o!==u)}t.action=null}function Rh(t){t=t.listeners;for(var o=0;o<t.length;o++)(0,t[o])()}function Oh(t,o){return o}function $h(t,o){if($e){var r=Ve.formState;if(r!==null){e:{var u=Te;if($e){if(Ze){t:{for(var m=Ze,y=rn;m.nodeType!==8;){if(!y){m=null;break t}if(m=cn(m.nextSibling),m===null){m=null;break t}}y=m.data,m=y==="F!"||y==="F"?m:null}if(m){Ze=cn(m.nextSibling),u=m.data==="F!";break e}}Eo(u)}u=!1}u&&(o=r[0])}}return r=Rt(),r.memoizedState=r.baseState=o,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oh,lastRenderedState:o},r.queue=u,r=tg.bind(null,Te,u),u.dispatch=r,u=Cd(!1),y=Dd.bind(null,Te,!1,u.queue),u=Rt(),m={state:o,dispatch:null,action:t,pending:null},u.queue=m,r=Wk.bind(null,Te,m,y,r),m.dispatch=r,u.memoizedState=t,[o,r,!1]}function Fh(t){var o=rt();return Ih(o,Ge,t)}function Ih(t,o,r){if(o=Sd(t,o,Oh)[0],t=wl(Jn)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var u=wr(o)}catch(C){throw C===ps?pl:C}else u=o;o=rt();var m=o.queue,y=m.dispatch;return r!==o.memoizedState&&(Te.flags|=2048,ys(9,{destroy:void 0},Xk.bind(null,m,r),null)),[u,y,t]}function Xk(t,o){t.action=o}function Lh(t){var o=rt(),r=Ge;if(r!==null)return Ih(o,r,t);rt(),o=o.memoizedState,r=rt();var u=r.queue.dispatch;return r.memoizedState=t,[o,u,!1]}function ys(t,o,r,u){return t={tag:t,create:r,deps:u,inst:o,next:null},o=Te.updateQueue,o===null&&(o=vl(),Te.updateQueue=o),r=o.lastEffect,r===null?o.lastEffect=t.next=t:(u=r.next,r.next=t,t.next=u,o.lastEffect=t),t}function Bh(){return rt().memoizedState}function Sl(t,o,r,u){var m=Rt();Te.flags|=t,m.memoizedState=ys(1|o,{destroy:void 0},r,u===void 0?null:u)}function Ml(t,o,r,u){var m=rt();u=u===void 0?null:u;var y=m.memoizedState.inst;Ge!==null&&u!==null&&yd(u,Ge.memoizedState.deps)?m.memoizedState=ys(o,y,r,u):(Te.flags|=t,m.memoizedState=ys(1|o,y,r,u))}function Ph(t,o){Sl(8390656,8,t,o)}function jd(t,o){Ml(2048,8,t,o)}function Zk(t){Te.flags|=4;var o=Te.updateQueue;if(o===null)o=vl(),Te.updateQueue=o,o.events=[t];else{var r=o.events;r===null?o.events=[t]:r.push(t)}}function Hh(t){var o=rt().memoizedState;return Zk({ref:o,nextImpl:t}),function(){if((Pe&2)!==0)throw Error(s(440));return o.impl.apply(void 0,arguments)}}function Uh(t,o){return Ml(4,2,t,o)}function Gh(t,o){return Ml(4,4,t,o)}function qh(t,o){if(typeof o=="function"){t=t();var r=o(t);return function(){typeof r=="function"?r():o(null)}}if(o!=null)return t=t(),o.current=t,function(){o.current=null}}function Kh(t,o,r){r=r!=null?r.concat([t]):null,Ml(4,4,qh.bind(null,o,t),r)}function Td(){}function Yh(t,o){var r=rt();o=o===void 0?null:o;var u=r.memoizedState;return o!==null&&yd(o,u[1])?u[0]:(r.memoizedState=[t,o],t)}function Vh(t,o){var r=rt();o=o===void 0?null:o;var u=r.memoizedState;if(o!==null&&yd(o,u[1]))return u[0];if(u=t(),wa){En(!0);try{t()}finally{En(!1)}}return r.memoizedState=[u,o],u}function Nd(t,o,r){return r===void 0||(Qn&1073741824)!==0&&(Re&261930)===0?t.memoizedState=o:(t.memoizedState=r,t=Wg(),Te.lanes|=t,Oo|=t,r)}function Wh(t,o,r,u){return Kt(r,o)?r:ms.current!==null?(t=Nd(t,r,u),Kt(t,o)||(ut=!0),t):(Qn&42)===0||(Qn&1073741824)!==0&&(Re&261930)===0?(ut=!0,t.memoizedState=r):(t=Wg(),Te.lanes|=t,Oo|=t,o)}function Xh(t,o,r,u,m){var y=U.p;U.p=y!==0&&8>y?y:8;var C=D.T,R={};D.T=R,Dd(t,!1,o,r);try{var Y=m(),ne=D.S;if(ne!==null&&ne(R,Y),Y!==null&&typeof Y=="object"&&typeof Y.then=="function"){var le=Kk(Y,u);Sr(t,o,le,Qt(t))}else Sr(t,o,u,Qt(t))}catch(de){Sr(t,o,{then:function(){},status:"rejected",reason:de},Qt())}finally{U.p=y,C!==null&&R.types!==null&&(C.types=R.types),D.T=C}}function Qk(){}function Ad(t,o,r,u){if(t.tag!==5)throw Error(s(476));var m=Zh(t).queue;Xh(t,m,o,q,r===null?Qk:function(){return Qh(t),r(u)})}function Zh(t){var o=t.memoizedState;if(o!==null)return o;o={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jn,lastRenderedState:q},next:null};var r={};return o.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Jn,lastRenderedState:r},next:null},t.memoizedState=o,t=t.alternate,t!==null&&(t.memoizedState=o),o}function Qh(t){var o=Zh(t);o.next===null&&(o=t.alternate.memoizedState),Sr(t,o.next.queue,{},Qt())}function _d(){return St(Br)}function Jh(){return rt().memoizedState}function eg(){return rt().memoizedState}function Jk(t){for(var o=t.return;o!==null;){switch(o.tag){case 24:case 3:var r=Qt();t=No(r);var u=Ao(o,t,r);u!==null&&(Ht(u,o,r),xr(u,o,r)),o={cache:rd()},t.payload=o;return}o=o.return}}function ew(t,o,r){var u=Qt();r={lane:u,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Cl(t)?ng(o,r):(r=Wu(t,o,r,u),r!==null&&(Ht(r,t,u),og(r,o,u)))}function tg(t,o,r){var u=Qt();Sr(t,o,r,u)}function Sr(t,o,r,u){var m={lane:u,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(Cl(t))ng(o,m);else{var y=t.alternate;if(t.lanes===0&&(y===null||y.lanes===0)&&(y=o.lastRenderedReducer,y!==null))try{var C=o.lastRenderedState,R=y(C,r);if(m.hasEagerState=!0,m.eagerState=R,Kt(R,C))return sl(t,o,m,0),Ve===null&&al(),!1}catch{}if(r=Wu(t,o,m,u),r!==null)return Ht(r,t,u),og(r,o,u),!0}return!1}function Dd(t,o,r,u){if(u={lane:2,revertLane:up(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},Cl(t)){if(o)throw Error(s(479))}else o=Wu(t,r,u,2),o!==null&&Ht(o,t,2)}function Cl(t){var o=t.alternate;return t===Te||o!==null&&o===Te}function ng(t,o){hs=xl=!0;var r=t.pending;r===null?o.next=o:(o.next=r.next,r.next=o),t.pending=o}function og(t,o,r){if((r&4194048)!==0){var u=o.lanes;u&=t.pendingLanes,r|=u,o.lanes=r,Ii(t,r)}}var Mr={readContext:St,use:kl,useCallback:ot,useContext:ot,useEffect:ot,useImperativeHandle:ot,useLayoutEffect:ot,useInsertionEffect:ot,useMemo:ot,useReducer:ot,useRef:ot,useState:ot,useDebugValue:ot,useDeferredValue:ot,useTransition:ot,useSyncExternalStore:ot,useId:ot,useHostTransitionStatus:ot,useFormState:ot,useActionState:ot,useOptimistic:ot,useMemoCache:ot,useCacheRefresh:ot};Mr.useEffectEvent=ot;var ag={readContext:St,use:kl,useCallback:function(t,o){return Rt().memoizedState=[t,o===void 0?null:o],t},useContext:St,useEffect:Ph,useImperativeHandle:function(t,o,r){r=r!=null?r.concat([t]):null,Sl(4194308,4,qh.bind(null,o,t),r)},useLayoutEffect:function(t,o){return Sl(4194308,4,t,o)},useInsertionEffect:function(t,o){Sl(4,2,t,o)},useMemo:function(t,o){var r=Rt();o=o===void 0?null:o;var u=t();if(wa){En(!0);try{t()}finally{En(!1)}}return r.memoizedState=[u,o],u},useReducer:function(t,o,r){var u=Rt();if(r!==void 0){var m=r(o);if(wa){En(!0);try{r(o)}finally{En(!1)}}}else m=o;return u.memoizedState=u.baseState=m,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:m},u.queue=t,t=t.dispatch=ew.bind(null,Te,t),[u.memoizedState,t]},useRef:function(t){var o=Rt();return t={current:t},o.memoizedState=t},useState:function(t){t=Cd(t);var o=t.queue,r=tg.bind(null,Te,o);return o.dispatch=r,[t.memoizedState,r]},useDebugValue:Td,useDeferredValue:function(t,o){var r=Rt();return Nd(r,t,o)},useTransition:function(){var t=Cd(!1);return t=Xh.bind(null,Te,t.queue,!0,!1),Rt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,o,r){var u=Te,m=Rt();if($e){if(r===void 0)throw Error(s(407));r=r()}else{if(r=o(),Ve===null)throw Error(s(349));(Re&127)!==0||Ch(u,o,r)}m.memoizedState=r;var y={value:r,getSnapshot:o};return m.queue=y,Ph(jh.bind(null,u,y,t),[t]),u.flags|=2048,ys(9,{destroy:void 0},Eh.bind(null,u,y,r,o),null),r},useId:function(){var t=Rt(),o=Ve.identifierPrefix;if($e){var r=Nn,u=Tn;r=(u&~(1<<32-zt(u)-1)).toString(32)+r,o="_"+o+"R_"+r,r=bl++,0<r&&(o+="H"+r.toString(32)),o+="_"}else r=Yk++,o="_"+o+"r_"+r.toString(32)+"_";return t.memoizedState=o},useHostTransitionStatus:_d,useFormState:$h,useActionState:$h,useOptimistic:function(t){var o=Rt();o.memoizedState=o.baseState=t;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=r,o=Dd.bind(null,Te,!0,r),r.dispatch=o,[t,o]},useMemoCache:wd,useCacheRefresh:function(){return Rt().memoizedState=Jk.bind(null,Te)},useEffectEvent:function(t){var o=Rt(),r={impl:t};return o.memoizedState=r,function(){if((Pe&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}},zd={readContext:St,use:kl,useCallback:Yh,useContext:St,useEffect:jd,useImperativeHandle:Kh,useInsertionEffect:Uh,useLayoutEffect:Gh,useMemo:Vh,useReducer:wl,useRef:Bh,useState:function(){return wl(Jn)},useDebugValue:Td,useDeferredValue:function(t,o){var r=rt();return Wh(r,Ge.memoizedState,t,o)},useTransition:function(){var t=wl(Jn)[0],o=rt().memoizedState;return[typeof t=="boolean"?t:wr(t),o]},useSyncExternalStore:Mh,useId:Jh,useHostTransitionStatus:_d,useFormState:Fh,useActionState:Fh,useOptimistic:function(t,o){var r=rt();return Ah(r,Ge,t,o)},useMemoCache:wd,useCacheRefresh:eg};zd.useEffectEvent=Hh;var sg={readContext:St,use:kl,useCallback:Yh,useContext:St,useEffect:jd,useImperativeHandle:Kh,useInsertionEffect:Uh,useLayoutEffect:Gh,useMemo:Vh,useReducer:Md,useRef:Bh,useState:function(){return Md(Jn)},useDebugValue:Td,useDeferredValue:function(t,o){var r=rt();return Ge===null?Nd(r,t,o):Wh(r,Ge.memoizedState,t,o)},useTransition:function(){var t=Md(Jn)[0],o=rt().memoizedState;return[typeof t=="boolean"?t:wr(t),o]},useSyncExternalStore:Mh,useId:Jh,useHostTransitionStatus:_d,useFormState:Lh,useActionState:Lh,useOptimistic:function(t,o){var r=rt();return Ge!==null?Ah(r,Ge,t,o):(r.baseState=t,[t,r.queue.dispatch])},useMemoCache:wd,useCacheRefresh:eg};sg.useEffectEvent=Hh;function Rd(t,o,r,u){o=t.memoizedState,r=r(u,o),r=r==null?o:x({},o,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var Od={enqueueSetState:function(t,o,r){t=t._reactInternals;var u=Qt(),m=No(u);m.payload=o,r!=null&&(m.callback=r),o=Ao(t,m,u),o!==null&&(Ht(o,t,u),xr(o,t,u))},enqueueReplaceState:function(t,o,r){t=t._reactInternals;var u=Qt(),m=No(u);m.tag=1,m.payload=o,r!=null&&(m.callback=r),o=Ao(t,m,u),o!==null&&(Ht(o,t,u),xr(o,t,u))},enqueueForceUpdate:function(t,o){t=t._reactInternals;var r=Qt(),u=No(r);u.tag=2,o!=null&&(u.callback=o),o=Ao(t,u,r),o!==null&&(Ht(o,t,r),xr(o,t,r))}};function rg(t,o,r,u,m,y,C){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,y,C):o.prototype&&o.prototype.isPureReactComponent?!ur(r,u)||!ur(m,y):!0}function ig(t,o,r,u){t=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(r,u),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(r,u),o.state!==t&&Od.enqueueReplaceState(o,o.state,null)}function Sa(t,o){var r=o;if("ref"in o){r={};for(var u in o)u!=="ref"&&(r[u]=o[u])}if(t=t.defaultProps){r===o&&(r=x({},r));for(var m in t)r[m]===void 0&&(r[m]=t[m])}return r}function lg(t){ol(t)}function cg(t){console.error(t)}function ug(t){ol(t)}function El(t,o){try{var r=t.onUncaughtError;r(o.value,{componentStack:o.stack})}catch(u){setTimeout(function(){throw u})}}function dg(t,o,r){try{var u=t.onCaughtError;u(r.value,{componentStack:r.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function $d(t,o,r){return r=No(r),r.tag=3,r.payload={element:null},r.callback=function(){El(t,o)},r}function pg(t){return t=No(t),t.tag=3,t}function fg(t,o,r,u){var m=r.type.getDerivedStateFromError;if(typeof m=="function"){var y=u.value;t.payload=function(){return m(y)},t.callback=function(){dg(o,r,u)}}var C=r.stateNode;C!==null&&typeof C.componentDidCatch=="function"&&(t.callback=function(){dg(o,r,u),typeof m!="function"&&($o===null?$o=new Set([this]):$o.add(this));var R=u.stack;this.componentDidCatch(u.value,{componentStack:R!==null?R:""})})}function tw(t,o,r,u,m){if(r.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(o=r.alternate,o!==null&&cs(o,r,m,!0),r=Vt.current,r!==null){switch(r.tag){case 31:case 13:return ln===null?Il():r.alternate===null&&at===0&&(at=3),r.flags&=-257,r.flags|=65536,r.lanes=m,u===fl?r.flags|=16384:(o=r.updateQueue,o===null?r.updateQueue=new Set([u]):o.add(u),ip(t,u,m)),!1;case 22:return r.flags|=65536,u===fl?r.flags|=16384:(o=r.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([u])},r.updateQueue=o):(r=o.retryQueue,r===null?o.retryQueue=new Set([u]):r.add(u)),ip(t,u,m)),!1}throw Error(s(435,r.tag))}return ip(t,u,m),Il(),!1}if($e)return o=Vt.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=m,u!==td&&(t=Error(s(422),{cause:u}),fr(on(t,r)))):(u!==td&&(o=Error(s(423),{cause:u}),fr(on(o,r))),t=t.current.alternate,t.flags|=65536,m&=-m,t.lanes|=m,u=on(u,r),m=$d(t.stateNode,u,m),pd(t,m),at!==4&&(at=2)),!1;var y=Error(s(520),{cause:u});if(y=on(y,r),Dr===null?Dr=[y]:Dr.push(y),at!==4&&(at=2),o===null)return!0;u=on(u,r),r=o;do{switch(r.tag){case 3:return r.flags|=65536,t=m&-m,r.lanes|=t,t=$d(r.stateNode,u,t),pd(r,t),!1;case 1:if(o=r.type,y=r.stateNode,(r.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||y!==null&&typeof y.componentDidCatch=="function"&&($o===null||!$o.has(y))))return r.flags|=65536,m&=-m,r.lanes|=m,m=pg(m),fg(m,t,r,u),pd(r,m),!1}r=r.return}while(r!==null);return!1}var Fd=Error(s(461)),ut=!1;function Mt(t,o,r,u){o.child=t===null?yh(o,null,r,u):ka(o,t.child,r,u)}function mg(t,o,r,u,m){r=r.render;var y=o.ref;if("ref"in u){var C={};for(var R in u)R!=="ref"&&(C[R]=u[R])}else C=u;return ya(o),u=xd(t,o,r,C,y,m),R=bd(),t!==null&&!ut?(vd(t,o,m),eo(t,o,m)):($e&&R&&Ju(o),o.flags|=1,Mt(t,o,u,m),o.child)}function hg(t,o,r,u,m){if(t===null){var y=r.type;return typeof y=="function"&&!Xu(y)&&y.defaultProps===void 0&&r.compare===null?(o.tag=15,o.type=y,gg(t,o,y,u,m)):(t=il(r.type,null,u,o,o.mode,m),t.ref=o.ref,t.return=o,o.child=t)}if(y=t.child,!qd(t,m)){var C=y.memoizedProps;if(r=r.compare,r=r!==null?r:ur,r(C,u)&&t.ref===o.ref)return eo(t,o,m)}return o.flags|=1,t=Vn(y,u),t.ref=o.ref,t.return=o,o.child=t}function gg(t,o,r,u,m){if(t!==null){var y=t.memoizedProps;if(ur(y,u)&&t.ref===o.ref)if(ut=!1,o.pendingProps=u=y,qd(t,m))(t.flags&131072)!==0&&(ut=!0);else return o.lanes=t.lanes,eo(t,o,m)}return Id(t,o,r,u,m)}function yg(t,o,r,u){var m=u.children,y=t!==null?t.memoizedState:null;if(t===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((o.flags&128)!==0){if(y=y!==null?y.baseLanes|r:r,t!==null){for(u=o.child=t.child,m=0;u!==null;)m=m|u.lanes|u.childLanes,u=u.sibling;u=m&~y}else u=0,o.child=null;return xg(t,o,y,r,u)}if((r&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},t!==null&&dl(o,y!==null?y.cachePool:null),y!==null?vh(o,y):md(),kh(o);else return u=o.lanes=536870912,xg(t,o,y!==null?y.baseLanes|r:r,r,u)}else y!==null?(dl(o,y.cachePool),vh(o,y),Do(),o.memoizedState=null):(t!==null&&dl(o,null),md(),Do());return Mt(t,o,m,r),o.child}function Cr(t,o){return t!==null&&t.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function xg(t,o,r,u,m){var y=ld();return y=y===null?null:{parent:lt._currentValue,pool:y},o.memoizedState={baseLanes:r,cachePool:y},t!==null&&dl(o,null),md(),kh(o),t!==null&&cs(t,o,u,!0),o.childLanes=m,null}function jl(t,o){return o=Nl({mode:o.mode,children:o.children},t.mode),o.ref=t.ref,t.child=o,o.return=t,o}function bg(t,o,r){return ka(o,t.child,null,r),t=jl(o,o.pendingProps),t.flags|=2,Wt(o),o.memoizedState=null,t}function nw(t,o,r){var u=o.pendingProps,m=(o.flags&128)!==0;if(o.flags&=-129,t===null){if($e){if(u.mode==="hidden")return t=jl(o,u),o.lanes=536870912,Cr(null,t);if(gd(o),(t=Ze)?(t=_y(t,rn),t=t!==null&&t.data==="&"?t:null,t!==null&&(o.memoizedState={dehydrated:t,treeContext:Mo!==null?{id:Tn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},r=nh(t),r.return=o,o.child=r,wt=o,Ze=null)):t=null,t===null)throw Eo(o);return o.lanes=536870912,null}return jl(o,u)}var y=t.memoizedState;if(y!==null){var C=y.dehydrated;if(gd(o),m)if(o.flags&256)o.flags&=-257,o=bg(t,o,r);else if(o.memoizedState!==null)o.child=t.child,o.flags|=128,o=null;else throw Error(s(558));else if(ut||cs(t,o,r,!1),m=(r&t.childLanes)!==0,ut||m){if(u=Ve,u!==null&&(C=Li(u,r),C!==0&&C!==y.retryLane))throw y.retryLane=C,fa(t,C),Ht(u,t,C),Fd;Il(),o=bg(t,o,r)}else t=y.treeContext,Ze=cn(C.nextSibling),wt=o,$e=!0,Co=null,rn=!1,t!==null&&sh(o,t),o=jl(o,u),o.flags|=4096;return o}return t=Vn(t.child,{mode:u.mode,children:u.children}),t.ref=o.ref,o.child=t,t.return=o,t}function Tl(t,o){var r=o.ref;if(r===null)t!==null&&t.ref!==null&&(o.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(s(284));(t===null||t.ref!==r)&&(o.flags|=4194816)}}function Id(t,o,r,u,m){return ya(o),r=xd(t,o,r,u,void 0,m),u=bd(),t!==null&&!ut?(vd(t,o,m),eo(t,o,m)):($e&&u&&Ju(o),o.flags|=1,Mt(t,o,r,m),o.child)}function vg(t,o,r,u,m,y){return ya(o),o.updateQueue=null,r=Sh(o,u,r,m),wh(t),u=bd(),t!==null&&!ut?(vd(t,o,y),eo(t,o,y)):($e&&u&&Ju(o),o.flags|=1,Mt(t,o,r,y),o.child)}function kg(t,o,r,u,m){if(ya(o),o.stateNode===null){var y=ss,C=r.contextType;typeof C=="object"&&C!==null&&(y=St(C)),y=new r(u,y),o.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,y.updater=Od,o.stateNode=y,y._reactInternals=o,y=o.stateNode,y.props=u,y.state=o.memoizedState,y.refs={},ud(o),C=r.contextType,y.context=typeof C=="object"&&C!==null?St(C):ss,y.state=o.memoizedState,C=r.getDerivedStateFromProps,typeof C=="function"&&(Rd(o,r,C,u),y.state=o.memoizedState),typeof r.getDerivedStateFromProps=="function"||typeof y.getSnapshotBeforeUpdate=="function"||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(C=y.state,typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount(),C!==y.state&&Od.enqueueReplaceState(y,y.state,null),vr(o,u,y,m),br(),y.state=o.memoizedState),typeof y.componentDidMount=="function"&&(o.flags|=4194308),u=!0}else if(t===null){y=o.stateNode;var R=o.memoizedProps,Y=Sa(r,R);y.props=Y;var ne=y.context,le=r.contextType;C=ss,typeof le=="object"&&le!==null&&(C=St(le));var de=r.getDerivedStateFromProps;le=typeof de=="function"||typeof y.getSnapshotBeforeUpdate=="function",R=o.pendingProps!==R,le||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(R||ne!==C)&&ig(o,y,u,C),To=!1;var se=o.memoizedState;y.state=se,vr(o,u,y,m),br(),ne=o.memoizedState,R||se!==ne||To?(typeof de=="function"&&(Rd(o,r,de,u),ne=o.memoizedState),(Y=To||rg(o,r,Y,u,se,ne,C))?(le||typeof y.UNSAFE_componentWillMount!="function"&&typeof y.componentWillMount!="function"||(typeof y.componentWillMount=="function"&&y.componentWillMount(),typeof y.UNSAFE_componentWillMount=="function"&&y.UNSAFE_componentWillMount()),typeof y.componentDidMount=="function"&&(o.flags|=4194308)):(typeof y.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=u,o.memoizedState=ne),y.props=u,y.state=ne,y.context=C,u=Y):(typeof y.componentDidMount=="function"&&(o.flags|=4194308),u=!1)}else{y=o.stateNode,dd(t,o),C=o.memoizedProps,le=Sa(r,C),y.props=le,de=o.pendingProps,se=y.context,ne=r.contextType,Y=ss,typeof ne=="object"&&ne!==null&&(Y=St(ne)),R=r.getDerivedStateFromProps,(ne=typeof R=="function"||typeof y.getSnapshotBeforeUpdate=="function")||typeof y.UNSAFE_componentWillReceiveProps!="function"&&typeof y.componentWillReceiveProps!="function"||(C!==de||se!==Y)&&ig(o,y,u,Y),To=!1,se=o.memoizedState,y.state=se,vr(o,u,y,m),br();var ie=o.memoizedState;C!==de||se!==ie||To||t!==null&&t.dependencies!==null&&cl(t.dependencies)?(typeof R=="function"&&(Rd(o,r,R,u),ie=o.memoizedState),(le=To||rg(o,r,le,u,se,ie,Y)||t!==null&&t.dependencies!==null&&cl(t.dependencies))?(ne||typeof y.UNSAFE_componentWillUpdate!="function"&&typeof y.componentWillUpdate!="function"||(typeof y.componentWillUpdate=="function"&&y.componentWillUpdate(u,ie,Y),typeof y.UNSAFE_componentWillUpdate=="function"&&y.UNSAFE_componentWillUpdate(u,ie,Y)),typeof y.componentDidUpdate=="function"&&(o.flags|=4),typeof y.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof y.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(o.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(o.flags|=1024),o.memoizedProps=u,o.memoizedState=ie),y.props=u,y.state=ie,y.context=Y,u=le):(typeof y.componentDidUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(o.flags|=4),typeof y.getSnapshotBeforeUpdate!="function"||C===t.memoizedProps&&se===t.memoizedState||(o.flags|=1024),u=!1)}return y=u,Tl(t,o),u=(o.flags&128)!==0,y||u?(y=o.stateNode,r=u&&typeof r.getDerivedStateFromError!="function"?null:y.render(),o.flags|=1,t!==null&&u?(o.child=ka(o,t.child,null,m),o.child=ka(o,null,r,m)):Mt(t,o,r,m),o.memoizedState=y.state,t=o.child):t=eo(t,o,m),t}function wg(t,o,r,u){return ha(),o.flags|=256,Mt(t,o,r,u),o.child}var Ld={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bd(t){return{baseLanes:t,cachePool:dh()}}function Pd(t,o,r){return t=t!==null?t.childLanes&~r:0,o&&(t|=Zt),t}function Sg(t,o,r){var u=o.pendingProps,m=!1,y=(o.flags&128)!==0,C;if((C=y)||(C=t!==null&&t.memoizedState===null?!1:(st.current&2)!==0),C&&(m=!0,o.flags&=-129),C=(o.flags&32)!==0,o.flags&=-33,t===null){if($e){if(m?_o(o):Do(),(t=Ze)?(t=_y(t,rn),t=t!==null&&t.data!=="&"?t:null,t!==null&&(o.memoizedState={dehydrated:t,treeContext:Mo!==null?{id:Tn,overflow:Nn}:null,retryLane:536870912,hydrationErrors:null},r=nh(t),r.return=o,o.child=r,wt=o,Ze=null)):t=null,t===null)throw Eo(o);return Sp(t)?o.lanes=32:o.lanes=536870912,null}var R=u.children;return u=u.fallback,m?(Do(),m=o.mode,R=Nl({mode:"hidden",children:R},m),u=ma(u,m,r,null),R.return=o,u.return=o,R.sibling=u,o.child=R,u=o.child,u.memoizedState=Bd(r),u.childLanes=Pd(t,C,r),o.memoizedState=Ld,Cr(null,u)):(_o(o),Hd(o,R))}var Y=t.memoizedState;if(Y!==null&&(R=Y.dehydrated,R!==null)){if(y)o.flags&256?(_o(o),o.flags&=-257,o=Ud(t,o,r)):o.memoizedState!==null?(Do(),o.child=t.child,o.flags|=128,o=null):(Do(),R=u.fallback,m=o.mode,u=Nl({mode:"visible",children:u.children},m),R=ma(R,m,r,null),R.flags|=2,u.return=o,R.return=o,u.sibling=R,o.child=u,ka(o,t.child,null,r),u=o.child,u.memoizedState=Bd(r),u.childLanes=Pd(t,C,r),o.memoizedState=Ld,o=Cr(null,u));else if(_o(o),Sp(R)){if(C=R.nextSibling&&R.nextSibling.dataset,C)var ne=C.dgst;C=ne,u=Error(s(419)),u.stack="",u.digest=C,fr({value:u,source:null,stack:null}),o=Ud(t,o,r)}else if(ut||cs(t,o,r,!1),C=(r&t.childLanes)!==0,ut||C){if(C=Ve,C!==null&&(u=Li(C,r),u!==0&&u!==Y.retryLane))throw Y.retryLane=u,fa(t,u),Ht(C,t,u),Fd;wp(R)||Il(),o=Ud(t,o,r)}else wp(R)?(o.flags|=192,o.child=t.child,o=null):(t=Y.treeContext,Ze=cn(R.nextSibling),wt=o,$e=!0,Co=null,rn=!1,t!==null&&sh(o,t),o=Hd(o,u.children),o.flags|=4096);return o}return m?(Do(),R=u.fallback,m=o.mode,Y=t.child,ne=Y.sibling,u=Vn(Y,{mode:"hidden",children:u.children}),u.subtreeFlags=Y.subtreeFlags&65011712,ne!==null?R=Vn(ne,R):(R=ma(R,m,r,null),R.flags|=2),R.return=o,u.return=o,u.sibling=R,o.child=u,Cr(null,u),u=o.child,R=t.child.memoizedState,R===null?R=Bd(r):(m=R.cachePool,m!==null?(Y=lt._currentValue,m=m.parent!==Y?{parent:Y,pool:Y}:m):m=dh(),R={baseLanes:R.baseLanes|r,cachePool:m}),u.memoizedState=R,u.childLanes=Pd(t,C,r),o.memoizedState=Ld,Cr(t.child,u)):(_o(o),r=t.child,t=r.sibling,r=Vn(r,{mode:"visible",children:u.children}),r.return=o,r.sibling=null,t!==null&&(C=o.deletions,C===null?(o.deletions=[t],o.flags|=16):C.push(t)),o.child=r,o.memoizedState=null,r)}function Hd(t,o){return o=Nl({mode:"visible",children:o},t.mode),o.return=t,t.child=o}function Nl(t,o){return t=Yt(22,t,null,o),t.lanes=0,t}function Ud(t,o,r){return ka(o,t.child,null,r),t=Hd(o,o.pendingProps.children),t.flags|=2,o.memoizedState=null,t}function Mg(t,o,r){t.lanes|=o;var u=t.alternate;u!==null&&(u.lanes|=o),ad(t.return,o,r)}function Gd(t,o,r,u,m,y){var C=t.memoizedState;C===null?t.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:u,tail:r,tailMode:m,treeForkCount:y}:(C.isBackwards=o,C.rendering=null,C.renderingStartTime=0,C.last=u,C.tail=r,C.tailMode=m,C.treeForkCount=y)}function Cg(t,o,r){var u=o.pendingProps,m=u.revealOrder,y=u.tail;u=u.children;var C=st.current,R=(C&2)!==0;if(R?(C=C&1|2,o.flags|=128):C&=1,Z(st,C),Mt(t,o,u,r),u=$e?pr:0,!R&&t!==null&&(t.flags&128)!==0)e:for(t=o.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Mg(t,r,o);else if(t.tag===19)Mg(t,r,o);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===o)break e;for(;t.sibling===null;){if(t.return===null||t.return===o)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(m){case"forwards":for(r=o.child,m=null;r!==null;)t=r.alternate,t!==null&&yl(t)===null&&(m=r),r=r.sibling;r=m,r===null?(m=o.child,o.child=null):(m=r.sibling,r.sibling=null),Gd(o,!1,m,r,y,u);break;case"backwards":case"unstable_legacy-backwards":for(r=null,m=o.child,o.child=null;m!==null;){if(t=m.alternate,t!==null&&yl(t)===null){o.child=m;break}t=m.sibling,m.sibling=r,r=m,m=t}Gd(o,!0,r,null,y,u);break;case"together":Gd(o,!1,null,null,void 0,u);break;default:o.memoizedState=null}return o.child}function eo(t,o,r){if(t!==null&&(o.dependencies=t.dependencies),Oo|=o.lanes,(r&o.childLanes)===0)if(t!==null){if(cs(t,o,r,!1),(r&o.childLanes)===0)return null}else return null;if(t!==null&&o.child!==t.child)throw Error(s(153));if(o.child!==null){for(t=o.child,r=Vn(t,t.pendingProps),o.child=r,r.return=o;t.sibling!==null;)t=t.sibling,r=r.sibling=Vn(t,t.pendingProps),r.return=o;r.sibling=null}return o.child}function qd(t,o){return(t.lanes&o)!==0?!0:(t=t.dependencies,!!(t!==null&&cl(t)))}function ow(t,o,r){switch(o.tag){case 3:H(o,o.stateNode.containerInfo),jo(o,lt,t.memoizedState.cache),ha();break;case 27:case 5:Q(o);break;case 4:H(o,o.stateNode.containerInfo);break;case 10:jo(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,gd(o),null;break;case 13:var u=o.memoizedState;if(u!==null)return u.dehydrated!==null?(_o(o),o.flags|=128,null):(r&o.child.childLanes)!==0?Sg(t,o,r):(_o(o),t=eo(t,o,r),t!==null?t.sibling:null);_o(o);break;case 19:var m=(t.flags&128)!==0;if(u=(r&o.childLanes)!==0,u||(cs(t,o,r,!1),u=(r&o.childLanes)!==0),m){if(u)return Cg(t,o,r);o.flags|=128}if(m=o.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),Z(st,st.current),u)break;return null;case 22:return o.lanes=0,yg(t,o,r,o.pendingProps);case 24:jo(o,lt,t.memoizedState.cache)}return eo(t,o,r)}function Eg(t,o,r){if(t!==null)if(t.memoizedProps!==o.pendingProps)ut=!0;else{if(!qd(t,r)&&(o.flags&128)===0)return ut=!1,ow(t,o,r);ut=(t.flags&131072)!==0}else ut=!1,$e&&(o.flags&1048576)!==0&&ah(o,pr,o.index);switch(o.lanes=0,o.tag){case 16:e:{var u=o.pendingProps;if(t=ba(o.elementType),o.type=t,typeof t=="function")Xu(t)?(u=Sa(t,u),o.tag=1,o=kg(null,o,t,u,r)):(o.tag=0,o=Id(null,o,t,u,r));else{if(t!=null){var m=t.$$typeof;if(m===M){o.tag=11,o=mg(null,o,t,u,r);break e}else if(m===_){o.tag=14,o=hg(null,o,t,u,r);break e}}throw o=P(t)||t,Error(s(306,o,""))}}return o;case 0:return Id(t,o,o.type,o.pendingProps,r);case 1:return u=o.type,m=Sa(u,o.pendingProps),kg(t,o,u,m,r);case 3:e:{if(H(o,o.stateNode.containerInfo),t===null)throw Error(s(387));u=o.pendingProps;var y=o.memoizedState;m=y.element,dd(t,o),vr(o,u,null,r);var C=o.memoizedState;if(u=C.cache,jo(o,lt,u),u!==y.cache&&sd(o,[lt],r,!0),br(),u=C.element,y.isDehydrated)if(y={element:u,isDehydrated:!1,cache:C.cache},o.updateQueue.baseState=y,o.memoizedState=y,o.flags&256){o=wg(t,o,u,r);break e}else if(u!==m){m=on(Error(s(424)),o),fr(m),o=wg(t,o,u,r);break e}else for(t=o.stateNode.containerInfo,t.nodeType===9?t=t.body:t=t.nodeName==="HTML"?t.ownerDocument.body:t,Ze=cn(t.firstChild),wt=o,$e=!0,Co=null,rn=!0,r=yh(o,null,u,r),o.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(ha(),u===m){o=eo(t,o,r);break e}Mt(t,o,u,r)}o=o.child}return o;case 26:return Tl(t,o),t===null?(r=Fy(o.type,null,o.pendingProps,null))?o.memoizedState=r:$e||(r=o.type,t=o.pendingProps,u=ql(me.current).createElement(r),u[ht]=o,u[At]=t,Ct(u,r,t),it(u),o.stateNode=u):o.memoizedState=Fy(o.type,t.memoizedProps,o.pendingProps,t.memoizedState),null;case 27:return Q(o),t===null&&$e&&(u=o.stateNode=Ry(o.type,o.pendingProps,me.current),wt=o,rn=!0,m=Ze,Bo(o.type)?(Mp=m,Ze=cn(u.firstChild)):Ze=m),Mt(t,o,o.pendingProps.children,r),Tl(t,o),t===null&&(o.flags|=4194304),o.child;case 5:return t===null&&$e&&((m=u=Ze)&&(u=zw(u,o.type,o.pendingProps,rn),u!==null?(o.stateNode=u,wt=o,Ze=cn(u.firstChild),rn=!1,m=!0):m=!1),m||Eo(o)),Q(o),m=o.type,y=o.pendingProps,C=t!==null?t.memoizedProps:null,u=y.children,bp(m,y)?u=null:C!==null&&bp(m,C)&&(o.flags|=32),o.memoizedState!==null&&(m=xd(t,o,Vk,null,null,r),Br._currentValue=m),Tl(t,o),Mt(t,o,u,r),o.child;case 6:return t===null&&$e&&((t=r=Ze)&&(r=Rw(r,o.pendingProps,rn),r!==null?(o.stateNode=r,wt=o,Ze=null,t=!0):t=!1),t||Eo(o)),null;case 13:return Sg(t,o,r);case 4:return H(o,o.stateNode.containerInfo),u=o.pendingProps,t===null?o.child=ka(o,null,u,r):Mt(t,o,u,r),o.child;case 11:return mg(t,o,o.type,o.pendingProps,r);case 7:return Mt(t,o,o.pendingProps,r),o.child;case 8:return Mt(t,o,o.pendingProps.children,r),o.child;case 12:return Mt(t,o,o.pendingProps.children,r),o.child;case 10:return u=o.pendingProps,jo(o,o.type,u.value),Mt(t,o,u.children,r),o.child;case 9:return m=o.type._context,u=o.pendingProps.children,ya(o),m=St(m),u=u(m),o.flags|=1,Mt(t,o,u,r),o.child;case 14:return hg(t,o,o.type,o.pendingProps,r);case 15:return gg(t,o,o.type,o.pendingProps,r);case 19:return Cg(t,o,r);case 31:return nw(t,o,r);case 22:return yg(t,o,r,o.pendingProps);case 24:return ya(o),u=St(lt),t===null?(m=ld(),m===null&&(m=Ve,y=rd(),m.pooledCache=y,y.refCount++,y!==null&&(m.pooledCacheLanes|=r),m=y),o.memoizedState={parent:u,cache:m},ud(o),jo(o,lt,m)):((t.lanes&r)!==0&&(dd(t,o),vr(o,null,null,r),br()),m=t.memoizedState,y=o.memoizedState,m.parent!==u?(m={parent:u,cache:u},o.memoizedState=m,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=m),jo(o,lt,u)):(u=y.cache,jo(o,lt,u),u!==m.cache&&sd(o,[lt],r,!0))),Mt(t,o,o.pendingProps.children,r),o.child;case 29:throw o.pendingProps}throw Error(s(156,o.tag))}function to(t){t.flags|=4}function Kd(t,o,r,u,m){if((o=(t.mode&32)!==0)&&(o=!1),o){if(t.flags|=16777216,(m&335544128)===m)if(t.stateNode.complete)t.flags|=8192;else if(Jg())t.flags|=8192;else throw va=fl,cd}else t.flags&=-16777217}function jg(t,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Hy(o))if(Jg())t.flags|=8192;else throw va=fl,cd}function Al(t,o){o!==null&&(t.flags|=4),t.flags&16384&&(o=t.tag!==22?$i():536870912,t.lanes|=o,ks|=o)}function Er(t,o){if(!$e)switch(t.tailMode){case"hidden":o=t.tail;for(var r=null;o!==null;)o.alternate!==null&&(r=o),o=o.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var u=null;r!==null;)r.alternate!==null&&(u=r),r=r.sibling;u===null?o||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null}}function Qe(t){var o=t.alternate!==null&&t.alternate.child===t.child,r=0,u=0;if(o)for(var m=t.child;m!==null;)r|=m.lanes|m.childLanes,u|=m.subtreeFlags&65011712,u|=m.flags&65011712,m.return=t,m=m.sibling;else for(m=t.child;m!==null;)r|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=t,m=m.sibling;return t.subtreeFlags|=u,t.childLanes=r,o}function aw(t,o,r){var u=o.pendingProps;switch(ed(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Qe(o),null;case 1:return Qe(o),null;case 3:return r=o.stateNode,u=null,t!==null&&(u=t.memoizedState.cache),o.memoizedState.cache!==u&&(o.flags|=2048),Zn(lt),ce(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(ls(o)?to(o):t===null||t.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,nd())),Qe(o),null;case 26:var m=o.type,y=o.memoizedState;return t===null?(to(o),y!==null?(Qe(o),jg(o,y)):(Qe(o),Kd(o,m,null,u,r))):y?y!==t.memoizedState?(to(o),Qe(o),jg(o,y)):(Qe(o),o.flags&=-16777217):(t=t.memoizedProps,t!==u&&to(o),Qe(o),Kd(o,m,t,u,r)),null;case 27:if(ge(o),r=me.current,m=o.type,t!==null&&o.stateNode!=null)t.memoizedProps!==u&&to(o);else{if(!u){if(o.stateNode===null)throw Error(s(166));return Qe(o),null}t=ae.current,ls(o)?rh(o):(t=Ry(m,u,r),o.stateNode=t,to(o))}return Qe(o),null;case 5:if(ge(o),m=o.type,t!==null&&o.stateNode!=null)t.memoizedProps!==u&&to(o);else{if(!u){if(o.stateNode===null)throw Error(s(166));return Qe(o),null}if(y=ae.current,ls(o))rh(o);else{var C=ql(me.current);switch(y){case 1:y=C.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:y=C.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":y=C.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":y=C.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":y=C.createElement("div"),y.innerHTML="<script><\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof u.is=="string"?C.createElement("select",{is:u.is}):C.createElement("select"),u.multiple?y.multiple=!0:u.size&&(y.size=u.size);break;default:y=typeof u.is=="string"?C.createElement(m,{is:u.is}):C.createElement(m)}}y[ht]=o,y[At]=u;e:for(C=o.child;C!==null;){if(C.tag===5||C.tag===6)y.appendChild(C.stateNode);else if(C.tag!==4&&C.tag!==27&&C.child!==null){C.child.return=C,C=C.child;continue}if(C===o)break e;for(;C.sibling===null;){if(C.return===null||C.return===o)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}o.stateNode=y;e:switch(Ct(y,m,u),m){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&to(o)}}return Qe(o),Kd(o,o.type,t===null?null:t.memoizedProps,o.pendingProps,r),null;case 6:if(t&&o.stateNode!=null)t.memoizedProps!==u&&to(o);else{if(typeof u!="string"&&o.stateNode===null)throw Error(s(166));if(t=me.current,ls(o)){if(t=o.stateNode,r=o.memoizedProps,u=null,m=wt,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}t[ht]=o,t=!!(t.nodeValue===r||u!==null&&u.suppressHydrationWarning===!0||Sy(t.nodeValue,r)),t||Eo(o,!0)}else t=ql(t).createTextNode(u),t[ht]=o,o.stateNode=t}return Qe(o),null;case 31:if(r=o.memoizedState,t===null||t.memoizedState!==null){if(u=ls(o),r!==null){if(t===null){if(!u)throw Error(s(318));if(t=o.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[ht]=o}else ha(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Qe(o),t=!1}else r=nd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=r),t=!0;if(!t)return o.flags&256?(Wt(o),o):(Wt(o),null);if((o.flags&128)!==0)throw Error(s(558))}return Qe(o),null;case 13:if(u=o.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(m=ls(o),u!==null&&u.dehydrated!==null){if(t===null){if(!m)throw Error(s(318));if(m=o.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(s(317));m[ht]=o}else ha(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;Qe(o),m=!1}else m=nd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=m),m=!0;if(!m)return o.flags&256?(Wt(o),o):(Wt(o),null)}return Wt(o),(o.flags&128)!==0?(o.lanes=r,o):(r=u!==null,t=t!==null&&t.memoizedState!==null,r&&(u=o.child,m=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(m=u.alternate.memoizedState.cachePool.pool),y=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(y=u.memoizedState.cachePool.pool),y!==m&&(u.flags|=2048)),r!==t&&r&&(o.child.flags|=8192),Al(o,o.updateQueue),Qe(o),null);case 4:return ce(),t===null&&mp(o.stateNode.containerInfo),Qe(o),null;case 10:return Zn(o.type),Qe(o),null;case 19:if(L(st),u=o.memoizedState,u===null)return Qe(o),null;if(m=(o.flags&128)!==0,y=u.rendering,y===null)if(m)Er(u,!1);else{if(at!==0||t!==null&&(t.flags&128)!==0)for(t=o.child;t!==null;){if(y=yl(t),y!==null){for(o.flags|=128,Er(u,!1),t=y.updateQueue,o.updateQueue=t,Al(o,t),o.subtreeFlags=0,t=r,r=o.child;r!==null;)th(r,t),r=r.sibling;return Z(st,st.current&1|2),$e&&Wn(o,u.treeForkCount),o.child}t=t.sibling}u.tail!==null&&kt()>Ol&&(o.flags|=128,m=!0,Er(u,!1),o.lanes=4194304)}else{if(!m)if(t=yl(y),t!==null){if(o.flags|=128,m=!0,t=t.updateQueue,o.updateQueue=t,Al(o,t),Er(u,!0),u.tail===null&&u.tailMode==="hidden"&&!y.alternate&&!$e)return Qe(o),null}else 2*kt()-u.renderingStartTime>Ol&&r!==536870912&&(o.flags|=128,m=!0,Er(u,!1),o.lanes=4194304);u.isBackwards?(y.sibling=o.child,o.child=y):(t=u.last,t!==null?t.sibling=y:o.child=y,u.last=y)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=kt(),t.sibling=null,r=st.current,Z(st,m?r&1|2:r&1),$e&&Wn(o,u.treeForkCount),t):(Qe(o),null);case 22:case 23:return Wt(o),hd(),u=o.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(o.flags|=8192):u&&(o.flags|=8192),u?(r&536870912)!==0&&(o.flags&128)===0&&(Qe(o),o.subtreeFlags&6&&(o.flags|=8192)):Qe(o),r=o.updateQueue,r!==null&&Al(o,r.retryQueue),r=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),u=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(u=o.memoizedState.cachePool.pool),u!==r&&(o.flags|=2048),t!==null&&L(xa),null;case 24:return r=null,t!==null&&(r=t.memoizedState.cache),o.memoizedState.cache!==r&&(o.flags|=2048),Zn(lt),Qe(o),null;case 25:return null;case 30:return null}throw Error(s(156,o.tag))}function sw(t,o){switch(ed(o),o.tag){case 1:return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 3:return Zn(lt),ce(),t=o.flags,(t&65536)!==0&&(t&128)===0?(o.flags=t&-65537|128,o):null;case 26:case 27:case 5:return ge(o),null;case 31:if(o.memoizedState!==null){if(Wt(o),o.alternate===null)throw Error(s(340));ha()}return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 13:if(Wt(o),t=o.memoizedState,t!==null&&t.dehydrated!==null){if(o.alternate===null)throw Error(s(340));ha()}return t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 19:return L(st),null;case 4:return ce(),null;case 10:return Zn(o.type),null;case 22:case 23:return Wt(o),hd(),t!==null&&L(xa),t=o.flags,t&65536?(o.flags=t&-65537|128,o):null;case 24:return Zn(lt),null;case 25:return null;default:return null}}function Tg(t,o){switch(ed(o),o.tag){case 3:Zn(lt),ce();break;case 26:case 27:case 5:ge(o);break;case 4:ce();break;case 31:o.memoizedState!==null&&Wt(o);break;case 13:Wt(o);break;case 19:L(st);break;case 10:Zn(o.type);break;case 22:case 23:Wt(o),hd(),t!==null&&L(xa);break;case 24:Zn(lt)}}function jr(t,o){try{var r=o.updateQueue,u=r!==null?r.lastEffect:null;if(u!==null){var m=u.next;r=m;do{if((r.tag&t)===t){u=void 0;var y=r.create,C=r.inst;u=y(),C.destroy=u}r=r.next}while(r!==m)}}catch(R){Ue(o,o.return,R)}}function zo(t,o,r){try{var u=o.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var y=m.next;u=y;do{if((u.tag&t)===t){var C=u.inst,R=C.destroy;if(R!==void 0){C.destroy=void 0,m=o;var Y=r,ne=R;try{ne()}catch(le){Ue(m,Y,le)}}}u=u.next}while(u!==y)}}catch(le){Ue(o,o.return,le)}}function Ng(t){var o=t.updateQueue;if(o!==null){var r=t.stateNode;try{bh(o,r)}catch(u){Ue(t,t.return,u)}}}function Ag(t,o,r){r.props=Sa(t.type,t.memoizedProps),r.state=t.memoizedState;try{r.componentWillUnmount()}catch(u){Ue(t,o,u)}}function Tr(t,o){try{var r=t.ref;if(r!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof r=="function"?t.refCleanup=r(u):r.current=u}}catch(m){Ue(t,o,m)}}function An(t,o){var r=t.ref,u=t.refCleanup;if(r!==null)if(typeof u=="function")try{u()}catch(m){Ue(t,o,m)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(m){Ue(t,o,m)}else r.current=null}function _g(t){var o=t.type,r=t.memoizedProps,u=t.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":r.autoFocus&&u.focus();break e;case"img":r.src?u.src=r.src:r.srcSet&&(u.srcset=r.srcSet)}}catch(m){Ue(t,t.return,m)}}function Yd(t,o,r){try{var u=t.stateNode;jw(u,t.type,r,o),u[At]=o}catch(m){Ue(t,t.return,m)}}function Dg(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Bo(t.type)||t.tag===4}function Vd(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Dg(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Bo(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Wd(t,o,r){var u=t.tag;if(u===5||u===6)t=t.stateNode,o?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(t,o):(o=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,o.appendChild(t),r=r._reactRootContainer,r!=null||o.onclick!==null||(o.onclick=Kn));else if(u!==4&&(u===27&&Bo(t.type)&&(r=t.stateNode,o=null),t=t.child,t!==null))for(Wd(t,o,r),t=t.sibling;t!==null;)Wd(t,o,r),t=t.sibling}function _l(t,o,r){var u=t.tag;if(u===5||u===6)t=t.stateNode,o?r.insertBefore(t,o):r.appendChild(t);else if(u!==4&&(u===27&&Bo(t.type)&&(r=t.stateNode),t=t.child,t!==null))for(_l(t,o,r),t=t.sibling;t!==null;)_l(t,o,r),t=t.sibling}function zg(t){var o=t.stateNode,r=t.memoizedProps;try{for(var u=t.type,m=o.attributes;m.length;)o.removeAttributeNode(m[0]);Ct(o,u,r),o[ht]=t,o[At]=r}catch(y){Ue(t,t.return,y)}}var no=!1,dt=!1,Xd=!1,Rg=typeof WeakSet=="function"?WeakSet:Set,xt=null;function rw(t,o){if(t=t.containerInfo,yp=Ql,t=Km(t),Uu(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var u=r.getSelection&&r.getSelection();if(u&&u.rangeCount!==0){r=u.anchorNode;var m=u.anchorOffset,y=u.focusNode;u=u.focusOffset;try{r.nodeType,y.nodeType}catch{r=null;break e}var C=0,R=-1,Y=-1,ne=0,le=0,de=t,se=null;t:for(;;){for(var ie;de!==r||m!==0&&de.nodeType!==3||(R=C+m),de!==y||u!==0&&de.nodeType!==3||(Y=C+u),de.nodeType===3&&(C+=de.nodeValue.length),(ie=de.firstChild)!==null;)se=de,de=ie;for(;;){if(de===t)break t;if(se===r&&++ne===m&&(R=C),se===y&&++le===u&&(Y=C),(ie=de.nextSibling)!==null)break;de=se,se=de.parentNode}de=ie}r=R===-1||Y===-1?null:{start:R,end:Y}}else r=null}r=r||{start:0,end:0}}else r=null;for(xp={focusedElem:t,selectionRange:r},Ql=!1,xt=o;xt!==null;)if(o=xt,t=o.child,(o.subtreeFlags&1028)!==0&&t!==null)t.return=o,xt=t;else for(;xt!==null;){switch(o=xt,y=o.alternate,t=o.flags,o.tag){case 0:if((t&4)!==0&&(t=o.updateQueue,t=t!==null?t.events:null,t!==null))for(r=0;r<t.length;r++)m=t[r],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((t&1024)!==0&&y!==null){t=void 0,r=o,m=y.memoizedProps,y=y.memoizedState,u=r.stateNode;try{var be=Sa(r.type,m);t=u.getSnapshotBeforeUpdate(be,y),u.__reactInternalSnapshotBeforeUpdate=t}catch(Ce){Ue(r,r.return,Ce)}}break;case 3:if((t&1024)!==0){if(t=o.stateNode.containerInfo,r=t.nodeType,r===9)kp(t);else if(r===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":kp(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(s(163))}if(t=o.sibling,t!==null){t.return=o.return,xt=t;break}xt=o.return}}function Og(t,o,r){var u=r.flags;switch(r.tag){case 0:case 11:case 15:ao(t,r),u&4&&jr(5,r);break;case 1:if(ao(t,r),u&4)if(t=r.stateNode,o===null)try{t.componentDidMount()}catch(C){Ue(r,r.return,C)}else{var m=Sa(r.type,o.memoizedProps);o=o.memoizedState;try{t.componentDidUpdate(m,o,t.__reactInternalSnapshotBeforeUpdate)}catch(C){Ue(r,r.return,C)}}u&64&&Ng(r),u&512&&Tr(r,r.return);break;case 3:if(ao(t,r),u&64&&(t=r.updateQueue,t!==null)){if(o=null,r.child!==null)switch(r.child.tag){case 27:case 5:o=r.child.stateNode;break;case 1:o=r.child.stateNode}try{bh(t,o)}catch(C){Ue(r,r.return,C)}}break;case 27:o===null&&u&4&&zg(r);case 26:case 5:ao(t,r),o===null&&u&4&&_g(r),u&512&&Tr(r,r.return);break;case 12:ao(t,r);break;case 31:ao(t,r),u&4&&Ig(t,r);break;case 13:ao(t,r),u&4&&Lg(t,r),u&64&&(t=r.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(r=hw.bind(null,r),Ow(t,r))));break;case 22:if(u=r.memoizedState!==null||no,!u){o=o!==null&&o.memoizedState!==null||dt,m=no;var y=dt;no=u,(dt=o)&&!y?so(t,r,(r.subtreeFlags&8772)!==0):ao(t,r),no=m,dt=y}break;case 30:break;default:ao(t,r)}}function $g(t){var o=t.alternate;o!==null&&(t.alternate=null,$g(o)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(o=t.stateNode,o!==null&&er(o)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var et=null,It=!1;function oo(t,o,r){for(r=r.child;r!==null;)Fg(t,o,r),r=r.sibling}function Fg(t,o,r){if(Dt&&typeof Dt.onCommitFiberUnmount=="function")try{Dt.onCommitFiberUnmount(aa,r)}catch{}switch(r.tag){case 26:dt||An(r,o),oo(t,o,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:dt||An(r,o);var u=et,m=It;Bo(r.type)&&(et=r.stateNode,It=!1),oo(t,o,r),Fr(r.stateNode),et=u,It=m;break;case 5:dt||An(r,o);case 6:if(u=et,m=It,et=null,oo(t,o,r),et=u,It=m,et!==null)if(It)try{(et.nodeType===9?et.body:et.nodeName==="HTML"?et.ownerDocument.body:et).removeChild(r.stateNode)}catch(y){Ue(r,o,y)}else try{et.removeChild(r.stateNode)}catch(y){Ue(r,o,y)}break;case 18:et!==null&&(It?(t=et,Ny(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,r.stateNode),Ns(t)):Ny(et,r.stateNode));break;case 4:u=et,m=It,et=r.stateNode.containerInfo,It=!0,oo(t,o,r),et=u,It=m;break;case 0:case 11:case 14:case 15:zo(2,r,o),dt||zo(4,r,o),oo(t,o,r);break;case 1:dt||(An(r,o),u=r.stateNode,typeof u.componentWillUnmount=="function"&&Ag(r,o,u)),oo(t,o,r);break;case 21:oo(t,o,r);break;case 22:dt=(u=dt)||r.memoizedState!==null,oo(t,o,r),dt=u;break;default:oo(t,o,r)}}function Ig(t,o){if(o.memoizedState===null&&(t=o.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{Ns(t)}catch(r){Ue(o,o.return,r)}}}function Lg(t,o){if(o.memoizedState===null&&(t=o.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Ns(t)}catch(r){Ue(o,o.return,r)}}function iw(t){switch(t.tag){case 31:case 13:case 19:var o=t.stateNode;return o===null&&(o=t.stateNode=new Rg),o;case 22:return t=t.stateNode,o=t._retryCache,o===null&&(o=t._retryCache=new Rg),o;default:throw Error(s(435,t.tag))}}function Dl(t,o){var r=iw(t);o.forEach(function(u){if(!r.has(u)){r.add(u);var m=gw.bind(null,t,u);u.then(m,m)}})}function Lt(t,o){var r=o.deletions;if(r!==null)for(var u=0;u<r.length;u++){var m=r[u],y=t,C=o,R=C;e:for(;R!==null;){switch(R.tag){case 27:if(Bo(R.type)){et=R.stateNode,It=!1;break e}break;case 5:et=R.stateNode,It=!1;break e;case 3:case 4:et=R.stateNode.containerInfo,It=!0;break e}R=R.return}if(et===null)throw Error(s(160));Fg(y,C,m),et=null,It=!1,y=m.alternate,y!==null&&(y.return=null),m.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)Bg(o,t),o=o.sibling}var xn=null;function Bg(t,o){var r=t.alternate,u=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:Lt(o,t),Bt(t),u&4&&(zo(3,t,t.return),jr(3,t),zo(5,t,t.return));break;case 1:Lt(o,t),Bt(t),u&512&&(dt||r===null||An(r,r.return)),u&64&&no&&(t=t.updateQueue,t!==null&&(u=t.callbacks,u!==null&&(r=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=r===null?u:r.concat(u))));break;case 26:var m=xn;if(Lt(o,t),Bt(t),u&512&&(dt||r===null||An(r,r.return)),u&4){var y=r!==null?r.memoizedState:null;if(u=t.memoizedState,r===null)if(u===null)if(t.stateNode===null){e:{u=t.type,r=t.memoizedProps,m=m.ownerDocument||m;t:switch(u){case"title":y=m.getElementsByTagName("title")[0],(!y||y[ia]||y[ht]||y.namespaceURI==="http://www.w3.org/2000/svg"||y.hasAttribute("itemprop"))&&(y=m.createElement(u),m.head.insertBefore(y,m.querySelector("head > title"))),Ct(y,u,r),y[ht]=t,it(y),u=y;break e;case"link":var C=By("link","href",m).get(u+(r.href||""));if(C){for(var R=0;R<C.length;R++)if(y=C[R],y.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&y.getAttribute("rel")===(r.rel==null?null:r.rel)&&y.getAttribute("title")===(r.title==null?null:r.title)&&y.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){C.splice(R,1);break t}}y=m.createElement(u),Ct(y,u,r),m.head.appendChild(y);break;case"meta":if(C=By("meta","content",m).get(u+(r.content||""))){for(R=0;R<C.length;R++)if(y=C[R],y.getAttribute("content")===(r.content==null?null:""+r.content)&&y.getAttribute("name")===(r.name==null?null:r.name)&&y.getAttribute("property")===(r.property==null?null:r.property)&&y.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&y.getAttribute("charset")===(r.charSet==null?null:r.charSet)){C.splice(R,1);break t}}y=m.createElement(u),Ct(y,u,r),m.head.appendChild(y);break;default:throw Error(s(468,u))}y[ht]=t,it(y),u=y}t.stateNode=u}else Py(m,t.type,t.stateNode);else t.stateNode=Ly(m,u,t.memoizedProps);else y!==u?(y===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):y.count--,u===null?Py(m,t.type,t.stateNode):Ly(m,u,t.memoizedProps)):u===null&&t.stateNode!==null&&Yd(t,t.memoizedProps,r.memoizedProps)}break;case 27:Lt(o,t),Bt(t),u&512&&(dt||r===null||An(r,r.return)),r!==null&&u&4&&Yd(t,t.memoizedProps,r.memoizedProps);break;case 5:if(Lt(o,t),Bt(t),u&512&&(dt||r===null||An(r,r.return)),t.flags&32){m=t.stateNode;try{Qa(m,"")}catch(be){Ue(t,t.return,be)}}u&4&&t.stateNode!=null&&(m=t.memoizedProps,Yd(t,m,r!==null?r.memoizedProps:m)),u&1024&&(Xd=!0);break;case 6:if(Lt(o,t),Bt(t),u&4){if(t.stateNode===null)throw Error(s(162));u=t.memoizedProps,r=t.stateNode;try{r.nodeValue=u}catch(be){Ue(t,t.return,be)}}break;case 3:if(Vl=null,m=xn,xn=Kl(o.containerInfo),Lt(o,t),xn=m,Bt(t),u&4&&r!==null&&r.memoizedState.isDehydrated)try{Ns(o.containerInfo)}catch(be){Ue(t,t.return,be)}Xd&&(Xd=!1,Pg(t));break;case 4:u=xn,xn=Kl(t.stateNode.containerInfo),Lt(o,t),Bt(t),xn=u;break;case 12:Lt(o,t),Bt(t);break;case 31:Lt(o,t),Bt(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,Dl(t,u)));break;case 13:Lt(o,t),Bt(t),t.child.flags&8192&&t.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Rl=kt()),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,Dl(t,u)));break;case 22:m=t.memoizedState!==null;var Y=r!==null&&r.memoizedState!==null,ne=no,le=dt;if(no=ne||m,dt=le||Y,Lt(o,t),dt=le,no=ne,Bt(t),u&8192)e:for(o=t.stateNode,o._visibility=m?o._visibility&-2:o._visibility|1,m&&(r===null||Y||no||dt||Ma(t)),r=null,o=t;;){if(o.tag===5||o.tag===26){if(r===null){Y=r=o;try{if(y=Y.stateNode,m)C=y.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none";else{R=Y.stateNode;var de=Y.memoizedProps.style,se=de!=null&&de.hasOwnProperty("display")?de.display:null;R.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(be){Ue(Y,Y.return,be)}}}else if(o.tag===6){if(r===null){Y=o;try{Y.stateNode.nodeValue=m?"":Y.memoizedProps}catch(be){Ue(Y,Y.return,be)}}}else if(o.tag===18){if(r===null){Y=o;try{var ie=Y.stateNode;m?Ay(ie,!0):Ay(Y.stateNode,!1)}catch(be){Ue(Y,Y.return,be)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===t)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===t)break e;for(;o.sibling===null;){if(o.return===null||o.return===t)break e;r===o&&(r=null),o=o.return}r===o&&(r=null),o.sibling.return=o.return,o=o.sibling}u&4&&(u=t.updateQueue,u!==null&&(r=u.retryQueue,r!==null&&(u.retryQueue=null,Dl(t,r))));break;case 19:Lt(o,t),Bt(t),u&4&&(u=t.updateQueue,u!==null&&(t.updateQueue=null,Dl(t,u)));break;case 30:break;case 21:break;default:Lt(o,t),Bt(t)}}function Bt(t){var o=t.flags;if(o&2){try{for(var r,u=t.return;u!==null;){if(Dg(u)){r=u;break}u=u.return}if(r==null)throw Error(s(160));switch(r.tag){case 27:var m=r.stateNode,y=Vd(t);_l(t,y,m);break;case 5:var C=r.stateNode;r.flags&32&&(Qa(C,""),r.flags&=-33);var R=Vd(t);_l(t,R,C);break;case 3:case 4:var Y=r.stateNode.containerInfo,ne=Vd(t);Wd(t,ne,Y);break;default:throw Error(s(161))}}catch(le){Ue(t,t.return,le)}t.flags&=-3}o&4096&&(t.flags&=-4097)}function Pg(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var o=t;Pg(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),t=t.sibling}}function ao(t,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)Og(t,o.alternate,o),o=o.sibling}function Ma(t){for(t=t.child;t!==null;){var o=t;switch(o.tag){case 0:case 11:case 14:case 15:zo(4,o,o.return),Ma(o);break;case 1:An(o,o.return);var r=o.stateNode;typeof r.componentWillUnmount=="function"&&Ag(o,o.return,r),Ma(o);break;case 27:Fr(o.stateNode);case 26:case 5:An(o,o.return),Ma(o);break;case 22:o.memoizedState===null&&Ma(o);break;case 30:Ma(o);break;default:Ma(o)}t=t.sibling}}function so(t,o,r){for(r=r&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var u=o.alternate,m=t,y=o,C=y.flags;switch(y.tag){case 0:case 11:case 15:so(m,y,r),jr(4,y);break;case 1:if(so(m,y,r),u=y,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(ne){Ue(u,u.return,ne)}if(u=y,m=u.updateQueue,m!==null){var R=u.stateNode;try{var Y=m.shared.hiddenCallbacks;if(Y!==null)for(m.shared.hiddenCallbacks=null,m=0;m<Y.length;m++)xh(Y[m],R)}catch(ne){Ue(u,u.return,ne)}}r&&C&64&&Ng(y),Tr(y,y.return);break;case 27:zg(y);case 26:case 5:so(m,y,r),r&&u===null&&C&4&&_g(y),Tr(y,y.return);break;case 12:so(m,y,r);break;case 31:so(m,y,r),r&&C&4&&Ig(m,y);break;case 13:so(m,y,r),r&&C&4&&Lg(m,y);break;case 22:y.memoizedState===null&&so(m,y,r),Tr(y,y.return);break;case 30:break;default:so(m,y,r)}o=o.sibling}}function Zd(t,o){var r=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),t=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(t=o.memoizedState.cachePool.pool),t!==r&&(t!=null&&t.refCount++,r!=null&&mr(r))}function Qd(t,o){t=null,o.alternate!==null&&(t=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==t&&(o.refCount++,t!=null&&mr(t))}function bn(t,o,r,u){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)Hg(t,o,r,u),o=o.sibling}function Hg(t,o,r,u){var m=o.flags;switch(o.tag){case 0:case 11:case 15:bn(t,o,r,u),m&2048&&jr(9,o);break;case 1:bn(t,o,r,u);break;case 3:bn(t,o,r,u),m&2048&&(t=null,o.alternate!==null&&(t=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==t&&(o.refCount++,t!=null&&mr(t)));break;case 12:if(m&2048){bn(t,o,r,u),t=o.stateNode;try{var y=o.memoizedProps,C=y.id,R=y.onPostCommit;typeof R=="function"&&R(C,o.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(Y){Ue(o,o.return,Y)}}else bn(t,o,r,u);break;case 31:bn(t,o,r,u);break;case 13:bn(t,o,r,u);break;case 23:break;case 22:y=o.stateNode,C=o.alternate,o.memoizedState!==null?y._visibility&2?bn(t,o,r,u):Nr(t,o):y._visibility&2?bn(t,o,r,u):(y._visibility|=2,xs(t,o,r,u,(o.subtreeFlags&10256)!==0||!1)),m&2048&&Zd(C,o);break;case 24:bn(t,o,r,u),m&2048&&Qd(o.alternate,o);break;default:bn(t,o,r,u)}}function xs(t,o,r,u,m){for(m=m&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var y=t,C=o,R=r,Y=u,ne=C.flags;switch(C.tag){case 0:case 11:case 15:xs(y,C,R,Y,m),jr(8,C);break;case 23:break;case 22:var le=C.stateNode;C.memoizedState!==null?le._visibility&2?xs(y,C,R,Y,m):Nr(y,C):(le._visibility|=2,xs(y,C,R,Y,m)),m&&ne&2048&&Zd(C.alternate,C);break;case 24:xs(y,C,R,Y,m),m&&ne&2048&&Qd(C.alternate,C);break;default:xs(y,C,R,Y,m)}o=o.sibling}}function Nr(t,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var r=t,u=o,m=u.flags;switch(u.tag){case 22:Nr(r,u),m&2048&&Zd(u.alternate,u);break;case 24:Nr(r,u),m&2048&&Qd(u.alternate,u);break;default:Nr(r,u)}o=o.sibling}}var Ar=8192;function bs(t,o,r){if(t.subtreeFlags&Ar)for(t=t.child;t!==null;)Ug(t,o,r),t=t.sibling}function Ug(t,o,r){switch(t.tag){case 26:bs(t,o,r),t.flags&Ar&&t.memoizedState!==null&&Yw(r,xn,t.memoizedState,t.memoizedProps);break;case 5:bs(t,o,r);break;case 3:case 4:var u=xn;xn=Kl(t.stateNode.containerInfo),bs(t,o,r),xn=u;break;case 22:t.memoizedState===null&&(u=t.alternate,u!==null&&u.memoizedState!==null?(u=Ar,Ar=16777216,bs(t,o,r),Ar=u):bs(t,o,r));break;default:bs(t,o,r)}}function Gg(t){var o=t.alternate;if(o!==null&&(t=o.child,t!==null)){o.child=null;do o=t.sibling,t.sibling=null,t=o;while(t!==null)}}function _r(t){var o=t.deletions;if((t.flags&16)!==0){if(o!==null)for(var r=0;r<o.length;r++){var u=o[r];xt=u,Kg(u,t)}Gg(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)qg(t),t=t.sibling}function qg(t){switch(t.tag){case 0:case 11:case 15:_r(t),t.flags&2048&&zo(9,t,t.return);break;case 3:_r(t);break;case 12:_r(t);break;case 22:var o=t.stateNode;t.memoizedState!==null&&o._visibility&2&&(t.return===null||t.return.tag!==13)?(o._visibility&=-3,zl(t)):_r(t);break;default:_r(t)}}function zl(t){var o=t.deletions;if((t.flags&16)!==0){if(o!==null)for(var r=0;r<o.length;r++){var u=o[r];xt=u,Kg(u,t)}Gg(t)}for(t=t.child;t!==null;){switch(o=t,o.tag){case 0:case 11:case 15:zo(8,o,o.return),zl(o);break;case 22:r=o.stateNode,r._visibility&2&&(r._visibility&=-3,zl(o));break;default:zl(o)}t=t.sibling}}function Kg(t,o){for(;xt!==null;){var r=xt;switch(r.tag){case 0:case 11:case 15:zo(8,r,o);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var u=r.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:mr(r.memoizedState.cache)}if(u=r.child,u!==null)u.return=r,xt=u;else e:for(r=t;xt!==null;){u=xt;var m=u.sibling,y=u.return;if($g(u),u===r){xt=null;break e}if(m!==null){m.return=y,xt=m;break e}xt=y}}}var lw={getCacheForType:function(t){var o=St(lt),r=o.data.get(t);return r===void 0&&(r=t(),o.data.set(t,r)),r},cacheSignal:function(){return St(lt).controller.signal}},cw=typeof WeakMap=="function"?WeakMap:Map,Pe=0,Ve=null,_e=null,Re=0,He=0,Xt=null,Ro=!1,vs=!1,Jd=!1,ro=0,at=0,Oo=0,Ca=0,ep=0,Zt=0,ks=0,Dr=null,Pt=null,tp=!1,Rl=0,Yg=0,Ol=1/0,$l=null,$o=null,gt=0,Fo=null,ws=null,io=0,np=0,op=null,Vg=null,zr=0,ap=null;function Qt(){return(Pe&2)!==0&&Re!==0?Re&-Re:D.T!==null?up():Bi()}function Wg(){if(Zt===0)if((Re&536870912)===0||$e){var t=qa;qa<<=1,(qa&3932160)===0&&(qa=262144),Zt=t}else Zt=536870912;return t=Vt.current,t!==null&&(t.flags|=32),Zt}function Ht(t,o,r){(t===Ve&&(He===2||He===9)||t.cancelPendingCommit!==null)&&(Ss(t,0),Io(t,Re,Zt,!1)),ra(t,r),((Pe&2)===0||t!==Ve)&&(t===Ve&&((Pe&2)===0&&(Ca|=r),at===4&&Io(t,Re,Zt,!1)),_n(t))}function Xg(t,o,r){if((Pe&6)!==0)throw Error(s(327));var u=!r&&(o&127)===0&&(o&t.expiredLanes)===0||sa(t,o),m=u?pw(t,o):rp(t,o,!0),y=u;do{if(m===0){vs&&!u&&Io(t,o,0,!1);break}else{if(r=t.current.alternate,y&&!uw(r)){m=rp(t,o,!1),y=!1;continue}if(m===2){if(y=o,t.errorRecoveryDisabledLanes&y)var C=0;else C=t.pendingLanes&-536870913,C=C!==0?C:C&536870912?536870912:0;if(C!==0){o=C;e:{var R=t;m=Dr;var Y=R.current.memoizedState.isDehydrated;if(Y&&(Ss(R,C).flags|=256),C=rp(R,C,!1),C!==2){if(Jd&&!Y){R.errorRecoveryDisabledLanes|=y,Ca|=y,m=4;break e}y=Pt,Pt=m,y!==null&&(Pt===null?Pt=y:Pt.push.apply(Pt,y))}m=C}if(y=!1,m!==2)continue}}if(m===1){Ss(t,0),Io(t,o,0,!0);break}e:{switch(u=t,y=m,y){case 0:case 1:throw Error(s(345));case 4:if((o&4194048)!==o)break;case 6:Io(u,o,Zt,!Ro);break e;case 2:Pt=null;break;case 3:case 5:break;default:throw Error(s(329))}if((o&62914560)===o&&(m=Rl+300-kt(),10<m)){if(Io(u,o,Zt,!Ro),Ya(u,0,!0)!==0)break e;io=o,u.timeoutHandle=jy(Zg.bind(null,u,r,Pt,$l,tp,o,Zt,Ca,ks,Ro,y,"Throttled",-0,0),m);break e}Zg(u,r,Pt,$l,tp,o,Zt,Ca,ks,Ro,y,null,-0,0)}}break}while(!0);_n(t)}function Zg(t,o,r,u,m,y,C,R,Y,ne,le,de,se,ie){if(t.timeoutHandle=-1,de=o.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Kn},Ug(o,y,de);var be=(y&62914560)===y?Rl-kt():(y&4194048)===y?Yg-kt():0;if(be=Vw(de,be),be!==null){io=y,t.cancelPendingCommit=be(sy.bind(null,t,o,y,r,u,m,C,R,Y,le,de,null,se,ie)),Io(t,y,C,!ne);return}}sy(t,o,y,r,u,m,C,R,Y)}function uw(t){for(var o=t;;){var r=o.tag;if((r===0||r===11||r===15)&&o.flags&16384&&(r=o.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var u=0;u<r.length;u++){var m=r[u],y=m.getSnapshot;m=m.value;try{if(!Kt(y(),m))return!1}catch{return!1}}if(r=o.child,o.subtreeFlags&16384&&r!==null)r.return=o,o=r;else{if(o===t)break;for(;o.sibling===null;){if(o.return===null||o.return===t)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function Io(t,o,r,u){o&=~ep,o&=~Ca,t.suspendedLanes|=o,t.pingedLanes&=~o,u&&(t.warmLanes|=o),u=t.expirationTimes;for(var m=o;0<m;){var y=31-zt(m),C=1<<y;u[y]=-1,m&=~C}r!==0&&Fi(t,r,o)}function Fl(){return(Pe&6)===0?(Rr(0),!1):!0}function sp(){if(_e!==null){if(He===0)var t=_e.return;else t=_e,Xn=ga=null,kd(t),fs=null,gr=0,t=_e;for(;t!==null;)Tg(t.alternate,t),t=t.return;_e=null}}function Ss(t,o){var r=t.timeoutHandle;r!==-1&&(t.timeoutHandle=-1,Aw(r)),r=t.cancelPendingCommit,r!==null&&(t.cancelPendingCommit=null,r()),io=0,sp(),Ve=t,_e=r=Vn(t.current,null),Re=o,He=0,Xt=null,Ro=!1,vs=sa(t,o),Jd=!1,ks=Zt=ep=Ca=Oo=at=0,Pt=Dr=null,tp=!1,(o&8)!==0&&(o|=o&32);var u=t.entangledLanes;if(u!==0)for(t=t.entanglements,u&=o;0<u;){var m=31-zt(u),y=1<<m;o|=t[m],u&=~y}return ro=o,al(),r}function Qg(t,o){Te=null,D.H=Mr,o===ps||o===pl?(o=mh(),He=3):o===cd?(o=mh(),He=4):He=o===Fd?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,Xt=o,_e===null&&(at=1,El(t,on(o,t.current)))}function Jg(){var t=Vt.current;return t===null?!0:(Re&4194048)===Re?ln===null:(Re&62914560)===Re||(Re&536870912)!==0?t===ln:!1}function ey(){var t=D.H;return D.H=Mr,t===null?Mr:t}function ty(){var t=D.A;return D.A=lw,t}function Il(){at=4,Ro||(Re&4194048)!==Re&&Vt.current!==null||(vs=!0),(Oo&134217727)===0&&(Ca&134217727)===0||Ve===null||Io(Ve,Re,Zt,!1)}function rp(t,o,r){var u=Pe;Pe|=2;var m=ey(),y=ty();(Ve!==t||Re!==o)&&($l=null,Ss(t,o)),o=!1;var C=at;e:do try{if(He!==0&&_e!==null){var R=_e,Y=Xt;switch(He){case 8:sp(),C=6;break e;case 3:case 2:case 9:case 6:Vt.current===null&&(o=!0);var ne=He;if(He=0,Xt=null,Ms(t,R,Y,ne),r&&vs){C=0;break e}break;default:ne=He,He=0,Xt=null,Ms(t,R,Y,ne)}}dw(),C=at;break}catch(le){Qg(t,le)}while(!0);return o&&t.shellSuspendCounter++,Xn=ga=null,Pe=u,D.H=m,D.A=y,_e===null&&(Ve=null,Re=0,al()),C}function dw(){for(;_e!==null;)ny(_e)}function pw(t,o){var r=Pe;Pe|=2;var u=ey(),m=ty();Ve!==t||Re!==o?($l=null,Ol=kt()+500,Ss(t,o)):vs=sa(t,o);e:do try{if(He!==0&&_e!==null){o=_e;var y=Xt;t:switch(He){case 1:He=0,Xt=null,Ms(t,o,y,1);break;case 2:case 9:if(ph(y)){He=0,Xt=null,oy(o);break}o=function(){He!==2&&He!==9||Ve!==t||(He=7),_n(t)},y.then(o,o);break e;case 3:He=7;break e;case 4:He=5;break e;case 7:ph(y)?(He=0,Xt=null,oy(o)):(He=0,Xt=null,Ms(t,o,y,7));break;case 5:var C=null;switch(_e.tag){case 26:C=_e.memoizedState;case 5:case 27:var R=_e;if(C?Hy(C):R.stateNode.complete){He=0,Xt=null;var Y=R.sibling;if(Y!==null)_e=Y;else{var ne=R.return;ne!==null?(_e=ne,Ll(ne)):_e=null}break t}}He=0,Xt=null,Ms(t,o,y,5);break;case 6:He=0,Xt=null,Ms(t,o,y,6);break;case 8:sp(),at=6;break e;default:throw Error(s(462))}}fw();break}catch(le){Qg(t,le)}while(!0);return Xn=ga=null,D.H=u,D.A=m,Pe=r,_e!==null?0:(Ve=null,Re=0,al(),at)}function fw(){for(;_e!==null&&!tn();)ny(_e)}function ny(t){var o=Eg(t.alternate,t,ro);t.memoizedProps=t.pendingProps,o===null?Ll(t):_e=o}function oy(t){var o=t,r=o.alternate;switch(o.tag){case 15:case 0:o=vg(r,o,o.pendingProps,o.type,void 0,Re);break;case 11:o=vg(r,o,o.pendingProps,o.type.render,o.ref,Re);break;case 5:kd(o);default:Tg(r,o),o=_e=th(o,ro),o=Eg(r,o,ro)}t.memoizedProps=t.pendingProps,o===null?Ll(t):_e=o}function Ms(t,o,r,u){Xn=ga=null,kd(o),fs=null,gr=0;var m=o.return;try{if(tw(t,m,o,r,Re)){at=1,El(t,on(r,t.current)),_e=null;return}}catch(y){if(m!==null)throw _e=m,y;at=1,El(t,on(r,t.current)),_e=null;return}o.flags&32768?($e||u===1?t=!0:vs||(Re&536870912)!==0?t=!1:(Ro=t=!0,(u===2||u===9||u===3||u===6)&&(u=Vt.current,u!==null&&u.tag===13&&(u.flags|=16384))),ay(o,t)):Ll(o)}function Ll(t){var o=t;do{if((o.flags&32768)!==0){ay(o,Ro);return}t=o.return;var r=aw(o.alternate,o,ro);if(r!==null){_e=r;return}if(o=o.sibling,o!==null){_e=o;return}_e=o=t}while(o!==null);at===0&&(at=5)}function ay(t,o){do{var r=sw(t.alternate,t);if(r!==null){r.flags&=32767,_e=r;return}if(r=t.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!o&&(t=t.sibling,t!==null)){_e=t;return}_e=t=r}while(t!==null);at=6,_e=null}function sy(t,o,r,u,m,y,C,R,Y){t.cancelPendingCommit=null;do Bl();while(gt!==0);if((Pe&6)!==0)throw Error(s(327));if(o!==null){if(o===t.current)throw Error(s(177));if(y=o.lanes|o.childLanes,y|=Vu,Mu(t,r,y,C,R,Y),t===Ve&&(_e=Ve=null,Re=0),ws=o,Fo=t,io=r,np=y,op=m,Vg=u,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(t.callbackNode=null,t.callbackPriority=0,yw(oa,function(){return uy(),null})):(t.callbackNode=null,t.callbackPriority=0),u=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||u){u=D.T,D.T=null,m=U.p,U.p=2,C=Pe,Pe|=4;try{rw(t,o,r)}finally{Pe=C,U.p=m,D.T=u}}gt=1,ry(),iy(),ly()}}function ry(){if(gt===1){gt=0;var t=Fo,o=ws,r=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||r){r=D.T,D.T=null;var u=U.p;U.p=2;var m=Pe;Pe|=4;try{Bg(o,t);var y=xp,C=Km(t.containerInfo),R=y.focusedElem,Y=y.selectionRange;if(C!==R&&R&&R.ownerDocument&&qm(R.ownerDocument.documentElement,R)){if(Y!==null&&Uu(R)){var ne=Y.start,le=Y.end;if(le===void 0&&(le=ne),"selectionStart"in R)R.selectionStart=ne,R.selectionEnd=Math.min(le,R.value.length);else{var de=R.ownerDocument||document,se=de&&de.defaultView||window;if(se.getSelection){var ie=se.getSelection(),be=R.textContent.length,Ce=Math.min(Y.start,be),Ke=Y.end===void 0?Ce:Math.min(Y.end,be);!ie.extend&&Ce>Ke&&(C=Ke,Ke=Ce,Ce=C);var ee=Gm(R,Ce),X=Gm(R,Ke);if(ee&&X&&(ie.rangeCount!==1||ie.anchorNode!==ee.node||ie.anchorOffset!==ee.offset||ie.focusNode!==X.node||ie.focusOffset!==X.offset)){var te=de.createRange();te.setStart(ee.node,ee.offset),ie.removeAllRanges(),Ce>Ke?(ie.addRange(te),ie.extend(X.node,X.offset)):(te.setEnd(X.node,X.offset),ie.addRange(te))}}}}for(de=[],ie=R;ie=ie.parentNode;)ie.nodeType===1&&de.push({element:ie,left:ie.scrollLeft,top:ie.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<de.length;R++){var ue=de[R];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Ql=!!yp,xp=yp=null}finally{Pe=m,U.p=u,D.T=r}}t.current=o,gt=2}}function iy(){if(gt===2){gt=0;var t=Fo,o=ws,r=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||r){r=D.T,D.T=null;var u=U.p;U.p=2;var m=Pe;Pe|=4;try{Og(t,o.alternate,o)}finally{Pe=m,U.p=u,D.T=r}}gt=3}}function ly(){if(gt===4||gt===3){gt=0,hn();var t=Fo,o=ws,r=io,u=Vg;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?gt=5:(gt=0,ws=Fo=null,cy(t,t.pendingLanes));var m=t.pendingLanes;if(m===0&&($o=null),Js(r),o=o.stateNode,Dt&&typeof Dt.onCommitFiberRoot=="function")try{Dt.onCommitFiberRoot(aa,o,void 0,(o.current.flags&128)===128)}catch{}if(u!==null){o=D.T,m=U.p,U.p=2,D.T=null;try{for(var y=t.onRecoverableError,C=0;C<u.length;C++){var R=u[C];y(R.value,{componentStack:R.stack})}}finally{D.T=o,U.p=m}}(io&3)!==0&&Bl(),_n(t),m=t.pendingLanes,(r&261930)!==0&&(m&42)!==0?t===ap?zr++:(zr=0,ap=t):zr=0,Rr(0)}}function cy(t,o){(t.pooledCacheLanes&=o)===0&&(o=t.pooledCache,o!=null&&(t.pooledCache=null,mr(o)))}function Bl(){return ry(),iy(),ly(),uy()}function uy(){if(gt!==5)return!1;var t=Fo,o=np;np=0;var r=Js(io),u=D.T,m=U.p;try{U.p=32>r?32:r,D.T=null,r=op,op=null;var y=Fo,C=io;if(gt=0,ws=Fo=null,io=0,(Pe&6)!==0)throw Error(s(331));var R=Pe;if(Pe|=4,qg(y.current),Hg(y,y.current,C,r),Pe=R,Rr(0,!1),Dt&&typeof Dt.onPostCommitFiberRoot=="function")try{Dt.onPostCommitFiberRoot(aa,y)}catch{}return!0}finally{U.p=m,D.T=u,cy(t,o)}}function dy(t,o,r){o=on(r,o),o=$d(t.stateNode,o,2),t=Ao(t,o,2),t!==null&&(ra(t,2),_n(t))}function Ue(t,o,r){if(t.tag===3)dy(t,t,r);else for(;o!==null;){if(o.tag===3){dy(o,t,r);break}else if(o.tag===1){var u=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&($o===null||!$o.has(u))){t=on(r,t),r=pg(2),u=Ao(o,r,2),u!==null&&(fg(r,u,o,t),ra(u,2),_n(u));break}}o=o.return}}function ip(t,o,r){var u=t.pingCache;if(u===null){u=t.pingCache=new cw;var m=new Set;u.set(o,m)}else m=u.get(o),m===void 0&&(m=new Set,u.set(o,m));m.has(r)||(Jd=!0,m.add(r),t=mw.bind(null,t,o,r),o.then(t,t))}function mw(t,o,r){var u=t.pingCache;u!==null&&u.delete(o),t.pingedLanes|=t.suspendedLanes&r,t.warmLanes&=~r,Ve===t&&(Re&r)===r&&(at===4||at===3&&(Re&62914560)===Re&&300>kt()-Rl?(Pe&2)===0&&Ss(t,0):ep|=r,ks===Re&&(ks=0)),_n(t)}function py(t,o){o===0&&(o=$i()),t=fa(t,o),t!==null&&(ra(t,o),_n(t))}function hw(t){var o=t.memoizedState,r=0;o!==null&&(r=o.retryLane),py(t,r)}function gw(t,o){var r=0;switch(t.tag){case 31:case 13:var u=t.stateNode,m=t.memoizedState;m!==null&&(r=m.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(o),py(t,r)}function yw(t,o){return vt(t,o)}var Pl=null,Cs=null,lp=!1,Hl=!1,cp=!1,Lo=0;function _n(t){t!==Cs&&t.next===null&&(Cs===null?Pl=Cs=t:Cs=Cs.next=t),Hl=!0,lp||(lp=!0,bw())}function Rr(t,o){if(!cp&&Hl){cp=!0;do for(var r=!1,u=Pl;u!==null;){if(t!==0){var m=u.pendingLanes;if(m===0)var y=0;else{var C=u.suspendedLanes,R=u.pingedLanes;y=(1<<31-zt(42|t)+1)-1,y&=m&~(C&~R),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(r=!0,gy(u,y))}else y=Re,y=Ya(u,u===Ve?y:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(y&3)===0||sa(u,y)||(r=!0,gy(u,y));u=u.next}while(r);cp=!1}}function xw(){fy()}function fy(){Hl=lp=!1;var t=0;Lo!==0&&Nw()&&(t=Lo);for(var o=kt(),r=null,u=Pl;u!==null;){var m=u.next,y=my(u,o);y===0?(u.next=null,r===null?Pl=m:r.next=m,m===null&&(Cs=r)):(r=u,(t!==0||(y&3)!==0)&&(Hl=!0)),u=m}gt!==0&>!==5||Rr(t),Lo!==0&&(Lo=0)}function my(t,o){for(var r=t.suspendedLanes,u=t.pingedLanes,m=t.expirationTimes,y=t.pendingLanes&-62914561;0<y;){var C=31-zt(y),R=1<<C,Y=m[C];Y===-1?((R&r)===0||(R&u)!==0)&&(m[C]=Su(R,o)):Y<=o&&(t.expiredLanes|=R),y&=~R}if(o=Ve,r=Re,r=Ya(t,t===o?r:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u=t.callbackNode,r===0||t===o&&(He===2||He===9)||t.cancelPendingCommit!==null)return u!==null&&u!==null&&mn(u),t.callbackNode=null,t.callbackPriority=0;if((r&3)===0||sa(t,r)){if(o=r&-r,o===t.callbackPriority)return o;switch(u!==null&&mn(u),Js(r)){case 2:case 8:r=yo;break;case 32:r=oa;break;case 268435456:r=Ua;break;default:r=oa}return u=hy.bind(null,t),r=vt(r,u),t.callbackPriority=o,t.callbackNode=r,o}return u!==null&&u!==null&&mn(u),t.callbackPriority=2,t.callbackNode=null,2}function hy(t,o){if(gt!==0&>!==5)return t.callbackNode=null,t.callbackPriority=0,null;var r=t.callbackNode;if(Bl()&&t.callbackNode!==r)return null;var u=Re;return u=Ya(t,t===Ve?u:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u===0?null:(Xg(t,u,o),my(t,kt()),t.callbackNode!=null&&t.callbackNode===r?hy.bind(null,t):null)}function gy(t,o){if(Bl())return null;Xg(t,o,!0)}function bw(){_w(function(){(Pe&6)!==0?vt(Pn,xw):fy()})}function up(){if(Lo===0){var t=us;t===0&&(t=Ga,Ga<<=1,(Ga&261888)===0&&(Ga=256)),Lo=t}return Lo}function yy(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:Xi(""+t)}function xy(t,o){var r=o.ownerDocument.createElement("input");return r.name=o.name,r.value=o.value,t.id&&r.setAttribute("form",t.id),o.parentNode.insertBefore(r,o),t=new FormData(t),r.parentNode.removeChild(r),t}function vw(t,o,r,u,m){if(o==="submit"&&r&&r.stateNode===m){var y=yy((m[At]||null).action),C=u.submitter;C&&(o=(o=C[At]||null)?yy(o.formAction):C.getAttribute("formAction"),o!==null&&(y=o,C=null));var R=new el("action","action",null,u,m);t.push({event:R,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Lo!==0){var Y=C?xy(m,C):new FormData(m);Ad(r,{pending:!0,data:Y,method:m.method,action:y},null,Y)}}else typeof y=="function"&&(R.preventDefault(),Y=C?xy(m,C):new FormData(m),Ad(r,{pending:!0,data:Y,method:m.method,action:y},y,Y))},currentTarget:m}]})}}for(var dp=0;dp<Yu.length;dp++){var pp=Yu[dp],kw=pp.toLowerCase(),ww=pp[0].toUpperCase()+pp.slice(1);yn(kw,"on"+ww)}yn(Wm,"onAnimationEnd"),yn(Xm,"onAnimationIteration"),yn(Zm,"onAnimationStart"),yn("dblclick","onDoubleClick"),yn("focusin","onFocus"),yn("focusout","onBlur"),yn(Ik,"onTransitionRun"),yn(Lk,"onTransitionStart"),yn(Bk,"onTransitionCancel"),yn(Qm,"onTransitionEnd"),wo("onMouseEnter",["mouseout","mouseover"]),wo("onMouseLeave",["mouseout","mouseover"]),wo("onPointerEnter",["pointerout","pointerover"]),wo("onPointerLeave",["pointerout","pointerover"]),Gn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Gn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Gn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Gn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Gn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Gn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Or="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Sw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Or));function by(t,o){o=(o&4)!==0;for(var r=0;r<t.length;r++){var u=t[r],m=u.event;u=u.listeners;e:{var y=void 0;if(o)for(var C=u.length-1;0<=C;C--){var R=u[C],Y=R.instance,ne=R.currentTarget;if(R=R.listener,Y!==y&&m.isPropagationStopped())break e;y=R,m.currentTarget=ne;try{y(m)}catch(le){ol(le)}m.currentTarget=null,y=Y}else for(C=0;C<u.length;C++){if(R=u[C],Y=R.instance,ne=R.currentTarget,R=R.listener,Y!==y&&m.isPropagationStopped())break e;y=R,m.currentTarget=ne;try{y(m)}catch(le){ol(le)}m.currentTarget=null,y=Y}}}}function De(t,o){var r=o[Va];r===void 0&&(r=o[Va]=new Set);var u=t+"__bubble";r.has(u)||(vy(o,t,2,!1),r.add(u))}function fp(t,o,r){var u=0;o&&(u|=4),vy(r,t,u,o)}var Ul="_reactListening"+Math.random().toString(36).slice(2);function mp(t){if(!t[Ul]){t[Ul]=!0,Gi.forEach(function(r){r!=="selectionchange"&&(Sw.has(r)||fp(r,!1,t),fp(r,!0,t))});var o=t.nodeType===9?t:t.ownerDocument;o===null||o[Ul]||(o[Ul]=!0,fp("selectionchange",!1,o))}}function vy(t,o,r,u){switch(Wy(o)){case 2:var m=Zw;break;case 8:m=Qw;break;default:m=Np}r=m.bind(null,o,r,t),m=void 0,!Ru||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(m=!0),u?m!==void 0?t.addEventListener(o,r,{capture:!0,passive:m}):t.addEventListener(o,r,!0):m!==void 0?t.addEventListener(o,r,{passive:m}):t.addEventListener(o,r,!1)}function hp(t,o,r,u,m){var y=u;if((o&1)===0&&(o&2)===0&&u!==null)e:for(;;){if(u===null)return;var C=u.tag;if(C===3||C===4){var R=u.stateNode.containerInfo;if(R===m)break;if(C===4)for(C=u.return;C!==null;){var Y=C.tag;if((Y===3||Y===4)&&C.stateNode.containerInfo===m)return;C=C.return}for(;R!==null;){if(C=xo(R),C===null)return;if(Y=C.tag,Y===5||Y===6||Y===26||Y===27){u=y=C;continue e}R=R.parentNode}}u=u.return}Cm(function(){var ne=y,le=Du(r),de=[];e:{var se=Jm.get(t);if(se!==void 0){var ie=el,be=t;switch(t){case"keypress":if(Qi(r)===0)break e;case"keydown":case"keyup":ie=gk;break;case"focusin":be="focus",ie=Iu;break;case"focusout":be="blur",ie=Iu;break;case"beforeblur":case"afterblur":ie=Iu;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ie=Tm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ie=ak;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ie=bk;break;case Wm:case Xm:case Zm:ie=ik;break;case Qm:ie=kk;break;case"scroll":case"scrollend":ie=nk;break;case"wheel":ie=Sk;break;case"copy":case"cut":case"paste":ie=ck;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ie=Am;break;case"toggle":case"beforetoggle":ie=Ck}var Ce=(o&4)!==0,Ke=!Ce&&(t==="scroll"||t==="scrollend"),ee=Ce?se!==null?se+"Capture":null:se;Ce=[];for(var X=ne,te;X!==null;){var ue=X;if(te=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||te===null||ee===null||(ue=or(X,ee),ue!=null&&Ce.push($r(X,ue,te))),Ke)break;X=X.return}0<Ce.length&&(se=new ie(se,be,null,r,le),de.push({event:se,listeners:Ce}))}}if((o&7)===0){e:{if(se=t==="mouseover"||t==="pointerover",ie=t==="mouseout"||t==="pointerout",se&&r!==_u&&(be=r.relatedTarget||r.fromElement)&&(xo(be)||be[Un]))break e;if((ie||se)&&(se=le.window===le?le:(se=le.ownerDocument)?se.defaultView||se.parentWindow:window,ie?(be=r.relatedTarget||r.toElement,ie=ne,be=be?xo(be):null,be!==null&&(Ke=l(be),Ce=be.tag,be!==Ke||Ce!==5&&Ce!==27&&Ce!==6)&&(be=null)):(ie=null,be=ne),ie!==be)){if(Ce=Tm,ue="onMouseLeave",ee="onMouseEnter",X="mouse",(t==="pointerout"||t==="pointerover")&&(Ce=Am,ue="onPointerLeave",ee="onPointerEnter",X="pointer"),Ke=ie==null?se:vo(ie),te=be==null?se:vo(be),se=new Ce(ue,X+"leave",ie,r,le),se.target=Ke,se.relatedTarget=te,ue=null,xo(le)===ne&&(Ce=new Ce(ee,X+"enter",be,r,le),Ce.target=te,Ce.relatedTarget=Ke,ue=Ce),Ke=ue,ie&&be)t:{for(Ce=Mw,ee=ie,X=be,te=0,ue=ee;ue;ue=Ce(ue))te++;ue=0;for(var Me=X;Me;Me=Ce(Me))ue++;for(;0<te-ue;)ee=Ce(ee),te--;for(;0<ue-te;)X=Ce(X),ue--;for(;te--;){if(ee===X||X!==null&&ee===X.alternate){Ce=ee;break t}ee=Ce(ee),X=Ce(X)}Ce=null}else Ce=null;ie!==null&&ky(de,se,ie,Ce,!1),be!==null&&Ke!==null&&ky(de,Ke,be,Ce,!0)}}e:{if(se=ne?vo(ne):window,ie=se.nodeName&&se.nodeName.toLowerCase(),ie==="select"||ie==="input"&&se.type==="file")var Le=Im;else if($m(se))if(Lm)Le=Ok;else{Le=zk;var ve=Dk}else ie=se.nodeName,!ie||ie.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?ne&&Au(ne.elementType)&&(Le=Im):Le=Rk;if(Le&&(Le=Le(t,ne))){Fm(de,Le,r,le);break e}ve&&ve(t,se,ne),t==="focusout"&&ne&&se.type==="number"&&ne.memoizedProps.value!=null&&nr(se,"number",se.value)}switch(ve=ne?vo(ne):window,t){case"focusin":($m(ve)||ve.contentEditable==="true")&&(ns=ve,Gu=ne,dr=null);break;case"focusout":dr=Gu=ns=null;break;case"mousedown":qu=!0;break;case"contextmenu":case"mouseup":case"dragend":qu=!1,Ym(de,r,le);break;case"selectionchange":if(Fk)break;case"keydown":case"keyup":Ym(de,r,le)}var Ne;if(Bu)e:{switch(t){case"compositionstart":var Oe="onCompositionStart";break e;case"compositionend":Oe="onCompositionEnd";break e;case"compositionupdate":Oe="onCompositionUpdate";break e}Oe=void 0}else ts?Rm(t,r)&&(Oe="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(Oe="onCompositionStart");Oe&&(_m&&r.locale!=="ko"&&(ts||Oe!=="onCompositionStart"?Oe==="onCompositionEnd"&&ts&&(Ne=Em()):(So=le,Ou="value"in So?So.value:So.textContent,ts=!0)),ve=Gl(ne,Oe),0<ve.length&&(Oe=new Nm(Oe,t,null,r,le),de.push({event:Oe,listeners:ve}),Ne?Oe.data=Ne:(Ne=Om(r),Ne!==null&&(Oe.data=Ne)))),(Ne=jk?Tk(t,r):Nk(t,r))&&(Oe=Gl(ne,"onBeforeInput"),0<Oe.length&&(ve=new Nm("onBeforeInput","beforeinput",null,r,le),de.push({event:ve,listeners:Oe}),ve.data=Ne)),vw(de,t,ne,r,le)}by(de,o)})}function $r(t,o,r){return{instance:t,listener:o,currentTarget:r}}function Gl(t,o){for(var r=o+"Capture",u=[];t!==null;){var m=t,y=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||y===null||(m=or(t,r),m!=null&&u.unshift($r(t,m,y)),m=or(t,o),m!=null&&u.push($r(t,m,y))),t.tag===3)return u;t=t.return}return[]}function Mw(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function ky(t,o,r,u,m){for(var y=o._reactName,C=[];r!==null&&r!==u;){var R=r,Y=R.alternate,ne=R.stateNode;if(R=R.tag,Y!==null&&Y===u)break;R!==5&&R!==26&&R!==27||ne===null||(Y=ne,m?(ne=or(r,y),ne!=null&&C.unshift($r(r,ne,Y))):m||(ne=or(r,y),ne!=null&&C.push($r(r,ne,Y)))),r=r.return}C.length!==0&&t.push({event:o,listeners:C})}var Cw=/\r\n?/g,Ew=/\u0000|\uFFFD/g;function wy(t){return(typeof t=="string"?t:""+t).replace(Cw,`
|
|
9
|
+
`).replace(Ew,"")}function Sy(t,o){return o=wy(o),wy(t)===o}function qe(t,o,r,u,m,y){switch(r){case"children":typeof u=="string"?o==="body"||o==="textarea"&&u===""||Qa(t,u):(typeof u=="number"||typeof u=="bigint")&&o!=="body"&&Qa(t,""+u);break;case"className":Xa(t,"class",u);break;case"tabIndex":Xa(t,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Xa(t,r,u);break;case"style":Sm(t,u,y);break;case"data":if(o!=="object"){Xa(t,"data",u);break}case"src":case"href":if(u===""&&(o!=="a"||r!=="href")){t.removeAttribute(r);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(r);break}u=Xi(""+u),t.setAttribute(r,u);break;case"action":case"formAction":if(typeof u=="function"){t.setAttribute(r,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof y=="function"&&(r==="formAction"?(o!=="input"&&qe(t,o,"name",m.name,m,null),qe(t,o,"formEncType",m.formEncType,m,null),qe(t,o,"formMethod",m.formMethod,m,null),qe(t,o,"formTarget",m.formTarget,m,null)):(qe(t,o,"encType",m.encType,m,null),qe(t,o,"method",m.method,m,null),qe(t,o,"target",m.target,m,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(r);break}u=Xi(""+u),t.setAttribute(r,u);break;case"onClick":u!=null&&(t.onclick=Kn);break;case"onScroll":u!=null&&De("scroll",t);break;case"onScrollEnd":u!=null&&De("scrollend",t);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(r=u.__html,r!=null){if(m.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"multiple":t.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":t.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){t.removeAttribute("xlink:href");break}r=Xi(""+u),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,""+u):t.removeAttribute(r);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,""):t.removeAttribute(r);break;case"capture":case"download":u===!0?t.setAttribute(r,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(r,u):t.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?t.setAttribute(r,u):t.removeAttribute(r);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?t.removeAttribute(r):t.setAttribute(r,u);break;case"popover":De("beforetoggle",t),De("toggle",t),Wa(t,"popover",u);break;case"xlinkActuate":gn(t,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":gn(t,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":gn(t,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":gn(t,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":gn(t,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":gn(t,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":gn(t,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":gn(t,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":gn(t,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Wa(t,"is",u);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=ek.get(r)||r,Wa(t,r,u))}}function gp(t,o,r,u,m,y){switch(r){case"style":Sm(t,u,y);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(r=u.__html,r!=null){if(m.children!=null)throw Error(s(60));t.innerHTML=r}}break;case"children":typeof u=="string"?Qa(t,u):(typeof u=="number"||typeof u=="bigint")&&Qa(t,""+u);break;case"onScroll":u!=null&&De("scroll",t);break;case"onScrollEnd":u!=null&&De("scrollend",t);break;case"onClick":u!=null&&(t.onclick=Kn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!qi.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(m=r.endsWith("Capture"),o=r.slice(2,m?r.length-7:void 0),y=t[At]||null,y=y!=null?y[r]:null,typeof y=="function"&&t.removeEventListener(o,y,m),typeof u=="function")){typeof y!="function"&&y!==null&&(r in t?t[r]=null:t.hasAttribute(r)&&t.removeAttribute(r)),t.addEventListener(o,u,m);break e}r in t?t[r]=u:u===!0?t.setAttribute(r,""):Wa(t,r,u)}}}function Ct(t,o,r){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":De("error",t),De("load",t);var u=!1,m=!1,y;for(y in r)if(r.hasOwnProperty(y)){var C=r[y];if(C!=null)switch(y){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:qe(t,o,y,C,r,null)}}m&&qe(t,o,"srcSet",r.srcSet,r,null),u&&qe(t,o,"src",r.src,r,null);return;case"input":De("invalid",t);var R=y=C=m=null,Y=null,ne=null;for(u in r)if(r.hasOwnProperty(u)){var le=r[u];if(le!=null)switch(u){case"name":m=le;break;case"type":C=le;break;case"checked":Y=le;break;case"defaultChecked":ne=le;break;case"value":y=le;break;case"defaultValue":R=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(s(137,o));break;default:qe(t,o,u,le,r,null)}}Wi(t,y,R,Y,ne,C,m,!1);return;case"select":De("invalid",t),u=C=y=null;for(m in r)if(r.hasOwnProperty(m)&&(R=r[m],R!=null))switch(m){case"value":y=R;break;case"defaultValue":C=R;break;case"multiple":u=R;default:qe(t,o,m,R,r,null)}o=y,r=C,t.multiple=!!u,o!=null?qn(t,!!u,o,!1):r!=null&&qn(t,!!u,r,!0);return;case"textarea":De("invalid",t),y=m=u=null;for(C in r)if(r.hasOwnProperty(C)&&(R=r[C],R!=null))switch(C){case"value":u=R;break;case"defaultValue":m=R;break;case"children":y=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(s(91));break;default:qe(t,o,C,R,r,null)}km(t,u,m,y);return;case"option":for(Y in r)r.hasOwnProperty(Y)&&(u=r[Y],u!=null)&&(Y==="selected"?t.selected=u&&typeof u!="function"&&typeof u!="symbol":qe(t,o,Y,u,r,null));return;case"dialog":De("beforetoggle",t),De("toggle",t),De("cancel",t),De("close",t);break;case"iframe":case"object":De("load",t);break;case"video":case"audio":for(u=0;u<Or.length;u++)De(Or[u],t);break;case"image":De("error",t),De("load",t);break;case"details":De("toggle",t);break;case"embed":case"source":case"link":De("error",t),De("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ne in r)if(r.hasOwnProperty(ne)&&(u=r[ne],u!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,o));default:qe(t,o,ne,u,r,null)}return;default:if(Au(o)){for(le in r)r.hasOwnProperty(le)&&(u=r[le],u!==void 0&&gp(t,o,le,u,r,void 0));return}}for(R in r)r.hasOwnProperty(R)&&(u=r[R],u!=null&&qe(t,o,R,u,r,null))}function jw(t,o,r,u){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,y=null,C=null,R=null,Y=null,ne=null,le=null;for(ie in r){var de=r[ie];if(r.hasOwnProperty(ie)&&de!=null)switch(ie){case"checked":break;case"value":break;case"defaultValue":Y=de;default:u.hasOwnProperty(ie)||qe(t,o,ie,null,u,de)}}for(var se in u){var ie=u[se];if(de=r[se],u.hasOwnProperty(se)&&(ie!=null||de!=null))switch(se){case"type":y=ie;break;case"name":m=ie;break;case"checked":ne=ie;break;case"defaultChecked":le=ie;break;case"value":C=ie;break;case"defaultValue":R=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(s(137,o));break;default:ie!==de&&qe(t,o,se,ie,u,de)}}ca(t,C,R,Y,ne,le,y,m);return;case"select":ie=C=R=se=null;for(y in r)if(Y=r[y],r.hasOwnProperty(y)&&Y!=null)switch(y){case"value":break;case"multiple":ie=Y;default:u.hasOwnProperty(y)||qe(t,o,y,null,u,Y)}for(m in u)if(y=u[m],Y=r[m],u.hasOwnProperty(m)&&(y!=null||Y!=null))switch(m){case"value":se=y;break;case"defaultValue":R=y;break;case"multiple":C=y;default:y!==Y&&qe(t,o,m,y,u,Y)}o=R,r=C,u=ie,se!=null?qn(t,!!r,se,!1):!!u!=!!r&&(o!=null?qn(t,!!r,o,!0):qn(t,!!r,r?[]:"",!1));return;case"textarea":ie=se=null;for(R in r)if(m=r[R],r.hasOwnProperty(R)&&m!=null&&!u.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:qe(t,o,R,null,u,m)}for(C in u)if(m=u[C],y=r[C],u.hasOwnProperty(C)&&(m!=null||y!=null))switch(C){case"value":se=m;break;case"defaultValue":ie=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(s(91));break;default:m!==y&&qe(t,o,C,m,u,y)}vm(t,se,ie);return;case"option":for(var be in r)se=r[be],r.hasOwnProperty(be)&&se!=null&&!u.hasOwnProperty(be)&&(be==="selected"?t.selected=!1:qe(t,o,be,null,u,se));for(Y in u)se=u[Y],ie=r[Y],u.hasOwnProperty(Y)&&se!==ie&&(se!=null||ie!=null)&&(Y==="selected"?t.selected=se&&typeof se!="function"&&typeof se!="symbol":qe(t,o,Y,se,u,ie));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ce in r)se=r[Ce],r.hasOwnProperty(Ce)&&se!=null&&!u.hasOwnProperty(Ce)&&qe(t,o,Ce,null,u,se);for(ne in u)if(se=u[ne],ie=r[ne],u.hasOwnProperty(ne)&&se!==ie&&(se!=null||ie!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(s(137,o));break;default:qe(t,o,ne,se,u,ie)}return;default:if(Au(o)){for(var Ke in r)se=r[Ke],r.hasOwnProperty(Ke)&&se!==void 0&&!u.hasOwnProperty(Ke)&&gp(t,o,Ke,void 0,u,se);for(le in u)se=u[le],ie=r[le],!u.hasOwnProperty(le)||se===ie||se===void 0&&ie===void 0||gp(t,o,le,se,u,ie);return}}for(var ee in r)se=r[ee],r.hasOwnProperty(ee)&&se!=null&&!u.hasOwnProperty(ee)&&qe(t,o,ee,null,u,se);for(de in u)se=u[de],ie=r[de],!u.hasOwnProperty(de)||se===ie||se==null&&ie==null||qe(t,o,de,se,u,ie)}function My(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Tw(){if(typeof performance.getEntriesByType=="function"){for(var t=0,o=0,r=performance.getEntriesByType("resource"),u=0;u<r.length;u++){var m=r[u],y=m.transferSize,C=m.initiatorType,R=m.duration;if(y&&R&&My(C)){for(C=0,R=m.responseEnd,u+=1;u<r.length;u++){var Y=r[u],ne=Y.startTime;if(ne>R)break;var le=Y.transferSize,de=Y.initiatorType;le&&My(de)&&(Y=Y.responseEnd,C+=le*(Y<R?1:(R-ne)/(Y-ne)))}if(--u,o+=8*(y+C)/(m.duration/1e3),t++,10<t)break}}if(0<t)return o/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var yp=null,xp=null;function ql(t){return t.nodeType===9?t:t.ownerDocument}function Cy(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Ey(t,o){if(t===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&o==="foreignObject"?0:t}function bp(t,o){return t==="textarea"||t==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var vp=null;function Nw(){var t=window.event;return t&&t.type==="popstate"?t===vp?!1:(vp=t,!0):(vp=null,!1)}var jy=typeof setTimeout=="function"?setTimeout:void 0,Aw=typeof clearTimeout=="function"?clearTimeout:void 0,Ty=typeof Promise=="function"?Promise:void 0,_w=typeof queueMicrotask=="function"?queueMicrotask:typeof Ty<"u"?function(t){return Ty.resolve(null).then(t).catch(Dw)}:jy;function Dw(t){setTimeout(function(){throw t})}function Bo(t){return t==="head"}function Ny(t,o){var r=o,u=0;do{var m=r.nextSibling;if(t.removeChild(r),m&&m.nodeType===8)if(r=m.data,r==="/$"||r==="/&"){if(u===0){t.removeChild(m),Ns(o);return}u--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")u++;else if(r==="html")Fr(t.ownerDocument.documentElement);else if(r==="head"){r=t.ownerDocument.head,Fr(r);for(var y=r.firstChild;y;){var C=y.nextSibling,R=y.nodeName;y[ia]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&y.rel.toLowerCase()==="stylesheet"||r.removeChild(y),y=C}}else r==="body"&&Fr(t.ownerDocument.body);r=m}while(r);Ns(o)}function Ay(t,o){var r=t;t=0;do{var u=r.nextSibling;if(r.nodeType===1?o?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(o?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),u&&u.nodeType===8)if(r=u.data,r==="/$"){if(t===0)break;t--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||t++;r=u}while(r)}function kp(t){var o=t.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var r=o;switch(o=o.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":kp(r),er(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}t.removeChild(r)}}function zw(t,o,r,u){for(;t.nodeType===1;){var m=r;if(t.nodeName.toLowerCase()!==o.toLowerCase()){if(!u&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(u){if(!t[ia])switch(o){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(y=t.getAttribute("rel"),y==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(y!==m.rel||t.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||t.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||t.getAttribute("title")!==(m.title==null?null:m.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(y=t.getAttribute("src"),(y!==(m.src==null?null:m.src)||t.getAttribute("type")!==(m.type==null?null:m.type)||t.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&y&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(o==="input"&&t.type==="hidden"){var y=m.name==null?null:""+m.name;if(m.type==="hidden"&&t.getAttribute("name")===y)return t}else return t;if(t=cn(t.nextSibling),t===null)break}return null}function Rw(t,o,r){if(o==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!r||(t=cn(t.nextSibling),t===null))return null;return t}function _y(t,o){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!o||(t=cn(t.nextSibling),t===null))return null;return t}function wp(t){return t.data==="$?"||t.data==="$~"}function Sp(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function Ow(t,o){var r=t.ownerDocument;if(t.data==="$~")t._reactRetry=o;else if(t.data!=="$?"||r.readyState!=="loading")o();else{var u=function(){o(),r.removeEventListener("DOMContentLoaded",u)};r.addEventListener("DOMContentLoaded",u),t._reactRetry=u}}function cn(t){for(;t!=null;t=t.nextSibling){var o=t.nodeType;if(o===1||o===3)break;if(o===8){if(o=t.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return t}var Mp=null;function Dy(t){t=t.nextSibling;for(var o=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"||r==="/&"){if(o===0)return cn(t.nextSibling);o--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||o++}t=t.nextSibling}return null}function zy(t){t=t.previousSibling;for(var o=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(o===0)return t;o--}else r!=="/$"&&r!=="/&"||o++}t=t.previousSibling}return null}function Ry(t,o,r){switch(o=ql(r),t){case"html":if(t=o.documentElement,!t)throw Error(s(452));return t;case"head":if(t=o.head,!t)throw Error(s(453));return t;case"body":if(t=o.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function Fr(t){for(var o=t.attributes;o.length;)t.removeAttributeNode(o[0]);er(t)}var un=new Map,Oy=new Set;function Kl(t){return typeof t.getRootNode=="function"?t.getRootNode():t.nodeType===9?t:t.ownerDocument}var lo=U.d;U.d={f:$w,r:Fw,D:Iw,C:Lw,L:Bw,m:Pw,X:Uw,S:Hw,M:Gw};function $w(){var t=lo.f(),o=Fl();return t||o}function Fw(t){var o=bo(t);o!==null&&o.tag===5&&o.type==="form"?Qh(o):lo.r(t)}var Es=typeof document>"u"?null:document;function $y(t,o,r){var u=Es;if(u&&typeof o=="string"&&o){var m=$t(o);m='link[rel="'+t+'"][href="'+m+'"]',typeof r=="string"&&(m+='[crossorigin="'+r+'"]'),Oy.has(m)||(Oy.add(m),t={rel:t,crossOrigin:r,href:o},u.querySelector(m)===null&&(o=u.createElement("link"),Ct(o,"link",t),it(o),u.head.appendChild(o)))}}function Iw(t){lo.D(t),$y("dns-prefetch",t,null)}function Lw(t,o){lo.C(t,o),$y("preconnect",t,o)}function Bw(t,o,r){lo.L(t,o,r);var u=Es;if(u&&t&&o){var m='link[rel="preload"][as="'+$t(o)+'"]';o==="image"&&r&&r.imageSrcSet?(m+='[imagesrcset="'+$t(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(m+='[imagesizes="'+$t(r.imageSizes)+'"]')):m+='[href="'+$t(t)+'"]';var y=m;switch(o){case"style":y=js(t);break;case"script":y=Ts(t)}un.has(y)||(t=x({rel:"preload",href:o==="image"&&r&&r.imageSrcSet?void 0:t,as:o},r),un.set(y,t),u.querySelector(m)!==null||o==="style"&&u.querySelector(Ir(y))||o==="script"&&u.querySelector(Lr(y))||(o=u.createElement("link"),Ct(o,"link",t),it(o),u.head.appendChild(o)))}}function Pw(t,o){lo.m(t,o);var r=Es;if(r&&t){var u=o&&typeof o.as=="string"?o.as:"script",m='link[rel="modulepreload"][as="'+$t(u)+'"][href="'+$t(t)+'"]',y=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=Ts(t)}if(!un.has(y)&&(t=x({rel:"modulepreload",href:t},o),un.set(y,t),r.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(Lr(y)))return}u=r.createElement("link"),Ct(u,"link",t),it(u),r.head.appendChild(u)}}}function Hw(t,o,r){lo.S(t,o,r);var u=Es;if(u&&t){var m=ko(u).hoistableStyles,y=js(t);o=o||"default";var C=m.get(y);if(!C){var R={loading:0,preload:null};if(C=u.querySelector(Ir(y)))R.loading=5;else{t=x({rel:"stylesheet",href:t,"data-precedence":o},r),(r=un.get(y))&&Cp(t,r);var Y=C=u.createElement("link");it(Y),Ct(Y,"link",t),Y._p=new Promise(function(ne,le){Y.onload=ne,Y.onerror=le}),Y.addEventListener("load",function(){R.loading|=1}),Y.addEventListener("error",function(){R.loading|=2}),R.loading|=4,Yl(C,o,u)}C={type:"stylesheet",instance:C,count:1,state:R},m.set(y,C)}}}function Uw(t,o){lo.X(t,o);var r=Es;if(r&&t){var u=ko(r).hoistableScripts,m=Ts(t),y=u.get(m);y||(y=r.querySelector(Lr(m)),y||(t=x({src:t,async:!0},o),(o=un.get(m))&&Ep(t,o),y=r.createElement("script"),it(y),Ct(y,"link",t),r.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(m,y))}}function Gw(t,o){lo.M(t,o);var r=Es;if(r&&t){var u=ko(r).hoistableScripts,m=Ts(t),y=u.get(m);y||(y=r.querySelector(Lr(m)),y||(t=x({src:t,async:!0,type:"module"},o),(o=un.get(m))&&Ep(t,o),y=r.createElement("script"),it(y),Ct(y,"link",t),r.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},u.set(m,y))}}function Fy(t,o,r,u){var m=(m=me.current)?Kl(m):null;if(!m)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(o=js(r.href),r=ko(m).hoistableStyles,u=r.get(o),u||(u={type:"style",instance:null,count:0,state:null},r.set(o,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){t=js(r.href);var y=ko(m).hoistableStyles,C=y.get(t);if(C||(m=m.ownerDocument||m,C={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(t,C),(y=m.querySelector(Ir(t)))&&!y._p&&(C.instance=y,C.state.loading=5),un.has(t)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},un.set(t,r),y||qw(m,t,r,C.state))),o&&u===null)throw Error(s(528,""));return C}if(o&&u!==null)throw Error(s(529,""));return null;case"script":return o=r.async,r=r.src,typeof r=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=Ts(r),r=ko(m).hoistableScripts,u=r.get(o),u||(u={type:"script",instance:null,count:0,state:null},r.set(o,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function js(t){return'href="'+$t(t)+'"'}function Ir(t){return'link[rel="stylesheet"]['+t+"]"}function Iy(t){return x({},t,{"data-precedence":t.precedence,precedence:null})}function qw(t,o,r,u){t.querySelector('link[rel="preload"][as="style"]['+o+"]")?u.loading=1:(o=t.createElement("link"),u.preload=o,o.addEventListener("load",function(){return u.loading|=1}),o.addEventListener("error",function(){return u.loading|=2}),Ct(o,"link",r),it(o),t.head.appendChild(o))}function Ts(t){return'[src="'+$t(t)+'"]'}function Lr(t){return"script[async]"+t}function Ly(t,o,r){if(o.count++,o.instance===null)switch(o.type){case"style":var u=t.querySelector('style[data-href~="'+$t(r.href)+'"]');if(u)return o.instance=u,it(u),u;var m=x({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),it(u),Ct(u,"style",m),Yl(u,r.precedence,t),o.instance=u;case"stylesheet":m=js(r.href);var y=t.querySelector(Ir(m));if(y)return o.state.loading|=4,o.instance=y,it(y),y;u=Iy(r),(m=un.get(m))&&Cp(u,m),y=(t.ownerDocument||t).createElement("link"),it(y);var C=y;return C._p=new Promise(function(R,Y){C.onload=R,C.onerror=Y}),Ct(y,"link",u),o.state.loading|=4,Yl(y,r.precedence,t),o.instance=y;case"script":return y=Ts(r.src),(m=t.querySelector(Lr(y)))?(o.instance=m,it(m),m):(u=r,(m=un.get(y))&&(u=x({},r),Ep(u,m)),t=t.ownerDocument||t,m=t.createElement("script"),it(m),Ct(m,"link",u),t.head.appendChild(m),o.instance=m);case"void":return null;default:throw Error(s(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(u=o.instance,o.state.loading|=4,Yl(u,r.precedence,t));return o.instance}function Yl(t,o,r){for(var u=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,y=m,C=0;C<u.length;C++){var R=u[C];if(R.dataset.precedence===o)y=R;else if(y!==m)break}y?y.parentNode.insertBefore(t,y.nextSibling):(o=r.nodeType===9?r.head:r,o.insertBefore(t,o.firstChild))}function Cp(t,o){t.crossOrigin==null&&(t.crossOrigin=o.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=o.referrerPolicy),t.title==null&&(t.title=o.title)}function Ep(t,o){t.crossOrigin==null&&(t.crossOrigin=o.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=o.referrerPolicy),t.integrity==null&&(t.integrity=o.integrity)}var Vl=null;function By(t,o,r){if(Vl===null){var u=new Map,m=Vl=new Map;m.set(r,u)}else m=Vl,u=m.get(r),u||(u=new Map,m.set(r,u));if(u.has(t))return u;for(u.set(t,null),r=r.getElementsByTagName(t),m=0;m<r.length;m++){var y=r[m];if(!(y[ia]||y[ht]||t==="link"&&y.getAttribute("rel")==="stylesheet")&&y.namespaceURI!=="http://www.w3.org/2000/svg"){var C=y.getAttribute(o)||"";C=t+C;var R=u.get(C);R?R.push(y):u.set(C,[y])}}return u}function Py(t,o,r){t=t.ownerDocument||t,t.head.insertBefore(r,o==="title"?t.querySelector("head > title"):null)}function Kw(t,o,r){if(r===1||o.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;return o.rel==="stylesheet"?(t=o.disabled,typeof o.precedence=="string"&&t==null):!0;case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function Hy(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function Yw(t,o,r,u){if(r.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var m=js(u.href),y=o.querySelector(Ir(m));if(y){o=y._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(t.count++,t=Wl.bind(t),o.then(t,t)),r.state.loading|=4,r.instance=y,it(y);return}y=o.ownerDocument||o,u=Iy(u),(m=un.get(m))&&Cp(u,m),y=y.createElement("link"),it(y);var C=y;C._p=new Promise(function(R,Y){C.onload=R,C.onerror=Y}),Ct(y,"link",u),r.instance=y}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(r,o),(o=r.state.preload)&&(r.state.loading&3)===0&&(t.count++,r=Wl.bind(t),o.addEventListener("load",r),o.addEventListener("error",r))}}var jp=0;function Vw(t,o){return t.stylesheets&&t.count===0&&Zl(t,t.stylesheets),0<t.count||0<t.imgCount?function(r){var u=setTimeout(function(){if(t.stylesheets&&Zl(t,t.stylesheets),t.unsuspend){var y=t.unsuspend;t.unsuspend=null,y()}},6e4+o);0<t.imgBytes&&jp===0&&(jp=62500*Tw());var m=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Zl(t,t.stylesheets),t.unsuspend)){var y=t.unsuspend;t.unsuspend=null,y()}},(t.imgBytes>jp?50:800)+o);return t.unsuspend=r,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Wl(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zl(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Xl=null;function Zl(t,o){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Xl=new Map,o.forEach(Ww,t),Xl=null,Wl.call(t))}function Ww(t,o){if(!(o.state.loading&4)){var r=Xl.get(t);if(r)var u=r.get(null);else{r=new Map,Xl.set(t,r);for(var m=t.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y<m.length;y++){var C=m[y];(C.nodeName==="LINK"||C.getAttribute("media")!=="not all")&&(r.set(C.dataset.precedence,C),u=C)}u&&r.set(null,u)}m=o.instance,C=m.getAttribute("data-precedence"),y=r.get(C)||u,y===u&&r.set(null,m),r.set(C,m),this.count++,u=Wl.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),y?y.parentNode.insertBefore(m,y.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(m,t.firstChild)),o.state.loading|=4}}var Br={$$typeof:S,Provider:null,Consumer:null,_currentValue:q,_currentValue2:q,_threadCount:0};function Xw(t,o,r,u,m,y,C,R,Y){this.tag=1,this.containerInfo=t,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Zs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zs(0),this.hiddenUpdates=Zs(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=y,this.onRecoverableError=C,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Y,this.incompleteTransitions=new Map}function Uy(t,o,r,u,m,y,C,R,Y,ne,le,de){return t=new Xw(t,o,r,C,Y,ne,le,de,R),o=1,y===!0&&(o|=24),y=Yt(3,null,null,o),t.current=y,y.stateNode=t,o=rd(),o.refCount++,t.pooledCache=o,o.refCount++,y.memoizedState={element:u,isDehydrated:r,cache:o},ud(y),t}function Gy(t){return t?(t=ss,t):ss}function qy(t,o,r,u,m,y){m=Gy(m),u.context===null?u.context=m:u.pendingContext=m,u=No(o),u.payload={element:r},y=y===void 0?null:y,y!==null&&(u.callback=y),r=Ao(t,u,o),r!==null&&(Ht(r,t,o),xr(r,t,o))}function Ky(t,o){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<o?r:o}}function Tp(t,o){Ky(t,o),(t=t.alternate)&&Ky(t,o)}function Yy(t){if(t.tag===13||t.tag===31){var o=fa(t,67108864);o!==null&&Ht(o,t,67108864),Tp(t,67108864)}}function Vy(t){if(t.tag===13||t.tag===31){var o=Qt();o=Qs(o);var r=fa(t,o);r!==null&&Ht(r,t,o),Tp(t,o)}}var Ql=!0;function Zw(t,o,r,u){var m=D.T;D.T=null;var y=U.p;try{U.p=2,Np(t,o,r,u)}finally{U.p=y,D.T=m}}function Qw(t,o,r,u){var m=D.T;D.T=null;var y=U.p;try{U.p=8,Np(t,o,r,u)}finally{U.p=y,D.T=m}}function Np(t,o,r,u){if(Ql){var m=Ap(u);if(m===null)hp(t,o,u,Jl,r),Xy(t,u);else if(eS(m,t,o,r,u))u.stopPropagation();else if(Xy(t,u),o&4&&-1<Jw.indexOf(t)){for(;m!==null;){var y=bo(m);if(y!==null)switch(y.tag){case 3:if(y=y.stateNode,y.current.memoizedState.isDehydrated){var C=Hn(y.pendingLanes);if(C!==0){var R=y;for(R.pendingLanes|=2,R.entangledLanes|=2;C;){var Y=1<<31-zt(C);R.entanglements[1]|=Y,C&=~Y}_n(y),(Pe&6)===0&&(Ol=kt()+500,Rr(0))}}break;case 31:case 13:R=fa(y,2),R!==null&&Ht(R,y,2),Fl(),Tp(y,2)}if(y=Ap(u),y===null&&hp(t,o,u,Jl,r),y===m)break;m=y}m!==null&&u.stopPropagation()}else hp(t,o,u,null,r)}}function Ap(t){return t=Du(t),_p(t)}var Jl=null;function _p(t){if(Jl=null,t=xo(t),t!==null){var o=l(t);if(o===null)t=null;else{var r=o.tag;if(r===13){if(t=d(o),t!==null)return t;t=null}else if(r===31){if(t=p(o),t!==null)return t;t=null}else if(r===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;t=null}else o!==t&&(t=null)}}return Jl=t,null}function Wy(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ha()){case Pn:return 2;case yo:return 8;case oa:case yu:return 32;case Ua:return 268435456;default:return 32}default:return 32}}var Dp=!1,Po=null,Ho=null,Uo=null,Pr=new Map,Hr=new Map,Go=[],Jw="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Xy(t,o){switch(t){case"focusin":case"focusout":Po=null;break;case"dragenter":case"dragleave":Ho=null;break;case"mouseover":case"mouseout":Uo=null;break;case"pointerover":case"pointerout":Pr.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hr.delete(o.pointerId)}}function Ur(t,o,r,u,m,y){return t===null||t.nativeEvent!==y?(t={blockedOn:o,domEventName:r,eventSystemFlags:u,nativeEvent:y,targetContainers:[m]},o!==null&&(o=bo(o),o!==null&&Yy(o)),t):(t.eventSystemFlags|=u,o=t.targetContainers,m!==null&&o.indexOf(m)===-1&&o.push(m),t)}function eS(t,o,r,u,m){switch(o){case"focusin":return Po=Ur(Po,t,o,r,u,m),!0;case"dragenter":return Ho=Ur(Ho,t,o,r,u,m),!0;case"mouseover":return Uo=Ur(Uo,t,o,r,u,m),!0;case"pointerover":var y=m.pointerId;return Pr.set(y,Ur(Pr.get(y)||null,t,o,r,u,m)),!0;case"gotpointercapture":return y=m.pointerId,Hr.set(y,Ur(Hr.get(y)||null,t,o,r,u,m)),!0}return!1}function Zy(t){var o=xo(t.target);if(o!==null){var r=l(o);if(r!==null){if(o=r.tag,o===13){if(o=d(r),o!==null){t.blockedOn=o,Pi(t.priority,function(){Vy(r)});return}}else if(o===31){if(o=p(r),o!==null){t.blockedOn=o,Pi(t.priority,function(){Vy(r)});return}}else if(o===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function ec(t){if(t.blockedOn!==null)return!1;for(var o=t.targetContainers;0<o.length;){var r=Ap(t.nativeEvent);if(r===null){r=t.nativeEvent;var u=new r.constructor(r.type,r);_u=u,r.target.dispatchEvent(u),_u=null}else return o=bo(r),o!==null&&Yy(o),t.blockedOn=r,!1;o.shift()}return!0}function Qy(t,o,r){ec(t)&&r.delete(o)}function tS(){Dp=!1,Po!==null&&ec(Po)&&(Po=null),Ho!==null&&ec(Ho)&&(Ho=null),Uo!==null&&ec(Uo)&&(Uo=null),Pr.forEach(Qy),Hr.forEach(Qy)}function tc(t,o){t.blockedOn===o&&(t.blockedOn=null,Dp||(Dp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,tS)))}var nc=null;function Jy(t){nc!==t&&(nc=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){nc===t&&(nc=null);for(var o=0;o<t.length;o+=3){var r=t[o],u=t[o+1],m=t[o+2];if(typeof u!="function"){if(_p(u||r)===null)continue;break}var y=bo(r);y!==null&&(t.splice(o,3),o-=3,Ad(y,{pending:!0,data:m,method:r.method,action:u},u,m))}}))}function Ns(t){function o(Y){return tc(Y,t)}Po!==null&&tc(Po,t),Ho!==null&&tc(Ho,t),Uo!==null&&tc(Uo,t),Pr.forEach(o),Hr.forEach(o);for(var r=0;r<Go.length;r++){var u=Go[r];u.blockedOn===t&&(u.blockedOn=null)}for(;0<Go.length&&(r=Go[0],r.blockedOn===null);)Zy(r),r.blockedOn===null&&Go.shift();if(r=(t.ownerDocument||t).$$reactFormReplay,r!=null)for(u=0;u<r.length;u+=3){var m=r[u],y=r[u+1],C=m[At]||null;if(typeof y=="function")C||Jy(r);else if(C){var R=null;if(y&&y.hasAttribute("formAction")){if(m=y,C=y[At]||null)R=C.formAction;else if(_p(m)!==null)continue}else R=C.action;typeof R=="function"?r[u+1]=R:(r.splice(u,3),u-=3),Jy(r)}}}function e0(){function t(y){y.canIntercept&&y.info==="react-transition"&&y.intercept({handler:function(){return new Promise(function(C){return m=C})},focusReset:"manual",scroll:"manual"})}function o(){m!==null&&(m(),m=null),u||setTimeout(r,20)}function r(){if(!u&&!navigation.transition){var y=navigation.currentEntry;y&&y.url!=null&&navigation.navigate(y.url,{state:y.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,m=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(r,100),function(){u=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),m!==null&&(m(),m=null)}}}function zp(t){this._internalRoot=t}oc.prototype.render=zp.prototype.render=function(t){var o=this._internalRoot;if(o===null)throw Error(s(409));var r=o.current,u=Qt();qy(r,u,t,o,null,null)},oc.prototype.unmount=zp.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var o=t.containerInfo;qy(t.current,2,null,t,null,null),Fl(),o[Un]=null}};function oc(t){this._internalRoot=t}oc.prototype.unstable_scheduleHydration=function(t){if(t){var o=Bi();t={blockedOn:null,target:t,priority:o};for(var r=0;r<Go.length&&o!==0&&o<Go[r].priority;r++);Go.splice(r,0,t),r===0&&Zy(t)}};var t0=n.version;if(t0!=="19.2.4")throw Error(s(527,t0,"19.2.4"));U.findDOMNode=function(t){var o=t._reactInternals;if(o===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=h(o),t=t!==null?g(t):null,t=t===null?null:t.stateNode,t};var nS={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ac=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ac.isDisabled&&ac.supportsFiber)try{aa=ac.inject(nS),Dt=ac}catch{}}return qr.createRoot=function(t,o){if(!i(t))throw Error(s(299));var r=!1,u="",m=lg,y=cg,C=ug;return o!=null&&(o.unstable_strictMode===!0&&(r=!0),o.identifierPrefix!==void 0&&(u=o.identifierPrefix),o.onUncaughtError!==void 0&&(m=o.onUncaughtError),o.onCaughtError!==void 0&&(y=o.onCaughtError),o.onRecoverableError!==void 0&&(C=o.onRecoverableError)),o=Uy(t,1,!1,null,null,r,u,null,m,y,C,e0),t[Un]=o.current,mp(t),new zp(o)},qr.hydrateRoot=function(t,o,r){if(!i(t))throw Error(s(299));var u=!1,m="",y=lg,C=cg,R=ug,Y=null;return r!=null&&(r.unstable_strictMode===!0&&(u=!0),r.identifierPrefix!==void 0&&(m=r.identifierPrefix),r.onUncaughtError!==void 0&&(y=r.onUncaughtError),r.onCaughtError!==void 0&&(C=r.onCaughtError),r.onRecoverableError!==void 0&&(R=r.onRecoverableError),r.formState!==void 0&&(Y=r.formState)),o=Uy(t,1,!0,o,r??null,u,m,Y,y,C,R,e0),o.context=Gy(null),r=o.current,u=Qt(),u=Qs(u),m=No(u),m.callback=null,Ao(r,m,u),r=u,o.current.lanes=r,ra(o,r),_n(o),t[Un]=o.current,mp(t),new oc(o)},qr.version="19.2.4",qr}var d0;function dS(){if(d0)return $p.exports;d0=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),$p.exports=uS(),$p.exports}var pS=dS();const fS="modulepreload",mS=function(e){return"/"+e},p0={},ta=function(n,a,s){let i=Promise.resolve();if(a&&a.length>0){let f=function(h){return Promise.all(h.map(g=>Promise.resolve(g).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),p=d?.nonce||d?.getAttribute("nonce");i=f(a.map(h=>{if(h=mS(h),h in p0)return;p0[h]=!0;const g=h.endsWith(".css"),x=g?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${x}`))return;const b=document.createElement("link");if(b.rel=g?"stylesheet":fS,g||(b.as="script"),b.crossOrigin="",b.href=h,p&&b.setAttribute("nonce",p),document.head.appendChild(b),g)return new Promise((v,k)=>{b.addEventListener("load",v),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${h}`)))})}))}function l(d){const p=new Event("vite:preloadError",{cancelable:!0});if(p.payload=d,window.dispatchEvent(p),!p.defaultPrevented)throw d}return i.then(d=>{for(const p of d||[])p.status==="rejected"&&l(p.reason);return n().catch(l)})},f0=e=>{let n;const a=new Set,s=(h,g)=>{const x=typeof h=="function"?h(n):h;if(!Object.is(x,n)){const b=n;n=g??(typeof x!="object"||x===null)?x:Object.assign({},n,x),a.forEach(v=>v(n,b))}},i=()=>n,p={setState:s,getState:i,getInitialState:()=>f,subscribe:h=>(a.add(h),()=>a.delete(h))},f=n=e(s,i,p);return p},hS=(e=>e?f0(e):f0),gS=e=>e;function yS(e,n=gS){const a=Qr.useSyncExternalStore(e.subscribe,Qr.useCallback(()=>n(e.getState()),[e,n]),Qr.useCallback(()=>n(e.getInitialState()),[e,n]));return Qr.useDebugValue(a),a}const m0=e=>{const n=hS(e),a=s=>yS(n,s);return Object.assign(a,n),a},qt=(e=>e?m0(e):m0);function xS(e,n){let a;try{a=e()}catch{return}return{getItem:i=>{var l;const d=f=>f===null?null:JSON.parse(f,void 0),p=(l=a.getItem(i))!=null?l:null;return p instanceof Promise?p.then(d):d(p)},setItem:(i,l)=>a.setItem(i,JSON.stringify(l,void 0)),removeItem:i=>a.removeItem(i)}}const uf=e=>n=>{try{const a=e(n);return a instanceof Promise?a:{then(s){return uf(s)(a)},catch(s){return this}}}catch(a){return{then(s){return this},catch(s){return uf(s)(a)}}}},bS=(e,n)=>(a,s,i)=>{let l={storage:xS(()=>window.localStorage),partialize:j=>j,version:0,merge:(j,T)=>({...T,...j}),...n},d=!1,p=0;const f=new Set,h=new Set;let g=l.storage;if(!g)return e((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${l.name}', the given storage is currently unavailable.`),a(...j)},s,i);const x=()=>{const j=l.partialize({...s()});return g.setItem(l.name,{state:j,version:l.version})},b=i.setState;i.setState=(j,T)=>(b(j,T),x());const v=e((...j)=>(a(...j),x()),s,i);i.getInitialState=()=>v;let k;const w=()=>{var j,T;if(!g)return;const E=++p;d=!1,f.forEach(M=>{var $;return M(($=s())!=null?$:v)});const S=((T=l.onRehydrateStorage)==null?void 0:T.call(l,(j=s())!=null?j:v))||void 0;return uf(g.getItem.bind(g))(l.name).then(M=>{if(M)if(typeof M.version=="number"&&M.version!==l.version){if(l.migrate){const $=l.migrate(M.state,M.version);return $ instanceof Promise?$.then(A=>[!0,A]):[!0,$]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,M.state];return[!1,void 0]}).then(M=>{var $;if(E!==p)return;const[A,_]=M;if(k=l.merge(_,($=s())!=null?$:v),a(k,!0),A)return x()}).then(()=>{E===p&&(S?.(k,void 0),k=s(),d=!0,h.forEach(M=>M(k)))}).catch(M=>{E===p&&S?.(void 0,M)})};return i.persist={setOptions:j=>{l={...l,...j},j.storage&&(g=j.storage)},clearStorage:()=>{g?.removeItem(l.name)},getOptions:()=>l,rehydrate:()=>w(),hasHydrated:()=>d,onHydrate:j=>(f.add(j),()=>{f.delete(j)}),onFinishHydration:j=>(h.add(j),()=>{h.delete(j)})},l.skipHydration||w(),k||v},vS=bS,Qo={"ground-truth":{label:"Ground Truth",color:"#e74c3c",icon:"🔴",instruction:"Do not contradict this."},signal:{label:"Signal",color:"#f1c40f",icon:"🟡",instruction:"Interpret — look for the underlying need, not the surface request."},evidence:{label:"Evidence",color:"#3498db",icon:"🔵",instruction:"Cite and weigh against other evidence."},framework:{label:"Framework",color:"#2ecc71",icon:"🟢",instruction:"Use to structure thinking, but not as immutable."},hypothesis:{label:"Hypothesis",color:"#9b59b6",icon:"🟣",instruction:"Help validate or invalidate with evidence and signals."},guideline:{label:"Guideline",color:"#FE5000",icon:"📏",instruction:"Extract and enforce as constraints, workflow rules, and output formatting."}},kS=[[["signal","feedback","user feedback"],"signal"],[["discovery","_temp_"],"hypothesis"],[["roadmap","plans/","plan/"],"framework"],[["intel","competitors","competitive","research","savings-analysis"],"evidence"],[["cmo-handoff","release","demo","newsletter"],"evidence"],[["sales prep","event prep","executive profiler"],"framework"],[["guidelines","contributing","code-style","coding-standards","engineering-rules"],"guideline"],[["products"],"ground-truth",["feedback"]],[["clients/"],"ground-truth",["feedback"]],[["companies"],"evidence"],[["voyage-preparation","navarea-map"],"ground-truth"]],wS=[{patterns:[/^#{1,2}\s*(spec|specification|schema|api|contract|definition|interface)/mi,/\b(MUST|SHALL|REQUIRED)\b/g,/```(json|yaml|graphql|proto|sql)\b/g,/\b(version|v\d+\.\d+)/gi],type:"ground-truth",weight:10,minMatches:2},{patterns:[/\b(user said|customer|feedback|interview|request(ed)?|pain point|frustrat|complain|asked for|wants? to|need(s|ed)?)\b/gi,/\b(nps|csat|satisfaction|churn|retention)\b/gi,/[""][^""]{10,}[""]/g,/\b(quote|verbatim)\b/gi],type:"signal",weight:8,minMatches:2},{patterns:[/\b(analysis|benchmark|comparison|metric|kpi|data|report|finding|result|measured|observed)\b/gi,/\d+(\.\d+)?%/g,/\b(increase|decrease|growth|decline|trend)\b/gi,/\|\s*\w+\s*\|/g],type:"evidence",weight:7,minMatches:2},{patterns:[/\b(framework|methodology|process|template|playbook|checklist|step \d|phase \d|stage \d)\b/gi,/\b(when to|how to|best practice|guideline|principle|pattern)\b/gi,/^\s*[-*]\s*\[[ x]\]/gm,/\b(input|output|trigger|criteria)\b/gi],type:"framework",weight:6,minMatches:2},{patterns:[/\b(hypothesis|proposal|rfc|suggest(ion)?|idea|explore|what if|could we|might|experiment|assumption|validate)\b/gi,/\b(pro(s)?|con(s)?|trade-?off|risk|upside|downside)\b/gi,/\b(option [a-c]|alternative|approach \d)\b/gi],type:"hypothesis",weight:5,minMatches:2},{patterns:[/\b(MUST|SHALL|NEVER|ALWAYS|REQUIRED|FORBIDDEN|DO NOT)\b/g,/\b(convention|standard|guideline|rule|policy|style guide|best practice|coding standard)\b/gi,/\b(naming|branch|commit|pr|pull request)\s*(convention|format|rule|pattern)/gi,/\b(linting|formatting|eslint|prettier|editorconfig)\b/gi],type:"guideline",weight:8,minMatches:2}],SS=[{test:(e,n)=>n==="ground-truth",depth:0},{test:(e,n)=>n==="signal",depth:0},{test:e=>e.length<2e3,depth:0},{test:(e,n)=>n==="hypothesis",depth:1},{test:(e,n)=>n==="evidence"&&e.length>8e3,depth:2},{test:(e,n)=>n==="evidence",depth:1},{test:(e,n)=>n==="framework"&&e.length>8e3,depth:2},{test:(e,n)=>n==="framework",depth:1},{test:(e,n)=>n==="guideline",depth:0}];function ni(e,n){return df(e,n).knowledgeType}function df(e,n){const a=e.toLowerCase();for(const[l,d,p]of kS)if(l.some(f=>a.includes(f))){if(p&&p.some(h=>a.includes(h)))continue;const f=sc(n||"",d);return{knowledgeType:d,depth:f,confidence:"high",reason:`Path matches "${l.find(h=>a.includes(h))}"`}}if(n&&n.length>50){const l=[];for(const d of wS){let p=0,f=0;for(const g of d.patterns){g.lastIndex=0;const x=n.match(g);x&&x.length>0&&(f++,p+=x.length)}const h=d.minMatches??1;f>=h&&l.push({type:d.type,score:p*d.weight,matches:f})}if(l.length>0){l.sort((h,g)=>g.score-h.score);const d=l[0],p=d.score>30?"high":d.score>10?"medium":"low",f=sc(n,d.type);return{knowledgeType:d.type,depth:f,confidence:p,reason:`Content analysis: ${d.matches} pattern groups, score ${d.score}`}}}const s=e.split(".").pop()?.toLowerCase();if(s){const l={json:"ground-truth",yaml:"ground-truth",yml:"ground-truth",toml:"ground-truth",sql:"ground-truth",graphql:"ground-truth",proto:"ground-truth",csv:"evidence",tsv:"evidence",xlsx:"evidence",py:"guideline",ts:"guideline",js:"guideline",tsx:"guideline",jsx:"guideline",log:"guideline",txt:"evidence"};if(l[s]){const d=sc(n||"",l[s]);return{knowledgeType:l[s],depth:d,confidence:"low",reason:`File extension .${s}`}}}return{knowledgeType:"evidence",depth:sc(n||"","evidence"),confidence:"low",reason:"Default"}}function sc(e,n){for(const a of SS)if(a.test(e,n))return a.depth;return 1}const sb=[{id:"markdown",label:"Markdown",icon:"📝",ext:".md"},{id:"html-slides",label:"HTML Slides",icon:"🎯",ext:".html"},{id:"email",label:"Email Draft",icon:"✉️",ext:""},{id:"code",label:"Code",icon:"💻",ext:".py"},{id:"csv",label:"Data Table",icon:"📊",ext:".csv"},{id:"json",label:"JSON",icon:"{}",ext:".json"},{id:"diagram",label:"Diagram",icon:"🔀",ext:".svg"},{id:"slack",label:"Slack Post",icon:"💬",ext:""}];function MS(e){const n=e.toLowerCase();return n.includes("slide")||n.includes("presentation")||n.includes("pitch")||n.includes("deck")?"html-slides":n.includes("email")||n.includes("draft")||n.includes("send to")?"email":n.includes("script")||n.includes("function")||n.includes("code")||n.includes("implement")?"code":n.includes("table")||n.includes("csv")||n.includes("spreadsheet")||n.includes("data")?"csv":n.includes("json")||n.includes("api")||n.includes("schema")?"json":n.includes("diagram")||n.includes("flowchart")||n.includes("architecture")?"diagram":n.includes("slack")||n.includes("post in")?"slack":"markdown"}const Fs=[{label:"Full",pct:1},{label:"Detail",pct:.75},{label:"Summary",pct:.5},{label:"Headlines",pct:.25},{label:"Mention",pct:.1}],h0={model:"claude-opus-4",temperature:.7,systemPrompt:"",planningMode:"single-shot",maxTokens:4096};function ke(e,n,a,s,i,l=0){return{sourceId:e,name:n,path:a,category:s,knowledgeType:ni(a),depth:l,baseTokens:i}}const CS=[{id:"senior-pm",name:"Senior PM",agentConfig:{model:"claude-opus-4",temperature:.5,planningMode:"chain-of-thought",maxTokens:8192},channels:[ke("knowledge-products","Products","00 - Knowledge/Products/","knowledge",16e3,0),ke("knowledge-products-feedback","Feedback","00 - Knowledge/Products/Feedback/","knowledge",4800,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,1),ke("signals-kcc","User feedback / KCC","07 - Signals/User feedback/kcc/","intel",5200,1),ke("signals-general","User feedback / General","07 - Signals/User feedback/general/","intel",7500,1),ke("discovery-eu-ets","EU ETS Cost Layer","01 - Discovery/EU ETS Cost Layer/","discovery",3200,2),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,2),ke("discovery-fleet-dashboard","Fleet Dashboard","01 - Discovery/Fleet Dashboard/","discovery",3500,2),ke("roadmap","03 - Roadmap","03 - Roadmap/","knowledge",12e3,1)]},{id:"competitive-intel",name:"Competitive Intel",agentConfig:{model:"claude-opus-4",temperature:.3,planningMode:"react",maxTokens:8192},channels:[ke("knowledge-competitors","Competitors","00 - Knowledge/Competitors/","knowledge",22e3,0),ke("knowledge-competitors-stormgeo","StormGeo","00 - Knowledge/Competitors/Features/stormgeo/","knowledge",4500,0),ke("knowledge-competitors-dtn","DTN","00 - Knowledge/Competitors/Features/dtn/","knowledge",3800,0),ke("knowledge-competitors-sofar","Sofar","00 - Knowledge/Competitors/Features/sofar/","knowledge",3200,0),ke("knowledge-competitors-wni","WNI","00 - Knowledge/Competitors/Features/wni/","knowledge",3600,0),ke("cmo-competitive-intel","05 - Competitive Intel","CMO-Handoff/05 - Competitive Intel/","intel",5800,1),ke("intel-competitive","01 - Competitive Intel","05 - Intel/01 - Competitive Intel/","intel",12e3,0)]},{id:"company-intel",name:"Company Intel",channels:[ke("knowledge-companies","Companies","00 - Knowledge/Companies/","knowledge",14e3,0),ke("cmo-company-profiles","01 - Company Profiles","CMO-Handoff/01 - Company Profiles/","knowledge",28e3,0),ke("cmo-charter-structures","02 - Charter Structures","CMO-Handoff/02 - Charter Structures/","knowledge",8500,1)]},{id:"feedback-manager",name:"Feedback Manager",agentConfig:{model:"claude-sonnet-4",temperature:.4,planningMode:"chain-of-thought",maxTokens:4096},channels:[ke("knowledge-products-feedback","Feedback","00 - Knowledge/Products/Feedback/","knowledge",4800,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,0),ke("signals-kcc","User feedback / KCC","07 - Signals/User feedback/kcc/","intel",5200,0),ke("signals-baru","User feedback / Baru","07 - Signals/User feedback/baru/","intel",4500,0),ke("signals-general","User feedback / General","07 - Signals/User feedback/general/","intel",7500,0),ke("intel-feedback","04 - Feedback Synthesis","05 - Intel/04 - Feedback Synthesis/","intel",4800,1)]},{id:"odfjell-deep-dive",name:"Odfjell Deep Dive",channels:[ke("odfjell-savings","odfjell-savings-analysis","odfjell-savings-analysis/","intel",14e3,0),ke("knowledge-clients-odfjell","Odfjell","00 - Knowledge/Clients/odfjell/","knowledge",4200,0),ke("signals-odfjell","User feedback / Odfjell","07 - Signals/User feedback/odfjell/","intel",6800,0),ke("cmo-charter-structures","02 - Charter Structures","CMO-Handoff/02 - Charter Structures/","knowledge",8500,1),ke("knowledge-competitors-stormgeo","StormGeo","00 - Knowledge/Competitors/Features/stormgeo/","knowledge",4500,2)]},{id:"voyage-prep-dev",name:"Voyage Prep Dev",channels:[ke("voyage-prep","voyage-preparation","voyage-preparation/","discovery",18e3,0),ke("temp-voyage","_temp_voyage-briefing","_temp_voyage-briefing/","discovery",6400,0),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,1),ke("knowledge-products-nr","Navigation Reports","00 - Knowledge/Products/NR/","knowledge",8200,1)]},{id:"event-prep",name:"Event Prep",channels:[ke("sales-prep-events","Event Prep","06 - Sales Prep/Event Prep/","agents",9500,0),ke("sales-prep-exec","Executive Profiler","06 - Sales Prep/Executive Profiler/","agents",8500,0),ke("cmo-event-prep","07 - Event Prep Profiles","CMO-Handoff/07 - Event Prep Profiles/","agents",3500,0),ke("cmo-company-profiles","01 - Company Profiles","CMO-Handoff/01 - Company Profiles/","knowledge",28e3,2)]},{id:"maritime-intel",name:"Maritime Intel",channels:[ke("intel-maritime","02 - Maritime Intel","05 - Intel/02 - Maritime Intel/","intel",14e3,0),ke("navarea-map","navarea-map","navarea-map/","intel",11e3,0),ke("intel-research","03 - Research","05 - Intel/03 - Research/","intel",7200,1)]},{id:"discovery-all",name:"Discovery",channels:[ke("discovery-eu-ets","EU ETS Cost Layer","01 - Discovery/EU ETS Cost Layer/","discovery",3200,0),ke("discovery-weather-routing","Weather Routing v2","01 - Discovery/Weather Routing v2/","discovery",4100,0),ke("discovery-cii-monitor","CII Monitor","01 - Discovery/CII Monitor/","discovery",2800,0),ke("discovery-fleet-dashboard","Fleet Dashboard","01 - Discovery/Fleet Dashboard/","discovery",3500,0),ke("discovery-voyage-compare","Voyage Compare","01 - Discovery/Voyage Compare/","discovery",2600,0),ke("discovery-port-insights","Port Insights","01 - Discovery/Port Insights/","discovery",2200,0),ke("discovery-api-v2","API v2","01 - Discovery/API v2/","discovery",3800,0),ke("discovery-alerts-engine","Alerts Engine","01 - Discovery/Alerts Engine/","discovery",2400,0),ke("discovery-bunker-opt","Bunker Optimization","01 - Discovery/Bunker Optimization/","discovery",3100,0),ke("discovery-cargo-tracking","Cargo Tracking","01 - Discovery/Cargo Tracking/","discovery",2700,0)]},{id:"all-knowledge",name:"All Knowledge",channels:[ke("knowledge","00 - Knowledge","00 - Knowledge/","knowledge",82e3,2),ke("knowledge-clients","Clients","00 - Knowledge/Clients/","knowledge",18e3,1),ke("knowledge-companies","Companies","00 - Knowledge/Companies/","knowledge",14e3,1),ke("knowledge-competitors","Competitors","00 - Knowledge/Competitors/","knowledge",22e3,1),ke("knowledge-products","Products","00 - Knowledge/Products/","knowledge",16e3,0),ke("knowledge-market","Market","00 - Knowledge/Market/","knowledge",6500,2),ke("knowledge-users","Users","00 - Knowledge/Users/","knowledge",5500,2)]}],Kc=[{id:"mcp-filesystem",name:"Filesystem",npmPackage:"@modelcontextprotocol/server-filesystem",description:"Read, write, and manage local files with configurable access controls",icon:"folder",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-filesystem"],configFields:[{key:"ALLOWED_DIRS",label:"Allowed Directories (comma-separated)",type:"text",placeholder:"/home/user/projects,/tmp",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["files","local","read","write"],authMethod:"none"},{id:"mcp-memory",name:"Memory (Knowledge Graph)",npmPackage:"@modelcontextprotocol/server-memory",description:"Persistent knowledge graph memory for agent state and relationships",icon:"brain",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-memory"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["memory","knowledge-graph","state","persistence"],authMethod:"none"},{id:"mcp-fetch",name:"Fetch",npmPackage:"@modelcontextprotocol/server-fetch",description:"Fetch web content and convert to markdown for LLM consumption",icon:"download",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-fetch"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["web","fetch","scrape","markdown"],authMethod:"none"},{id:"mcp-git",name:"Git",npmPackage:"@modelcontextprotocol/server-git",description:"Read, search, and manipulate Git repositories - log, diff, blame",icon:"git-branch",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"uvx",defaultArgs:["mcp-server-git"],configFields:[{key:"GIT_REPO_PATH",label:"Repository Path",type:"text",placeholder:"/path/to/repo",required:!1}],repo:"https://github.com/modelcontextprotocol/servers",tags:["git","version-control","diff","log"],authMethod:"none"},{id:"mcp-sequential-thinking",name:"Sequential Thinking",npmPackage:"@modelcontextprotocol/server-sequential-thinking",description:"Dynamic and reflective problem-solving through structured thought sequences",icon:"list-ordered",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-sequential-thinking"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["thinking","reasoning","chain-of-thought"],authMethod:"none"},{id:"mcp-time",name:"Time",npmPackage:"@modelcontextprotocol/server-time",description:"Get current time and convert between timezones",icon:"clock",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-time"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["time","timezone","date"],authMethod:"none"},{id:"mcp-everything",name:"Everything (Test)",npmPackage:"@modelcontextprotocol/server-everything",description:"Reference test server with prompts, resources, and tools for MCP testing",icon:"star",category:"coding",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-everything"],configFields:[],repo:"https://github.com/modelcontextprotocol/servers",tags:["test","reference","debug"],authMethod:"none"},{id:"mcp-brave-search",name:"Brave Search",npmPackage:"@modelcontextprotocol/server-brave-search",description:"Web and local search powered by Brave Search API",icon:"search",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-brave-search"],configFields:[{key:"BRAVE_API_KEY",label:"API Key",type:"password",placeholder:"BSA...",required:!0}],website:"https://brave.com/search/api/",tags:["search","web","brave"],authMethod:"api-key"},{id:"mcp-tavily",name:"Tavily Search",npmPackage:"tavily-mcp",description:"AI-optimized search engine with structured results and answer extraction",icon:"search",category:"research",author:"Tavily",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","tavily-mcp"],configFields:[{key:"TAVILY_API_KEY",label:"API Key",type:"password",placeholder:"tvly-...",required:!0}],website:"https://tavily.com",tags:["search","ai-search","research"],authMethod:"api-key"},{id:"mcp-exa",name:"Exa Search",npmPackage:"exa-mcp-server",description:"Neural search engine - find similar content, get page contents",icon:"search",category:"research",author:"Exa",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","exa-mcp-server"],configFields:[{key:"EXA_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://exa.ai",tags:["search","neural-search","semantic"],authMethod:"api-key"},{id:"mcp-firecrawl",name:"Firecrawl",npmPackage:"firecrawl-mcp",description:"Web scraping and crawling - extract structured data from any website",icon:"flame",category:"research",author:"Firecrawl",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","firecrawl-mcp"],configFields:[{key:"FIRECRAWL_API_KEY",label:"API Key",type:"password",placeholder:"fc-...",required:!0}],website:"https://firecrawl.dev",tags:["scraping","crawling","web","extract"],authMethod:"api-key"},{id:"mcp-puppeteer",name:"Puppeteer",npmPackage:"@modelcontextprotocol/server-puppeteer",description:"Browser automation - screenshots, navigation, form filling, scraping",icon:"globe",category:"research",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-puppeteer"],configFields:[],tags:["browser","automation","screenshots","scraping"],authMethod:"none"},{id:"mcp-playwright",name:"Playwright",npmPackage:"@playwright/mcp",description:"Browser automation with Playwright - cross-browser testing and scraping",icon:"globe",category:"research",author:"Microsoft",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@playwright/mcp"],configFields:[],tags:["browser","playwright","testing","automation"],authMethod:"none"},{id:"mcp-github",name:"GitHub",npmPackage:"@modelcontextprotocol/server-github",description:"GitHub repos, issues, PRs, code search, and actions",icon:"git-branch",category:"coding",author:"GitHub",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-github"],configFields:[{key:"GITHUB_TOKEN",label:"Personal Access Token",type:"password",placeholder:"ghp_...",required:!0}],website:"https://github.com",tags:["github","git","issues","pr","code"],authMethod:"api-key"},{id:"github-remote",name:"GitHub (Cloud)",npmPackage:"@modelcontextprotocol/server-github-cloud",description:"GitHub repos, issues, PRs – OAuth via GitHub App",icon:"git-branch",category:"coding",author:"GitHub",transport:"sse",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-github-cloud"],url:"https://api.githubcopilot.com/mcp/",authMethod:"oauth",configFields:[],website:"https://github.com",tags:["github","git","issues","pr","code","oauth"]},{id:"mcp-gitlab",name:"GitLab",npmPackage:"@modelcontextprotocol/server-gitlab",description:"GitLab API - projects, issues, merge requests, pipelines",icon:"git-merge",category:"coding",author:"GitLab",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-gitlab"],configFields:[{key:"GITLAB_TOKEN",label:"Access Token",type:"password",placeholder:"glpat-...",required:!0},{key:"GITLAB_URL",label:"Instance URL",type:"url",placeholder:"https://gitlab.com",required:!1}],tags:["gitlab","git","ci-cd","merge-request"],authMethod:"api-key"},{id:"mcp-linear",name:"Linear",npmPackage:"@linear/mcp-server",description:"Linear project management - issues, projects, cycles, and teams",icon:"target",category:"coding",author:"Linear",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@linear/mcp-server"],configFields:[{key:"LINEAR_API_KEY",label:"API Key",type:"password",placeholder:"lin_api_...",required:!0}],website:"https://linear.app",tags:["linear","project-management","issues","agile"],authMethod:"api-key"},{id:"mcp-sentry",name:"Sentry",npmPackage:"@sentry/mcp-server",description:"Error tracking and performance monitoring - issues, events, releases",icon:"shield",category:"coding",author:"Sentry",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@sentry/mcp-server"],configFields:[{key:"SENTRY_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"sntrys_...",required:!0}],website:"https://sentry.io",tags:["sentry","errors","monitoring","debugging"],authMethod:"api-key"},{id:"mcp-docker",name:"Docker",npmPackage:"docker-mcp",description:"Manage Docker containers, images, volumes, and networks",icon:"box",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","docker-mcp"],configFields:[],tags:["docker","containers","devops","infrastructure"],authMethod:"none"},{id:"mcp-kubernetes",name:"Kubernetes",npmPackage:"kubernetes-mcp",description:"Kubernetes cluster management - pods, deployments, services, logs",icon:"server",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","kubernetes-mcp"],configFields:[{key:"KUBECONFIG",label:"Kubeconfig Path",type:"text",placeholder:"~/.kube/config",required:!1}],tags:["kubernetes","k8s","devops","orchestration"],authMethod:"none"},{id:"mcp-vercel",name:"Vercel",npmPackage:"@vercel/mcp",description:"Vercel deployments, domains, environment variables, and logs",icon:"triangle",category:"coding",author:"Vercel",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@vercel/mcp"],configFields:[{key:"VERCEL_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],website:"https://vercel.com",tags:["vercel","deploy","hosting","serverless"],authMethod:"api-key"},{id:"mcp-cloudflare",name:"Cloudflare",npmPackage:"@cloudflare/mcp-server-cloudflare",description:"Cloudflare Workers, KV, R2, D1, and DNS management",icon:"cloud",category:"coding",author:"Cloudflare",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@cloudflare/mcp-server-cloudflare"],configFields:[{key:"CLOUDFLARE_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],website:"https://cloudflare.com",tags:["cloudflare","workers","cdn","dns"],authMethod:"api-key"},{id:"mcp-netlify",name:"Netlify",npmPackage:"netlify-mcp",description:"Netlify sites, deploys, functions, and build hooks",icon:"globe",category:"coding",author:"Netlify",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","netlify-mcp"],configFields:[{key:"NETLIFY_TOKEN",label:"Personal Access Token",type:"password",placeholder:"",required:!0}],tags:["netlify","deploy","hosting","jamstack"],authMethod:"api-key"},{id:"mcp-npm",name:"npm Registry",npmPackage:"npm-mcp",description:"Search npm packages, view details, check versions and dependencies",icon:"package",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","npm-mcp"],configFields:[],tags:["npm","packages","dependencies","registry"],authMethod:"none"},{id:"mcp-postgres",name:"PostgreSQL",npmPackage:"@modelcontextprotocol/server-postgres",description:"Query PostgreSQL databases - schema inspection, read/write operations",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-postgres"],configFields:[{key:"DATABASE_URL",label:"Connection String",type:"password",placeholder:"postgresql://user:pass@host:5432/db",required:!0}],tags:["postgres","database","sql","query"],authMethod:"api-key"},{id:"mcp-mysql",name:"MySQL",npmPackage:"mysql-mcp-server",description:"MySQL database operations - queries, schema, migrations",icon:"database",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mysql-mcp-server"],configFields:[{key:"MYSQL_URL",label:"Connection String",type:"password",placeholder:"mysql://user:pass@host:3306/db",required:!0}],tags:["mysql","database","sql"],authMethod:"api-key"},{id:"mcp-sqlite",name:"SQLite",npmPackage:"@modelcontextprotocol/server-sqlite",description:"SQLite database - local file-based SQL with business intelligence",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-sqlite"],configFields:[{key:"SQLITE_PATH",label:"Database File Path",type:"text",placeholder:"/path/to/database.db",required:!0}],tags:["sqlite","database","sql","local"],authMethod:"none"},{id:"mcp-mongodb",name:"MongoDB",npmPackage:"mongodb-mcp-server",description:"MongoDB operations - collections, documents, aggregation pipelines",icon:"database",category:"data",author:"MongoDB",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mongodb-mcp-server"],configFields:[{key:"MONGODB_URI",label:"Connection URI",type:"password",placeholder:"mongodb+srv://user:pass@cluster.mongodb.net/db",required:!0}],tags:["mongodb","nosql","database","documents"],authMethod:"api-key"},{id:"mcp-redis",name:"Redis",npmPackage:"@modelcontextprotocol/server-redis",description:"Redis key-value store - get, set, scan, pub/sub",icon:"database",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-redis"],configFields:[{key:"REDIS_URL",label:"Connection URL",type:"password",placeholder:"redis://localhost:6379",required:!0}],tags:["redis","cache","key-value","pub-sub"],authMethod:"api-key"},{id:"mcp-supabase",name:"Supabase",npmPackage:"@supabase/mcp-server",description:"Supabase - database, auth, storage, edge functions, realtime",icon:"database",category:"data",author:"Supabase",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@supabase/mcp-server"],configFields:[{key:"SUPABASE_URL",label:"Project URL",type:"url",placeholder:"https://xxx.supabase.co",required:!0},{key:"SUPABASE_SERVICE_ROLE_KEY",label:"Service Role Key",type:"password",placeholder:"eyJ...",required:!0}],website:"https://supabase.com",tags:["supabase","database","auth","storage","postgres"],authMethod:"api-key"},{id:"mcp-neon",name:"Neon",npmPackage:"@neondatabase/mcp-server-neon",description:"Neon serverless Postgres - branches, queries, schema management",icon:"database",category:"data",author:"Neon",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@neondatabase/mcp-server-neon"],configFields:[{key:"NEON_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://neon.tech",tags:["neon","postgres","serverless","database"],authMethod:"api-key"},{id:"mcp-turso",name:"Turso",npmPackage:"@tursodatabase/mcp-server",description:"Turso edge database - SQLite at the edge, libSQL",icon:"database",category:"data",author:"Turso",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@tursodatabase/mcp-server"],configFields:[{key:"TURSO_DATABASE_URL",label:"Database URL",type:"url",placeholder:"libsql://db-org.turso.io",required:!0},{key:"TURSO_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"",required:!0}],website:"https://turso.tech",tags:["turso","sqlite","edge","database"],authMethod:"api-key"},{id:"mcp-pinecone",name:"Pinecone",npmPackage:"@pinecone-database/mcp",description:"Pinecone vector database - upsert, query, delete vectors",icon:"database",category:"data",author:"Pinecone",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@pinecone-database/mcp"],configFields:[{key:"PINECONE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://pinecone.io",tags:["pinecone","vector","embeddings","rag"],authMethod:"api-key"},{id:"mcp-qdrant",name:"Qdrant",npmPackage:"qdrant-mcp",description:"Qdrant vector search - collections, points, filtering, similarity",icon:"database",category:"data",author:"Qdrant",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","qdrant-mcp"],configFields:[{key:"QDRANT_URL",label:"URL",type:"url",placeholder:"http://localhost:6333",required:!0},{key:"QDRANT_API_KEY",label:"API Key",type:"password",placeholder:"",required:!1}],website:"https://qdrant.tech",tags:["qdrant","vector","search","embeddings"],authMethod:"api-key"},{id:"mcp-slack",name:"Slack",npmPackage:"@modelcontextprotocol/server-slack",description:"Slack workspace - channels, messages, threads, search, reactions",icon:"hash",category:"data",author:"Slack",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-slack"],configFields:[{key:"SLACK_BOT_TOKEN",label:"Bot Token",type:"password",placeholder:"xoxb-...",required:!0},{key:"SLACK_TEAM_ID",label:"Team ID",type:"text",placeholder:"T0...",required:!1}],website:"https://slack.com",tags:["slack","messaging","channels","team"],authMethod:"api-key"},{id:"slack-remote",name:"Slack (Cloud)",npmPackage:"",description:"Slack workspace - OAuth, no bot token needed",icon:"hash",category:"data",author:"Slack",transport:"streamable-http",runtimes:["claude","amp","codex"],command:"",defaultArgs:[],url:"https://mcp.slack.com/sse",authMethod:"oauth",configFields:[],website:"https://slack.com",tags:["slack","messaging","channels","team","oauth"]},{id:"mcp-discord",name:"Discord",npmPackage:"discord-mcp",description:"Discord bot - read messages, manage channels, send notifications",icon:"message-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","discord-mcp"],configFields:[{key:"DISCORD_TOKEN",label:"Bot Token",type:"password",placeholder:"",required:!0}],tags:["discord","messaging","bot","community"],authMethod:"api-key"},{id:"mcp-gmail",name:"Gmail",npmPackage:"@gongrzhe/server-gmail-autoauth-mcp",description:"Read, send, search, and manage Gmail with OAuth auto-auth",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@gongrzhe/server-gmail-autoauth-mcp"],configFields:[{key:"GMAIL_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"...apps.googleusercontent.com",required:!0},{key:"GMAIL_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"GOCSPX-...",required:!0}],tags:["gmail","email","google","oauth"],authMethod:"api-key"},{id:"mcp-email",name:"Email (SMTP/IMAP)",npmPackage:"email-mcp",description:"Send and read emails via SMTP/IMAP - works with any email provider",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","email-mcp"],configFields:[{key:"SMTP_HOST",label:"SMTP Host",type:"text",placeholder:"smtp.gmail.com",required:!0},{key:"SMTP_USER",label:"Username",type:"text",placeholder:"user@example.com",required:!0},{key:"SMTP_PASS",label:"Password",type:"password",placeholder:"",required:!0}],tags:["email","smtp","imap","send"],authMethod:"api-key"},{id:"mcp-twilio",name:"Twilio",npmPackage:"twilio-mcp",description:"Send SMS, make calls, manage phone numbers via Twilio API",icon:"phone",category:"data",author:"Twilio",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","twilio-mcp"],configFields:[{key:"TWILIO_ACCOUNT_SID",label:"Account SID",type:"text",placeholder:"AC...",required:!0},{key:"TWILIO_AUTH_TOKEN",label:"Auth Token",type:"password",placeholder:"",required:!0}],website:"https://twilio.com",tags:["twilio","sms","phone","messaging"],authMethod:"api-key"},{id:"mcp-notion",name:"Notion",npmPackage:"@notionhq/notion-mcp-server",description:"Notion pages, databases, blocks - read, create, update, search",icon:"book-open",category:"writing",author:"Notion",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@notionhq/notion-mcp-server"],configFields:[{key:"NOTION_TOKEN",label:"Integration Token",type:"password",placeholder:"ntn_...",required:!0}],website:"https://notion.so",tags:["notion","docs","wiki","database","pages"],authMethod:"api-key"},{id:"notion-remote",name:"Notion (Cloud)",npmPackage:"",description:"Notion pages, databases, blocks - OAuth, no API key needed",icon:"book-open",category:"writing",author:"Notion",transport:"streamable-http",runtimes:["claude","amp","codex"],command:"",defaultArgs:[],url:"https://mcp.notion.com/mcp",authMethod:"oauth",configFields:[],website:"https://notion.so",tags:["notion","docs","wiki","database","pages","oauth"]},{id:"mcp-google-drive",name:"Google Drive",npmPackage:"@modelcontextprotocol/server-gdrive",description:"Google Drive - search, read, create files and folders",icon:"hard-drive",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-gdrive"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-drive","files","docs","sheets","storage"],authMethod:"api-key"},{id:"mcp-google-sheets",name:"Google Sheets",npmPackage:"google-sheets-mcp",description:"Read and write Google Sheets - cells, ranges, formulas",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","google-sheets-mcp"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-sheets","spreadsheet","data","tables"],authMethod:"api-key"},{id:"mcp-google-calendar",name:"Google Calendar",npmPackage:"google-calendar-mcp",description:"Google Calendar - events, scheduling, availability, reminders",icon:"calendar",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","google-calendar-mcp"],configFields:[{key:"GOOGLE_CLIENT_ID",label:"OAuth Client ID",type:"text",placeholder:"",required:!0},{key:"GOOGLE_CLIENT_SECRET",label:"OAuth Client Secret",type:"password",placeholder:"",required:!0}],tags:["google-calendar","events","scheduling","calendar"],authMethod:"api-key"},{id:"mcp-google-maps",name:"Google Maps",npmPackage:"@modelcontextprotocol/server-google-maps",description:"Google Maps - geocoding, directions, places, distance matrix",icon:"map-pin",category:"data",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-google-maps"],configFields:[{key:"GOOGLE_MAPS_API_KEY",label:"API Key",type:"password",placeholder:"AIza...",required:!0}],tags:["google-maps","geocoding","directions","places"],authMethod:"api-key"},{id:"mcp-confluence",name:"Confluence",npmPackage:"confluence-mcp",description:"Atlassian Confluence - spaces, pages, search, content management",icon:"book-open",category:"writing",author:"Atlassian",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","confluence-mcp"],configFields:[{key:"CONFLUENCE_URL",label:"Instance URL",type:"url",placeholder:"https://your-org.atlassian.net/wiki",required:!0},{key:"CONFLUENCE_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0},{key:"CONFLUENCE_EMAIL",label:"Email",type:"text",placeholder:"user@company.com",required:!0}],tags:["confluence","wiki","docs","atlassian"],authMethod:"api-key"},{id:"mcp-jira",name:"Jira",npmPackage:"jira-mcp",description:"Jira - issues, boards, sprints, epics, JQL search",icon:"clipboard-list",category:"coding",author:"Atlassian",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","jira-mcp"],configFields:[{key:"JIRA_URL",label:"Instance URL",type:"url",placeholder:"https://your-org.atlassian.net",required:!0},{key:"JIRA_EMAIL",label:"Email",type:"text",placeholder:"user@company.com",required:!0},{key:"JIRA_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["jira","issues","agile","boards","atlassian"],authMethod:"api-key"},{id:"mcp-asana",name:"Asana",npmPackage:"asana-mcp",description:"Asana - tasks, projects, sections, comments, assignees",icon:"check-square",category:"coding",author:"Asana",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","asana-mcp"],configFields:[{key:"ASANA_TOKEN",label:"Personal Access Token",type:"password",placeholder:"1/...",required:!0}],website:"https://asana.com",tags:["asana","tasks","project-management"],authMethod:"api-key"},{id:"mcp-todoist",name:"Todoist",npmPackage:"todoist-mcp",description:"Todoist - tasks, projects, labels, filters, productivity",icon:"check-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","todoist-mcp"],configFields:[{key:"TODOIST_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],website:"https://todoist.com",tags:["todoist","tasks","productivity","todo"],authMethod:"api-key"},{id:"mcp-obsidian",name:"Obsidian",npmPackage:"obsidian-mcp",description:"Obsidian vault - read, search, create notes, manage links",icon:"file-text",category:"writing",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","obsidian-mcp"],configFields:[{key:"OBSIDIAN_VAULT_PATH",label:"Vault Path",type:"text",placeholder:"/path/to/vault",required:!0}],tags:["obsidian","notes","markdown","knowledge-base"],authMethod:"none"},{id:"mcp-airtable",name:"Airtable",npmPackage:"airtable-mcp",description:"Airtable bases, tables, records - CRUD operations and views",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","airtable-mcp"],configFields:[{key:"AIRTABLE_TOKEN",label:"Personal Access Token",type:"password",placeholder:"pat...",required:!0}],website:"https://airtable.com",tags:["airtable","database","spreadsheet","records"]},{id:"mcp-hubspot",name:"HubSpot",npmPackage:"hubspot-mcp",description:"HubSpot CRM - contacts, companies, deals, tickets, engagement",icon:"hexagon",category:"data",author:"HubSpot",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","hubspot-mcp"],configFields:[{key:"HUBSPOT_ACCESS_TOKEN",label:"Private App Token",type:"password",placeholder:"pat-...",required:!0}],website:"https://hubspot.com",tags:["hubspot","crm","sales","contacts","deals"]},{id:"mcp-salesforce",name:"Salesforce",npmPackage:"salesforce-mcp",description:"Salesforce - SOQL queries, objects, records, reports",icon:"cloud",category:"data",author:"Salesforce",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","salesforce-mcp"],configFields:[{key:"SF_LOGIN_URL",label:"Login URL",type:"url",placeholder:"https://login.salesforce.com",required:!0},{key:"SF_USERNAME",label:"Username",type:"text",placeholder:"",required:!0},{key:"SF_PASSWORD",label:"Password + Security Token",type:"password",placeholder:"",required:!0}],tags:["salesforce","crm","soql","sales"],authMethod:"api-key"},{id:"mcp-stripe",name:"Stripe",npmPackage:"@stripe/mcp",description:"Stripe payments - customers, invoices, subscriptions, products",icon:"credit-card",category:"data",author:"Stripe",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@stripe/mcp"],configFields:[{key:"STRIPE_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"sk_...",required:!0}],website:"https://stripe.com",tags:["stripe","payments","billing","subscriptions"]},{id:"mcp-shopify",name:"Shopify",npmPackage:"@shopify/dev-mcp",description:"Shopify store - products, orders, customers, inventory",icon:"shopping-bag",category:"data",author:"Shopify",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@shopify/dev-mcp"],configFields:[{key:"SHOPIFY_STORE_URL",label:"Store URL",type:"url",placeholder:"your-store.myshopify.com",required:!0},{key:"SHOPIFY_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"shpat_...",required:!0}],tags:["shopify","ecommerce","products","orders"],authMethod:"api-key"},{id:"mcp-openai",name:"OpenAI",npmPackage:"openai-mcp",description:"OpenAI API - completions, embeddings, DALL-E, Whisper, assistants",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","openai-mcp"],configFields:[{key:"OPENAI_API_KEY",label:"API Key",type:"password",placeholder:"sk-...",required:!0}],tags:["openai","gpt","embeddings","dalle","whisper"],authMethod:"api-key"},{id:"mcp-anthropic",name:"Anthropic Claude",npmPackage:"anthropic-mcp",description:"Anthropic API - Claude completions, tool use, system prompts",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","anthropic-mcp"],configFields:[{key:"ANTHROPIC_API_KEY",label:"API Key",type:"password",placeholder:"sk-ant-...",required:!0}],tags:["anthropic","claude","ai","llm"],authMethod:"api-key"},{id:"mcp-replicate",name:"Replicate",npmPackage:"replicate-mcp",description:"Replicate - run open-source ML models via API",icon:"cpu",category:"coding",author:"Replicate",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","replicate-mcp"],configFields:[{key:"REPLICATE_API_TOKEN",label:"API Token",type:"password",placeholder:"r8_...",required:!0}],website:"https://replicate.com",tags:["replicate","ml","models","inference"]},{id:"mcp-huggingface",name:"Hugging Face",npmPackage:"huggingface-mcp",description:"Hugging Face - models, datasets, spaces, inference API",icon:"cpu",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","huggingface-mcp"],configFields:[{key:"HF_TOKEN",label:"Access Token",type:"password",placeholder:"hf_...",required:!0}],website:"https://huggingface.co",tags:["huggingface","models","datasets","ml"]},{id:"mcp-aws",name:"AWS",npmPackage:"aws-mcp",description:"AWS services - S3, Lambda, EC2, DynamoDB, CloudWatch",icon:"cloud",category:"coding",author:"AWS",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","aws-mcp"],configFields:[{key:"AWS_ACCESS_KEY_ID",label:"Access Key ID",type:"text",placeholder:"AKIA...",required:!0},{key:"AWS_SECRET_ACCESS_KEY",label:"Secret Access Key",type:"password",placeholder:"",required:!0},{key:"AWS_REGION",label:"Region",type:"text",placeholder:"us-east-1",required:!1}],tags:["aws","s3","lambda","ec2","cloud"],authMethod:"api-key"},{id:"mcp-gcp",name:"Google Cloud",npmPackage:"gcp-mcp",description:"Google Cloud Platform - BigQuery, Cloud Storage, Compute, Pub/Sub",icon:"cloud",category:"coding",author:"Google",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","gcp-mcp"],configFields:[{key:"GOOGLE_APPLICATION_CREDENTIALS",label:"Service Account Key Path",type:"text",placeholder:"/path/to/key.json",required:!0}],tags:["gcp","bigquery","cloud-storage","google-cloud"],authMethod:"none"},{id:"mcp-azure",name:"Azure",npmPackage:"azure-mcp",description:"Azure services - Blob Storage, Functions, Cosmos DB, Key Vault",icon:"cloud",category:"coding",author:"Microsoft",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","azure-mcp"],configFields:[{key:"AZURE_SUBSCRIPTION_ID",label:"Subscription ID",type:"text",placeholder:"",required:!0},{key:"AZURE_TENANT_ID",label:"Tenant ID",type:"text",placeholder:"",required:!0},{key:"AZURE_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"AZURE_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["azure","cloud","microsoft","blob-storage"],authMethod:"api-key"},{id:"mcp-n8n",name:"n8n",npmPackage:"n8n-mcp",description:"n8n workflow automation - trigger, manage, inspect workflows",icon:"workflow",category:"coding",author:"n8n",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","n8n-mcp"],configFields:[{key:"N8N_URL",label:"Instance URL",type:"url",placeholder:"http://localhost:5678",required:!0},{key:"N8N_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://n8n.io",tags:["n8n","automation","workflow","integration"]},{id:"mcp-zapier",name:"Zapier",npmPackage:"zapier-mcp",description:"Zapier - trigger Zaps, manage connections, inspect runs",icon:"zap",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","zapier-mcp"],configFields:[{key:"ZAPIER_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["zapier","automation","workflow","zaps"],authMethod:"api-key"},{id:"mcp-make",name:"Make (Integromat)",npmPackage:"make-mcp",description:"Make.com - scenarios, modules, connections, execution history",icon:"workflow",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","make-mcp"],configFields:[{key:"MAKE_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["make","integromat","automation","scenarios"],authMethod:"api-key"},{id:"mcp-datadog",name:"Datadog",npmPackage:"datadog-mcp",description:"Datadog - metrics, dashboards, monitors, logs, APM",icon:"bar-chart",category:"data",author:"Datadog",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","datadog-mcp"],configFields:[{key:"DD_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"DD_APP_KEY",label:"App Key",type:"password",placeholder:"",required:!0}],website:"https://datadoghq.com",tags:["datadog","monitoring","metrics","apm"]},{id:"mcp-grafana",name:"Grafana",npmPackage:"grafana-mcp",description:"Grafana - dashboards, alerts, data sources, panels",icon:"bar-chart",category:"data",author:"Grafana",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","grafana-mcp"],configFields:[{key:"GRAFANA_URL",label:"Instance URL",type:"url",placeholder:"http://localhost:3000",required:!0},{key:"GRAFANA_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["grafana","dashboards","monitoring","visualization"],authMethod:"api-key"},{id:"mcp-posthog",name:"PostHog",npmPackage:"posthog-mcp",description:"PostHog product analytics - events, funnels, feature flags, surveys",icon:"bar-chart-3",category:"data",author:"PostHog",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","posthog-mcp"],configFields:[{key:"POSTHOG_HOST",label:"Host URL",type:"url",placeholder:"https://app.posthog.com",required:!0},{key:"POSTHOG_API_KEY",label:"Personal API Key",type:"password",placeholder:"phx_...",required:!0}],website:"https://posthog.com",tags:["posthog","analytics","events","product"]},{id:"mcp-mixpanel",name:"Mixpanel",npmPackage:"mixpanel-mcp",description:"Mixpanel - events, funnels, cohorts, user analytics",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","mixpanel-mcp"],configFields:[{key:"MIXPANEL_TOKEN",label:"Project Token",type:"password",placeholder:"",required:!0},{key:"MIXPANEL_API_SECRET",label:"API Secret",type:"password",placeholder:"",required:!1}],tags:["mixpanel","analytics","events","funnels"],authMethod:"api-key"},{id:"mcp-twitter",name:"Twitter / X",npmPackage:"twitter-mcp",description:"Twitter/X - tweets, search, timeline, DMs, analytics",icon:"message-circle",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","twitter-mcp"],configFields:[{key:"TWITTER_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"TWITTER_API_SECRET",label:"API Secret",type:"password",placeholder:"",required:!0},{key:"TWITTER_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0},{key:"TWITTER_ACCESS_SECRET",label:"Access Token Secret",type:"password",placeholder:"",required:!0}],tags:["twitter","x","social","tweets"],authMethod:"api-key"},{id:"mcp-youtube",name:"YouTube",npmPackage:"youtube-mcp",description:"YouTube - search videos, get transcripts, channel analytics",icon:"play",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","youtube-mcp"],configFields:[{key:"YOUTUBE_API_KEY",label:"API Key",type:"password",placeholder:"AIza...",required:!0}],tags:["youtube","video","transcripts","search"],authMethod:"api-key"},{id:"mcp-spotify",name:"Spotify",npmPackage:"spotify-mcp",description:"Spotify - search tracks, manage playlists, playback control",icon:"music",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","spotify-mcp"],configFields:[{key:"SPOTIFY_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"SPOTIFY_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["spotify","music","playlists","audio"],authMethod:"api-key"},{id:"mcp-figma",name:"Figma",npmPackage:"figma-mcp",description:"Figma - read files, components, styles, export assets",icon:"palette",category:"design",author:"Figma",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","figma-mcp"],configFields:[{key:"FIGMA_ACCESS_TOKEN",label:"Personal Access Token",type:"password",placeholder:"figd_...",required:!0}],website:"https://figma.com",tags:["figma","design","ui","components"]},{id:"mcp-21st-dev",name:"21st.dev Magic",npmPackage:"@21st-dev/magic-mcp",description:"Create crafted UI components inspired by best design engineers",icon:"sparkles",category:"design",author:"21st.dev",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@21st-dev/magic-mcp"],configFields:[{key:"TWENTYFIRST_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://21st.dev",tags:["ui","components","design","magic"]},{id:"mcp-cloudinary",name:"Cloudinary",npmPackage:"cloudinary-mcp",description:"Cloudinary - upload, transform, optimize images and videos",icon:"image",category:"design",author:"Cloudinary",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","cloudinary-mcp"],configFields:[{key:"CLOUDINARY_URL",label:"Cloudinary URL",type:"password",placeholder:"cloudinary://api_key:api_secret@cloud_name",required:!0}],tags:["cloudinary","images","media","cdn","transform"],authMethod:"api-key"},{id:"mcp-vault",name:"HashiCorp Vault",npmPackage:"vault-mcp",description:"HashiCorp Vault - secrets management, dynamic credentials",icon:"lock",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","vault-mcp"],configFields:[{key:"VAULT_ADDR",label:"Vault Address",type:"url",placeholder:"http://localhost:8200",required:!0},{key:"VAULT_TOKEN",label:"Token",type:"password",placeholder:"hvs.",required:!0}],tags:["vault","secrets","security","hashicorp"],authMethod:"api-key"},{id:"mcp-1password",name:"1Password",npmPackage:"1password-mcp",description:"1Password - read secrets, vaults, items securely",icon:"lock",category:"data",author:"1Password",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","1password-mcp"],configFields:[{key:"OP_SERVICE_ACCOUNT_TOKEN",label:"Service Account Token",type:"password",placeholder:"ops_...",required:!0}],tags:["1password","secrets","passwords","security"],authMethod:"api-key"},{id:"mcp-snowflake",name:"Snowflake",npmPackage:"snowflake-mcp",description:"Snowflake data warehouse - queries, tables, schemas, warehouses",icon:"database",category:"data",author:"Snowflake",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","snowflake-mcp"],configFields:[{key:"SNOWFLAKE_ACCOUNT",label:"Account",type:"text",placeholder:"org-account",required:!0},{key:"SNOWFLAKE_USER",label:"Username",type:"text",placeholder:"",required:!0},{key:"SNOWFLAKE_PASSWORD",label:"Password",type:"password",placeholder:"",required:!0}],tags:["snowflake","data-warehouse","sql","analytics"],authMethod:"api-key"},{id:"mcp-bigquery",name:"BigQuery",npmPackage:"bigquery-mcp",description:"Google BigQuery - run SQL queries, manage datasets and tables",icon:"database",category:"data",author:"Google",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","bigquery-mcp"],configFields:[{key:"GOOGLE_APPLICATION_CREDENTIALS",label:"Service Account Key Path",type:"text",placeholder:"/path/to/key.json",required:!0},{key:"BIGQUERY_PROJECT_ID",label:"Project ID",type:"text",placeholder:"my-project",required:!0}],tags:["bigquery","sql","analytics","google-cloud"],authMethod:"none"},{id:"mcp-elasticsearch",name:"Elasticsearch",npmPackage:"elasticsearch-mcp",description:"Elasticsearch - search, index, aggregate, analyze data",icon:"search",category:"data",author:"Elastic",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","elasticsearch-mcp"],configFields:[{key:"ELASTICSEARCH_URL",label:"URL",type:"url",placeholder:"http://localhost:9200",required:!0},{key:"ELASTICSEARCH_API_KEY",label:"API Key",type:"password",placeholder:"",required:!1}],tags:["elasticsearch","search","indexing","analytics"],authMethod:"api-key"},{id:"mcp-rabbitmq",name:"RabbitMQ",npmPackage:"rabbitmq-mcp",description:"RabbitMQ - queues, exchanges, publish/consume messages",icon:"send",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","rabbitmq-mcp"],configFields:[{key:"RABBITMQ_URL",label:"Connection URL",type:"password",placeholder:"amqp://user:pass@localhost:5672",required:!0}],tags:["rabbitmq","queue","messaging","amqp"],authMethod:"api-key"},{id:"mcp-kafka",name:"Kafka",npmPackage:"kafka-mcp",description:"Apache Kafka - topics, produce/consume, consumer groups",icon:"send",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","kafka-mcp"],configFields:[{key:"KAFKA_BROKERS",label:"Brokers (comma-separated)",type:"text",placeholder:"localhost:9092",required:!0}],tags:["kafka","streaming","events","queue"],authMethod:"none"},{id:"mcp-plaid",name:"Plaid",npmPackage:"plaid-mcp",description:"Plaid financial data - bank accounts, transactions, balances",icon:"credit-card",category:"data",author:"Plaid",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","plaid-mcp"],configFields:[{key:"PLAID_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"PLAID_SECRET",label:"Secret",type:"password",placeholder:"",required:!0}],website:"https://plaid.com",tags:["plaid","banking","finance","transactions"]},{id:"mcp-quickbooks",name:"QuickBooks",npmPackage:"quickbooks-mcp",description:"QuickBooks - invoices, expenses, customers, reports",icon:"receipt",category:"data",author:"Intuit",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","quickbooks-mcp"],configFields:[{key:"QUICKBOOKS_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"QUICKBOOKS_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["quickbooks","accounting","invoices","finance"],authMethod:"api-key"},{id:"mcp-xero",name:"Xero",npmPackage:"xero-mcp",description:"Xero accounting - invoices, contacts, bank transactions, reports",icon:"receipt",category:"data",author:"Xero",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","xero-mcp"],configFields:[{key:"XERO_CLIENT_ID",label:"Client ID",type:"text",placeholder:"",required:!0},{key:"XERO_CLIENT_SECRET",label:"Client Secret",type:"password",placeholder:"",required:!0}],tags:["xero","accounting","invoices","finance"],authMethod:"api-key"},{id:"mcp-wordpress",name:"WordPress",npmPackage:"wordpress-mcp",description:"WordPress - posts, pages, media, comments via REST API",icon:"file-text",category:"writing",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","wordpress-mcp"],configFields:[{key:"WORDPRESS_URL",label:"Site URL",type:"url",placeholder:"https://yoursite.com",required:!0},{key:"WORDPRESS_USER",label:"Username",type:"text",placeholder:"",required:!0},{key:"WORDPRESS_APP_PASSWORD",label:"Application Password",type:"password",placeholder:"",required:!0}],tags:["wordpress","cms","blog","content"],authMethod:"api-key"},{id:"mcp-contentful",name:"Contentful",npmPackage:"contentful-mcp",description:"Contentful - content types, entries, assets, spaces",icon:"file-text",category:"writing",author:"Contentful",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","contentful-mcp"],configFields:[{key:"CONTENTFUL_SPACE_ID",label:"Space ID",type:"text",placeholder:"",required:!0},{key:"CONTENTFUL_ACCESS_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],tags:["contentful","cms","headless","content"],authMethod:"api-key"},{id:"mcp-sanity",name:"Sanity",npmPackage:"sanity-mcp",description:"Sanity CMS - documents, GROQ queries, assets, mutations",icon:"file-text",category:"writing",author:"Sanity",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","sanity-mcp"],configFields:[{key:"SANITY_PROJECT_ID",label:"Project ID",type:"text",placeholder:"",required:!0},{key:"SANITY_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["sanity","cms","headless","groq"],authMethod:"api-key"},{id:"mcp-weather",name:"Weather",npmPackage:"weather-mcp",description:"Weather data - current conditions, forecasts, historical data",icon:"cloud",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","weather-mcp"],configFields:[{key:"OPENWEATHER_API_KEY",label:"OpenWeatherMap API Key",type:"password",placeholder:"",required:!0}],tags:["weather","forecast","climate","temperature"],authMethod:"api-key"},{id:"mcp-wolfram",name:"Wolfram Alpha",npmPackage:"wolfram-mcp",description:"Wolfram Alpha computational intelligence - math, science, data",icon:"calculator",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","wolfram-mcp"],configFields:[{key:"WOLFRAM_APP_ID",label:"App ID",type:"password",placeholder:"",required:!0}],tags:["wolfram","math","science","computation"],authMethod:"api-key"},{id:"mcp-whois",name:"WHOIS",npmPackage:"whois-mcp",description:"Domain WHOIS lookup - registration, expiry, nameservers",icon:"globe",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","whois-mcp"],configFields:[],tags:["whois","domain","dns","lookup"],authMethod:"none"},{id:"mcp-mermaid",name:"Mermaid",npmPackage:"mermaid-mcp",description:"Generate Mermaid diagrams - flowcharts, sequence, gantt, class",icon:"workflow",category:"design",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","mermaid-mcp"],configFields:[],tags:["mermaid","diagrams","flowchart","visualization"],authMethod:"none"},{id:"mcp-screenshot",name:"Screenshot",npmPackage:"screenshot-mcp",description:"Take screenshots of websites - full page, element, viewport",icon:"camera",category:"research",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","screenshot-mcp"],configFields:[],tags:["screenshot","capture","web","image"],authMethod:"none"},{id:"mcp-pdf",name:"PDF Tools",npmPackage:"pdf-mcp",description:"Extract text, tables, and images from PDF documents",icon:"file",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","pdf-mcp"],configFields:[],tags:["pdf","extract","text","documents"],authMethod:"none"},{id:"mcp-csv",name:"CSV Tools",npmPackage:"csv-mcp",description:"Parse, query, transform, and generate CSV/TSV files",icon:"table",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","csv-mcp"],configFields:[],tags:["csv","tsv","data","tables","transform"],authMethod:"none"},{id:"mcp-s3",name:"S3 / Object Storage",npmPackage:"s3-mcp",description:"S3-compatible storage - list, read, write, delete objects",icon:"hard-drive",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","s3-mcp"],configFields:[{key:"S3_ENDPOINT",label:"Endpoint",type:"url",placeholder:"https://s3.amazonaws.com",required:!1},{key:"S3_ACCESS_KEY",label:"Access Key",type:"text",placeholder:"",required:!0},{key:"S3_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"",required:!0},{key:"S3_BUCKET",label:"Bucket Name",type:"text",placeholder:"my-bucket",required:!0}],tags:["s3","storage","objects","bucket"],authMethod:"api-key"},{id:"mcp-ssh",name:"SSH",npmPackage:"ssh-mcp",description:"Execute commands on remote servers via SSH",icon:"terminal",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","ssh-mcp"],configFields:[{key:"SSH_HOST",label:"Host",type:"text",placeholder:"192.168.1.100",required:!0},{key:"SSH_USER",label:"Username",type:"text",placeholder:"root",required:!0},{key:"SSH_KEY_PATH",label:"Private Key Path",type:"text",placeholder:"~/.ssh/id_rsa",required:!1}],tags:["ssh","remote","terminal","server"],authMethod:"none"},{id:"mcp-terraform",name:"Terraform",npmPackage:"terraform-mcp",description:"Terraform - plan, apply, state, modules, resources",icon:"server",category:"coding",author:"HashiCorp",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","terraform-mcp"],configFields:[],tags:["terraform","iac","infrastructure","devops"],authMethod:"none"},{id:"mcp-prometheus",name:"Prometheus",npmPackage:"prometheus-mcp",description:"Prometheus - PromQL queries, metrics, alerts, targets",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","prometheus-mcp"],configFields:[{key:"PROMETHEUS_URL",label:"URL",type:"url",placeholder:"http://localhost:9090",required:!0}],tags:["prometheus","metrics","monitoring","promql"],authMethod:"none"},{id:"mcp-intercom",name:"Intercom",npmPackage:"intercom-mcp",description:"Intercom - conversations, contacts, companies, articles",icon:"message-circle",category:"data",author:"Intercom",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","intercom-mcp"],configFields:[{key:"INTERCOM_TOKEN",label:"Access Token",type:"password",placeholder:"",required:!0}],tags:["intercom","support","chat","crm"],authMethod:"api-key"},{id:"mcp-zendesk",name:"Zendesk",npmPackage:"zendesk-mcp",description:"Zendesk - tickets, users, organizations, search",icon:"headphones",category:"data",author:"Zendesk",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","zendesk-mcp"],configFields:[{key:"ZENDESK_SUBDOMAIN",label:"Subdomain",type:"text",placeholder:"your-org",required:!0},{key:"ZENDESK_EMAIL",label:"Email",type:"text",placeholder:"agent@company.com",required:!0},{key:"ZENDESK_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["zendesk","support","tickets","helpdesk"],authMethod:"api-key"},{id:"mcp-freshdesk",name:"Freshdesk",npmPackage:"freshdesk-mcp",description:"Freshdesk - tickets, contacts, groups, canned responses",icon:"headphones",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","freshdesk-mcp"],configFields:[{key:"FRESHDESK_DOMAIN",label:"Domain",type:"text",placeholder:"your-org.freshdesk.com",required:!0},{key:"FRESHDESK_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],tags:["freshdesk","support","tickets","helpdesk"],authMethod:"api-key"},{id:"mcp-clickup",name:"ClickUp",npmPackage:"clickup-mcp",description:"ClickUp - tasks, lists, spaces, goals, docs, time tracking",icon:"check-square",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","clickup-mcp"],configFields:[{key:"CLICKUP_TOKEN",label:"Personal API Token",type:"password",placeholder:"pk_...",required:!0}],tags:["clickup","tasks","project-management","productivity"],authMethod:"api-key"},{id:"mcp-trello",name:"Trello",npmPackage:"trello-mcp",description:"Trello - boards, lists, cards, checklists, members",icon:"layout",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","trello-mcp"],configFields:[{key:"TRELLO_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"TRELLO_TOKEN",label:"Token",type:"password",placeholder:"",required:!0}],tags:["trello","boards","kanban","cards"],authMethod:"api-key"},{id:"mcp-monday",name:"Monday.com",npmPackage:"monday-mcp",description:"Monday.com - boards, items, columns, updates, automations",icon:"layout",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","monday-mcp"],configFields:[{key:"MONDAY_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["monday","boards","project-management","workflow"],authMethod:"api-key"},{id:"mcp-github-actions",name:"GitHub Actions",npmPackage:"github-actions-mcp",description:"GitHub Actions - workflows, runs, jobs, artifacts, secrets",icon:"play-circle",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","github-actions-mcp"],configFields:[{key:"GITHUB_TOKEN",label:"Personal Access Token",type:"password",placeholder:"ghp_...",required:!0}],tags:["github-actions","ci-cd","workflows","automation"],authMethod:"api-key"},{id:"mcp-circleci",name:"CircleCI",npmPackage:"circleci-mcp",description:"CircleCI - pipelines, jobs, workflows, orbs, insights",icon:"play-circle",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","circleci-mcp"],configFields:[{key:"CIRCLECI_TOKEN",label:"Personal API Token",type:"password",placeholder:"",required:!0}],tags:["circleci","ci-cd","pipelines","automation"],authMethod:"api-key"},{id:"mcp-upstash",name:"Upstash",npmPackage:"@upstash/mcp-server",description:"Upstash - serverless Redis and Kafka, QStash message queue",icon:"database",category:"data",author:"Upstash",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@upstash/mcp-server"],configFields:[{key:"UPSTASH_REDIS_REST_URL",label:"Redis REST URL",type:"url",placeholder:"",required:!0},{key:"UPSTASH_REDIS_REST_TOKEN",label:"Redis REST Token",type:"password",placeholder:"",required:!0}],website:"https://upstash.com",tags:["upstash","redis","kafka","serverless"]},{id:"mcp-sendgrid",name:"SendGrid",npmPackage:"sendgrid-mcp",description:"SendGrid - send transactional emails, manage templates, contacts",icon:"mail",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","sendgrid-mcp"],configFields:[{key:"SENDGRID_API_KEY",label:"API Key",type:"password",placeholder:"SG.",required:!0}],tags:["sendgrid","email","transactional","templates"],authMethod:"api-key"},{id:"mcp-resend",name:"Resend",npmPackage:"resend-mcp",description:"Resend - send emails with React Email templates",icon:"mail",category:"data",author:"Resend",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","resend-mcp"],configFields:[{key:"RESEND_API_KEY",label:"API Key",type:"password",placeholder:"re_...",required:!0}],website:"https://resend.com",tags:["resend","email","react-email","transactional"]},{id:"mcp-openapi",name:"OpenAPI",npmPackage:"openapi-mcp",description:"Load any OpenAPI/Swagger spec and call its endpoints as MCP tools",icon:"globe",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","openapi-mcp"],configFields:[{key:"OPENAPI_SPEC_URL",label:"Spec URL",type:"url",placeholder:"https://api.example.com/openapi.json",required:!0}],tags:["openapi","swagger","rest","api"],authMethod:"none"},{id:"mcp-graphql",name:"GraphQL",npmPackage:"graphql-mcp",description:"Query any GraphQL endpoint - introspection, queries, mutations",icon:"globe",category:"coding",author:"Community",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","graphql-mcp"],configFields:[{key:"GRAPHQL_URL",label:"Endpoint URL",type:"url",placeholder:"https://api.example.com/graphql",required:!0},{key:"GRAPHQL_AUTH_HEADER",label:"Auth Header Value",type:"password",placeholder:"Bearer ...",required:!1}],tags:["graphql","api","query","mutation"],authMethod:"api-key"},{id:"mcp-coda",name:"Coda",npmPackage:"coda-mcp",description:"Coda docs - tables, rows, formulas, pages, automations",icon:"file-text",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","coda-mcp"],configFields:[{key:"CODA_API_TOKEN",label:"API Token",type:"password",placeholder:"",required:!0}],tags:["coda","docs","tables","automation"],authMethod:"api-key"},{id:"mcp-segment",name:"Segment",npmPackage:"segment-mcp",description:"Segment - track events, identify users, manage sources & destinations",icon:"bar-chart",category:"data",author:"Twilio",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","segment-mcp"],configFields:[{key:"SEGMENT_WRITE_KEY",label:"Write Key",type:"password",placeholder:"",required:!0}],tags:["segment","analytics","events","cdp"],authMethod:"api-key"},{id:"mcp-amplitude",name:"Amplitude",npmPackage:"amplitude-mcp",description:"Amplitude - events, user analytics, cohorts, retention",icon:"bar-chart",category:"data",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","amplitude-mcp"],configFields:[{key:"AMPLITUDE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0},{key:"AMPLITUDE_SECRET_KEY",label:"Secret Key",type:"password",placeholder:"",required:!0}],tags:["amplitude","analytics","events","product"],authMethod:"api-key"},{id:"mcp-context7",name:"Context7",npmPackage:"@upstash/context7-mcp",description:"Pull up-to-date library documentation and code examples on demand",icon:"book-open",category:"domain",author:"Upstash",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@upstash/context7-mcp"],configFields:[],tags:["docs","documentation","libraries","context"],authMethod:"none"},{id:"mcp-aws-kb-retrieval",name:"AWS KB Retrieval",npmPackage:"@modelcontextprotocol/server-aws-kb-retrieval",description:"Retrieve from AWS Bedrock Knowledge Bases using RAG",icon:"database",category:"domain",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-aws-kb-retrieval"],configFields:[{key:"AWS_ACCESS_KEY_ID",label:"Access Key ID",type:"text",placeholder:"AKIA...",required:!0},{key:"AWS_SECRET_ACCESS_KEY",label:"Secret Access Key",type:"password",placeholder:"",required:!0},{key:"AWS_REGION",label:"Region",type:"text",placeholder:"us-east-1",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["aws","bedrock","rag","knowledge-base"]},{id:"mcp-everart",name:"EverArt",npmPackage:"@modelcontextprotocol/server-everart",description:"AI image generation with multiple models via EverArt platform",icon:"image",category:"design",author:"MCP Official",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@modelcontextprotocol/server-everart"],configFields:[{key:"EVERART_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],repo:"https://github.com/modelcontextprotocol/servers",tags:["image","generation","ai-art","design"]},{id:"mcp-greptile",name:"Greptile",npmPackage:"@greptile/mcp-server",description:"AI-powered codebase search and understanding",icon:"search",category:"coding",author:"Greptile",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@greptile/mcp-server"],configFields:[{key:"GREPTILE_API_KEY",label:"API Key",type:"password",placeholder:"",required:!0}],website:"https://greptile.com",tags:["code-search","codebase","ai","understanding"]},{id:"mcp-e2b",name:"E2B Code Interpreter",npmPackage:"@e2b/mcp-server",description:"Sandboxed code execution - run Python, JS, and more in secure cloud sandbox",icon:"terminal",category:"coding",author:"E2B",transport:"stdio",runtimes:["claude","amp","codex"],command:"npx",defaultArgs:["-y","@e2b/mcp-server"],configFields:[{key:"E2B_API_KEY",label:"API Key",type:"password",placeholder:"e2b_...",required:!0}],website:"https://e2b.dev",tags:["sandbox","code-execution","interpreter","python"]},{id:"mcp-hubspot-dev",name:"HubSpot Developer",npmPackage:"@hubspot/mcp-server",description:"HubSpot developer tools - CMS, projects, functions, deploy",icon:"hexagon",category:"domain",author:"HubSpot",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","@hubspot/mcp-server"],configFields:[{key:"HUBSPOT_PORTAL_ID",label:"Portal ID",type:"text",placeholder:"",required:!0}],website:"https://developers.hubspot.com",tags:["hubspot","cms","developer","deploy"]},{id:"mcp-medical-ref",name:"Medical Reference",npmPackage:"medical-ref-mcp",description:"Medical terminology, drug interactions, clinical guidelines lookup",icon:"heart",category:"domain",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","medical-ref-mcp"],configFields:[],tags:["medical","healthcare","drugs","clinical"],authMethod:"none"},{id:"mcp-legal",name:"Legal Research",npmPackage:"legal-mcp",description:"Legal document search - case law, statutes, regulations",icon:"scale",category:"domain",author:"Community",transport:"stdio",runtimes:["claude","amp"],command:"npx",defaultArgs:["-y","legal-mcp"],configFields:[],tags:["legal","law","case-law","regulations"],authMethod:"none"}],kc=[{id:"web-search",name:"Web Search",description:"Search the web using Brave Search API for real-time information retrieval",icon:"search",category:"research",author:"Anthropic",installs:12400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install web-search",installed:!1},{id:"github",name:"GitHub",description:"GitHub operations — repos, issues, PRs, and code search via gh CLI",icon:"git-branch",category:"coding",author:"Anthropic",installs:9800,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install github",installed:!1},{id:"weather",name:"Weather",description:"Weather data from wttr.in and Open-Meteo for forecasts and conditions",icon:"cloud",category:"data",author:"Community",installs:4200,runtimes:["claude","amp"],installCmd:"npx modular-skills install weather",installed:!1},{id:"coding-agent",name:"Coding Agent",description:"Delegate complex coding tasks to Claude Code or Codex sub-agents",icon:"code",category:"coding",author:"Anthropic",installs:18200,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install coding-agent",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"openai-whisper",name:"OpenAI Whisper",description:"Transcribe audio files to text using OpenAI Whisper API",icon:"mic",category:"data",author:"OpenAI",installs:6700,runtimes:["claude","amp","codex","openai"],installCmd:"npx modular-skills install openai-whisper",installed:!1},{id:"openai-image-gen",name:"Image Generation",description:"Generate images from text prompts using DALL-E or Stable Diffusion",icon:"image",category:"design",author:"OpenAI",installs:8900,runtimes:["claude","amp","openai"],installCmd:"npx modular-skills install openai-image-gen",installed:!1},{id:"notion-api",name:"Notion API",description:"Full Notion integration — read, create, update pages and databases",icon:"book-open",category:"writing",author:"Notion",installs:7300,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install notion-api",installed:!1},{id:"hubspot-integration",name:"HubSpot CRM",description:"HubSpot CRM operations — contacts, companies, deals, and pipelines",icon:"hexagon",category:"data",author:"HubSpot",installs:3100,runtimes:["claude","amp"],installCmd:"npx modular-skills install hubspot-integration",installed:!1},{id:"n8n-workflow-patterns",name:"n8n Workflows",description:"Build and manage n8n automation workflows with proven patterns",icon:"workflow",category:"coding",author:"n8n",installs:2800,runtimes:["claude","amp"],installCmd:"npx modular-skills install n8n-workflow-patterns",installed:!1},{id:"maritime-expert",name:"Maritime Expert",description:"Maritime domain expertise — vessel tracking, port ops, cargo management",icon:"anchor",category:"domain",author:"Nimbalyst",installs:1200,runtimes:["claude","amp"],installCmd:"npx modular-skills install maritime-expert",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"feedback-analyzer",name:"Feedback Analyzer",description:"Extract insights from customer feedback — patterns, sentiment, priorities",icon:"bar-chart-3",category:"research",author:"Nimbalyst",installs:2400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install feedback-analyzer",installed:!0,installedTarget:"all",installedScope:"global"},{id:"roadmap-builder",name:"Roadmap Builder",description:"Create strategic product roadmaps with OKRs and stakeholder alignment",icon:"map",category:"writing",author:"Community",installs:1800,runtimes:["claude","amp"],installCmd:"npx modular-skills install roadmap-builder",installed:!1},{id:"presentation-generator",name:"Presentation Gen",description:"Generate interactive HTML presentations with animations and styling",icon:"presentation",category:"design",author:"Community",installs:3600,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install presentation-generator",installed:!0,installedTarget:"claude",installedScope:"project"},{id:"clean-code",name:"Clean Code",description:"Pragmatic coding standards — concise, direct, no over-engineering",icon:"sparkles",category:"coding",author:"Community",installs:5400,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install clean-code",installed:!1},{id:"html-style",name:"HTML Style",description:"Apply opinionated styling to unstyled HTML with a cohesive design system",icon:"palette",category:"design",author:"Community",installs:2100,runtimes:["claude","amp"],installCmd:"npx modular-skills install html-style",installed:!1},{id:"find-skills",name:"Find Skills",description:"Meta-skill that discovers and recommends other skills for your task",icon:"compass",category:"research",author:"Anthropic",installs:4800,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install find-skills",installed:!1},{id:"fluidsim",name:"FluidSim",description:"Computational fluid dynamics — Navier-Stokes, shallow water, turbulence",icon:"waves",category:"domain",author:"SciPy",installs:800,runtimes:["claude"],installCmd:"npx modular-skills install fluidsim",installed:!1},{id:"threejs-fundamentals",name:"Three.js",description:"Three.js 3D graphics — scene setup, cameras, lighting, animation",icon:"box",category:"coding",author:"Community",installs:3200,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install threejs-fundamentals",installed:!1},{id:"web-design-guidelines",name:"Web Design Review",description:"Review UI code against Web Interface Guidelines for best practices",icon:"layout",category:"design",author:"Community",installs:2900,runtimes:["claude","amp"],installCmd:"npx modular-skills install web-design-guidelines",installed:!1},{id:"skill-creator",name:"Skill Creator",description:"Build and package new skills with proper manifests and adapters",icon:"wrench",category:"coding",author:"Anthropic",installs:1500,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install skill-creator",installed:!1},{id:"vercel-react",name:"Vercel React",description:"React and Next.js performance optimization patterns from Vercel Engineering",icon:"triangle",category:"coding",author:"Vercel",installs:7100,runtimes:["claude","amp","codex"],installCmd:"npx modular-skills install vercel-react",installed:!1},{id:"claude-platform",name:"Claude Platform",description:"Build apps with Claude API — SDK patterns, tool use, streaming",icon:"cpu",category:"coding",author:"Anthropic",installs:11200,runtimes:["claude"],installCmd:"npx modular-skills install claude-platform",installed:!1}];function ES(e){return{id:e.id,name:e.name,description:e.description,icon:e.icon,category:e.category,author:e.author,transport:e.transport,runtimes:e.runtimes,installCmd:`npx -y ${e.npmPackage}`,command:e.command,defaultArgs:e.defaultArgs,configFields:e.configFields,installed:!1,configured:!1}}const jS=Kc.map(ES),TS=[{id:"preset-fullstack-dev",name:"Full-Stack Developer",description:"Complete dev setup with GitHub, filesystem, coding agent, and clean code standards",icon:"code",skills:["coding-agent","clean-code","github","threejs-fundamentals"],mcpServers:["mcp-github","mcp-filesystem","mcp-linear"],canvasDescription:"Knowledge → Agent (Claude Opus) → Code Output | Skills: Coding Agent, Clean Code, GitHub | MCP: GitHub, Filesystem, Linear"},{id:"preset-research-analyst",name:"Research Analyst",description:"Web search, scraping, and analysis tools for deep research",icon:"search",skills:["web-search","feedback-analyzer","find-skills"],mcpServers:["mcp-brave-search","mcp-firecrawl","mcp-puppeteer"],canvasDescription:"Web Sources → Agent (Claude Opus) → Markdown Report | Skills: Web Search, Feedback Analyzer | MCP: Brave, Firecrawl, Puppeteer"},{id:"preset-content-writer",name:"Content Writer",description:"Writing-focused setup with Notion, presentation gen, and design review",icon:"pen-tool",skills:["presentation-generator","html-style","web-design-guidelines","notion-api"],mcpServers:["mcp-notion","mcp-slack"],canvasDescription:"Notion Pages → Agent (Claude Sonnet) → HTML/Markdown | Skills: Presentation Gen, HTML Style | MCP: Notion, Slack"},{id:"preset-data-pipeline",name:"Data Pipeline",description:"Database, API, and CRM integrations for data workflows",icon:"database",skills:["hubspot-integration","n8n-workflow-patterns","weather"],mcpServers:["mcp-postgres","mcp-supabase","mcp-hubspot"],canvasDescription:"CRM + DB → Agent (Claude Sonnet) → JSON/CSV | Skills: HubSpot, n8n Workflows | MCP: PostgreSQL, Supabase, HubSpot"},{id:"preset-maritime-ops",name:"Maritime Operations",description:"Maritime domain with vessel tracking, weather data, and fleet management",icon:"anchor",skills:["maritime-expert","weather","feedback-analyzer"],mcpServers:["mcp-slack","mcp-notion"],canvasDescription:"Maritime Knowledge → Agent (Claude Opus) → Reports | Skills: Maritime Expert, Weather | MCP: Slack, Notion"},{id:"preset-design-system",name:"Design System",description:"Design-focused setup with visual review, styling, and presentation tools",icon:"palette",skills:["web-design-guidelines","html-style","presentation-generator","openai-image-gen"],mcpServers:["mcp-puppeteer"],canvasDescription:"Design Specs → Agent (Claude Sonnet) → HTML/CSS | Skills: Web Design, HTML Style, Image Gen | MCP: Puppeteer"},{id:"preset-senior-pm",name:"Senior PM",description:"Discovery synthesis specialist — turns messy brainstorms into prioritized product strategy with RICE framework",icon:"user",skills:["feedback-analyzer","roadmap-builder"],mcpServers:["mcp-notion","mcp-slack"],canvasDescription:"Knowledge + Signals → Agent (Claude Opus) → Synthesis Report | Skills: Feedback Analyzer, Roadmap Builder | MCP: Notion, Slack"},{id:"preset-feedback-manager",name:"Feedback Manager",description:"Feedback lifecycle specialist — organizes, challenges, and maintains the single source of truth for user feedback",icon:"inbox",skills:["feedback-analyzer"],mcpServers:["mcp-gmail","mcp-notion","mcp-slack"],canvasDescription:"Gmail + Signals → Agent (Claude Sonnet) → Feedback Reports | Skills: Feedback Analyzer | MCP: Gmail, Notion, Slack"},{id:"preset-competitor-scraper",name:"Competitor Feature Scraper",description:"Scrapes competitor websites to extract product features, claims, and screenshots for competitive comparison",icon:"search",skills:["web-search"],mcpServers:["mcp-firecrawl"],canvasDescription:"Competitor Knowledge → Agent (Claude Sonnet) → Feature Profiles | Skills: Web Search | MCP: Firecrawl"}],zs={claude:{label:"Claude",color:"#FE5000"},amp:{label:"Amp",color:"#8B5CF6"},codex:{label:"Codex",color:"#10B981"},openai:{label:"OpenAI",color:"#74AA9C"},gemini:{label:"Gemini",color:"#4285F4"}},g0=[{id:"all",label:"All"},{id:"research",label:"Research"},{id:"coding",label:"Coding"},{id:"data",label:"Data"},{id:"design",label:"Design"},{id:"writing",label:"Writing"},{id:"domain",label:"Domain"}],Ae="/api";async function rb(e,n){const a=new TextDecoder;let s="";for(;;){const{done:i,value:l}=await e.read();if(i)break;s+=a.decode(l,{stream:!0});const d=s.split(`
|
|
10
|
+
`);s=d.pop()??"";for(const p of d){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const h=f.slice(6);if(h==="[DONE]"||n(h))return}}}function ib(e){const{prompt:n,model:a,systemPrompt:s,maxTurns:i,onChunk:l,onDone:d,onError:p}=e,f=new AbortController;return fetch(`${Ae}/agent-sdk/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n,model:a,systemPrompt:s,maxTurns:i}),signal:f.signal}).then(async h=>{if(!h.ok){const x=await h.text().catch(()=>"");throw new Error(`Agent SDK error ${h.status}: ${x||h.statusText}`)}const g=h.body?.getReader();if(!g)throw new Error("No response body");await rb(g,x=>{try{const b=JSON.parse(x);if(b.type==="text"&&b.content)l(b.content);else if(b.type==="error")return p(new Error(b.message)),!0}catch{}}),d()}).catch(h=>{h instanceof DOMException&&h.name==="AbortError"||p(h instanceof Error?h:new Error(String(h)))}),f}function lb(e){const{providerId:n,model:a,messages:s,temperature:i=.7,maxTokens:l=4096,onChunk:d,onDone:p,onError:f}=e,h=new AbortController;return fetch(`${Ae}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,model:a,messages:s,temperature:i,max_tokens:l}),signal:h.signal}).then(async g=>{if(!g.ok){const b=await g.text().catch(()=>"");throw new Error(`LLM error ${g.status}: ${b||g.statusText}`)}const x=g.body?.getReader();if(!x)throw new Error("No response body");await rb(x,b=>{try{const v=JSON.parse(b);v.type==="content_block_delta"&&v.delta?.text?d(v.delta.text):v.choices?.[0]?.delta?.content&&d(v.choices[0].delta.content)}catch{}}),p()}).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||f(g instanceof Error?g:new Error(String(g)))}),h}async function Yc(e){const{providerId:n,model:a,messages:s,temperature:i=.3,maxTokens:l=2048}=e,d=await fetch(`${Ae}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:n,model:a,messages:s,temperature:i,maxTokens:l})});if(!d.ok){const h=await d.text().catch(()=>"");throw new Error(`LLM error ${d.status}: ${h||d.statusText}`)}const p=await d.text(),f=[];for(const h of p.split(`
|
|
11
|
+
`)){if(!h.startsWith("data: "))continue;const g=h.slice(6).trim();if(g==="[DONE]")break;try{const x=JSON.parse(g);x.type==="content_block_delta"&&x.delta?.text?f.push(x.delta.text):x.choices?.[0]?.delta?.content?f.push(x.choices[0].delta.content):x.type==="text"&&x.content&&f.push(x.content)}catch{}}return f.join("").trim()}async function Vc(e){const n=await fetch(`${Ae}/agent-sdk/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const i=await n.text().catch(()=>"");throw new Error(`Agent SDK error ${n.status}: ${i||n.statusText}`)}const a=await n.text(),s=[];for(const i of a.split(`
|
|
12
|
+
`)){if(!i.startsWith("data: "))continue;const l=i.slice(6).trim();if(l==="[DONE]")break;try{const d=JSON.parse(l);d.type==="text"&&d.content&&s.push(d.content)}catch{}}return s.join("").trim()}const Ko=`${Ae}/mcp`;async function co(e,n){try{const a=await fetch(e,{...n,headers:{"Content-Type":"application/json",...n?.headers}});if(!a.ok)return null;const s=await a.json();return s?.data??s}catch{return null}}const Xe=qt((e,n)=>({servers:[],loaded:!1,loading:!1,error:void 0,loadServers:async()=>{if(n().loading||n().loaded)return;e({loading:!0,error:void 0});const a=await co(Ko),s=await co(`${Ae}/claude-config/mcp`);if(!a&&!s){e({servers:[],loaded:!0,loading:!1,error:"Backend unavailable. Start the server with `npm run server` on port 4800."});return}const i=a??[],l=s??[],d=new Set(i.map(f=>f.id)),p=[...i,...l.filter(f=>!d.has(f.id)).map(f=>({id:f.id,name:f.name,type:f.type,command:f.command??"",args:f.args??[],env:f.env??{},url:f.url,headers:f.headers,status:(f.status==="enabled"||f.status==="deferred","disconnected"),tools:[],mcpStatus:f.status}))];e({servers:p,loaded:!0,loading:!1}),await n().syncFromConfig()},syncFromConfig:async()=>{const{useConsoleStore:a}=await ta(async()=>{const{useConsoleStore:d}=await Promise.resolve().then(()=>Cv);return{useConsoleStore:d}},void 0),s=a.getState().mcpServers,i=n().servers,l=new Set(i.map(d=>d.id));for(const d of s)d.added&&!l.has(d.id)&&await n().addServer({id:d.id,name:d.name,command:"",args:[],env:{}})},addServer:async a=>{const s=n().servers.find(l=>l.id===a.id);if(s)return s;const i=await co(Ko,{method:"POST",body:JSON.stringify(a)});return i&&e({servers:[...n().servers,i]}),i},updateServer:async(a,s)=>{const i=await co(`${Ko}/${a}`,{method:"PUT",body:JSON.stringify(s)});return i&&e({servers:n().servers.map(l=>l.id===a?{...l,...i}:l)}),i},connectServer:async a=>{e({servers:n().servers.map(i=>i.id===a?{...i,status:"connecting"}:i)});const s=await co(`${Ko}/${a}/connect`,{method:"POST"});e({servers:n().servers.map(i=>i.id===a?{...i,status:s?.status??"error",tools:s?.tools??[],lastError:s?void 0:"Connection failed"}:i)})},disconnectServer:async a=>{await co(`${Ko}/${a}/disconnect`,{method:"POST"}),e({servers:n().servers.map(s=>s.id===a?{...s,status:"disconnected",tools:[]}:s)})},removeServer:async a=>{await co(`${Ko}/${a}`,{method:"DELETE"}),e({servers:n().servers.filter(s=>s.id!==a)})},callTool:async(a,s,i)=>(await co(`${Ko}/${a}/call`,{method:"POST",body:JSON.stringify({toolName:s,arguments:i})}))?.result??null,refreshHealth:async a=>{const s=await co(`${Ko}/${a}/health`);s&&e({servers:n().servers.map(i=>i.id===a?{...i,status:s.status,tools:s.tools,uptime:s.uptime,lastError:s.lastError}:i)})},getConnectedTools:()=>n().servers.filter(a=>a.status==="connected").flatMap(a=>a.tools)}));let oi=null;function NS(){oi||(oi=setInterval(()=>{const{servers:e,refreshHealth:n}=Xe.getState();for(const a of e)a.status==="connected"&&n(a.id)},3e4))}function AS(){oi&&(clearInterval(oi),oi=null)}const _S=Object.freeze(Object.defineProperty({__proto__:null,startHealthPolling:NS,stopHealthPolling:AS,useMcpStore:Xe},Symbol.toStringTag,{value:"Module"}));function ft(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let a=0,s;a<e.length;a++)(s=ft(e[a]))!==""&&(n+=(n&&" ")+s);else for(let a in e)e[a]&&(n+=(n&&" ")+a);return n}var DS={value:()=>{}};function Wc(){for(var e=0,n=arguments.length,a={},s;e<n;++e){if(!(s=arguments[e]+"")||s in a||/[\s.]/.test(s))throw new Error("illegal type: "+s);a[s]=[]}return new wc(a)}function wc(e){this._=e}function zS(e,n){return e.trim().split(/^|\s+/).map(function(a){var s="",i=a.indexOf(".");if(i>=0&&(s=a.slice(i+1),a=a.slice(0,i)),a&&!n.hasOwnProperty(a))throw new Error("unknown type: "+a);return{type:a,name:s}})}wc.prototype=Wc.prototype={constructor:wc,on:function(e,n){var a=this._,s=zS(e+"",a),i,l=-1,d=s.length;if(arguments.length<2){for(;++l<d;)if((i=(e=s[l]).type)&&(i=RS(a[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<d;)if(i=(e=s[l]).type)a[i]=y0(a[i],e.name,n);else if(n==null)for(i in a)a[i]=y0(a[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var a in n)e[a]=n[a].slice();return new wc(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var a=new Array(i),s=0,i,l;s<i;++s)a[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,i=l.length;s<i;++s)l[s].value.apply(n,a)},apply:function(e,n,a){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],i=0,l=s.length;i<l;++i)s[i].value.apply(n,a)}};function RS(e,n){for(var a=0,s=e.length,i;a<s;++a)if((i=e[a]).name===n)return i.value}function y0(e,n,a){for(var s=0,i=e.length;s<i;++s)if(e[s].name===n){e[s]=DS,e=e.slice(0,s).concat(e.slice(s+1));break}return a!=null&&e.push({name:n,value:a}),e}var pf="http://www.w3.org/1999/xhtml";const x0={svg:"http://www.w3.org/2000/svg",xhtml:pf,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Xc(e){var n=e+="",a=n.indexOf(":");return a>=0&&(n=e.slice(0,a))!=="xmlns"&&(e=e.slice(a+1)),x0.hasOwnProperty(n)?{space:x0[n],local:e}:e}function OS(e){return function(){var n=this.ownerDocument,a=this.namespaceURI;return a===pf&&n.documentElement.namespaceURI===pf?n.createElement(e):n.createElementNS(a,e)}}function $S(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function cb(e){var n=Xc(e);return(n.local?$S:OS)(n)}function FS(){}function Of(e){return e==null?FS:function(){return this.querySelector(e)}}function IS(e){typeof e!="function"&&(e=Of(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],d=l.length,p=s[i]=new Array(d),f,h,g=0;g<d;++g)(f=l[g])&&(h=e.call(f,f.__data__,g,l))&&("__data__"in f&&(h.__data__=f.__data__),p[g]=h);return new en(s,this._parents)}function LS(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function BS(){return[]}function ub(e){return e==null?BS:function(){return this.querySelectorAll(e)}}function PS(e){return function(){return LS(e.apply(this,arguments))}}function HS(e){typeof e=="function"?e=PS(e):e=ub(e);for(var n=this._groups,a=n.length,s=[],i=[],l=0;l<a;++l)for(var d=n[l],p=d.length,f,h=0;h<p;++h)(f=d[h])&&(s.push(e.call(f,f.__data__,h,d)),i.push(f));return new en(s,i)}function db(e){return function(){return this.matches(e)}}function pb(e){return function(n){return n.matches(e)}}var US=Array.prototype.find;function GS(e){return function(){return US.call(this.children,e)}}function qS(){return this.firstElementChild}function KS(e){return this.select(e==null?qS:GS(typeof e=="function"?e:pb(e)))}var YS=Array.prototype.filter;function VS(){return Array.from(this.children)}function WS(e){return function(){return YS.call(this.children,e)}}function XS(e){return this.selectAll(e==null?VS:WS(typeof e=="function"?e:pb(e)))}function ZS(e){typeof e!="function"&&(e=db(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],d=l.length,p=s[i]=[],f,h=0;h<d;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&p.push(f);return new en(s,this._parents)}function fb(e){return new Array(e.length)}function QS(){return new en(this._enter||this._groups.map(fb),this._parents)}function Ac(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ac.prototype={constructor:Ac,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function JS(e){return function(){return e}}function e2(e,n,a,s,i,l){for(var d=0,p,f=n.length,h=l.length;d<h;++d)(p=n[d])?(p.__data__=l[d],s[d]=p):a[d]=new Ac(e,l[d]);for(;d<f;++d)(p=n[d])&&(i[d]=p)}function t2(e,n,a,s,i,l,d){var p,f,h=new Map,g=n.length,x=l.length,b=new Array(g),v;for(p=0;p<g;++p)(f=n[p])&&(b[p]=v=d.call(f,f.__data__,p,n)+"",h.has(v)?i[p]=f:h.set(v,f));for(p=0;p<x;++p)v=d.call(e,l[p],p,l)+"",(f=h.get(v))?(s[p]=f,f.__data__=l[p],h.delete(v)):a[p]=new Ac(e,l[p]);for(p=0;p<g;++p)(f=n[p])&&h.get(b[p])===f&&(i[p]=f)}function n2(e){return e.__data__}function o2(e,n){if(!arguments.length)return Array.from(this,n2);var a=n?t2:e2,s=this._parents,i=this._groups;typeof e!="function"&&(e=JS(e));for(var l=i.length,d=new Array(l),p=new Array(l),f=new Array(l),h=0;h<l;++h){var g=s[h],x=i[h],b=x.length,v=a2(e.call(g,g&&g.__data__,h,s)),k=v.length,w=p[h]=new Array(k),j=d[h]=new Array(k),T=f[h]=new Array(b);a(g,x,w,j,T,v,n);for(var E=0,S=0,M,$;E<k;++E)if(M=w[E]){for(E>=S&&(S=E+1);!($=j[S])&&++S<k;);M._next=$||null}}return d=new en(d,s),d._enter=p,d._exit=f,d}function a2(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function s2(){return new en(this._exit||this._groups.map(fb),this._parents)}function r2(e,n,a){var s=this.enter(),i=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(i=n(i),i&&(i=i.selection())),a==null?l.remove():a(l),s&&i?s.merge(i).order():i}function i2(e){for(var n=e.selection?e.selection():e,a=this._groups,s=n._groups,i=a.length,l=s.length,d=Math.min(i,l),p=new Array(i),f=0;f<d;++f)for(var h=a[f],g=s[f],x=h.length,b=p[f]=new Array(x),v,k=0;k<x;++k)(v=h[k]||g[k])&&(b[k]=v);for(;f<i;++f)p[f]=a[f];return new en(p,this._parents)}function l2(){for(var e=this._groups,n=-1,a=e.length;++n<a;)for(var s=e[n],i=s.length-1,l=s[i],d;--i>=0;)(d=s[i])&&(l&&d.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(d,l),l=d);return this}function c2(e){e||(e=u2);function n(x,b){return x&&b?e(x.__data__,b.__data__):!x-!b}for(var a=this._groups,s=a.length,i=new Array(s),l=0;l<s;++l){for(var d=a[l],p=d.length,f=i[l]=new Array(p),h,g=0;g<p;++g)(h=d[g])&&(f[g]=h);f.sort(n)}return new en(i,this._parents).order()}function u2(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function d2(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function p2(){return Array.from(this)}function f2(){for(var e=this._groups,n=0,a=e.length;n<a;++n)for(var s=e[n],i=0,l=s.length;i<l;++i){var d=s[i];if(d)return d}return null}function m2(){let e=0;for(const n of this)++e;return e}function h2(){return!this.node()}function g2(e){for(var n=this._groups,a=0,s=n.length;a<s;++a)for(var i=n[a],l=0,d=i.length,p;l<d;++l)(p=i[l])&&e.call(p,p.__data__,l,i);return this}function y2(e){return function(){this.removeAttribute(e)}}function x2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function b2(e,n){return function(){this.setAttribute(e,n)}}function v2(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function k2(e,n){return function(){var a=n.apply(this,arguments);a==null?this.removeAttribute(e):this.setAttribute(e,a)}}function w2(e,n){return function(){var a=n.apply(this,arguments);a==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,a)}}function S2(e,n){var a=Xc(e);if(arguments.length<2){var s=this.node();return a.local?s.getAttributeNS(a.space,a.local):s.getAttribute(a)}return this.each((n==null?a.local?x2:y2:typeof n=="function"?a.local?w2:k2:a.local?v2:b2)(a,n))}function mb(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function M2(e){return function(){this.style.removeProperty(e)}}function C2(e,n,a){return function(){this.style.setProperty(e,n,a)}}function E2(e,n,a){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,a)}}function j2(e,n,a){return arguments.length>1?this.each((n==null?M2:typeof n=="function"?E2:C2)(e,n,a??"")):Is(this.node(),e)}function Is(e,n){return e.style.getPropertyValue(n)||mb(e).getComputedStyle(e,null).getPropertyValue(n)}function T2(e){return function(){delete this[e]}}function N2(e,n){return function(){this[e]=n}}function A2(e,n){return function(){var a=n.apply(this,arguments);a==null?delete this[e]:this[e]=a}}function _2(e,n){return arguments.length>1?this.each((n==null?T2:typeof n=="function"?A2:N2)(e,n)):this.node()[e]}function hb(e){return e.trim().split(/^|\s+/)}function $f(e){return e.classList||new gb(e)}function gb(e){this._node=e,this._names=hb(e.getAttribute("class")||"")}gb.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function yb(e,n){for(var a=$f(e),s=-1,i=n.length;++s<i;)a.add(n[s])}function xb(e,n){for(var a=$f(e),s=-1,i=n.length;++s<i;)a.remove(n[s])}function D2(e){return function(){yb(this,e)}}function z2(e){return function(){xb(this,e)}}function R2(e,n){return function(){(n.apply(this,arguments)?yb:xb)(this,e)}}function O2(e,n){var a=hb(e+"");if(arguments.length<2){for(var s=$f(this.node()),i=-1,l=a.length;++i<l;)if(!s.contains(a[i]))return!1;return!0}return this.each((typeof n=="function"?R2:n?D2:z2)(a,n))}function $2(){this.textContent=""}function F2(e){return function(){this.textContent=e}}function I2(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function L2(e){return arguments.length?this.each(e==null?$2:(typeof e=="function"?I2:F2)(e)):this.node().textContent}function B2(){this.innerHTML=""}function P2(e){return function(){this.innerHTML=e}}function H2(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function U2(e){return arguments.length?this.each(e==null?B2:(typeof e=="function"?H2:P2)(e)):this.node().innerHTML}function G2(){this.nextSibling&&this.parentNode.appendChild(this)}function q2(){return this.each(G2)}function K2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Y2(){return this.each(K2)}function V2(e){var n=typeof e=="function"?e:cb(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function W2(){return null}function X2(e,n){var a=typeof e=="function"?e:cb(e),s=n==null?W2:typeof n=="function"?n:Of(n);return this.select(function(){return this.insertBefore(a.apply(this,arguments),s.apply(this,arguments)||null)})}function Z2(){var e=this.parentNode;e&&e.removeChild(this)}function Q2(){return this.each(Z2)}function J2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function eM(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function tM(e){return this.select(e?eM:J2)}function nM(e){return arguments.length?this.property("__data__",e):this.node().__data__}function oM(e){return function(n){e.call(this,n,this.__data__)}}function aM(e){return e.trim().split(/^|\s+/).map(function(n){var a="",s=n.indexOf(".");return s>=0&&(a=n.slice(s+1),n=n.slice(0,s)),{type:n,name:a}})}function sM(e){return function(){var n=this.__on;if(n){for(var a=0,s=-1,i=n.length,l;a<i;++a)l=n[a],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++s]=l;++s?n.length=s:delete this.__on}}}function rM(e,n,a){return function(){var s=this.__on,i,l=oM(n);if(s){for(var d=0,p=s.length;d<p;++d)if((i=s[d]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=l,i.options=a),i.value=n;return}}this.addEventListener(e.type,l,a),i={type:e.type,name:e.name,value:n,listener:l,options:a},s?s.push(i):this.__on=[i]}}function iM(e,n,a){var s=aM(e+""),i,l=s.length,d;if(arguments.length<2){var p=this.node().__on;if(p){for(var f=0,h=p.length,g;f<h;++f)for(i=0,g=p[f];i<l;++i)if((d=s[i]).type===g.type&&d.name===g.name)return g.value}return}for(p=n?rM:sM,i=0;i<l;++i)this.each(p(s[i],n,a));return this}function bb(e,n,a){var s=mb(e),i=s.CustomEvent;typeof i=="function"?i=new i(n,a):(i=s.document.createEvent("Event"),a?(i.initEvent(n,a.bubbles,a.cancelable),i.detail=a.detail):i.initEvent(n,!1,!1)),e.dispatchEvent(i)}function lM(e,n){return function(){return bb(this,e,n)}}function cM(e,n){return function(){return bb(this,e,n.apply(this,arguments))}}function uM(e,n){return this.each((typeof n=="function"?cM:lM)(e,n))}function*dM(){for(var e=this._groups,n=0,a=e.length;n<a;++n)for(var s=e[n],i=0,l=s.length,d;i<l;++i)(d=s[i])&&(yield d)}var vb=[null];function en(e,n){this._groups=e,this._parents=n}function Ci(){return new en([[document.documentElement]],vb)}function pM(){return this}en.prototype=Ci.prototype={constructor:en,select:IS,selectAll:HS,selectChild:KS,selectChildren:XS,filter:ZS,data:o2,enter:QS,exit:s2,join:r2,merge:i2,selection:pM,order:l2,sort:c2,call:d2,nodes:p2,node:f2,size:m2,empty:h2,each:g2,attr:S2,style:j2,property:_2,classed:O2,text:L2,html:U2,raise:q2,lower:Y2,append:V2,insert:X2,remove:Q2,clone:tM,datum:nM,on:iM,dispatch:uM,[Symbol.iterator]:dM};function Jt(e){return typeof e=="string"?new en([[document.querySelector(e)]],[document.documentElement]):new en([[e]],vb)}function fM(e){let n;for(;n=e.sourceEvent;)e=n;return e}function vn(e,n){if(e=fM(e),n===void 0&&(n=e.currentTarget),n){var a=n.ownerSVGElement||n;if(a.createSVGPoint){var s=a.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const mM={passive:!1},ci={capture:!0,passive:!1};function Bp(e){e.stopImmediatePropagation()}function Rs(e){e.preventDefault(),e.stopImmediatePropagation()}function kb(e){var n=e.document.documentElement,a=Jt(e).on("dragstart.drag",Rs,ci);"onselectstart"in n?a.on("selectstart.drag",Rs,ci):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function wb(e,n){var a=e.document.documentElement,s=Jt(e).on("dragstart.drag",null);n&&(s.on("click.drag",Rs,ci),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in a?s.on("selectstart.drag",null):(a.style.MozUserSelect=a.__noselect,delete a.__noselect)}const rc=e=>()=>e;function ff(e,{sourceEvent:n,subject:a,target:s,identifier:i,active:l,x:d,y:p,dx:f,dy:h,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:a,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:d,enumerable:!0,configurable:!0},y:{value:p,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:g}})}ff.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function hM(e){return!e.ctrlKey&&!e.button}function gM(){return this.parentNode}function yM(e,n){return n??{x:e.x,y:e.y}}function xM(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sb(){var e=hM,n=gM,a=yM,s=xM,i={},l=Wc("start","drag","end"),d=0,p,f,h,g,x=0;function b(M){M.on("mousedown.drag",v).filter(s).on("touchstart.drag",j).on("touchmove.drag",T,mM).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(M,$){if(!(g||!e.call(this,M,$))){var A=S(this,n.call(this,M,$),M,$,"mouse");A&&(Jt(M.view).on("mousemove.drag",k,ci).on("mouseup.drag",w,ci),kb(M.view),Bp(M),h=!1,p=M.clientX,f=M.clientY,A("start",M))}}function k(M){if(Rs(M),!h){var $=M.clientX-p,A=M.clientY-f;h=$*$+A*A>x}i.mouse("drag",M)}function w(M){Jt(M.view).on("mousemove.drag mouseup.drag",null),wb(M.view,h),Rs(M),i.mouse("end",M)}function j(M,$){if(e.call(this,M,$)){var A=M.changedTouches,_=n.call(this,M,$),F=A.length,B,G;for(B=0;B<F;++B)(G=S(this,_,M,$,A[B].identifier,A[B]))&&(Bp(M),G("start",M,A[B]))}}function T(M){var $=M.changedTouches,A=$.length,_,F;for(_=0;_<A;++_)(F=i[$[_].identifier])&&(Rs(M),F("drag",M,$[_]))}function E(M){var $=M.changedTouches,A=$.length,_,F;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),_=0;_<A;++_)(F=i[$[_].identifier])&&(Bp(M),F("end",M,$[_]))}function S(M,$,A,_,F,B){var G=l.copy(),O=vn(B||A,$),K,V,P;if((P=a.call(M,new ff("beforestart",{sourceEvent:A,target:b,identifier:F,active:d,x:O[0],y:O[1],dx:0,dy:0,dispatch:G}),_))!=null)return K=P.x-O[0]||0,V=P.y-O[1]||0,function N(D,U,q){var W=O,oe;switch(D){case"start":i[F]=N,oe=d++;break;case"end":delete i[F],--d;case"drag":O=vn(q||U,$),oe=d;break}G.call(D,M,new ff(D,{sourceEvent:U,subject:P,target:b,identifier:F,active:oe,x:O[0]+K,y:O[1]+V,dx:O[0]-W[0],dy:O[1]-W[1],dispatch:G}),_)}}return b.filter=function(M){return arguments.length?(e=typeof M=="function"?M:rc(!!M),b):e},b.container=function(M){return arguments.length?(n=typeof M=="function"?M:rc(M),b):n},b.subject=function(M){return arguments.length?(a=typeof M=="function"?M:rc(M),b):a},b.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:rc(!!M),b):s},b.on=function(){var M=l.on.apply(l,arguments);return M===l?b:M},b.clickDistance=function(M){return arguments.length?(x=(M=+M)*M,b):Math.sqrt(x)},b}function Ff(e,n,a){e.prototype=n.prototype=a,a.constructor=e}function Mb(e,n){var a=Object.create(e.prototype);for(var s in n)a[s]=n[s];return a}function Ei(){}var ui=.7,_c=1/ui,Os="\\s*([+-]?\\d+)\\s*",di="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bM=/^#([0-9a-f]{3,8})$/,vM=new RegExp(`^rgb\\(${Os},${Os},${Os}\\)$`),kM=new RegExp(`^rgb\\(${Fn},${Fn},${Fn}\\)$`),wM=new RegExp(`^rgba\\(${Os},${Os},${Os},${di}\\)$`),SM=new RegExp(`^rgba\\(${Fn},${Fn},${Fn},${di}\\)$`),MM=new RegExp(`^hsl\\(${di},${Fn},${Fn}\\)$`),CM=new RegExp(`^hsla\\(${di},${Fn},${Fn},${di}\\)$`),b0={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ff(Ei,Oa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:v0,formatHex:v0,formatHex8:EM,formatHsl:jM,formatRgb:k0,toString:k0});function v0(){return this.rgb().formatHex()}function EM(){return this.rgb().formatHex8()}function jM(){return Cb(this).formatHsl()}function k0(){return this.rgb().formatRgb()}function Oa(e){var n,a;return e=(e+"").trim().toLowerCase(),(n=bM.exec(e))?(a=n[1].length,n=parseInt(n[1],16),a===6?w0(n):a===3?new Gt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):a===8?ic(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):a===4?ic(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=vM.exec(e))?new Gt(n[1],n[2],n[3],1):(n=kM.exec(e))?new Gt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=wM.exec(e))?ic(n[1],n[2],n[3],n[4]):(n=SM.exec(e))?ic(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=MM.exec(e))?C0(n[1],n[2]/100,n[3]/100,1):(n=CM.exec(e))?C0(n[1],n[2]/100,n[3]/100,n[4]):b0.hasOwnProperty(e)?w0(b0[e]):e==="transparent"?new Gt(NaN,NaN,NaN,0):null}function w0(e){return new Gt(e>>16&255,e>>8&255,e&255,1)}function ic(e,n,a,s){return s<=0&&(e=n=a=NaN),new Gt(e,n,a,s)}function TM(e){return e instanceof Ei||(e=Oa(e)),e?(e=e.rgb(),new Gt(e.r,e.g,e.b,e.opacity)):new Gt}function mf(e,n,a,s){return arguments.length===1?TM(e):new Gt(e,n,a,s??1)}function Gt(e,n,a,s){this.r=+e,this.g=+n,this.b=+a,this.opacity=+s}Ff(Gt,mf,Mb(Ei,{brighter(e){return e=e==null?_c:Math.pow(_c,e),new Gt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ui:Math.pow(ui,e),new Gt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Gt(_a(this.r),_a(this.g),_a(this.b),Dc(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:S0,formatHex:S0,formatHex8:NM,formatRgb:M0,toString:M0}));function S0(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}`}function NM(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}${Na((isNaN(this.opacity)?1:this.opacity)*255)}`}function M0(){const e=Dc(this.opacity);return`${e===1?"rgb(":"rgba("}${_a(this.r)}, ${_a(this.g)}, ${_a(this.b)}${e===1?")":`, ${e})`}`}function Dc(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function _a(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Na(e){return e=_a(e),(e<16?"0":"")+e.toString(16)}function C0(e,n,a,s){return s<=0?e=n=a=NaN:a<=0||a>=1?e=n=NaN:n<=0&&(e=NaN),new kn(e,n,a,s)}function Cb(e){if(e instanceof kn)return new kn(e.h,e.s,e.l,e.opacity);if(e instanceof Ei||(e=Oa(e)),!e)return new kn;if(e instanceof kn)return e;e=e.rgb();var n=e.r/255,a=e.g/255,s=e.b/255,i=Math.min(n,a,s),l=Math.max(n,a,s),d=NaN,p=l-i,f=(l+i)/2;return p?(n===l?d=(a-s)/p+(a<s)*6:a===l?d=(s-n)/p+2:d=(n-a)/p+4,p/=f<.5?l+i:2-l-i,d*=60):p=f>0&&f<1?0:d,new kn(d,p,f,e.opacity)}function AM(e,n,a,s){return arguments.length===1?Cb(e):new kn(e,n,a,s??1)}function kn(e,n,a,s){this.h=+e,this.s=+n,this.l=+a,this.opacity=+s}Ff(kn,AM,Mb(Ei,{brighter(e){return e=e==null?_c:Math.pow(_c,e),new kn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ui:Math.pow(ui,e),new kn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,a=this.l,s=a+(a<.5?a:1-a)*n,i=2*a-s;return new Gt(Pp(e>=240?e-240:e+120,i,s),Pp(e,i,s),Pp(e<120?e+240:e-120,i,s),this.opacity)},clamp(){return new kn(E0(this.h),lc(this.s),lc(this.l),Dc(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Dc(this.opacity);return`${e===1?"hsl(":"hsla("}${E0(this.h)}, ${lc(this.s)*100}%, ${lc(this.l)*100}%${e===1?")":`, ${e})`}`}}));function E0(e){return e=(e||0)%360,e<0?e+360:e}function lc(e){return Math.max(0,Math.min(1,e||0))}function Pp(e,n,a){return(e<60?n+(a-n)*e/60:e<180?a:e<240?n+(a-n)*(240-e)/60:n)*255}const If=e=>()=>e;function _M(e,n){return function(a){return e+a*n}}function DM(e,n,a){return e=Math.pow(e,a),n=Math.pow(n,a)-e,a=1/a,function(s){return Math.pow(e+s*n,a)}}function zM(e){return(e=+e)==1?Eb:function(n,a){return a-n?DM(n,a,e):If(isNaN(n)?a:n)}}function Eb(e,n){var a=n-e;return a?_M(e,a):If(isNaN(e)?n:e)}const zc=(function e(n){var a=zM(n);function s(i,l){var d=a((i=mf(i)).r,(l=mf(l)).r),p=a(i.g,l.g),f=a(i.b,l.b),h=Eb(i.opacity,l.opacity);return function(g){return i.r=d(g),i.g=p(g),i.b=f(g),i.opacity=h(g),i+""}}return s.gamma=e,s})(1);function RM(e,n){n||(n=[]);var a=e?Math.min(n.length,e.length):0,s=n.slice(),i;return function(l){for(i=0;i<a;++i)s[i]=e[i]*(1-l)+n[i]*l;return s}}function OM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function $M(e,n){var a=n?n.length:0,s=e?Math.min(a,e.length):0,i=new Array(s),l=new Array(a),d;for(d=0;d<s;++d)i[d]=ai(e[d],n[d]);for(;d<a;++d)l[d]=n[d];return function(p){for(d=0;d<s;++d)l[d]=i[d](p);return l}}function FM(e,n){var a=new Date;return e=+e,n=+n,function(s){return a.setTime(e*(1-s)+n*s),a}}function On(e,n){return e=+e,n=+n,function(a){return e*(1-a)+n*a}}function IM(e,n){var a={},s={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?a[i]=ai(e[i],n[i]):s[i]=n[i];return function(l){for(i in a)s[i]=a[i](l);return s}}var hf=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Hp=new RegExp(hf.source,"g");function LM(e){return function(){return e}}function BM(e){return function(n){return e(n)+""}}function jb(e,n){var a=hf.lastIndex=Hp.lastIndex=0,s,i,l,d=-1,p=[],f=[];for(e=e+"",n=n+"";(s=hf.exec(e))&&(i=Hp.exec(n));)(l=i.index)>a&&(l=n.slice(a,l),p[d]?p[d]+=l:p[++d]=l),(s=s[0])===(i=i[0])?p[d]?p[d]+=i:p[++d]=i:(p[++d]=null,f.push({i:d,x:On(s,i)})),a=Hp.lastIndex;return a<n.length&&(l=n.slice(a),p[d]?p[d]+=l:p[++d]=l),p.length<2?f[0]?BM(f[0].x):LM(n):(n=f.length,function(h){for(var g=0,x;g<n;++g)p[(x=f[g]).i]=x.x(h);return p.join("")})}function ai(e,n){var a=typeof n,s;return n==null||a==="boolean"?If(n):(a==="number"?On:a==="string"?(s=Oa(n))?(n=s,zc):jb:n instanceof Oa?zc:n instanceof Date?FM:OM(n)?RM:Array.isArray(n)?$M:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?IM:On)(e,n)}var j0=180/Math.PI,gf={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Tb(e,n,a,s,i,l){var d,p,f;return(d=Math.sqrt(e*e+n*n))&&(e/=d,n/=d),(f=e*a+n*s)&&(a-=e*f,s-=n*f),(p=Math.sqrt(a*a+s*s))&&(a/=p,s/=p,f/=p),e*s<n*a&&(e=-e,n=-n,f=-f,d=-d),{translateX:i,translateY:l,rotate:Math.atan2(n,e)*j0,skewX:Math.atan(f)*j0,scaleX:d,scaleY:p}}var cc;function PM(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?gf:Tb(n.a,n.b,n.c,n.d,n.e,n.f)}function HM(e){return e==null||(cc||(cc=document.createElementNS("http://www.w3.org/2000/svg","g")),cc.setAttribute("transform",e),!(e=cc.transform.baseVal.consolidate()))?gf:(e=e.matrix,Tb(e.a,e.b,e.c,e.d,e.e,e.f))}function Nb(e,n,a,s){function i(h){return h.length?h.pop()+" ":""}function l(h,g,x,b,v,k){if(h!==x||g!==b){var w=v.push("translate(",null,n,null,a);k.push({i:w-4,x:On(h,x)},{i:w-2,x:On(g,b)})}else(x||b)&&v.push("translate("+x+n+b+a)}function d(h,g,x,b){h!==g?(h-g>180?g+=360:g-h>180&&(h+=360),b.push({i:x.push(i(x)+"rotate(",null,s)-2,x:On(h,g)})):g&&x.push(i(x)+"rotate("+g+s)}function p(h,g,x,b){h!==g?b.push({i:x.push(i(x)+"skewX(",null,s)-2,x:On(h,g)}):g&&x.push(i(x)+"skewX("+g+s)}function f(h,g,x,b,v,k){if(h!==x||g!==b){var w=v.push(i(v)+"scale(",null,",",null,")");k.push({i:w-4,x:On(h,x)},{i:w-2,x:On(g,b)})}else(x!==1||b!==1)&&v.push(i(v)+"scale("+x+","+b+")")}return function(h,g){var x=[],b=[];return h=e(h),g=e(g),l(h.translateX,h.translateY,g.translateX,g.translateY,x,b),d(h.rotate,g.rotate,x,b),p(h.skewX,g.skewX,x,b),f(h.scaleX,h.scaleY,g.scaleX,g.scaleY,x,b),h=g=null,function(v){for(var k=-1,w=b.length,j;++k<w;)x[(j=b[k]).i]=j.x(v);return x.join("")}}}var UM=Nb(PM,"px, ","px)","deg)"),GM=Nb(HM,", ",")",")"),qM=1e-12;function T0(e){return((e=Math.exp(e))+1/e)/2}function KM(e){return((e=Math.exp(e))-1/e)/2}function YM(e){return((e=Math.exp(2*e))-1)/(e+1)}const Sc=(function e(n,a,s){function i(l,d){var p=l[0],f=l[1],h=l[2],g=d[0],x=d[1],b=d[2],v=g-p,k=x-f,w=v*v+k*k,j,T;if(w<qM)T=Math.log(b/h)/n,j=function(_){return[p+_*v,f+_*k,h*Math.exp(n*_*T)]};else{var E=Math.sqrt(w),S=(b*b-h*h+s*w)/(2*h*a*E),M=(b*b-h*h-s*w)/(2*b*a*E),$=Math.log(Math.sqrt(S*S+1)-S),A=Math.log(Math.sqrt(M*M+1)-M);T=(A-$)/n,j=function(_){var F=_*T,B=T0($),G=h/(a*E)*(B*YM(n*F+$)-KM($));return[p+G*v,f+G*k,h*B/T0(n*F+$)]}}return j.duration=T*1e3*n/Math.SQRT2,j}return i.rho=function(l){var d=Math.max(.001,+l),p=d*d,f=p*p;return e(d,p,f)},i})(Math.SQRT2,2,4);var Ls=0,Jr=0,Kr=0,Ab=1e3,Rc,ei,Oc=0,$a=0,Zc=0,pi=typeof performance=="object"&&performance.now?performance:Date,_b=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lf(){return $a||(_b(VM),$a=pi.now()+Zc)}function VM(){$a=0}function $c(){this._call=this._time=this._next=null}$c.prototype=Db.prototype={constructor:$c,restart:function(e,n,a){if(typeof e!="function")throw new TypeError("callback is not a function");a=(a==null?Lf():+a)+(n==null?0:+n),!this._next&&ei!==this&&(ei?ei._next=this:Rc=this,ei=this),this._call=e,this._time=a,yf()},stop:function(){this._call&&(this._call=null,this._time=1/0,yf())}};function Db(e,n,a){var s=new $c;return s.restart(e,n,a),s}function WM(){Lf(),++Ls;for(var e=Rc,n;e;)(n=$a-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Ls}function N0(){$a=(Oc=pi.now())+Zc,Ls=Jr=0;try{WM()}finally{Ls=0,ZM(),$a=0}}function XM(){var e=pi.now(),n=e-Oc;n>Ab&&(Zc-=n,Oc=e)}function ZM(){for(var e,n=Rc,a,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(a=n._next,n._next=null,n=e?e._next=a:Rc=a);ei=e,yf(s)}function yf(e){if(!Ls){Jr&&(Jr=clearTimeout(Jr));var n=e-$a;n>24?(e<1/0&&(Jr=setTimeout(N0,e-pi.now()-Zc)),Kr&&(Kr=clearInterval(Kr))):(Kr||(Oc=pi.now(),Kr=setInterval(XM,Ab)),Ls=1,_b(N0))}}function A0(e,n,a){var s=new $c;return n=n==null?0:+n,s.restart(i=>{s.stop(),e(i+n)},n,a),s}var QM=Wc("start","end","cancel","interrupt"),JM=[],zb=0,_0=1,xf=2,Mc=3,D0=4,bf=5,Cc=6;function Qc(e,n,a,s,i,l){var d=e.__transition;if(!d)e.__transition={};else if(a in d)return;eC(e,a,{name:n,index:s,group:i,on:QM,tween:JM,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:zb})}function Bf(e,n){var a=Cn(e,n);if(a.state>zb)throw new Error("too late; already scheduled");return a}function Bn(e,n){var a=Cn(e,n);if(a.state>Mc)throw new Error("too late; already running");return a}function Cn(e,n){var a=e.__transition;if(!a||!(a=a[n]))throw new Error("transition not found");return a}function eC(e,n,a){var s=e.__transition,i;s[n]=a,a.timer=Db(l,0,a.time);function l(h){a.state=_0,a.timer.restart(d,a.delay,a.time),a.delay<=h&&d(h-a.delay)}function d(h){var g,x,b,v;if(a.state!==_0)return f();for(g in s)if(v=s[g],v.name===a.name){if(v.state===Mc)return A0(d);v.state===D0?(v.state=Cc,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete s[g]):+g<n&&(v.state=Cc,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete s[g])}if(A0(function(){a.state===Mc&&(a.state=D0,a.timer.restart(p,a.delay,a.time),p(h))}),a.state=xf,a.on.call("start",e,e.__data__,a.index,a.group),a.state===xf){for(a.state=Mc,i=new Array(b=a.tween.length),g=0,x=-1;g<b;++g)(v=a.tween[g].value.call(e,e.__data__,a.index,a.group))&&(i[++x]=v);i.length=x+1}}function p(h){for(var g=h<a.duration?a.ease.call(null,h/a.duration):(a.timer.restart(f),a.state=bf,1),x=-1,b=i.length;++x<b;)i[x].call(e,g);a.state===bf&&(a.on.call("end",e,e.__data__,a.index,a.group),f())}function f(){a.state=Cc,a.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Ec(e,n){var a=e.__transition,s,i,l=!0,d;if(a){n=n==null?null:n+"";for(d in a){if((s=a[d]).name!==n){l=!1;continue}i=s.state>xf&&s.state<bf,s.state=Cc,s.timer.stop(),s.on.call(i?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete a[d]}l&&delete e.__transition}}function tC(e){return this.each(function(){Ec(this,e)})}function nC(e,n){var a,s;return function(){var i=Bn(this,e),l=i.tween;if(l!==a){s=a=l;for(var d=0,p=s.length;d<p;++d)if(s[d].name===n){s=s.slice(),s.splice(d,1);break}}i.tween=s}}function oC(e,n,a){var s,i;if(typeof a!="function")throw new Error;return function(){var l=Bn(this,e),d=l.tween;if(d!==s){i=(s=d).slice();for(var p={name:n,value:a},f=0,h=i.length;f<h;++f)if(i[f].name===n){i[f]=p;break}f===h&&i.push(p)}l.tween=i}}function aC(e,n){var a=this._id;if(e+="",arguments.length<2){for(var s=Cn(this.node(),a).tween,i=0,l=s.length,d;i<l;++i)if((d=s[i]).name===e)return d.value;return null}return this.each((n==null?nC:oC)(a,e,n))}function Pf(e,n,a){var s=e._id;return e.each(function(){var i=Bn(this,s);(i.value||(i.value={}))[n]=a.apply(this,arguments)}),function(i){return Cn(i,s).value[n]}}function Rb(e,n){var a;return(typeof n=="number"?On:n instanceof Oa?zc:(a=Oa(n))?(n=a,zc):jb)(e,n)}function sC(e){return function(){this.removeAttribute(e)}}function rC(e){return function(){this.removeAttributeNS(e.space,e.local)}}function iC(e,n,a){var s,i=a+"",l;return function(){var d=this.getAttribute(e);return d===i?null:d===s?l:l=n(s=d,a)}}function lC(e,n,a){var s,i=a+"",l;return function(){var d=this.getAttributeNS(e.space,e.local);return d===i?null:d===s?l:l=n(s=d,a)}}function cC(e,n,a){var s,i,l;return function(){var d,p=a(this),f;return p==null?void this.removeAttribute(e):(d=this.getAttribute(e),f=p+"",d===f?null:d===s&&f===i?l:(i=f,l=n(s=d,p)))}}function uC(e,n,a){var s,i,l;return function(){var d,p=a(this),f;return p==null?void this.removeAttributeNS(e.space,e.local):(d=this.getAttributeNS(e.space,e.local),f=p+"",d===f?null:d===s&&f===i?l:(i=f,l=n(s=d,p)))}}function dC(e,n){var a=Xc(e),s=a==="transform"?GM:Rb;return this.attrTween(e,typeof n=="function"?(a.local?uC:cC)(a,s,Pf(this,"attr."+e,n)):n==null?(a.local?rC:sC)(a):(a.local?lC:iC)(a,s,n))}function pC(e,n){return function(a){this.setAttribute(e,n.call(this,a))}}function fC(e,n){return function(a){this.setAttributeNS(e.space,e.local,n.call(this,a))}}function mC(e,n){var a,s;function i(){var l=n.apply(this,arguments);return l!==s&&(a=(s=l)&&fC(e,l)),a}return i._value=n,i}function hC(e,n){var a,s;function i(){var l=n.apply(this,arguments);return l!==s&&(a=(s=l)&&pC(e,l)),a}return i._value=n,i}function gC(e,n){var a="attr."+e;if(arguments.length<2)return(a=this.tween(a))&&a._value;if(n==null)return this.tween(a,null);if(typeof n!="function")throw new Error;var s=Xc(e);return this.tween(a,(s.local?mC:hC)(s,n))}function yC(e,n){return function(){Bf(this,e).delay=+n.apply(this,arguments)}}function xC(e,n){return n=+n,function(){Bf(this,e).delay=n}}function bC(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?yC:xC)(n,e)):Cn(this.node(),n).delay}function vC(e,n){return function(){Bn(this,e).duration=+n.apply(this,arguments)}}function kC(e,n){return n=+n,function(){Bn(this,e).duration=n}}function wC(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?vC:kC)(n,e)):Cn(this.node(),n).duration}function SC(e,n){if(typeof n!="function")throw new Error;return function(){Bn(this,e).ease=n}}function MC(e){var n=this._id;return arguments.length?this.each(SC(n,e)):Cn(this.node(),n).ease}function CC(e,n){return function(){var a=n.apply(this,arguments);if(typeof a!="function")throw new Error;Bn(this,e).ease=a}}function EC(e){if(typeof e!="function")throw new Error;return this.each(CC(this._id,e))}function jC(e){typeof e!="function"&&(e=db(e));for(var n=this._groups,a=n.length,s=new Array(a),i=0;i<a;++i)for(var l=n[i],d=l.length,p=s[i]=[],f,h=0;h<d;++h)(f=l[h])&&e.call(f,f.__data__,h,l)&&p.push(f);return new ho(s,this._parents,this._name,this._id)}function TC(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,a=e._groups,s=n.length,i=a.length,l=Math.min(s,i),d=new Array(s),p=0;p<l;++p)for(var f=n[p],h=a[p],g=f.length,x=d[p]=new Array(g),b,v=0;v<g;++v)(b=f[v]||h[v])&&(x[v]=b);for(;p<s;++p)d[p]=n[p];return new ho(d,this._parents,this._name,this._id)}function NC(e){return(e+"").trim().split(/^|\s+/).every(function(n){var a=n.indexOf(".");return a>=0&&(n=n.slice(0,a)),!n||n==="start"})}function AC(e,n,a){var s,i,l=NC(n)?Bf:Bn;return function(){var d=l(this,e),p=d.on;p!==s&&(i=(s=p).copy()).on(n,a),d.on=i}}function _C(e,n){var a=this._id;return arguments.length<2?Cn(this.node(),a).on.on(e):this.each(AC(a,e,n))}function DC(e){return function(){var n=this.parentNode;for(var a in this.__transition)if(+a!==e)return;n&&n.removeChild(this)}}function zC(){return this.on("end.remove",DC(this._id))}function RC(e){var n=this._name,a=this._id;typeof e!="function"&&(e=Of(e));for(var s=this._groups,i=s.length,l=new Array(i),d=0;d<i;++d)for(var p=s[d],f=p.length,h=l[d]=new Array(f),g,x,b=0;b<f;++b)(g=p[b])&&(x=e.call(g,g.__data__,b,p))&&("__data__"in g&&(x.__data__=g.__data__),h[b]=x,Qc(h[b],n,a,b,h,Cn(g,a)));return new ho(l,this._parents,n,a)}function OC(e){var n=this._name,a=this._id;typeof e!="function"&&(e=ub(e));for(var s=this._groups,i=s.length,l=[],d=[],p=0;p<i;++p)for(var f=s[p],h=f.length,g,x=0;x<h;++x)if(g=f[x]){for(var b=e.call(g,g.__data__,x,f),v,k=Cn(g,a),w=0,j=b.length;w<j;++w)(v=b[w])&&Qc(v,n,a,w,b,k);l.push(b),d.push(g)}return new ho(l,d,n,a)}var $C=Ci.prototype.constructor;function FC(){return new $C(this._groups,this._parents)}function IC(e,n){var a,s,i;return function(){var l=Is(this,e),d=(this.style.removeProperty(e),Is(this,e));return l===d?null:l===a&&d===s?i:i=n(a=l,s=d)}}function Ob(e){return function(){this.style.removeProperty(e)}}function LC(e,n,a){var s,i=a+"",l;return function(){var d=Is(this,e);return d===i?null:d===s?l:l=n(s=d,a)}}function BC(e,n,a){var s,i,l;return function(){var d=Is(this,e),p=a(this),f=p+"";return p==null&&(f=p=(this.style.removeProperty(e),Is(this,e))),d===f?null:d===s&&f===i?l:(i=f,l=n(s=d,p))}}function PC(e,n){var a,s,i,l="style."+n,d="end."+l,p;return function(){var f=Bn(this,e),h=f.on,g=f.value[l]==null?p||(p=Ob(n)):void 0;(h!==a||i!==g)&&(s=(a=h).copy()).on(d,i=g),f.on=s}}function HC(e,n,a){var s=(e+="")=="transform"?UM:Rb;return n==null?this.styleTween(e,IC(e,s)).on("end.style."+e,Ob(e)):typeof n=="function"?this.styleTween(e,BC(e,s,Pf(this,"style."+e,n))).each(PC(this._id,e)):this.styleTween(e,LC(e,s,n),a).on("end.style."+e,null)}function UC(e,n,a){return function(s){this.style.setProperty(e,n.call(this,s),a)}}function GC(e,n,a){var s,i;function l(){var d=n.apply(this,arguments);return d!==i&&(s=(i=d)&&UC(e,d,a)),s}return l._value=n,l}function qC(e,n,a){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,GC(e,n,a??""))}function KC(e){return function(){this.textContent=e}}function YC(e){return function(){var n=e(this);this.textContent=n??""}}function VC(e){return this.tween("text",typeof e=="function"?YC(Pf(this,"text",e)):KC(e==null?"":e+""))}function WC(e){return function(n){this.textContent=e.call(this,n)}}function XC(e){var n,a;function s(){var i=e.apply(this,arguments);return i!==a&&(n=(a=i)&&WC(i)),n}return s._value=e,s}function ZC(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,XC(e))}function QC(){for(var e=this._name,n=this._id,a=$b(),s=this._groups,i=s.length,l=0;l<i;++l)for(var d=s[l],p=d.length,f,h=0;h<p;++h)if(f=d[h]){var g=Cn(f,n);Qc(f,e,a,h,d,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new ho(s,this._parents,e,a)}function JC(){var e,n,a=this,s=a._id,i=a.size();return new Promise(function(l,d){var p={value:d},f={value:function(){--i===0&&l()}};a.each(function(){var h=Bn(this,s),g=h.on;g!==e&&(n=(e=g).copy(),n._.cancel.push(p),n._.interrupt.push(p),n._.end.push(f)),h.on=n}),i===0&&l()})}var eE=0;function ho(e,n,a,s){this._groups=e,this._parents=n,this._name=a,this._id=s}function $b(){return++eE}var uo=Ci.prototype;ho.prototype={constructor:ho,select:RC,selectAll:OC,selectChild:uo.selectChild,selectChildren:uo.selectChildren,filter:jC,merge:TC,selection:FC,transition:QC,call:uo.call,nodes:uo.nodes,node:uo.node,size:uo.size,empty:uo.empty,each:uo.each,on:_C,attr:dC,attrTween:gC,style:HC,styleTween:qC,text:VC,textTween:ZC,remove:zC,tween:aC,delay:bC,duration:wC,ease:MC,easeVarying:EC,end:JC,[Symbol.iterator]:uo[Symbol.iterator]};function tE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var nE={time:null,delay:0,duration:250,ease:tE};function oE(e,n){for(var a;!(a=e.__transition)||!(a=a[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return a}function aE(e){var n,a;e instanceof ho?(n=e._id,e=e._name):(n=$b(),(a=nE).time=Lf(),e=e==null?null:e+"");for(var s=this._groups,i=s.length,l=0;l<i;++l)for(var d=s[l],p=d.length,f,h=0;h<p;++h)(f=d[h])&&Qc(f,e,n,h,d,a||oE(f,n));return new ho(s,this._parents,e,n)}Ci.prototype.interrupt=tC;Ci.prototype.transition=aE;const uc=e=>()=>e;function sE(e,{sourceEvent:n,target:a,transform:s,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:a,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:i}})}function mo(e,n,a){this.k=e,this.x=n,this.y=a}mo.prototype={constructor:mo,scale:function(e){return e===1?this:new mo(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new mo(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Jc=new mo(1,0,0);Fb.prototype=mo.prototype;function Fb(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Jc;return e.__zoom}function Up(e){e.stopImmediatePropagation()}function Yr(e){e.preventDefault(),e.stopImmediatePropagation()}function rE(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function z0(){return this.__zoom||Jc}function lE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function cE(){return navigator.maxTouchPoints||"ontouchstart"in this}function uE(e,n,a){var s=e.invertX(n[0][0])-a[0][0],i=e.invertX(n[1][0])-a[1][0],l=e.invertY(n[0][1])-a[0][1],d=e.invertY(n[1][1])-a[1][1];return e.translate(i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i),d>l?(l+d)/2:Math.min(0,l)||Math.max(0,d))}function Ib(){var e=rE,n=iE,a=uE,s=lE,i=cE,l=[0,1/0],d=[[-1/0,-1/0],[1/0,1/0]],p=250,f=Sc,h=Wc("start","zoom","end"),g,x,b,v=500,k=150,w=0,j=10;function T(P){P.property("__zoom",z0).on("wheel.zoom",F,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",G).filter(i).on("touchstart.zoom",O).on("touchmove.zoom",K).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}T.transform=function(P,N,D,U){var q=P.selection?P.selection():P;q.property("__zoom",z0),P!==q?$(P,N,D,U):q.interrupt().each(function(){A(this,arguments).event(U).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},T.scaleBy=function(P,N,D,U){T.scaleTo(P,function(){var q=this.__zoom.k,W=typeof N=="function"?N.apply(this,arguments):N;return q*W},D,U)},T.scaleTo=function(P,N,D,U){T.transform(P,function(){var q=n.apply(this,arguments),W=this.__zoom,oe=D==null?M(q):typeof D=="function"?D.apply(this,arguments):D,I=W.invert(oe),L=typeof N=="function"?N.apply(this,arguments):N;return a(S(E(W,L),oe,I),q,d)},D,U)},T.translateBy=function(P,N,D,U){T.transform(P,function(){return a(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof D=="function"?D.apply(this,arguments):D),n.apply(this,arguments),d)},null,U)},T.translateTo=function(P,N,D,U,q){T.transform(P,function(){var W=n.apply(this,arguments),oe=this.__zoom,I=U==null?M(W):typeof U=="function"?U.apply(this,arguments):U;return a(Jc.translate(I[0],I[1]).scale(oe.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof D=="function"?-D.apply(this,arguments):-D),W,d)},U,q)};function E(P,N){return N=Math.max(l[0],Math.min(l[1],N)),N===P.k?P:new mo(N,P.x,P.y)}function S(P,N,D){var U=N[0]-D[0]*P.k,q=N[1]-D[1]*P.k;return U===P.x&&q===P.y?P:new mo(P.k,U,q)}function M(P){return[(+P[0][0]+ +P[1][0])/2,(+P[0][1]+ +P[1][1])/2]}function $(P,N,D,U){P.on("start.zoom",function(){A(this,arguments).event(U).start()}).on("interrupt.zoom end.zoom",function(){A(this,arguments).event(U).end()}).tween("zoom",function(){var q=this,W=arguments,oe=A(q,W).event(U),I=n.apply(q,W),L=D==null?M(I):typeof D=="function"?D.apply(q,W):D,Z=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),ae=q.__zoom,pe=typeof N=="function"?N.apply(q,W):N,me=f(ae.invert(L).concat(Z/ae.k),pe.invert(L).concat(Z/pe.k));return function(he){if(he===1)he=pe;else{var H=me(he),ce=Z/H[2];he=new mo(ce,L[0]-H[0]*ce,L[1]-H[1]*ce)}oe.zoom(null,he)}})}function A(P,N,D){return!D&&P.__zooming||new _(P,N)}function _(P,N){this.that=P,this.args=N,this.active=0,this.sourceEvent=null,this.extent=n.apply(P,N),this.taps=0}_.prototype={event:function(P){return P&&(this.sourceEvent=P),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(P,N){return this.mouse&&P!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&P!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&P!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(P){var N=Jt(this.that).datum();h.call(P,this.that,new sE(P,{sourceEvent:this.sourceEvent,target:T,transform:this.that.__zoom,dispatch:h}),N)}};function F(P,...N){if(!e.apply(this,arguments))return;var D=A(this,N).event(P),U=this.__zoom,q=Math.max(l[0],Math.min(l[1],U.k*Math.pow(2,s.apply(this,arguments)))),W=vn(P);if(D.wheel)(D.mouse[0][0]!==W[0]||D.mouse[0][1]!==W[1])&&(D.mouse[1]=U.invert(D.mouse[0]=W)),clearTimeout(D.wheel);else{if(U.k===q)return;D.mouse=[W,U.invert(W)],Ec(this),D.start()}Yr(P),D.wheel=setTimeout(oe,k),D.zoom("mouse",a(S(E(U,q),D.mouse[0],D.mouse[1]),D.extent,d));function oe(){D.wheel=null,D.end()}}function B(P,...N){if(b||!e.apply(this,arguments))return;var D=P.currentTarget,U=A(this,N,!0).event(P),q=Jt(P.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",Z,!0),W=vn(P,D),oe=P.clientX,I=P.clientY;kb(P.view),Up(P),U.mouse=[W,this.__zoom.invert(W)],Ec(this),U.start();function L(ae){if(Yr(ae),!U.moved){var pe=ae.clientX-oe,me=ae.clientY-I;U.moved=pe*pe+me*me>w}U.event(ae).zoom("mouse",a(S(U.that.__zoom,U.mouse[0]=vn(ae,D),U.mouse[1]),U.extent,d))}function Z(ae){q.on("mousemove.zoom mouseup.zoom",null),wb(ae.view,U.moved),Yr(ae),U.event(ae).end()}}function G(P,...N){if(e.apply(this,arguments)){var D=this.__zoom,U=vn(P.changedTouches?P.changedTouches[0]:P,this),q=D.invert(U),W=D.k*(P.shiftKey?.5:2),oe=a(S(E(D,W),U,q),n.apply(this,N),d);Yr(P),p>0?Jt(this).transition().duration(p).call($,oe,U,P):Jt(this).call(T.transform,oe,U,P)}}function O(P,...N){if(e.apply(this,arguments)){var D=P.touches,U=D.length,q=A(this,N,P.changedTouches.length===U).event(P),W,oe,I,L;for(Up(P),oe=0;oe<U;++oe)I=D[oe],L=vn(I,this),L=[L,this.__zoom.invert(L),I.identifier],q.touch0?!q.touch1&&q.touch0[2]!==L[2]&&(q.touch1=L,q.taps=0):(q.touch0=L,W=!0,q.taps=1+!!g);g&&(g=clearTimeout(g)),W&&(q.taps<2&&(x=L[0],g=setTimeout(function(){g=null},v)),Ec(this),q.start())}}function K(P,...N){if(this.__zooming){var D=A(this,N).event(P),U=P.changedTouches,q=U.length,W,oe,I,L;for(Yr(P),W=0;W<q;++W)oe=U[W],I=vn(oe,this),D.touch0&&D.touch0[2]===oe.identifier?D.touch0[0]=I:D.touch1&&D.touch1[2]===oe.identifier&&(D.touch1[0]=I);if(oe=D.that.__zoom,D.touch1){var Z=D.touch0[0],ae=D.touch0[1],pe=D.touch1[0],me=D.touch1[1],he=(he=pe[0]-Z[0])*he+(he=pe[1]-Z[1])*he,H=(H=me[0]-ae[0])*H+(H=me[1]-ae[1])*H;oe=E(oe,Math.sqrt(he/H)),I=[(Z[0]+pe[0])/2,(Z[1]+pe[1])/2],L=[(ae[0]+me[0])/2,(ae[1]+me[1])/2]}else if(D.touch0)I=D.touch0[0],L=D.touch0[1];else return;D.zoom("touch",a(S(oe,I,L),D.extent,d))}}function V(P,...N){if(this.__zooming){var D=A(this,N).event(P),U=P.changedTouches,q=U.length,W,oe;for(Up(P),b&&clearTimeout(b),b=setTimeout(function(){b=null},v),W=0;W<q;++W)oe=U[W],D.touch0&&D.touch0[2]===oe.identifier?delete D.touch0:D.touch1&&D.touch1[2]===oe.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(oe=vn(oe,this),Math.hypot(x[0]-oe[0],x[1]-oe[1])<j)){var I=Jt(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return T.wheelDelta=function(P){return arguments.length?(s=typeof P=="function"?P:uc(+P),T):s},T.filter=function(P){return arguments.length?(e=typeof P=="function"?P:uc(!!P),T):e},T.touchable=function(P){return arguments.length?(i=typeof P=="function"?P:uc(!!P),T):i},T.extent=function(P){return arguments.length?(n=typeof P=="function"?P:uc([[+P[0][0],+P[0][1]],[+P[1][0],+P[1][1]]]),T):n},T.scaleExtent=function(P){return arguments.length?(l[0]=+P[0],l[1]=+P[1],T):[l[0],l[1]]},T.translateExtent=function(P){return arguments.length?(d[0][0]=+P[0][0],d[1][0]=+P[1][0],d[0][1]=+P[0][1],d[1][1]=+P[1][1],T):[[d[0][0],d[0][1]],[d[1][0],d[1][1]]]},T.constrain=function(P){return arguments.length?(a=P,T):a},T.duration=function(P){return arguments.length?(p=+P,T):p},T.interpolate=function(P){return arguments.length?(f=P,T):f},T.on=function(){var P=h.on.apply(h,arguments);return P===h?T:P},T.clickDistance=function(P){return arguments.length?(w=(P=+P)*P,T):Math.sqrt(w)},T.tapDistance=function(P){return arguments.length?(j=+P,T):j},T}const In={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:a,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?a:s}", edge id: ${n}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},fi=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Lb=["Enter"," ","Escape"],Bb={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:n,y:a})=>`Moved selected node ${e}. New position, x: ${n}, y: ${a}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Bs;(function(e){e.Strict="strict",e.Loose="loose"})(Bs||(Bs={}));var Da;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Da||(Da={}));var mi;(function(e){e.Partial="partial",e.Full="full"})(mi||(mi={}));const Pb={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Zo;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Zo||(Zo={}));var Fc;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Fc||(Fc={}));var Se;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Se||(Se={}));const R0={[Se.Left]:Se.Right,[Se.Right]:Se.Left,[Se.Top]:Se.Bottom,[Se.Bottom]:Se.Top};function Hb(e){return e===null?null:e?"valid":"invalid"}const Ub=e=>"id"in e&&"source"in e&&"target"in e,dE=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Hf=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ji=(e,n=[0,0])=>{const{width:a,height:s}=go(e),i=e.origin??n,l=a*i[0],d=s*i[1];return{x:e.position.x-l,y:e.position.y-d}},pE=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const a=e.reduce((s,i)=>{const l=typeof i=="string";let d=!n.nodeLookup&&!l?i:void 0;n.nodeLookup&&(d=l?n.nodeLookup.get(i):Hf(i)?i:n.nodeLookup.get(i.id));const p=d?Ic(d,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return eu(s,p)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return tu(a)},Ti=(e,n={})=>{let a={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(i=>{(n.filter===void 0||n.filter(i))&&(a=eu(a,Ic(i)),s=!0)}),s?tu(a):{x:0,y:0,width:0,height:0}},Uf=(e,n,[a,s,i]=[0,0,1],l=!1,d=!1)=>{const p={...Ai(n,[a,s,i]),width:n.width/i,height:n.height/i},f=[];for(const h of e.values()){const{measured:g,selectable:x=!0,hidden:b=!1}=h;if(d&&!x||b)continue;const v=g.width??h.width??h.initialWidth??null,k=g.height??h.height??h.initialHeight??null,w=hi(p,Hs(h)),j=(v??0)*(k??0),T=l&&w>0;(!h.internals.handleBounds||T||w>=j||h.dragging)&&f.push(h)}return f},fE=(e,n)=>{const a=new Set;return e.forEach(s=>{a.add(s.id)}),n.filter(s=>a.has(s.source)||a.has(s.target))};function mE(e,n){const a=new Map,s=n?.nodes?new Set(n.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&(n?.includeHiddenNodes||!i.hidden)&&(!s||s.has(i.id))&&a.set(i.id,i)}),a}async function hE({nodes:e,width:n,height:a,panZoom:s,minZoom:i,maxZoom:l},d){if(e.size===0)return Promise.resolve(!0);const p=mE(e,d),f=Ti(p),h=Gf(f,n,a,d?.minZoom??i,d?.maxZoom??l,d?.padding??.1);return await s.setViewport(h,{duration:d?.duration,ease:d?.ease,interpolate:d?.interpolate}),Promise.resolve(!0)}function Gb({nodeId:e,nextPosition:n,nodeLookup:a,nodeOrigin:s=[0,0],nodeExtent:i,onError:l}){const d=a.get(e),p=d.parentId?a.get(d.parentId):void 0,{x:f,y:h}=p?p.internals.positionAbsolute:{x:0,y:0},g=d.origin??s;let x=d.extent||i;if(d.extent==="parent"&&!d.expandParent)if(!p)l?.("005",In.error005());else{const v=p.measured.width,k=p.measured.height;v&&k&&(x=[[f,h],[f+v,h+k]])}else p&&Us(d.extent)&&(x=[[d.extent[0][0]+f,d.extent[0][1]+h],[d.extent[1][0]+f,d.extent[1][1]+h]]);const b=Us(x)?Fa(n,x,d.measured):n;return(d.measured.width===void 0||d.measured.height===void 0)&&l?.("015",In.error015()),{position:{x:b.x-f+(d.measured.width??0)*g[0],y:b.y-h+(d.measured.height??0)*g[1]},positionAbsolute:b}}async function gE({nodesToRemove:e=[],edgesToRemove:n=[],nodes:a,edges:s,onBeforeDelete:i}){const l=new Set(e.map(b=>b.id)),d=[];for(const b of a){if(b.deletable===!1)continue;const v=l.has(b.id),k=!v&&b.parentId&&d.find(w=>w.id===b.parentId);(v||k)&&d.push(b)}const p=new Set(n.map(b=>b.id)),f=s.filter(b=>b.deletable!==!1),g=fE(d,f);for(const b of f)p.has(b.id)&&!g.find(k=>k.id===b.id)&&g.push(b);if(!i)return{edges:g,nodes:d};const x=await i({nodes:d,edges:g});return typeof x=="boolean"?x?{edges:g,nodes:d}:{edges:[],nodes:[]}:x}const Ps=(e,n=0,a=1)=>Math.min(Math.max(e,n),a),Fa=(e={x:0,y:0},n,a)=>({x:Ps(e.x,n[0][0],n[1][0]-(a?.width??0)),y:Ps(e.y,n[0][1],n[1][1]-(a?.height??0))});function qb(e,n,a){const{width:s,height:i}=go(a),{x:l,y:d}=a.internals.positionAbsolute;return Fa(e,[[l,d],[l+s,d+i]],n)}const O0=(e,n,a)=>e<n?Ps(Math.abs(e-n),1,n)/n:e>a?-Ps(Math.abs(e-a),1,n)/n:0,Kb=(e,n,a=15,s=40)=>{const i=O0(e.x,s,n.width-s)*a,l=O0(e.y,s,n.height-s)*a;return[i,l]},eu=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),vf=({x:e,y:n,width:a,height:s})=>({x:e,y:n,x2:e+a,y2:n+s}),tu=({x:e,y:n,x2:a,y2:s})=>({x:e,y:n,width:a-e,height:s-n}),Hs=(e,n=[0,0])=>{const{x:a,y:s}=Hf(e)?e.internals.positionAbsolute:ji(e,n);return{x:a,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Ic=(e,n=[0,0])=>{const{x:a,y:s}=Hf(e)?e.internals.positionAbsolute:ji(e,n);return{x:a,y:s,x2:a+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},Yb=(e,n)=>tu(eu(vf(e),vf(n))),hi=(e,n)=>{const a=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(a*s)},$0=e=>Sn(e.width)&&Sn(e.height)&&Sn(e.x)&&Sn(e.y),Sn=e=>!isNaN(e)&&isFinite(e),yE=(e,n)=>{},Ni=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),Ai=({x:e,y:n},[a,s,i],l=!1,d=[1,1])=>{const p={x:(e-a)/i,y:(n-s)/i};return l?Ni(p,d):p},Lc=({x:e,y:n},[a,s,i])=>({x:e*i+a,y:n*i+s});function As(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const a=parseFloat(e);if(!Number.isNaN(a))return Math.floor(a)}if(typeof e=="string"&&e.endsWith("%")){const a=parseFloat(e);if(!Number.isNaN(a))return Math.floor(n*a*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function xE(e,n,a){if(typeof e=="string"||typeof e=="number"){const s=As(e,a),i=As(e,n);return{top:s,right:i,bottom:s,left:i,x:i*2,y:s*2}}if(typeof e=="object"){const s=As(e.top??e.y??0,a),i=As(e.bottom??e.y??0,a),l=As(e.left??e.x??0,n),d=As(e.right??e.x??0,n);return{top:s,right:d,bottom:i,left:l,x:l+d,y:s+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function bE(e,n,a,s,i,l){const{x:d,y:p}=Lc(e,[n,a,s]),{x:f,y:h}=Lc({x:e.x+e.width,y:e.y+e.height},[n,a,s]),g=i-f,x=l-h;return{left:Math.floor(d),top:Math.floor(p),right:Math.floor(g),bottom:Math.floor(x)}}const Gf=(e,n,a,s,i,l)=>{const d=xE(l,n,a),p=(n-d.x)/e.width,f=(a-d.y)/e.height,h=Math.min(p,f),g=Ps(h,s,i),x=e.x+e.width/2,b=e.y+e.height/2,v=n/2-x*g,k=a/2-b*g,w=bE(e,v,k,g,n,a),j={left:Math.min(w.left-d.left,0),top:Math.min(w.top-d.top,0),right:Math.min(w.right-d.right,0),bottom:Math.min(w.bottom-d.bottom,0)};return{x:v-j.left+j.right,y:k-j.top+j.bottom,zoom:g}},gi=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Us(e){return e!=null&&e!=="parent"}function go(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Vb(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Wb(e,n={width:0,height:0},a,s,i){const l={...e},d=s.get(a);if(d){const p=d.origin||i;l.x+=d.internals.positionAbsolute.x-(n.width??0)*p[0],l.y+=d.internals.positionAbsolute.y-(n.height??0)*p[1]}return l}function F0(e,n){if(e.size!==n.size)return!1;for(const a of e)if(!n.has(a))return!1;return!0}function vE(){let e,n;return{promise:new Promise((s,i)=>{e=s,n=i}),resolve:e,reject:n}}function kE(e){return{...Bb,...e||{}}}function si(e,{snapGrid:n=[0,0],snapToGrid:a=!1,transform:s,containerBounds:i}){const{x:l,y:d}=Mn(e),p=Ai({x:l-(i?.left??0),y:d-(i?.top??0)},s),{x:f,y:h}=a?Ni(p,n):p;return{xSnapped:f,ySnapped:h,...p}}const qf=e=>({width:e.offsetWidth,height:e.offsetHeight}),Xb=e=>e?.getRootNode?.()||window?.document,wE=["INPUT","SELECT","TEXTAREA"];function Zb(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:wE.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const Qb=e=>"clientX"in e,Mn=(e,n)=>{const a=Qb(e),s=a?e.clientX:e.touches?.[0].clientX,i=a?e.clientY:e.touches?.[0].clientY;return{x:s-(n?.left??0),y:i-(n?.top??0)}},I0=(e,n,a,s,i)=>{const l=n.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(d=>{const p=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),type:e,nodeId:i,position:d.getAttribute("data-handlepos"),x:(p.left-a.left)/s,y:(p.top-a.top)/s,...qf(d)}})};function Jb({sourceX:e,sourceY:n,targetX:a,targetY:s,sourceControlX:i,sourceControlY:l,targetControlX:d,targetControlY:p}){const f=e*.125+i*.375+d*.375+a*.125,h=n*.125+l*.375+p*.375+s*.125,g=Math.abs(f-e),x=Math.abs(h-n);return[f,h,g,x]}function dc(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function L0({pos:e,x1:n,y1:a,x2:s,y2:i,c:l}){switch(e){case Se.Left:return[n-dc(n-s,l),a];case Se.Right:return[n+dc(s-n,l),a];case Se.Top:return[n,a-dc(a-i,l)];case Se.Bottom:return[n,a+dc(i-a,l)]}}function e1({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top,curvature:d=.25}){const[p,f]=L0({pos:a,x1:e,y1:n,x2:s,y2:i,c:d}),[h,g]=L0({pos:l,x1:s,y1:i,x2:e,y2:n,c:d}),[x,b,v,k]=Jb({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:p,sourceControlY:f,targetControlX:h,targetControlY:g});return[`M${e},${n} C${p},${f} ${h},${g} ${s},${i}`,x,b,v,k]}function t1({sourceX:e,sourceY:n,targetX:a,targetY:s}){const i=Math.abs(a-e)/2,l=a<e?a+i:a-i,d=Math.abs(s-n)/2,p=s<n?s+d:s-d;return[l,p,i,d]}function SE({sourceNode:e,targetNode:n,selected:a=!1,zIndex:s=0,elevateOnSelect:i=!1,zIndexMode:l="basic"}){if(l==="manual")return s;const d=i&&a?s+1e3:s,p=Math.max(e.parentId||i&&e.selected?e.internals.z:0,n.parentId||i&&n.selected?n.internals.z:0);return d+p}function ME({sourceNode:e,targetNode:n,width:a,height:s,transform:i}){const l=eu(Ic(e),Ic(n));l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const d={x:-i[0]/i[2],y:-i[1]/i[2],width:a/i[2],height:s/i[2]};return hi(d,tu(l))>0}const CE=({source:e,sourceHandle:n,target:a,targetHandle:s})=>`xy-edge__${e}${n||""}-${a}${s||""}`,EE=(e,n)=>n.some(a=>a.source===e.source&&a.target===e.target&&(a.sourceHandle===e.sourceHandle||!a.sourceHandle&&!e.sourceHandle)&&(a.targetHandle===e.targetHandle||!a.targetHandle&&!e.targetHandle)),jE=(e,n,a={})=>{if(!e.source||!e.target)return n;const s=a.getEdgeId||CE;let i;return Ub(e)?i={...e}:i={...e,id:s(e)},EE(i,n)?n:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,n.concat(i))};function n1({sourceX:e,sourceY:n,targetX:a,targetY:s}){const[i,l,d,p]=t1({sourceX:e,sourceY:n,targetX:a,targetY:s});return[`M ${e},${n}L ${a},${s}`,i,l,d,p]}const B0={[Se.Left]:{x:-1,y:0},[Se.Right]:{x:1,y:0},[Se.Top]:{x:0,y:-1},[Se.Bottom]:{x:0,y:1}},TE=({source:e,sourcePosition:n=Se.Bottom,target:a})=>n===Se.Left||n===Se.Right?e.x<a.x?{x:1,y:0}:{x:-1,y:0}:e.y<a.y?{x:0,y:1}:{x:0,y:-1},P0=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function NE({source:e,sourcePosition:n=Se.Bottom,target:a,targetPosition:s=Se.Top,center:i,offset:l,stepPosition:d}){const p=B0[n],f=B0[s],h={x:e.x+p.x*l,y:e.y+p.y*l},g={x:a.x+f.x*l,y:a.y+f.y*l},x=TE({source:h,sourcePosition:n,target:g}),b=x.x!==0?"x":"y",v=x[b];let k=[],w,j;const T={x:0,y:0},E={x:0,y:0},[,,S,M]=t1({sourceX:e.x,sourceY:e.y,targetX:a.x,targetY:a.y});if(p[b]*f[b]===-1){b==="x"?(w=i.x??h.x+(g.x-h.x)*d,j=i.y??(h.y+g.y)/2):(w=i.x??(h.x+g.x)/2,j=i.y??h.y+(g.y-h.y)*d);const A=[{x:w,y:h.y},{x:w,y:g.y}],_=[{x:h.x,y:j},{x:g.x,y:j}];p[b]===v?k=b==="x"?A:_:k=b==="x"?_:A}else{const A=[{x:h.x,y:g.y}],_=[{x:g.x,y:h.y}];if(b==="x"?k=p.x===v?_:A:k=p.y===v?A:_,n===s){const K=Math.abs(e[b]-a[b]);if(K<=l){const V=Math.min(l-1,l-K);p[b]===v?T[b]=(h[b]>e[b]?-1:1)*V:E[b]=(g[b]>a[b]?-1:1)*V}}if(n!==s){const K=b==="x"?"y":"x",V=p[b]===f[K],P=h[K]>g[K],N=h[K]<g[K];(p[b]===1&&(!V&&P||V&&N)||p[b]!==1&&(!V&&N||V&&P))&&(k=b==="x"?A:_)}const F={x:h.x+T.x,y:h.y+T.y},B={x:g.x+E.x,y:g.y+E.y},G=Math.max(Math.abs(F.x-k[0].x),Math.abs(B.x-k[0].x)),O=Math.max(Math.abs(F.y-k[0].y),Math.abs(B.y-k[0].y));G>=O?(w=(F.x+B.x)/2,j=k[0].y):(w=k[0].x,j=(F.y+B.y)/2)}return[[e,{x:h.x+T.x,y:h.y+T.y},...k,{x:g.x+E.x,y:g.y+E.y},a],w,j,S,M]}function AE(e,n,a,s){const i=Math.min(P0(e,n)/2,P0(n,a)/2,s),{x:l,y:d}=n;if(e.x===l&&l===a.x||e.y===d&&d===a.y)return`L${l} ${d}`;if(e.y===d){const h=e.x<a.x?-1:1,g=e.y<a.y?1:-1;return`L ${l+i*h},${d}Q ${l},${d} ${l},${d+i*g}`}const p=e.x<a.x?1:-1,f=e.y<a.y?-1:1;return`L ${l},${d+i*f}Q ${l},${d} ${l+i*p},${d}`}function kf({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top,borderRadius:d=5,centerX:p,centerY:f,offset:h=20,stepPosition:g=.5}){const[x,b,v,k,w]=NE({source:{x:e,y:n},sourcePosition:a,target:{x:s,y:i},targetPosition:l,center:{x:p,y:f},offset:h,stepPosition:g});return[x.reduce((T,E,S)=>{let M="";return S>0&&S<x.length-1?M=AE(x[S-1],E,x[S+1],d):M=`${S===0?"M":"L"}${E.x} ${E.y}`,T+=M,T},""),b,v,k,w]}function H0(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function _E(e){const{sourceNode:n,targetNode:a}=e;if(!H0(n)||!H0(a))return null;const s=n.internals.handleBounds||U0(n.handles),i=a.internals.handleBounds||U0(a.handles),l=G0(s?.source??[],e.sourceHandle),d=G0(e.connectionMode===Bs.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!l||!d)return e.onError?.("008",In.error008(l?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const p=l?.position||Se.Bottom,f=d?.position||Se.Top,h=Ia(n,l,p),g=Ia(a,d,f);return{sourceX:h.x,sourceY:h.y,targetX:g.x,targetY:g.y,sourcePosition:p,targetPosition:f}}function U0(e){if(!e)return null;const n=[],a=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?n.push(s):s.type==="target"&&a.push(s);return{source:n,target:a}}function Ia(e,n,a=Se.Left,s=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,l=(n?.y??0)+e.internals.positionAbsolute.y,{width:d,height:p}=n??go(e);if(s)return{x:i+d/2,y:l+p/2};switch(n?.position??a){case Se.Top:return{x:i+d/2,y:l};case Se.Right:return{x:i+d,y:l+p/2};case Se.Bottom:return{x:i+d/2,y:l+p};case Se.Left:return{x:i,y:l+p/2}}}function G0(e,n){return e&&(n?e.find(a=>a.id===n):e[0])||null}function wf(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function DE(e,{id:n,defaultColor:a,defaultMarkerStart:s,defaultMarkerEnd:i}){const l=new Set;return e.reduce((d,p)=>([p.markerStart||s,p.markerEnd||i].forEach(f=>{if(f&&typeof f=="object"){const h=wf(f,n);l.has(h)||(d.push({id:h,color:f.color||a,...f}),l.add(h))}}),d),[]).sort((d,p)=>d.id.localeCompare(p.id))}const o1=1e3,zE=10,Kf={nodeOrigin:[0,0],nodeExtent:fi,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},RE={...Kf,checkEquality:!0};function Yf(e,n){const a={...e};for(const s in n)n[s]!==void 0&&(a[s]=n[s]);return a}function OE(e,n,a){const s=Yf(Kf,a);for(const i of e.values())if(i.parentId)Wf(i,e,n,s);else{const l=ji(i,s.nodeOrigin),d=Us(i.extent)?i.extent:s.nodeExtent,p=Fa(l,d,go(i));i.internals.positionAbsolute=p}}function $E(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const a=[],s=[];for(const i of e.handles){const l={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?a.push(l):i.type==="target"&&s.push(l)}return{source:a,target:s}}function Vf(e){return e==="manual"}function Sf(e,n,a,s={}){const i=Yf(RE,s),l={i:0},d=new Map(n),p=i?.elevateNodesOnSelect&&!Vf(i.zIndexMode)?o1:0;let f=e.length>0;n.clear(),a.clear();for(const h of e){let g=d.get(h.id);if(i.checkEquality&&h===g?.internals.userNode)n.set(h.id,g);else{const x=ji(h,i.nodeOrigin),b=Us(h.extent)?h.extent:i.nodeExtent,v=Fa(x,b,go(h));g={...i.defaults,...h,measured:{width:h.measured?.width,height:h.measured?.height},internals:{positionAbsolute:v,handleBounds:$E(h,g),z:a1(h,p,i.zIndexMode),userNode:h}},n.set(h.id,g)}(g.measured===void 0||g.measured.width===void 0||g.measured.height===void 0)&&!g.hidden&&(f=!1),h.parentId&&Wf(g,n,a,s,l)}return f}function FE(e,n){if(!e.parentId)return;const a=n.get(e.parentId);a?a.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function Wf(e,n,a,s,i){const{elevateNodesOnSelect:l,nodeOrigin:d,nodeExtent:p,zIndexMode:f}=Yf(Kf,s),h=e.parentId,g=n.get(h);if(!g){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}FE(e,a),i&&!g.parentId&&g.internals.rootParentIndex===void 0&&f==="auto"&&(g.internals.rootParentIndex=++i.i,g.internals.z=g.internals.z+i.i*zE),i&&g.internals.rootParentIndex!==void 0&&(i.i=g.internals.rootParentIndex);const x=l&&!Vf(f)?o1:0,{x:b,y:v,z:k}=IE(e,g,d,p,x,f),{positionAbsolute:w}=e.internals,j=b!==w.x||v!==w.y;(j||k!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:j?{x:b,y:v}:w,z:k}})}function a1(e,n,a){const s=Sn(e.zIndex)?e.zIndex:0;return Vf(a)?s:s+(e.selected?n:0)}function IE(e,n,a,s,i,l){const{x:d,y:p}=n.internals.positionAbsolute,f=go(e),h=ji(e,a),g=Us(e.extent)?Fa(h,e.extent,f):h;let x=Fa({x:d+g.x,y:p+g.y},s,f);e.extent==="parent"&&(x=qb(x,f,n));const b=a1(e,i,l),v=n.internals.z??0;return{x:x.x,y:x.y,z:v>=b?v+1:b}}function Xf(e,n,a,s=[0,0]){const i=[],l=new Map;for(const d of e){const p=n.get(d.parentId);if(!p)continue;const f=l.get(d.parentId)?.expandedRect??Hs(p),h=Yb(f,d.rect);l.set(d.parentId,{expandedRect:h,parent:p})}return l.size>0&&l.forEach(({expandedRect:d,parent:p},f)=>{const h=p.internals.positionAbsolute,g=go(p),x=p.origin??s,b=d.x<h.x?Math.round(Math.abs(h.x-d.x)):0,v=d.y<h.y?Math.round(Math.abs(h.y-d.y)):0,k=Math.max(g.width,Math.round(d.width)),w=Math.max(g.height,Math.round(d.height)),j=(k-g.width)*x[0],T=(w-g.height)*x[1];(b>0||v>0||j||T)&&(i.push({id:f,type:"position",position:{x:p.position.x-b+j,y:p.position.y-v+T}}),a.get(f)?.forEach(E=>{e.some(S=>S.id===E.id)||i.push({id:E.id,type:"position",position:{x:E.position.x+b,y:E.position.y+v}})})),(g.width<d.width||g.height<d.height||b||v)&&i.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:k+(b?x[0]*b-j:0),height:w+(v?x[1]*v-T:0)}})}),i}function LE(e,n,a,s,i,l,d){const p=s?.querySelector(".xyflow__viewport");let f=!1;if(!p)return{changes:[],updatedInternals:f};const h=[],g=window.getComputedStyle(p),{m22:x}=new window.DOMMatrixReadOnly(g.transform),b=[];for(const v of e.values()){const k=n.get(v.id);if(!k)continue;if(k.hidden){n.set(k.id,{...k,internals:{...k.internals,handleBounds:void 0}}),f=!0;continue}const w=qf(v.nodeElement),j=k.measured.width!==w.width||k.measured.height!==w.height;if(!!(w.width&&w.height&&(j||!k.internals.handleBounds||v.force))){const E=v.nodeElement.getBoundingClientRect(),S=Us(k.extent)?k.extent:l;let{positionAbsolute:M}=k.internals;k.parentId&&k.extent==="parent"?M=qb(M,w,n.get(k.parentId)):S&&(M=Fa(M,S,w));const $={...k,measured:w,internals:{...k.internals,positionAbsolute:M,handleBounds:{source:I0("source",v.nodeElement,E,x,k.id),target:I0("target",v.nodeElement,E,x,k.id)}}};n.set(k.id,$),k.parentId&&Wf($,n,a,{nodeOrigin:i,zIndexMode:d}),f=!0,j&&(h.push({id:k.id,type:"dimensions",dimensions:w}),k.expandParent&&k.parentId&&b.push({id:k.id,parentId:k.parentId,rect:Hs($,i)}))}}if(b.length>0){const v=Xf(b,n,a,i);h.push(...v)}return{changes:h,updatedInternals:f}}async function BE({delta:e,panZoom:n,transform:a,translateExtent:s,width:i,height:l}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const d=await n.setViewportConstrained({x:a[0]+e.x,y:a[1]+e.y,zoom:a[2]},[[0,0],[i,l]],s),p=!!d&&(d.x!==a[0]||d.y!==a[1]||d.k!==a[2]);return Promise.resolve(p)}function q0(e,n,a,s,i,l){let d=i;const p=s.get(d)||new Map;s.set(d,p.set(a,n)),d=`${i}-${e}`;const f=s.get(d)||new Map;if(s.set(d,f.set(a,n)),l){d=`${i}-${e}-${l}`;const h=s.get(d)||new Map;s.set(d,h.set(a,n))}}function s1(e,n,a){e.clear(),n.clear();for(const s of a){const{source:i,target:l,sourceHandle:d=null,targetHandle:p=null}=s,f={edgeId:s.id,source:i,target:l,sourceHandle:d,targetHandle:p},h=`${i}-${d}--${l}-${p}`,g=`${l}-${p}--${i}-${d}`;q0("source",f,g,e,i,d),q0("target",f,h,e,l,p),n.set(s.id,s)}}function r1(e,n){if(!e.parentId)return!1;const a=n.get(e.parentId);return a?a.selected?!0:r1(a,n):!1}function K0(e,n,a){let s=e;do{if(s?.matches?.(n))return!0;if(s===a)return!1;s=s?.parentElement}while(s);return!1}function PE(e,n,a,s){const i=new Map;for(const[l,d]of e)if((d.selected||d.id===s)&&(!d.parentId||!r1(d,e))&&(d.draggable||n&&typeof d.draggable>"u")){const p=e.get(l);p&&i.set(l,{id:l,position:p.position||{x:0,y:0},distance:{x:a.x-p.internals.positionAbsolute.x,y:a.y-p.internals.positionAbsolute.y},extent:p.extent,parentId:p.parentId,origin:p.origin,expandParent:p.expandParent,internals:{positionAbsolute:p.internals.positionAbsolute||{x:0,y:0}},measured:{width:p.measured.width??0,height:p.measured.height??0}})}return i}function Gp({nodeId:e,dragItems:n,nodeLookup:a,dragging:s=!0}){const i=[];for(const[d,p]of n){const f=a.get(d)?.internals.userNode;f&&i.push({...f,position:p.position,dragging:s})}if(!e)return[i[0],i];const l=a.get(e)?.internals.userNode;return[l?{...l,position:n.get(e)?.position||l.position,dragging:s}:i[0],i]}function HE({dragItems:e,snapGrid:n,x:a,y:s}){const i=e.values().next().value;if(!i)return null;const l={x:a-i.distance.x,y:s-i.distance.y},d=Ni(l,n);return{x:d.x-l.x,y:d.y-l.y}}function UE({onNodeMouseDown:e,getStoreItems:n,onDragStart:a,onDrag:s,onDragStop:i}){let l={x:null,y:null},d=0,p=new Map,f=!1,h={x:0,y:0},g=null,x=!1,b=null,v=!1,k=!1,w=null;function j({noDragClassName:E,handleSelector:S,domNode:M,isSelectable:$,nodeId:A,nodeClickDistance:_=0}){b=Jt(M);function F({x:K,y:V}){const{nodeLookup:P,nodeExtent:N,snapGrid:D,snapToGrid:U,nodeOrigin:q,onNodeDrag:W,onSelectionDrag:oe,onError:I,updateNodePositions:L}=n();l={x:K,y:V};let Z=!1;const ae=p.size>1,pe=ae&&N?vf(Ti(p)):null,me=ae&&U?HE({dragItems:p,snapGrid:D,x:K,y:V}):null;for(const[he,H]of p){if(!P.has(he))continue;let ce={x:K-H.distance.x,y:V-H.distance.y};U&&(ce=me?{x:Math.round(ce.x+me.x),y:Math.round(ce.y+me.y)}:Ni(ce,D));let Q=null;if(ae&&N&&!H.extent&&pe){const{positionAbsolute:J}=H.internals,ye=J.x-pe.x+N[0][0],Ee=J.x+H.measured.width-pe.x2+N[1][0],Ie=J.y-pe.y+N[0][1],ze=J.y+H.measured.height-pe.y2+N[1][1];Q=[[ye,Ie],[Ee,ze]]}const{position:ge,positionAbsolute:xe}=Gb({nodeId:he,nextPosition:ce,nodeLookup:P,nodeExtent:Q||N,nodeOrigin:q,onError:I});Z=Z||H.position.x!==ge.x||H.position.y!==ge.y,H.position=ge,H.internals.positionAbsolute=xe}if(k=k||Z,!!Z&&(L(p,!0),w&&(s||W||!A&&oe))){const[he,H]=Gp({nodeId:A,dragItems:p,nodeLookup:P});s?.(w,p,he,H),W?.(w,he,H),A||oe?.(w,H)}}async function B(){if(!g)return;const{transform:K,panBy:V,autoPanSpeed:P,autoPanOnNodeDrag:N}=n();if(!N){f=!1,cancelAnimationFrame(d);return}const[D,U]=Kb(h,g,P);(D!==0||U!==0)&&(l.x=(l.x??0)-D/K[2],l.y=(l.y??0)-U/K[2],await V({x:D,y:U})&&F(l)),d=requestAnimationFrame(B)}function G(K){const{nodeLookup:V,multiSelectionActive:P,nodesDraggable:N,transform:D,snapGrid:U,snapToGrid:q,selectNodesOnDrag:W,onNodeDragStart:oe,onSelectionDragStart:I,unselectNodesAndEdges:L}=n();x=!0,(!W||!$)&&!P&&A&&(V.get(A)?.selected||L()),$&&W&&A&&e?.(A);const Z=si(K.sourceEvent,{transform:D,snapGrid:U,snapToGrid:q,containerBounds:g});if(l=Z,p=PE(V,N,Z,A),p.size>0&&(a||oe||!A&&I)){const[ae,pe]=Gp({nodeId:A,dragItems:p,nodeLookup:V});a?.(K.sourceEvent,p,ae,pe),oe?.(K.sourceEvent,ae,pe),A||I?.(K.sourceEvent,pe)}}const O=Sb().clickDistance(_).on("start",K=>{const{domNode:V,nodeDragThreshold:P,transform:N,snapGrid:D,snapToGrid:U}=n();g=V?.getBoundingClientRect()||null,v=!1,k=!1,w=K.sourceEvent,P===0&&G(K),l=si(K.sourceEvent,{transform:N,snapGrid:D,snapToGrid:U,containerBounds:g}),h=Mn(K.sourceEvent,g)}).on("drag",K=>{const{autoPanOnNodeDrag:V,transform:P,snapGrid:N,snapToGrid:D,nodeDragThreshold:U,nodeLookup:q}=n(),W=si(K.sourceEvent,{transform:P,snapGrid:N,snapToGrid:D,containerBounds:g});if(w=K.sourceEvent,(K.sourceEvent.type==="touchmove"&&K.sourceEvent.touches.length>1||A&&!q.has(A))&&(v=!0),!v){if(!f&&V&&x&&(f=!0,B()),!x){const oe=Mn(K.sourceEvent,g),I=oe.x-h.x,L=oe.y-h.y;Math.sqrt(I*I+L*L)>U&&G(K)}(l.x!==W.xSnapped||l.y!==W.ySnapped)&&p&&x&&(h=Mn(K.sourceEvent,g),F(W))}}).on("end",K=>{if(!(!x||v)&&(f=!1,x=!1,cancelAnimationFrame(d),p.size>0)){const{nodeLookup:V,updateNodePositions:P,onNodeDragStop:N,onSelectionDragStop:D}=n();if(k&&(P(p,!1),k=!1),i||N||!A&&D){const[U,q]=Gp({nodeId:A,dragItems:p,nodeLookup:V,dragging:!1});i?.(K.sourceEvent,p,U,q),N?.(K.sourceEvent,U,q),A||D?.(K.sourceEvent,q)}}}).filter(K=>{const V=K.target;return!K.button&&(!E||!K0(V,`.${E}`,M))&&(!S||K0(V,S,M))});b.call(O)}function T(){b?.on(".drag",null)}return{update:j,destroy:T}}function GE(e,n,a){const s=[],i={x:e.x-a,y:e.y-a,width:a*2,height:a*2};for(const l of n.values())hi(i,Hs(l))>0&&s.push(l);return s}const qE=250;function KE(e,n,a,s){let i=[],l=1/0;const d=GE(e,a,n+qE);for(const p of d){const f=[...p.internals.handleBounds?.source??[],...p.internals.handleBounds?.target??[]];for(const h of f){if(s.nodeId===h.nodeId&&s.type===h.type&&s.id===h.id)continue;const{x:g,y:x}=Ia(p,h,h.position,!0),b=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));b>n||(b<l?(i=[{...h,x:g,y:x}],l=b):b===l&&i.push({...h,x:g,y:x}))}}if(!i.length)return null;if(i.length>1){const p=s.type==="source"?"target":"source";return i.find(f=>f.type===p)??i[0]}return i[0]}function i1(e,n,a,s,i,l=!1){const d=s.get(e);if(!d)return null;const p=i==="strict"?d.internals.handleBounds?.[n]:[...d.internals.handleBounds?.source??[],...d.internals.handleBounds?.target??[]],f=(a?p?.find(h=>h.id===a):p?.[0])??null;return f&&l?{...f,...Ia(d,f,f.position,!0)}:f}function l1(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function YE(e,n){let a=null;return n?a=!0:e&&!n&&(a=!1),a}const c1=()=>!0;function VE(e,{connectionMode:n,connectionRadius:a,handleId:s,nodeId:i,edgeUpdaterType:l,isTarget:d,domNode:p,nodeLookup:f,lib:h,autoPanOnConnect:g,flowId:x,panBy:b,cancelConnection:v,onConnectStart:k,onConnect:w,onConnectEnd:j,isValidConnection:T=c1,onReconnectEnd:E,updateConnection:S,getTransform:M,getFromHandle:$,autoPanSpeed:A,dragThreshold:_=1,handleDomNode:F}){const B=Xb(e.target);let G=0,O;const{x:K,y:V}=Mn(e),P=l1(l,F),N=p?.getBoundingClientRect();let D=!1;if(!N||!P)return;const U=i1(i,P,s,f,n);if(!U)return;let q=Mn(e,N),W=!1,oe=null,I=!1,L=null;function Z(){if(!g||!N)return;const[ge,xe]=Kb(q,N,A);b({x:ge,y:xe}),G=requestAnimationFrame(Z)}const ae={...U,nodeId:i,type:P,position:U.position},pe=f.get(i);let he={inProgress:!0,isValid:null,from:Ia(pe,ae,Se.Left,!0),fromHandle:ae,fromPosition:ae.position,fromNode:pe,to:q,toHandle:null,toPosition:R0[ae.position],toNode:null,pointer:q};function H(){D=!0,S(he),k?.(e,{nodeId:i,handleId:s,handleType:P})}_===0&&H();function ce(ge){if(!D){const{x:ze,y:Nt}=Mn(ge),mt=ze-K,vt=Nt-V;if(!(mt*mt+vt*vt>_*_))return;H()}if(!$()||!ae){Q(ge);return}const xe=M();q=Mn(ge,N),O=KE(Ai(q,xe,!1,[1,1]),a,f,ae),W||(Z(),W=!0);const J=u1(ge,{handle:O,connectionMode:n,fromNodeId:i,fromHandleId:s,fromType:d?"target":"source",isValidConnection:T,doc:B,lib:h,flowId:x,nodeLookup:f});L=J.handleDomNode,oe=J.connection,I=YE(!!O,J.isValid);const ye=f.get(i),Ee=ye?Ia(ye,ae,Se.Left,!0):he.from,Ie={...he,from:Ee,isValid:I,to:J.toHandle&&I?Lc({x:J.toHandle.x,y:J.toHandle.y},xe):q,toHandle:J.toHandle,toPosition:I&&J.toHandle?J.toHandle.position:R0[ae.position],toNode:J.toHandle?f.get(J.toHandle.nodeId):null,pointer:q};S(Ie),he=Ie}function Q(ge){if(!("touches"in ge&&ge.touches.length>0)){if(D){(O||L)&&oe&&I&&w?.(oe);const{inProgress:xe,...J}=he,ye={...J,toPosition:he.toHandle?he.toPosition:null};j?.(ge,ye),l&&E?.(ge,ye)}v(),cancelAnimationFrame(G),W=!1,I=!1,oe=null,L=null,B.removeEventListener("mousemove",ce),B.removeEventListener("mouseup",Q),B.removeEventListener("touchmove",ce),B.removeEventListener("touchend",Q)}}B.addEventListener("mousemove",ce),B.addEventListener("mouseup",Q),B.addEventListener("touchmove",ce),B.addEventListener("touchend",Q)}function u1(e,{handle:n,connectionMode:a,fromNodeId:s,fromHandleId:i,fromType:l,doc:d,lib:p,flowId:f,isValidConnection:h=c1,nodeLookup:g}){const x=l==="target",b=n?d.querySelector(`.${p}-flow__handle[data-id="${f}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:v,y:k}=Mn(e),w=d.elementFromPoint(v,k),j=w?.classList.contains(`${p}-flow__handle`)?w:b,T={handleDomNode:j,isValid:!1,connection:null,toHandle:null};if(j){const E=l1(void 0,j),S=j.getAttribute("data-nodeid"),M=j.getAttribute("data-handleid"),$=j.classList.contains("connectable"),A=j.classList.contains("connectableend");if(!S||!E)return T;const _={source:x?S:s,sourceHandle:x?M:i,target:x?s:S,targetHandle:x?i:M};T.connection=_;const B=$&&A&&(a===Bs.Strict?x&&E==="source"||!x&&E==="target":S!==s||M!==i);T.isValid=B&&h(_),T.toHandle=i1(S,E,M,g,a,!0)}return T}const Mf={onPointerDown:VE,isValid:u1};function WE({domNode:e,panZoom:n,getTransform:a,getViewScale:s}){const i=Jt(e);function l({translateExtent:p,width:f,height:h,zoomStep:g=1,pannable:x=!0,zoomable:b=!0,inversePan:v=!1}){const k=S=>{if(S.sourceEvent.type!=="wheel"||!n)return;const M=a(),$=S.sourceEvent.ctrlKey&&gi()?10:1,A=-S.sourceEvent.deltaY*(S.sourceEvent.deltaMode===1?.05:S.sourceEvent.deltaMode?1:.002)*g,_=M[2]*Math.pow(2,A*$);n.scaleTo(_)};let w=[0,0];const j=S=>{(S.sourceEvent.type==="mousedown"||S.sourceEvent.type==="touchstart")&&(w=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY])},T=S=>{const M=a();if(S.sourceEvent.type!=="mousemove"&&S.sourceEvent.type!=="touchmove"||!n)return;const $=[S.sourceEvent.clientX??S.sourceEvent.touches[0].clientX,S.sourceEvent.clientY??S.sourceEvent.touches[0].clientY],A=[$[0]-w[0],$[1]-w[1]];w=$;const _=s()*Math.max(M[2],Math.log(M[2]))*(v?-1:1),F={x:M[0]-A[0]*_,y:M[1]-A[1]*_},B=[[0,0],[f,h]];n.setViewportConstrained({x:F.x,y:F.y,zoom:M[2]},B,p)},E=Ib().on("start",j).on("zoom",x?T:null).on("zoom.wheel",b?k:null);i.call(E,{})}function d(){i.on("zoom",null)}return{update:l,destroy:d,pointer:vn}}const nu=e=>({x:e.x,y:e.y,zoom:e.k}),qp=({x:e,y:n,zoom:a})=>Jc.translate(e,n).scale(a),_s=(e,n)=>e.target.closest(`.${n}`),d1=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),XE=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Kp=(e,n=0,a=XE,s=()=>{})=>{const i=typeof n=="number"&&n>0;return i||s(),i?e.transition().duration(n).ease(a).on("end",s):e},p1=e=>{const n=e.ctrlKey&&gi()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function ZE({zoomPanValues:e,noWheelClassName:n,d3Selection:a,d3Zoom:s,panOnScrollMode:i,panOnScrollSpeed:l,zoomOnPinch:d,onPanZoomStart:p,onPanZoom:f,onPanZoomEnd:h}){return g=>{if(_s(g,n))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const x=a.property("__zoom").k||1;if(g.ctrlKey&&d){const j=vn(g),T=p1(g),E=x*Math.pow(2,T);s.scaleTo(a,E,j,g);return}const b=g.deltaMode===1?20:1;let v=i===Da.Vertical?0:g.deltaX*b,k=i===Da.Horizontal?0:g.deltaY*b;!gi()&&g.shiftKey&&i!==Da.Vertical&&(v=g.deltaY*b,k=0),s.translateBy(a,-(v/x)*l,-(k/x)*l,{internal:!0});const w=nu(a.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f?.(g,w),e.panScrollTimeout=setTimeout(()=>{h?.(g,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,p?.(g,w))}}function QE({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:a}){return function(s,i){const l=s.type==="wheel",d=!n&&l&&!s.ctrlKey,p=_s(s,e);if(s.ctrlKey&&l&&p&&s.preventDefault(),d||p)return null;s.preventDefault(),a.call(this,s,i)}}function JE({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:a}){return s=>{if(s.sourceEvent?.internal)return;const i=nu(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,s.sourceEvent?.type==="mousedown"&&n(!0),a&&a?.(s.sourceEvent,i)}}function ej({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:a,onTransformChange:s,onPanZoom:i}){return l=>{e.usedRightMouseButton=!!(a&&d1(n,e.mouseButton??0)),l.sourceEvent?.sync||s([l.transform.x,l.transform.y,l.transform.k]),i&&!l.sourceEvent?.internal&&i?.(l.sourceEvent,nu(l.transform))}}function tj({zoomPanValues:e,panOnDrag:n,panOnScroll:a,onDraggingChange:s,onPanZoomEnd:i,onPaneContextMenu:l}){return d=>{if(!d.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,l&&d1(n,e.mouseButton??0)&&!e.usedRightMouseButton&&d.sourceEvent&&l(d.sourceEvent),e.usedRightMouseButton=!1,s(!1),i)){const p=nu(d.transform);e.prevViewport=p,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(d.sourceEvent,p)},a?150:0)}}}function nj({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:a,panOnDrag:s,panOnScroll:i,zoomOnDoubleClick:l,userSelectionActive:d,noWheelClassName:p,noPanClassName:f,lib:h,connectionInProgress:g}){return x=>{const b=e||n,v=a&&x.ctrlKey,k=x.type==="wheel";if(x.button===1&&x.type==="mousedown"&&(_s(x,`${h}-flow__node`)||_s(x,`${h}-flow__edge`)))return!0;if(!s&&!b&&!i&&!l&&!a||d||g&&!k||_s(x,p)&&k||_s(x,f)&&(!k||i&&k&&!e)||!a&&x.ctrlKey&&k)return!1;if(!a&&x.type==="touchstart"&&x.touches?.length>1)return x.preventDefault(),!1;if(!b&&!i&&!v&&k||!s&&(x.type==="mousedown"||x.type==="touchstart")||Array.isArray(s)&&!s.includes(x.button)&&x.type==="mousedown")return!1;const w=Array.isArray(s)&&s.includes(x.button)||!x.button||x.button<=1;return(!x.ctrlKey||k)&&w}}function oj({domNode:e,minZoom:n,maxZoom:a,translateExtent:s,viewport:i,onPanZoom:l,onPanZoomStart:d,onPanZoomEnd:p,onDraggingChange:f}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),x=Ib().scaleExtent([n,a]).translateExtent(s),b=Jt(e).call(x);E({x:i.x,y:i.y,zoom:Ps(i.zoom,n,a)},[[0,0],[g.width,g.height]],s);const v=b.on("wheel.zoom"),k=b.on("dblclick.zoom");x.wheelDelta(p1);function w(O,K){return b?new Promise(V=>{x?.interpolate(K?.interpolate==="linear"?ai:Sc).transform(Kp(b,K?.duration,K?.ease,()=>V(!0)),O)}):Promise.resolve(!1)}function j({noWheelClassName:O,noPanClassName:K,onPaneContextMenu:V,userSelectionActive:P,panOnScroll:N,panOnDrag:D,panOnScrollMode:U,panOnScrollSpeed:q,preventScrolling:W,zoomOnPinch:oe,zoomOnScroll:I,zoomOnDoubleClick:L,zoomActivationKeyPressed:Z,lib:ae,onTransformChange:pe,connectionInProgress:me,paneClickDistance:he,selectionOnDrag:H}){P&&!h.isZoomingOrPanning&&T();const ce=N&&!Z&&!P;x.clickDistance(H?1/0:!Sn(he)||he<0?0:he);const Q=ce?ZE({zoomPanValues:h,noWheelClassName:O,d3Selection:b,d3Zoom:x,panOnScrollMode:U,panOnScrollSpeed:q,zoomOnPinch:oe,onPanZoomStart:d,onPanZoom:l,onPanZoomEnd:p}):QE({noWheelClassName:O,preventScrolling:W,d3ZoomHandler:v});if(b.on("wheel.zoom",Q,{passive:!1}),!P){const xe=JE({zoomPanValues:h,onDraggingChange:f,onPanZoomStart:d});x.on("start",xe);const J=ej({zoomPanValues:h,panOnDrag:D,onPaneContextMenu:!!V,onPanZoom:l,onTransformChange:pe});x.on("zoom",J);const ye=tj({zoomPanValues:h,panOnDrag:D,panOnScroll:N,onPaneContextMenu:V,onPanZoomEnd:p,onDraggingChange:f});x.on("end",ye)}const ge=nj({zoomActivationKeyPressed:Z,panOnDrag:D,zoomOnScroll:I,panOnScroll:N,zoomOnDoubleClick:L,zoomOnPinch:oe,userSelectionActive:P,noPanClassName:K,noWheelClassName:O,lib:ae,connectionInProgress:me});x.filter(ge),L?b.on("dblclick.zoom",k):b.on("dblclick.zoom",null)}function T(){x.on("zoom",null)}async function E(O,K,V){const P=qp(O),N=x?.constrain()(P,K,V);return N&&await w(N),new Promise(D=>D(N))}async function S(O,K){const V=qp(O);return await w(V,K),new Promise(P=>P(V))}function M(O){if(b){const K=qp(O),V=b.property("__zoom");(V.k!==O.zoom||V.x!==O.x||V.y!==O.y)&&x?.transform(b,K,null,{sync:!0})}}function $(){const O=b?Fb(b.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function A(O,K){return b?new Promise(V=>{x?.interpolate(K?.interpolate==="linear"?ai:Sc).scaleTo(Kp(b,K?.duration,K?.ease,()=>V(!0)),O)}):Promise.resolve(!1)}function _(O,K){return b?new Promise(V=>{x?.interpolate(K?.interpolate==="linear"?ai:Sc).scaleBy(Kp(b,K?.duration,K?.ease,()=>V(!0)),O)}):Promise.resolve(!1)}function F(O){x?.scaleExtent(O)}function B(O){x?.translateExtent(O)}function G(O){const K=!Sn(O)||O<0?0:O;x?.clickDistance(K)}return{update:j,destroy:T,setViewport:S,setViewportConstrained:E,getViewport:$,scaleTo:A,scaleBy:_,setScaleExtent:F,setTranslateExtent:B,syncViewport:M,setClickDistance:G}}var Gs;(function(e){e.Line="line",e.Handle="handle"})(Gs||(Gs={}));function aj({width:e,prevWidth:n,height:a,prevHeight:s,affectsX:i,affectsY:l}){const d=e-n,p=a-s,f=[d>0?1:d<0?-1:0,p>0?1:p<0?-1:0];return d&&i&&(f[0]=f[0]*-1),p&&l&&(f[1]=f[1]*-1),f}function Y0(e){const n=e.includes("right")||e.includes("left"),a=e.includes("bottom")||e.includes("top"),s=e.includes("left"),i=e.includes("top");return{isHorizontal:n,isVertical:a,affectsX:s,affectsY:i}}function Yo(e,n){return Math.max(0,n-e)}function Vo(e,n){return Math.max(0,e-n)}function pc(e,n,a){return Math.max(0,n-e,e-a)}function V0(e,n){return e?!n:n}function sj(e,n,a,s,i,l,d,p){let{affectsX:f,affectsY:h}=n;const{isHorizontal:g,isVertical:x}=n,b=g&&x,{xSnapped:v,ySnapped:k}=a,{minWidth:w,maxWidth:j,minHeight:T,maxHeight:E}=s,{x:S,y:M,width:$,height:A,aspectRatio:_}=e;let F=Math.floor(g?v-e.pointerX:0),B=Math.floor(x?k-e.pointerY:0);const G=$+(f?-F:F),O=A+(h?-B:B),K=-l[0]*$,V=-l[1]*A;let P=pc(G,w,j),N=pc(O,T,E);if(d){let q=0,W=0;f&&F<0?q=Yo(S+F+K,d[0][0]):!f&&F>0&&(q=Vo(S+G+K,d[1][0])),h&&B<0?W=Yo(M+B+V,d[0][1]):!h&&B>0&&(W=Vo(M+O+V,d[1][1])),P=Math.max(P,q),N=Math.max(N,W)}if(p){let q=0,W=0;f&&F>0?q=Vo(S+F,p[0][0]):!f&&F<0&&(q=Yo(S+G,p[1][0])),h&&B>0?W=Vo(M+B,p[0][1]):!h&&B<0&&(W=Yo(M+O,p[1][1])),P=Math.max(P,q),N=Math.max(N,W)}if(i){if(g){const q=pc(G/_,T,E)*_;if(P=Math.max(P,q),d){let W=0;!f&&!h||f&&!h&&b?W=Vo(M+V+G/_,d[1][1])*_:W=Yo(M+V+(f?F:-F)/_,d[0][1])*_,P=Math.max(P,W)}if(p){let W=0;!f&&!h||f&&!h&&b?W=Yo(M+G/_,p[1][1])*_:W=Vo(M+(f?F:-F)/_,p[0][1])*_,P=Math.max(P,W)}}if(x){const q=pc(O*_,w,j)/_;if(N=Math.max(N,q),d){let W=0;!f&&!h||h&&!f&&b?W=Vo(S+O*_+K,d[1][0])/_:W=Yo(S+(h?B:-B)*_+K,d[0][0])/_,N=Math.max(N,W)}if(p){let W=0;!f&&!h||h&&!f&&b?W=Yo(S+O*_,p[1][0])/_:W=Vo(S+(h?B:-B)*_,p[0][0])/_,N=Math.max(N,W)}}}B=B+(B<0?N:-N),F=F+(F<0?P:-P),i&&(b?G>O*_?B=(V0(f,h)?-F:F)/_:F=(V0(f,h)?-B:B)*_:g?(B=F/_,h=f):(F=B*_,f=h));const D=f?S+F:S,U=h?M+B:M;return{width:$+(f?-F:F),height:A+(h?-B:B),x:l[0]*F*(f?-1:1)+D,y:l[1]*B*(h?-1:1)+U}}const f1={width:0,height:0,x:0,y:0},rj={...f1,pointerX:0,pointerY:0,aspectRatio:1};function ij(e){return[[0,0],[e.measured.width,e.measured.height]]}function lj(e,n,a){const s=n.position.x+e.position.x,i=n.position.y+e.position.y,l=e.measured.width??0,d=e.measured.height??0,p=a[0]*l,f=a[1]*d;return[[s-p,i-f],[s+l-p,i+d-f]]}function cj({domNode:e,nodeId:n,getStoreItems:a,onChange:s,onEnd:i}){const l=Jt(e);let d={controlDirection:Y0("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function p({controlPosition:h,boundaries:g,keepAspectRatio:x,resizeDirection:b,onResizeStart:v,onResize:k,onResizeEnd:w,shouldResize:j}){let T={...f1},E={...rj};d={boundaries:g,resizeDirection:b,keepAspectRatio:x,controlDirection:Y0(h)};let S,M=null,$=[],A,_,F,B=!1;const G=Sb().on("start",O=>{const{nodeLookup:K,transform:V,snapGrid:P,snapToGrid:N,nodeOrigin:D,paneDomNode:U}=a();if(S=K.get(n),!S)return;M=U?.getBoundingClientRect()??null;const{xSnapped:q,ySnapped:W}=si(O.sourceEvent,{transform:V,snapGrid:P,snapToGrid:N,containerBounds:M});T={width:S.measured.width??0,height:S.measured.height??0,x:S.position.x??0,y:S.position.y??0},E={...T,pointerX:q,pointerY:W,aspectRatio:T.width/T.height},A=void 0,S.parentId&&(S.extent==="parent"||S.expandParent)&&(A=K.get(S.parentId),_=A&&S.extent==="parent"?ij(A):void 0),$=[],F=void 0;for(const[oe,I]of K)if(I.parentId===n&&($.push({id:oe,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const L=lj(I,S,I.origin??D);F?F=[[Math.min(L[0][0],F[0][0]),Math.min(L[0][1],F[0][1])],[Math.max(L[1][0],F[1][0]),Math.max(L[1][1],F[1][1])]]:F=L}v?.(O,{...T})}).on("drag",O=>{const{transform:K,snapGrid:V,snapToGrid:P,nodeOrigin:N}=a(),D=si(O.sourceEvent,{transform:K,snapGrid:V,snapToGrid:P,containerBounds:M}),U=[];if(!S)return;const{x:q,y:W,width:oe,height:I}=T,L={},Z=S.origin??N,{width:ae,height:pe,x:me,y:he}=sj(E,d.controlDirection,D,d.boundaries,d.keepAspectRatio,Z,_,F),H=ae!==oe,ce=pe!==I,Q=me!==q&&H,ge=he!==W&&ce;if(!Q&&!ge&&!H&&!ce)return;if((Q||ge||Z[0]===1||Z[1]===1)&&(L.x=Q?me:T.x,L.y=ge?he:T.y,T.x=L.x,T.y=L.y,$.length>0)){const Ee=me-q,Ie=he-W;for(const ze of $)ze.position={x:ze.position.x-Ee+Z[0]*(ae-oe),y:ze.position.y-Ie+Z[1]*(pe-I)},U.push(ze)}if((H||ce)&&(L.width=H&&(!d.resizeDirection||d.resizeDirection==="horizontal")?ae:T.width,L.height=ce&&(!d.resizeDirection||d.resizeDirection==="vertical")?pe:T.height,T.width=L.width,T.height=L.height),A&&S.expandParent){const Ee=Z[0]*(L.width??0);L.x&&L.x<Ee&&(T.x=Ee,E.x=E.x-(L.x-Ee));const Ie=Z[1]*(L.height??0);L.y&&L.y<Ie&&(T.y=Ie,E.y=E.y-(L.y-Ie))}const xe=aj({width:T.width,prevWidth:oe,height:T.height,prevHeight:I,affectsX:d.controlDirection.affectsX,affectsY:d.controlDirection.affectsY}),J={...T,direction:xe};j?.(O,J)!==!1&&(B=!0,k?.(O,J),s(L,U))}).on("end",O=>{B&&(w?.(O,{...T}),i?.({...T}),B=!1)});l.call(G)}function f(){l.on(".drag",null)}return{update:p,destroy:f}}var Yp={exports:{}},Vp={},Wp={exports:{}},Xp={};var W0;function uj(){if(W0)return Xp;W0=1;var e=Mi();function n(x,b){return x===b&&(x!==0||1/x===1/b)||x!==x&&b!==b}var a=typeof Object.is=="function"?Object.is:n,s=e.useState,i=e.useEffect,l=e.useLayoutEffect,d=e.useDebugValue;function p(x,b){var v=b(),k=s({inst:{value:v,getSnapshot:b}}),w=k[0].inst,j=k[1];return l(function(){w.value=v,w.getSnapshot=b,f(w)&&j({inst:w})},[x,v,b]),i(function(){return f(w)&&j({inst:w}),x(function(){f(w)&&j({inst:w})})},[x]),d(v),v}function f(x){var b=x.getSnapshot;x=x.value;try{var v=b();return!a(x,v)}catch{return!0}}function h(x,b){return b()}var g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:p;return Xp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:g,Xp}var X0;function dj(){return X0||(X0=1,Wp.exports=uj()),Wp.exports}var Z0;function pj(){if(Z0)return Vp;Z0=1;var e=Mi(),n=dj();function a(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var s=typeof Object.is=="function"?Object.is:a,i=n.useSyncExternalStore,l=e.useRef,d=e.useEffect,p=e.useMemo,f=e.useDebugValue;return Vp.useSyncExternalStoreWithSelector=function(h,g,x,b,v){var k=l(null);if(k.current===null){var w={hasValue:!1,value:null};k.current=w}else w=k.current;k=p(function(){function T(A){if(!E){if(E=!0,S=A,A=b(A),v!==void 0&&w.hasValue){var _=w.value;if(v(_,A))return M=_}return M=A}if(_=M,s(S,A))return _;var F=b(A);return v!==void 0&&v(_,F)?(S=A,_):(S=A,M=F)}var E=!1,S,M,$=x===void 0?null:x;return[function(){return T(g())},$===null?void 0:function(){return T($())}]},[g,x,b,v]);var j=i(h,k[0],k[1]);return d(function(){w.hasValue=!0,w.value=j},[j]),f(j),j},Vp}var Q0;function fj(){return Q0||(Q0=1,Yp.exports=pj()),Yp.exports}var mj=fj();const hj=ob(mj),gj={},J0=e=>{let n;const a=new Set,s=(g,x)=>{const b=typeof g=="function"?g(n):g;if(!Object.is(b,n)){const v=n;n=x??(typeof b!="object"||b===null)?b:Object.assign({},n,b),a.forEach(k=>k(n,v))}},i=()=>n,f={setState:s,getState:i,getInitialState:()=>h,subscribe:g=>(a.add(g),()=>a.delete(g)),destroy:()=>{(gj?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),a.clear()}},h=n=e(s,i,f);return f},yj=e=>e?J0(e):J0,{useDebugValue:xj}=Qr,{useSyncExternalStoreWithSelector:bj}=hj,vj=e=>e;function m1(e,n=vj,a){const s=bj(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,a);return xj(s),s}const ex=(e,n)=>{const a=yj(e),s=(i,l=n)=>m1(a,i,l);return Object.assign(s,a),s},kj=(e,n)=>e?ex(e,n):ex;function tt(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[s,i]of e)if(!Object.is(i,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const a=Object.keys(e);if(a.length!==Object.keys(n).length)return!1;for(const s of a)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var ou=ab();const au=z.createContext(null),wj=au.Provider,h1=In.error001();function Fe(e,n){const a=z.useContext(au);if(a===null)throw new Error(h1);return m1(a,e,n)}function nt(){const e=z.useContext(au);if(e===null)throw new Error(h1);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const tx={display:"none"},Sj={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},g1="react-flow__node-desc",y1="react-flow__edge-desc",Mj="react-flow__aria-live",Cj=e=>e.ariaLiveMessage,Ej=e=>e.ariaLabelConfig;function jj({rfId:e}){const n=Fe(Cj);return c.jsx("div",{id:`${Mj}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Sj,children:n})}function Tj({rfId:e,disableKeyboardA11y:n}){const a=Fe(Ej);return c.jsxs(c.Fragment,{children:[c.jsx("div",{id:`${g1}-${e}`,style:tx,children:n?a["node.a11yDescription.default"]:a["node.a11yDescription.keyboardDisabled"]}),c.jsx("div",{id:`${y1}-${e}`,style:tx,children:a["edge.a11yDescription.default"]}),!n&&c.jsx(jj,{rfId:e})]})}const su=z.forwardRef(({position:e="top-left",children:n,className:a,style:s,...i},l)=>{const d=`${e}`.split("-");return c.jsx("div",{className:ft(["react-flow__panel",a,...d]),style:s,ref:l,...i,children:n})});su.displayName="Panel";function Nj({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:c.jsx(su,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:c.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Aj=e=>{const n=[],a=[];for(const[,s]of e.nodeLookup)s.selected&&n.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&a.push(s);return{selectedNodes:n,selectedEdges:a}},fc=e=>e.id;function _j(e,n){return tt(e.selectedNodes.map(fc),n.selectedNodes.map(fc))&&tt(e.selectedEdges.map(fc),n.selectedEdges.map(fc))}function Dj({onSelectionChange:e}){const n=nt(),{selectedNodes:a,selectedEdges:s}=Fe(Aj,_j);return z.useEffect(()=>{const i={nodes:a,edges:s};e?.(i),n.getState().onSelectionChangeHandlers.forEach(l=>l(i))},[a,s,e]),null}const zj=e=>!!e.onSelectionChangeHandlers;function Rj({onSelectionChange:e}){const n=Fe(zj);return e||n?c.jsx(Dj,{onSelectionChange:e}):null}const x1=[0,0],Oj={x:0,y:0,zoom:1},$j=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],nx=[...$j,"rfId"],Fj=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),ox={translateExtent:fi,nodeOrigin:x1,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Ij(e){const{setNodes:n,setEdges:a,setMinZoom:s,setMaxZoom:i,setTranslateExtent:l,setNodeExtent:d,reset:p,setDefaultNodesAndEdges:f}=Fe(Fj,tt),h=nt();z.useEffect(()=>(f(e.defaultNodes,e.defaultEdges),()=>{g.current=ox,p()}),[]);const g=z.useRef(ox);return z.useEffect(()=>{for(const x of nx){const b=e[x],v=g.current[x];b!==v&&(typeof e[x]>"u"||(x==="nodes"?n(b):x==="edges"?a(b):x==="minZoom"?s(b):x==="maxZoom"?i(b):x==="translateExtent"?l(b):x==="nodeExtent"?d(b):x==="ariaLabelConfig"?h.setState({ariaLabelConfig:kE(b)}):x==="fitView"?h.setState({fitViewQueued:b}):x==="fitViewOptions"?h.setState({fitViewOptions:b}):h.setState({[x]:b})))}g.current=e},nx.map(x=>e[x])),null}function ax(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lj(e){const[n,a]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){a(e);return}const s=ax(),i=()=>a(s?.matches?"dark":"light");return i(),s?.addEventListener("change",i),()=>{s?.removeEventListener("change",i)}},[e]),n!==null?n:ax()?.matches?"dark":"light"}const sx=typeof document<"u"?document:null;function yi(e=null,n={target:sx,actInsideInputWithModifier:!0}){const[a,s]=z.useState(!1),i=z.useRef(!1),l=z.useRef(new Set([])),[d,p]=z.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(x=>typeof x=="string").map(x=>x.replace("+",`
|
|
13
|
+
`).replace(`
|
|
14
|
+
|
|
15
|
+
`,`
|
|
16
|
+
+`).split(`
|
|
17
|
+
`)),g=h.reduce((x,b)=>x.concat(...b),[]);return[h,g]}return[[],[]]},[e]);return z.useEffect(()=>{const f=n?.target??sx,h=n?.actInsideInputWithModifier??!0;if(e!==null){const g=v=>{if(i.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!i.current||i.current&&!h)&&Zb(v))return!1;const w=ix(v.code,p);if(l.current.add(v[w]),rx(d,l.current,!1)){const j=v.composedPath?.()?.[0]||v.target,T=j?.nodeName==="BUTTON"||j?.nodeName==="A";n.preventDefault!==!1&&(i.current||!T)&&v.preventDefault(),s(!0)}},x=v=>{const k=ix(v.code,p);rx(d,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(v[k]),v.key==="Meta"&&l.current.clear(),i.current=!1},b=()=>{l.current.clear(),s(!1)};return f?.addEventListener("keydown",g),f?.addEventListener("keyup",x),window.addEventListener("blur",b),window.addEventListener("contextmenu",b),()=>{f?.removeEventListener("keydown",g),f?.removeEventListener("keyup",x),window.removeEventListener("blur",b),window.removeEventListener("contextmenu",b)}}},[e,s]),a}function rx(e,n,a){return e.filter(s=>a||s.length===n.size).some(s=>s.every(i=>n.has(i)))}function ix(e,n){return n.includes(e)?"code":"key"}const Bj=()=>{const e=nt();return z.useMemo(()=>({zoomIn:n=>{const{panZoom:a}=e.getState();return a?a.scaleBy(1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomOut:n=>{const{panZoom:a}=e.getState();return a?a.scaleBy(1/1.2,{duration:n?.duration}):Promise.resolve(!1)},zoomTo:(n,a)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(n,{duration:a?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(n,a)=>{const{transform:[s,i,l],panZoom:d}=e.getState();return d?(await d.setViewport({x:n.x??s,y:n.y??i,zoom:n.zoom??l},a),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[n,a,s]=e.getState().transform;return{x:n,y:a,zoom:s}},setCenter:async(n,a,s)=>e.getState().setCenter(n,a,s),fitBounds:async(n,a)=>{const{width:s,height:i,minZoom:l,maxZoom:d,panZoom:p}=e.getState(),f=Gf(n,s,i,l,d,a?.padding??.1);return p?(await p.setViewport(f,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(n,a={})=>{const{transform:s,snapGrid:i,snapToGrid:l,domNode:d}=e.getState();if(!d)return n;const{x:p,y:f}=d.getBoundingClientRect(),h={x:n.x-p,y:n.y-f},g=a.snapGrid??i,x=a.snapToGrid??l;return Ai(h,s,x,g)},flowToScreenPosition:n=>{const{transform:a,domNode:s}=e.getState();if(!s)return n;const{x:i,y:l}=s.getBoundingClientRect(),d=Lc(n,a);return{x:d.x+i,y:d.y+l}}}),[])};function b1(e,n){const a=[],s=new Map,i=[];for(const l of e)if(l.type==="add"){i.push(l);continue}else if(l.type==="remove"||l.type==="replace")s.set(l.id,[l]);else{const d=s.get(l.id);d?d.push(l):s.set(l.id,[l])}for(const l of n){const d=s.get(l.id);if(!d){a.push(l);continue}if(d[0].type==="remove")continue;if(d[0].type==="replace"){a.push({...d[0].item});continue}const p={...l};for(const f of d)Pj(f,p);a.push(p)}return i.length&&i.forEach(l=>{l.index!==void 0?a.splice(l.index,0,{...l.item}):a.push({...l.item})}),a}function Pj(e,n){switch(e.type){case"select":{n.selected=e.selected;break}case"position":{typeof e.position<"u"&&(n.position=e.position),typeof e.dragging<"u"&&(n.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(n.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(n.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(n.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(n.resizing=e.resizing);break}}}function Hj(e,n){return b1(e,n)}function Uj(e,n){return b1(e,n)}function Ta(e,n){return{id:e,type:"select",selected:n}}function Ds(e,n=new Set,a=!1){const s=[];for(const[i,l]of e){const d=n.has(i);!(l.selected===void 0&&!d)&&l.selected!==d&&(a&&(l.selected=d),s.push(Ta(l.id,d)))}return s}function lx({items:e=[],lookup:n}){const a=[],s=new Map(e.map(i=>[i.id,i]));for(const[i,l]of e.entries()){const d=n.get(l.id),p=d?.internals?.userNode??d;p!==void 0&&p!==l&&a.push({id:l.id,item:l,type:"replace"}),p===void 0&&a.push({item:l,type:"add",index:i})}for(const[i]of n)s.get(i)===void 0&&a.push({id:i,type:"remove"});return a}function cx(e){return{id:e.id,type:"remove"}}const ux=e=>dE(e),Gj=e=>Ub(e);function v1(e){return z.forwardRef(e)}const qj=typeof window<"u"?z.useLayoutEffect:z.useEffect;function dx(e){const[n,a]=z.useState(BigInt(0)),[s]=z.useState(()=>Kj(()=>a(i=>i+BigInt(1))));return qj(()=>{const i=s.get();i.length&&(e(i),s.reset())},[n]),s}function Kj(e){let n=[];return{get:()=>n,reset:()=>{n=[]},push:a=>{n.push(a),e()}}}const k1=z.createContext(null);function Yj({children:e}){const n=nt(),a=z.useCallback(p=>{const{nodes:f=[],setNodes:h,hasDefaultNodes:g,onNodesChange:x,nodeLookup:b,fitViewQueued:v,onNodesChangeMiddlewareMap:k}=n.getState();let w=f;for(const T of p)w=typeof T=="function"?T(w):T;let j=lx({items:w,lookup:b});for(const T of k.values())j=T(j);g&&h(w),j.length>0?x?.(j):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:T,nodes:E,setNodes:S}=n.getState();T&&S(E)})},[]),s=dx(a),i=z.useCallback(p=>{const{edges:f=[],setEdges:h,hasDefaultEdges:g,onEdgesChange:x,edgeLookup:b}=n.getState();let v=f;for(const k of p)v=typeof k=="function"?k(v):k;g?h(v):x&&x(lx({items:v,lookup:b}))},[]),l=dx(i),d=z.useMemo(()=>({nodeQueue:s,edgeQueue:l}),[]);return c.jsx(k1.Provider,{value:d,children:e})}function Vj(){const e=z.useContext(k1);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Wj=e=>!!e.panZoom;function Zf(){const e=Bj(),n=nt(),a=Vj(),s=Fe(Wj),i=z.useMemo(()=>{const l=x=>n.getState().nodeLookup.get(x),d=x=>{a.nodeQueue.push(x)},p=x=>{a.edgeQueue.push(x)},f=x=>{const{nodeLookup:b,nodeOrigin:v}=n.getState(),k=ux(x)?x:b.get(x.id),w=k.parentId?Wb(k.position,k.measured,k.parentId,b,v):k.position,j={...k,position:w,width:k.measured?.width??k.width,height:k.measured?.height??k.height};return Hs(j)},h=(x,b,v={replace:!1})=>{d(k=>k.map(w=>{if(w.id===x){const j=typeof b=="function"?b(w):b;return v.replace&&ux(j)?j:{...w,...j}}return w}))},g=(x,b,v={replace:!1})=>{p(k=>k.map(w=>{if(w.id===x){const j=typeof b=="function"?b(w):b;return v.replace&&Gj(j)?j:{...w,...j}}return w}))};return{getNodes:()=>n.getState().nodes.map(x=>({...x})),getNode:x=>l(x)?.internals.userNode,getInternalNode:l,getEdges:()=>{const{edges:x=[]}=n.getState();return x.map(b=>({...b}))},getEdge:x=>n.getState().edgeLookup.get(x),setNodes:d,setEdges:p,addNodes:x=>{const b=Array.isArray(x)?x:[x];a.nodeQueue.push(v=>[...v,...b])},addEdges:x=>{const b=Array.isArray(x)?x:[x];a.edgeQueue.push(v=>[...v,...b])},toObject:()=>{const{nodes:x=[],edges:b=[],transform:v}=n.getState(),[k,w,j]=v;return{nodes:x.map(T=>({...T})),edges:b.map(T=>({...T})),viewport:{x:k,y:w,zoom:j}}},deleteElements:async({nodes:x=[],edges:b=[]})=>{const{nodes:v,edges:k,onNodesDelete:w,onEdgesDelete:j,triggerNodeChanges:T,triggerEdgeChanges:E,onDelete:S,onBeforeDelete:M}=n.getState(),{nodes:$,edges:A}=await gE({nodesToRemove:x,edgesToRemove:b,nodes:v,edges:k,onBeforeDelete:M}),_=A.length>0,F=$.length>0;if(_){const B=A.map(cx);j?.(A),E(B)}if(F){const B=$.map(cx);w?.($),T(B)}return(F||_)&&S?.({nodes:$,edges:A}),{deletedNodes:$,deletedEdges:A}},getIntersectingNodes:(x,b=!0,v)=>{const k=$0(x),w=k?x:f(x),j=v!==void 0;return w?(v||n.getState().nodes).filter(T=>{const E=n.getState().nodeLookup.get(T.id);if(E&&!k&&(T.id===x.id||!E.internals.positionAbsolute))return!1;const S=Hs(j?T:E),M=hi(S,w);return b&&M>0||M>=S.width*S.height||M>=w.width*w.height}):[]},isNodeIntersecting:(x,b,v=!0)=>{const w=$0(x)?x:f(x);if(!w)return!1;const j=hi(w,b);return v&&j>0||j>=b.width*b.height||j>=w.width*w.height},updateNode:h,updateNodeData:(x,b,v={replace:!1})=>{h(x,k=>{const w=typeof b=="function"?b(k):b;return v.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},v)},updateEdge:g,updateEdgeData:(x,b,v={replace:!1})=>{g(x,k=>{const w=typeof b=="function"?b(k):b;return v.replace?{...k,data:w}:{...k,data:{...k.data,...w}}},v)},getNodesBounds:x=>{const{nodeLookup:b,nodeOrigin:v}=n.getState();return pE(x,{nodeLookup:b,nodeOrigin:v})},getHandleConnections:({type:x,id:b,nodeId:v})=>Array.from(n.getState().connectionLookup.get(`${v}-${x}${b?`-${b}`:""}`)?.values()??[]),getNodeConnections:({type:x,handleId:b,nodeId:v})=>Array.from(n.getState().connectionLookup.get(`${v}${x?b?`-${x}-${b}`:`-${x}`:""}`)?.values()??[]),fitView:async x=>{const b=n.getState().fitViewResolver??vE();return n.setState({fitViewQueued:!0,fitViewOptions:x,fitViewResolver:b}),a.nodeQueue.push(v=>[...v]),b.promise}}},[]);return z.useMemo(()=>({...i,...e,viewportInitialized:s}),[s])}const px=e=>e.selected,Xj=typeof window<"u"?window:void 0;function Zj({deleteKeyCode:e,multiSelectionKeyCode:n}){const a=nt(),{deleteElements:s}=Zf(),i=yi(e,{actInsideInputWithModifier:!1}),l=yi(n,{target:Xj});z.useEffect(()=>{if(i){const{edges:d,nodes:p}=a.getState();s({nodes:p.filter(px),edges:d.filter(px)}),a.setState({nodesSelectionActive:!1})}},[i]),z.useEffect(()=>{a.setState({multiSelectionActive:l})},[l])}function Qj(e){const n=nt();z.useEffect(()=>{const a=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=qf(e.current);(s.height===0||s.width===0)&&n.getState().onError?.("004",In.error004()),n.setState({width:s.width||500,height:s.height||500})};if(e.current){a(),window.addEventListener("resize",a);const s=new ResizeObserver(()=>a());return s.observe(e.current),()=>{window.removeEventListener("resize",a),s&&e.current&&s.unobserve(e.current)}}},[])}const ru={position:"absolute",width:"100%",height:"100%",top:0,left:0},Jj=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function e5({onPaneContextMenu:e,zoomOnScroll:n=!0,zoomOnPinch:a=!0,panOnScroll:s=!1,panOnScrollSpeed:i=.5,panOnScrollMode:l=Da.Free,zoomOnDoubleClick:d=!0,panOnDrag:p=!0,defaultViewport:f,translateExtent:h,minZoom:g,maxZoom:x,zoomActivationKeyCode:b,preventScrolling:v=!0,children:k,noWheelClassName:w,noPanClassName:j,onViewportChange:T,isControlledViewport:E,paneClickDistance:S,selectionOnDrag:M}){const $=nt(),A=z.useRef(null),{userSelectionActive:_,lib:F,connectionInProgress:B}=Fe(Jj,tt),G=yi(b),O=z.useRef();Qj(A);const K=z.useCallback(V=>{T?.({x:V[0],y:V[1],zoom:V[2]}),E||$.setState({transform:V})},[T,E]);return z.useEffect(()=>{if(A.current){O.current=oj({domNode:A.current,minZoom:g,maxZoom:x,translateExtent:h,viewport:f,onDraggingChange:D=>$.setState(U=>U.paneDragging===D?U:{paneDragging:D}),onPanZoomStart:(D,U)=>{const{onViewportChangeStart:q,onMoveStart:W}=$.getState();W?.(D,U),q?.(U)},onPanZoom:(D,U)=>{const{onViewportChange:q,onMove:W}=$.getState();W?.(D,U),q?.(U)},onPanZoomEnd:(D,U)=>{const{onViewportChangeEnd:q,onMoveEnd:W}=$.getState();W?.(D,U),q?.(U)}});const{x:V,y:P,zoom:N}=O.current.getViewport();return $.setState({panZoom:O.current,transform:[V,P,N],domNode:A.current.closest(".react-flow")}),()=>{O.current?.destroy()}}},[]),z.useEffect(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:n,zoomOnPinch:a,panOnScroll:s,panOnScrollSpeed:i,panOnScrollMode:l,zoomOnDoubleClick:d,panOnDrag:p,zoomActivationKeyPressed:G,preventScrolling:v,noPanClassName:j,userSelectionActive:_,noWheelClassName:w,lib:F,onTransformChange:K,connectionInProgress:B,selectionOnDrag:M,paneClickDistance:S})},[e,n,a,s,i,l,d,p,G,v,j,_,w,F,K,B,M,S]),c.jsx("div",{className:"react-flow__renderer",ref:A,style:ru,children:k})}const t5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function n5(){const{userSelectionActive:e,userSelectionRect:n}=Fe(t5,tt);return e&&n?c.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}const Zp=(e,n)=>a=>{a.target===n.current&&e?.(a)},o5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function a5({isSelecting:e,selectionKeyPressed:n,selectionMode:a=mi.Full,panOnDrag:s,paneClickDistance:i,selectionOnDrag:l,onSelectionStart:d,onSelectionEnd:p,onPaneClick:f,onPaneContextMenu:h,onPaneScroll:g,onPaneMouseEnter:x,onPaneMouseMove:b,onPaneMouseLeave:v,children:k}){const w=nt(),{userSelectionActive:j,elementsSelectable:T,dragging:E,connectionInProgress:S}=Fe(o5,tt),M=T&&(e||j),$=z.useRef(null),A=z.useRef(),_=z.useRef(new Set),F=z.useRef(new Set),B=z.useRef(!1),G=q=>{if(B.current||S){B.current=!1;return}f?.(q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=q=>{if(Array.isArray(s)&&s?.includes(2)){q.preventDefault();return}h?.(q)},K=g?q=>g(q):void 0,V=q=>{B.current&&(q.stopPropagation(),B.current=!1)},P=q=>{const{domNode:W}=w.getState();if(A.current=W?.getBoundingClientRect(),!A.current)return;const oe=q.target===$.current;if(!oe&&!!q.target.closest(".nokey")||!e||!(l&&oe||n)||q.button!==0||!q.isPrimary)return;q.target?.setPointerCapture?.(q.pointerId),B.current=!1;const{x:Z,y:ae}=Mn(q.nativeEvent,A.current);w.setState({userSelectionRect:{width:0,height:0,startX:Z,startY:ae,x:Z,y:ae}}),oe||(q.stopPropagation(),q.preventDefault())},N=q=>{const{userSelectionRect:W,transform:oe,nodeLookup:I,edgeLookup:L,connectionLookup:Z,triggerNodeChanges:ae,triggerEdgeChanges:pe,defaultEdgeOptions:me,resetSelectedElements:he}=w.getState();if(!A.current||!W)return;const{x:H,y:ce}=Mn(q.nativeEvent,A.current),{startX:Q,startY:ge}=W;if(!B.current){const Ie=n?0:i;if(Math.hypot(H-Q,ce-ge)<=Ie)return;he(),d?.(q)}B.current=!0;const xe={startX:Q,startY:ge,x:H<Q?H:Q,y:ce<ge?ce:ge,width:Math.abs(H-Q),height:Math.abs(ce-ge)},J=_.current,ye=F.current;_.current=new Set(Uf(I,xe,oe,a===mi.Partial,!0).map(Ie=>Ie.id)),F.current=new Set;const Ee=me?.selectable??!0;for(const Ie of _.current){const ze=Z.get(Ie);if(ze)for(const{edgeId:Nt}of ze.values()){const mt=L.get(Nt);mt&&(mt.selectable??Ee)&&F.current.add(Nt)}}if(!F0(J,_.current)){const Ie=Ds(I,_.current,!0);ae(Ie)}if(!F0(ye,F.current)){const Ie=Ds(L,F.current);pe(Ie)}w.setState({userSelectionRect:xe,userSelectionActive:!0,nodesSelectionActive:!1})},D=q=>{q.button===0&&(q.target?.releasePointerCapture?.(q.pointerId),!j&&q.target===$.current&&w.getState().userSelectionRect&&G?.(q),w.setState({userSelectionActive:!1,userSelectionRect:null}),B.current&&(p?.(q),w.setState({nodesSelectionActive:_.current.size>0})))},U=s===!0||Array.isArray(s)&&s.includes(0);return c.jsxs("div",{className:ft(["react-flow__pane",{draggable:U,dragging:E,selection:e}]),onClick:M?void 0:Zp(G,$),onContextMenu:Zp(O,$),onWheel:Zp(K,$),onPointerEnter:M?void 0:x,onPointerMove:M?N:b,onPointerUp:M?D:void 0,onPointerDownCapture:M?P:void 0,onClickCapture:M?V:void 0,onPointerLeave:v,ref:$,style:ru,children:[k,c.jsx(n5,{})]})}function Cf({id:e,store:n,unselect:a=!1,nodeRef:s}){const{addSelectedNodes:i,unselectNodesAndEdges:l,multiSelectionActive:d,nodeLookup:p,onError:f}=n.getState(),h=p.get(e);if(!h){f?.("012",In.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(a||h.selected&&d)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):i([e])}function w1({nodeRef:e,disabled:n=!1,noDragClassName:a,handleSelector:s,nodeId:i,isSelectable:l,nodeClickDistance:d}){const p=nt(),[f,h]=z.useState(!1),g=z.useRef();return z.useEffect(()=>{g.current=UE({getStoreItems:()=>p.getState(),onNodeMouseDown:x=>{Cf({id:x,store:p,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}})},[]),z.useEffect(()=>{if(!(n||!e.current||!g.current))return g.current.update({noDragClassName:a,handleSelector:s,domNode:e.current,isSelectable:l,nodeId:i,nodeClickDistance:d}),()=>{g.current?.destroy()}},[a,s,n,l,e,i,d]),f}const s5=e=>n=>n.selected&&(n.draggable||e&&typeof n.draggable>"u");function S1(){const e=nt();return z.useCallback(a=>{const{nodeExtent:s,snapToGrid:i,snapGrid:l,nodesDraggable:d,onError:p,updateNodePositions:f,nodeLookup:h,nodeOrigin:g}=e.getState(),x=new Map,b=s5(d),v=i?l[0]:5,k=i?l[1]:5,w=a.direction.x*v*a.factor,j=a.direction.y*k*a.factor;for(const[,T]of h){if(!b(T))continue;let E={x:T.internals.positionAbsolute.x+w,y:T.internals.positionAbsolute.y+j};i&&(E=Ni(E,l));const{position:S,positionAbsolute:M}=Gb({nodeId:T.id,nextPosition:E,nodeLookup:h,nodeExtent:s,nodeOrigin:g,onError:p});T.position=S,T.internals.positionAbsolute=M,x.set(T.id,T)}f(x)},[])}const Qf=z.createContext(null),r5=Qf.Provider;Qf.Consumer;const M1=()=>z.useContext(Qf),i5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),l5=(e,n,a)=>s=>{const{connectionClickStartHandle:i,connectionMode:l,connection:d}=s,{fromHandle:p,toHandle:f,isValid:h}=d,g=f?.nodeId===e&&f?.id===n&&f?.type===a;return{connectingFrom:p?.nodeId===e&&p?.id===n&&p?.type===a,connectingTo:g,clickConnecting:i?.nodeId===e&&i?.id===n&&i?.type===a,isPossibleEndHandle:l===Bs.Strict?p?.type!==a:e!==p?.nodeId||n!==p?.id,connectionInProcess:!!p,clickConnectionInProcess:!!i,valid:g&&h}};function c5({type:e="source",position:n=Se.Top,isValidConnection:a,isConnectable:s=!0,isConnectableStart:i=!0,isConnectableEnd:l=!0,id:d,onConnect:p,children:f,className:h,onMouseDown:g,onTouchStart:x,...b},v){const k=d||null,w=e==="target",j=nt(),T=M1(),{connectOnClick:E,noPanClassName:S,rfId:M}=Fe(i5,tt),{connectingFrom:$,connectingTo:A,clickConnecting:_,isPossibleEndHandle:F,connectionInProcess:B,clickConnectionInProcess:G,valid:O}=Fe(l5(T,k,e),tt);T||j.getState().onError?.("010",In.error010());const K=N=>{const{defaultEdgeOptions:D,onConnect:U,hasDefaultEdges:q}=j.getState(),W={...D,...N};if(q){const{edges:oe,setEdges:I}=j.getState();I(jE(W,oe))}U?.(W),p?.(W)},V=N=>{if(!T)return;const D=Qb(N.nativeEvent);if(i&&(D&&N.button===0||!D)){const U=j.getState();Mf.onPointerDown(N.nativeEvent,{handleDomNode:N.currentTarget,autoPanOnConnect:U.autoPanOnConnect,connectionMode:U.connectionMode,connectionRadius:U.connectionRadius,domNode:U.domNode,nodeLookup:U.nodeLookup,lib:U.lib,isTarget:w,handleId:k,nodeId:T,flowId:U.rfId,panBy:U.panBy,cancelConnection:U.cancelConnection,onConnectStart:U.onConnectStart,onConnectEnd:(...q)=>j.getState().onConnectEnd?.(...q),updateConnection:U.updateConnection,onConnect:K,isValidConnection:a||((...q)=>j.getState().isValidConnection?.(...q)??!0),getTransform:()=>j.getState().transform,getFromHandle:()=>j.getState().connection.fromHandle,autoPanSpeed:U.autoPanSpeed,dragThreshold:U.connectionDragThreshold})}D?g?.(N):x?.(N)},P=N=>{const{onClickConnectStart:D,onClickConnectEnd:U,connectionClickStartHandle:q,connectionMode:W,isValidConnection:oe,lib:I,rfId:L,nodeLookup:Z,connection:ae}=j.getState();if(!T||!q&&!i)return;if(!q){D?.(N.nativeEvent,{nodeId:T,handleId:k,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:T,type:e,id:k}});return}const pe=Xb(N.target),me=a||oe,{connection:he,isValid:H}=Mf.isValid(N.nativeEvent,{handle:{nodeId:T,id:k,type:e},connectionMode:W,fromNodeId:q.nodeId,fromHandleId:q.id||null,fromType:q.type,isValidConnection:me,flowId:L,doc:pe,lib:I,nodeLookup:Z});H&&he&&K(he);const ce=structuredClone(ae);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,U?.(N,ce),j.setState({connectionClickStartHandle:null})};return c.jsx("div",{"data-handleid":k,"data-nodeid":T,"data-handlepos":n,"data-id":`${M}-${T}-${k}-${e}`,className:ft(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",S,h,{source:!w,target:w,connectable:s,connectablestart:i,connectableend:l,clickconnecting:_,connectingfrom:$,connectingto:A,valid:O,connectionindicator:s&&(!B||F)&&(B||G?l:i)}]),onMouseDown:V,onTouchStart:V,onClick:E?P:void 0,ref:v,...b,children:f})}const qs=z.memo(v1(c5));function u5({data:e,isConnectable:n,sourcePosition:a=Se.Bottom}){return c.jsxs(c.Fragment,{children:[e?.label,c.jsx(qs,{type:"source",position:a,isConnectable:n})]})}function d5({data:e,isConnectable:n,targetPosition:a=Se.Top,sourcePosition:s=Se.Bottom}){return c.jsxs(c.Fragment,{children:[c.jsx(qs,{type:"target",position:a,isConnectable:n}),e?.label,c.jsx(qs,{type:"source",position:s,isConnectable:n})]})}function p5(){return null}function f5({data:e,isConnectable:n,targetPosition:a=Se.Top}){return c.jsxs(c.Fragment,{children:[c.jsx(qs,{type:"target",position:a,isConnectable:n}),e?.label]})}const Bc={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},fx={input:u5,default:d5,output:f5,group:p5};function m5(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const h5=e=>{const{width:n,height:a,x:s,y:i}=Ti(e.nodeLookup,{filter:l=>!!l.selected});return{width:Sn(n)?n:null,height:Sn(a)?a:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${i}px)`}};function g5({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:a}){const s=nt(),{width:i,height:l,transformString:d,userSelectionActive:p}=Fe(h5,tt),f=S1(),h=z.useRef(null);z.useEffect(()=>{a||h.current?.focus({preventScroll:!0})},[a]);const g=!p&&i!==null&&l!==null;if(w1({nodeRef:h,disabled:!g}),!g)return null;const x=e?v=>{const k=s.getState().nodes.filter(w=>w.selected);e(v,k)}:void 0,b=v=>{Object.prototype.hasOwnProperty.call(Bc,v.key)&&(v.preventDefault(),f({direction:Bc[v.key],factor:v.shiftKey?4:1}))};return c.jsx("div",{className:ft(["react-flow__nodesselection","react-flow__container",n]),style:{transform:d},children:c.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:x,tabIndex:a?void 0:-1,onKeyDown:a?void 0:b,style:{width:i,height:l}})})}const mx=typeof window<"u"?window:void 0,y5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function C1({children:e,onPaneClick:n,onPaneMouseEnter:a,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:l,onPaneScroll:d,paneClickDistance:p,deleteKeyCode:f,selectionKeyCode:h,selectionOnDrag:g,selectionMode:x,onSelectionStart:b,onSelectionEnd:v,multiSelectionKeyCode:k,panActivationKeyCode:w,zoomActivationKeyCode:j,elementsSelectable:T,zoomOnScroll:E,zoomOnPinch:S,panOnScroll:M,panOnScrollSpeed:$,panOnScrollMode:A,zoomOnDoubleClick:_,panOnDrag:F,defaultViewport:B,translateExtent:G,minZoom:O,maxZoom:K,preventScrolling:V,onSelectionContextMenu:P,noWheelClassName:N,noPanClassName:D,disableKeyboardA11y:U,onViewportChange:q,isControlledViewport:W}){const{nodesSelectionActive:oe,userSelectionActive:I}=Fe(y5,tt),L=yi(h,{target:mx}),Z=yi(w,{target:mx}),ae=Z||F,pe=Z||M,me=g&&ae!==!0,he=L||I||me;return Zj({deleteKeyCode:f,multiSelectionKeyCode:k}),c.jsx(e5,{onPaneContextMenu:l,elementsSelectable:T,zoomOnScroll:E,zoomOnPinch:S,panOnScroll:pe,panOnScrollSpeed:$,panOnScrollMode:A,zoomOnDoubleClick:_,panOnDrag:!L&&ae,defaultViewport:B,translateExtent:G,minZoom:O,maxZoom:K,zoomActivationKeyCode:j,preventScrolling:V,noWheelClassName:N,noPanClassName:D,onViewportChange:q,isControlledViewport:W,paneClickDistance:p,selectionOnDrag:me,children:c.jsxs(a5,{onSelectionStart:b,onSelectionEnd:v,onPaneClick:n,onPaneMouseEnter:a,onPaneMouseMove:s,onPaneMouseLeave:i,onPaneContextMenu:l,onPaneScroll:d,panOnDrag:ae,isSelecting:!!he,selectionMode:x,selectionKeyPressed:L,paneClickDistance:p,selectionOnDrag:me,children:[e,oe&&c.jsx(g5,{onSelectionContextMenu:P,noPanClassName:D,disableKeyboardA11y:U})]})})}C1.displayName="FlowRenderer";const x5=z.memo(C1),b5=e=>n=>e?Uf(n.nodeLookup,{x:0,y:0,width:n.width,height:n.height},n.transform,!0).map(a=>a.id):Array.from(n.nodeLookup.keys());function v5(e){return Fe(z.useCallback(b5(e),[e]),tt)}const k5=e=>e.updateNodeInternals;function w5(){const e=Fe(k5),[n]=z.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(a=>{const s=new Map;a.forEach(i=>{const l=i.target.getAttribute("data-id");s.set(l,{id:l,nodeElement:i.target,force:!0})}),e(s)}));return z.useEffect(()=>()=>{n?.disconnect()},[n]),n}function S5({node:e,nodeType:n,hasDimensions:a,resizeObserver:s}){const i=nt(),l=z.useRef(null),d=z.useRef(null),p=z.useRef(e.sourcePosition),f=z.useRef(e.targetPosition),h=z.useRef(n),g=a&&!!e.internals.handleBounds;return z.useEffect(()=>{l.current&&!e.hidden&&(!g||d.current!==l.current)&&(d.current&&s?.unobserve(d.current),s?.observe(l.current),d.current=l.current)},[g,e.hidden]),z.useEffect(()=>()=>{d.current&&(s?.unobserve(d.current),d.current=null)},[]),z.useEffect(()=>{if(l.current){const x=h.current!==n,b=p.current!==e.sourcePosition,v=f.current!==e.targetPosition;(x||b||v)&&(h.current=n,p.current=e.sourcePosition,f.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:l.current,force:!0}]])))}},[e.id,n,e.sourcePosition,e.targetPosition]),l}function M5({id:e,onClick:n,onMouseEnter:a,onMouseMove:s,onMouseLeave:i,onContextMenu:l,onDoubleClick:d,nodesDraggable:p,elementsSelectable:f,nodesConnectable:h,nodesFocusable:g,resizeObserver:x,noDragClassName:b,noPanClassName:v,disableKeyboardA11y:k,rfId:w,nodeTypes:j,nodeClickDistance:T,onError:E}){const{node:S,internals:M,isParent:$}=Fe(H=>{const ce=H.nodeLookup.get(e),Q=H.parentLookup.has(e);return{node:ce,internals:ce.internals,isParent:Q}},tt);let A=S.type||"default",_=j?.[A]||fx[A];_===void 0&&(E?.("003",In.error003(A)),A="default",_=j?.default||fx.default);const F=!!(S.draggable||p&&typeof S.draggable>"u"),B=!!(S.selectable||f&&typeof S.selectable>"u"),G=!!(S.connectable||h&&typeof S.connectable>"u"),O=!!(S.focusable||g&&typeof S.focusable>"u"),K=nt(),V=Vb(S),P=S5({node:S,nodeType:A,hasDimensions:V,resizeObserver:x}),N=w1({nodeRef:P,disabled:S.hidden||!F,noDragClassName:b,handleSelector:S.dragHandle,nodeId:e,isSelectable:B,nodeClickDistance:T}),D=S1();if(S.hidden)return null;const U=go(S),q=m5(S),W=B||F||n||a||s||i,oe=a?H=>a(H,{...M.userNode}):void 0,I=s?H=>s(H,{...M.userNode}):void 0,L=i?H=>i(H,{...M.userNode}):void 0,Z=l?H=>l(H,{...M.userNode}):void 0,ae=d?H=>d(H,{...M.userNode}):void 0,pe=H=>{const{selectNodesOnDrag:ce,nodeDragThreshold:Q}=K.getState();B&&(!ce||!F||Q>0)&&Cf({id:e,store:K,nodeRef:P}),n&&n(H,{...M.userNode})},me=H=>{if(!(Zb(H.nativeEvent)||k)){if(Lb.includes(H.key)&&B){const ce=H.key==="Escape";Cf({id:e,store:K,unselect:ce,nodeRef:P})}else if(F&&S.selected&&Object.prototype.hasOwnProperty.call(Bc,H.key)){H.preventDefault();const{ariaLabelConfig:ce}=K.getState();K.setState({ariaLiveMessage:ce["node.a11yDescription.ariaLiveMessage"]({direction:H.key.replace("Arrow","").toLowerCase(),x:~~M.positionAbsolute.x,y:~~M.positionAbsolute.y})}),D({direction:Bc[H.key],factor:H.shiftKey?4:1})}}},he=()=>{if(k||!P.current?.matches(":focus-visible"))return;const{transform:H,width:ce,height:Q,autoPanOnNodeFocus:ge,setCenter:xe}=K.getState();if(!ge)return;Uf(new Map([[e,S]]),{x:0,y:0,width:ce,height:Q},H,!0).length>0||xe(S.position.x+U.width/2,S.position.y+U.height/2,{zoom:H[2]})};return c.jsx("div",{className:ft(["react-flow__node",`react-flow__node-${A}`,{[v]:F},S.className,{selected:S.selected,selectable:B,parent:$,draggable:F,dragging:N}]),ref:P,style:{zIndex:M.z,transform:`translate(${M.positionAbsolute.x}px,${M.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:V?"visible":"hidden",...S.style,...q},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:oe,onMouseMove:I,onMouseLeave:L,onContextMenu:Z,onClick:pe,onDoubleClick:ae,onKeyDown:O?me:void 0,tabIndex:O?0:void 0,onFocus:O?he:void 0,role:S.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":k?void 0:`${g1}-${w}`,"aria-label":S.ariaLabel,...S.domAttributes,children:c.jsx(r5,{value:e,children:c.jsx(_,{id:e,data:S.data,type:A,positionAbsoluteX:M.positionAbsolute.x,positionAbsoluteY:M.positionAbsolute.y,selected:S.selected??!1,selectable:B,draggable:F,deletable:S.deletable??!0,isConnectable:G,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:N,dragHandle:S.dragHandle,zIndex:M.z,parentId:S.parentId,...U})})})}var C5=z.memo(M5);const E5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function E1(e){const{nodesDraggable:n,nodesConnectable:a,nodesFocusable:s,elementsSelectable:i,onError:l}=Fe(E5,tt),d=v5(e.onlyRenderVisibleElements),p=w5();return c.jsx("div",{className:"react-flow__nodes",style:ru,children:d.map(f=>c.jsx(C5,{id:f,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:p,nodesDraggable:n,nodesConnectable:a,nodesFocusable:s,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:l},f))})}E1.displayName="NodeRenderer";const j5=z.memo(E1);function T5(e){return Fe(z.useCallback(a=>{if(!e)return a.edges.map(i=>i.id);const s=[];if(a.width&&a.height)for(const i of a.edges){const l=a.nodeLookup.get(i.source),d=a.nodeLookup.get(i.target);l&&d&&ME({sourceNode:l,targetNode:d,width:a.width,height:a.height,transform:a.transform})&&s.push(i.id)}return s},[e]),tt)}const N5=({color:e="none",strokeWidth:n=1})=>{const a={strokeWidth:n,...e&&{stroke:e}};return c.jsx("polyline",{className:"arrow",style:a,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},A5=({color:e="none",strokeWidth:n=1})=>{const a={strokeWidth:n,...e&&{stroke:e,fill:e}};return c.jsx("polyline",{className:"arrowclosed",style:a,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},hx={[Fc.Arrow]:N5,[Fc.ArrowClosed]:A5};function _5(e){const n=nt();return z.useMemo(()=>Object.prototype.hasOwnProperty.call(hx,e)?hx[e]:(n.getState().onError?.("009",In.error009(e)),null),[e])}const D5=({id:e,type:n,color:a,width:s=12.5,height:i=12.5,markerUnits:l="strokeWidth",strokeWidth:d,orient:p="auto-start-reverse"})=>{const f=_5(n);return f?c.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:p,refX:"0",refY:"0",children:c.jsx(f,{color:a,strokeWidth:d})}):null},j1=({defaultColor:e,rfId:n})=>{const a=Fe(l=>l.edges),s=Fe(l=>l.defaultEdgeOptions),i=z.useMemo(()=>DE(a,{id:n,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[a,s,n,e]);return i.length?c.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:c.jsx("defs",{children:i.map(l=>c.jsx(D5,{id:l.id,type:l.type,color:l.color,width:l.width,height:l.height,markerUnits:l.markerUnits,strokeWidth:l.strokeWidth,orient:l.orient},l.id))})}):null};j1.displayName="MarkerDefinitions";var z5=z.memo(j1);function T1({x:e,y:n,label:a,labelStyle:s,labelShowBg:i=!0,labelBgStyle:l,labelBgPadding:d=[2,4],labelBgBorderRadius:p=2,children:f,className:h,...g}){const[x,b]=z.useState({x:1,y:0,width:0,height:0}),v=ft(["react-flow__edge-textwrapper",h]),k=z.useRef(null);return z.useEffect(()=>{if(k.current){const w=k.current.getBBox();b({x:w.x,y:w.y,width:w.width,height:w.height})}},[a]),a?c.jsxs("g",{transform:`translate(${e-x.width/2} ${n-x.height/2})`,className:v,visibility:x.width?"visible":"hidden",...g,children:[i&&c.jsx("rect",{width:x.width+2*d[0],x:-d[0],y:-d[1],height:x.height+2*d[1],className:"react-flow__edge-textbg",style:l,rx:p,ry:p}),c.jsx("text",{className:"react-flow__edge-text",y:x.height/2,dy:"0.3em",ref:k,style:s,children:a}),f]}):null}T1.displayName="EdgeText";const R5=z.memo(T1);function iu({path:e,labelX:n,labelY:a,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f,interactionWidth:h=20,...g}){return c.jsxs(c.Fragment,{children:[c.jsx("path",{...g,d:e,fill:"none",className:ft(["react-flow__edge-path",g.className])}),h?c.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,s&&Sn(n)&&Sn(a)?c.jsx(R5,{x:n,y:a,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:f}):null]})}function gx({pos:e,x1:n,y1:a,x2:s,y2:i}){return e===Se.Left||e===Se.Right?[.5*(n+s),a]:[n,.5*(a+i)]}function N1({sourceX:e,sourceY:n,sourcePosition:a=Se.Bottom,targetX:s,targetY:i,targetPosition:l=Se.Top}){const[d,p]=gx({pos:a,x1:e,y1:n,x2:s,y2:i}),[f,h]=gx({pos:l,x1:s,y1:i,x2:e,y2:n}),[g,x,b,v]=Jb({sourceX:e,sourceY:n,targetX:s,targetY:i,sourceControlX:d,sourceControlY:p,targetControlX:f,targetControlY:h});return[`M${e},${n} C${d},${p} ${f},${h} ${s},${i}`,g,x,b,v]}function A1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,sourcePosition:d,targetPosition:p,label:f,labelStyle:h,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:j,interactionWidth:T})=>{const[E,S,M]=N1({sourceX:a,sourceY:s,sourcePosition:d,targetX:i,targetY:l,targetPosition:p}),$=e.isInternal?void 0:n;return c.jsx(iu,{id:$,path:E,labelX:S,labelY:M,label:f,labelStyle:h,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:j,interactionWidth:T})})}const O5=A1({isInternal:!1}),_1=A1({isInternal:!0});O5.displayName="SimpleBezierEdge";_1.displayName="SimpleBezierEdgeInternal";function D1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,label:d,labelStyle:p,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:x,style:b,sourcePosition:v=Se.Bottom,targetPosition:k=Se.Top,markerEnd:w,markerStart:j,pathOptions:T,interactionWidth:E})=>{const[S,M,$]=kf({sourceX:a,sourceY:s,sourcePosition:v,targetX:i,targetY:l,targetPosition:k,borderRadius:T?.borderRadius,offset:T?.offset,stepPosition:T?.stepPosition}),A=e.isInternal?void 0:n;return c.jsx(iu,{id:A,path:S,labelX:M,labelY:$,label:d,labelStyle:p,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:w,markerStart:j,interactionWidth:E})})}const z1=D1({isInternal:!1}),R1=D1({isInternal:!0});z1.displayName="SmoothStepEdge";R1.displayName="SmoothStepEdgeInternal";function O1(e){return z.memo(({id:n,...a})=>{const s=e.isInternal?void 0:n;return c.jsx(z1,{...a,id:s,pathOptions:z.useMemo(()=>({borderRadius:0,offset:a.pathOptions?.offset}),[a.pathOptions?.offset])})})}const $5=O1({isInternal:!1}),$1=O1({isInternal:!0});$5.displayName="StepEdge";$1.displayName="StepEdgeInternal";function F1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,label:d,labelStyle:p,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:v,markerStart:k,interactionWidth:w})=>{const[j,T,E]=n1({sourceX:a,sourceY:s,targetX:i,targetY:l}),S=e.isInternal?void 0:n;return c.jsx(iu,{id:S,path:j,labelX:T,labelY:E,label:d,labelStyle:p,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:x,style:b,markerEnd:v,markerStart:k,interactionWidth:w})})}const F5=F1({isInternal:!1}),I1=F1({isInternal:!0});F5.displayName="StraightEdge";I1.displayName="StraightEdgeInternal";function L1(e){return z.memo(({id:n,sourceX:a,sourceY:s,targetX:i,targetY:l,sourcePosition:d=Se.Bottom,targetPosition:p=Se.Top,label:f,labelStyle:h,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:j,pathOptions:T,interactionWidth:E})=>{const[S,M,$]=e1({sourceX:a,sourceY:s,sourcePosition:d,targetX:i,targetY:l,targetPosition:p,curvature:T?.curvature}),A=e.isInternal?void 0:n;return c.jsx(iu,{id:A,path:S,labelX:M,labelY:$,label:f,labelStyle:h,labelShowBg:g,labelBgStyle:x,labelBgPadding:b,labelBgBorderRadius:v,style:k,markerEnd:w,markerStart:j,interactionWidth:E})})}const I5=L1({isInternal:!1}),B1=L1({isInternal:!0});I5.displayName="BezierEdge";B1.displayName="BezierEdgeInternal";const yx={default:B1,straight:I1,step:$1,smoothstep:R1,simplebezier:_1},xx={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},L5=(e,n,a)=>a===Se.Left?e-n:a===Se.Right?e+n:e,B5=(e,n,a)=>a===Se.Top?e-n:a===Se.Bottom?e+n:e,bx="react-flow__edgeupdater";function vx({position:e,centerX:n,centerY:a,radius:s=10,onMouseDown:i,onMouseEnter:l,onMouseOut:d,type:p}){return c.jsx("circle",{onMouseDown:i,onMouseEnter:l,onMouseOut:d,className:ft([bx,`${bx}-${p}`]),cx:L5(n,s,e),cy:B5(a,s,e),r:s,stroke:"transparent",fill:"transparent"})}function P5({isReconnectable:e,reconnectRadius:n,edge:a,sourceX:s,sourceY:i,targetX:l,targetY:d,sourcePosition:p,targetPosition:f,onReconnect:h,onReconnectStart:g,onReconnectEnd:x,setReconnecting:b,setUpdateHover:v}){const k=nt(),w=(M,$)=>{if(M.button!==0)return;const{autoPanOnConnect:A,domNode:_,connectionMode:F,connectionRadius:B,lib:G,onConnectStart:O,cancelConnection:K,nodeLookup:V,rfId:P,panBy:N,updateConnection:D}=k.getState(),U=$.type==="target",q=(I,L)=>{b(!1),x?.(I,a,$.type,L)},W=I=>h?.(a,I),oe=(I,L)=>{b(!0),g?.(M,a,$.type),O?.(I,L)};Mf.onPointerDown(M.nativeEvent,{autoPanOnConnect:A,connectionMode:F,connectionRadius:B,domNode:_,handleId:$.id,nodeId:$.nodeId,nodeLookup:V,isTarget:U,edgeUpdaterType:$.type,lib:G,flowId:P,cancelConnection:K,panBy:N,isValidConnection:(...I)=>k.getState().isValidConnection?.(...I)??!0,onConnect:W,onConnectStart:oe,onConnectEnd:(...I)=>k.getState().onConnectEnd?.(...I),onReconnectEnd:q,updateConnection:D,getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,dragThreshold:k.getState().connectionDragThreshold,handleDomNode:M.currentTarget})},j=M=>w(M,{nodeId:a.target,id:a.targetHandle??null,type:"target"}),T=M=>w(M,{nodeId:a.source,id:a.sourceHandle??null,type:"source"}),E=()=>v(!0),S=()=>v(!1);return c.jsxs(c.Fragment,{children:[(e===!0||e==="source")&&c.jsx(vx,{position:p,centerX:s,centerY:i,radius:n,onMouseDown:j,onMouseEnter:E,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&c.jsx(vx,{position:f,centerX:l,centerY:d,radius:n,onMouseDown:T,onMouseEnter:E,onMouseOut:S,type:"target"})]})}function H5({id:e,edgesFocusable:n,edgesReconnectable:a,elementsSelectable:s,onClick:i,onDoubleClick:l,onContextMenu:d,onMouseEnter:p,onMouseMove:f,onMouseLeave:h,reconnectRadius:g,onReconnect:x,onReconnectStart:b,onReconnectEnd:v,rfId:k,edgeTypes:w,noPanClassName:j,onError:T,disableKeyboardA11y:E}){let S=Fe(xe=>xe.edgeLookup.get(e));const M=Fe(xe=>xe.defaultEdgeOptions);S=M?{...M,...S}:S;let $=S.type||"default",A=w?.[$]||yx[$];A===void 0&&(T?.("011",In.error011($)),$="default",A=w?.default||yx.default);const _=!!(S.focusable||n&&typeof S.focusable>"u"),F=typeof x<"u"&&(S.reconnectable||a&&typeof S.reconnectable>"u"),B=!!(S.selectable||s&&typeof S.selectable>"u"),G=z.useRef(null),[O,K]=z.useState(!1),[V,P]=z.useState(!1),N=nt(),{zIndex:D,sourceX:U,sourceY:q,targetX:W,targetY:oe,sourcePosition:I,targetPosition:L}=Fe(z.useCallback(xe=>{const J=xe.nodeLookup.get(S.source),ye=xe.nodeLookup.get(S.target);if(!J||!ye)return{zIndex:S.zIndex,...xx};const Ee=_E({id:e,sourceNode:J,targetNode:ye,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:xe.connectionMode,onError:T});return{zIndex:SE({selected:S.selected,zIndex:S.zIndex,sourceNode:J,targetNode:ye,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode}),...Ee||xx}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex]),tt),Z=z.useMemo(()=>S.markerStart?`url('#${wf(S.markerStart,k)}')`:void 0,[S.markerStart,k]),ae=z.useMemo(()=>S.markerEnd?`url('#${wf(S.markerEnd,k)}')`:void 0,[S.markerEnd,k]);if(S.hidden||U===null||q===null||W===null||oe===null)return null;const pe=xe=>{const{addSelectedEdges:J,unselectNodesAndEdges:ye,multiSelectionActive:Ee}=N.getState();B&&(N.setState({nodesSelectionActive:!1}),S.selected&&Ee?(ye({nodes:[],edges:[S]}),G.current?.blur()):J([e])),i&&i(xe,S)},me=l?xe=>{l(xe,{...S})}:void 0,he=d?xe=>{d(xe,{...S})}:void 0,H=p?xe=>{p(xe,{...S})}:void 0,ce=f?xe=>{f(xe,{...S})}:void 0,Q=h?xe=>{h(xe,{...S})}:void 0,ge=xe=>{if(!E&&Lb.includes(xe.key)&&B){const{unselectNodesAndEdges:J,addSelectedEdges:ye}=N.getState();xe.key==="Escape"?(G.current?.blur(),J({edges:[S]})):ye([e])}};return c.jsx("svg",{style:{zIndex:D},children:c.jsxs("g",{className:ft(["react-flow__edge",`react-flow__edge-${$}`,S.className,j,{selected:S.selected,animated:S.animated,inactive:!B&&!i,updating:O,selectable:B}]),onClick:pe,onDoubleClick:me,onContextMenu:he,onMouseEnter:H,onMouseMove:ce,onMouseLeave:Q,onKeyDown:_?ge:void 0,tabIndex:_?0:void 0,role:S.ariaRole??(_?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":_?`${y1}-${k}`:void 0,ref:G,...S.domAttributes,children:[!V&&c.jsx(A,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:B,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:U,sourceY:q,targetX:W,targetY:oe,sourcePosition:I,targetPosition:L,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:Z,markerEnd:ae,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),F&&c.jsx(P5,{edge:S,isReconnectable:F,reconnectRadius:g,onReconnect:x,onReconnectStart:b,onReconnectEnd:v,sourceX:U,sourceY:q,targetX:W,targetY:oe,sourcePosition:I,targetPosition:L,setUpdateHover:K,setReconnecting:P})]})})}var U5=z.memo(H5);const G5=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function P1({defaultMarkerColor:e,onlyRenderVisibleElements:n,rfId:a,edgeTypes:s,noPanClassName:i,onReconnect:l,onEdgeContextMenu:d,onEdgeMouseEnter:p,onEdgeMouseMove:f,onEdgeMouseLeave:h,onEdgeClick:g,reconnectRadius:x,onEdgeDoubleClick:b,onReconnectStart:v,onReconnectEnd:k,disableKeyboardA11y:w}){const{edgesFocusable:j,edgesReconnectable:T,elementsSelectable:E,onError:S}=Fe(G5,tt),M=T5(n);return c.jsxs("div",{className:"react-flow__edges",children:[c.jsx(z5,{defaultColor:e,rfId:a}),M.map($=>c.jsx(U5,{id:$,edgesFocusable:j,edgesReconnectable:T,elementsSelectable:E,noPanClassName:i,onReconnect:l,onContextMenu:d,onMouseEnter:p,onMouseMove:f,onMouseLeave:h,onClick:g,reconnectRadius:x,onDoubleClick:b,onReconnectStart:v,onReconnectEnd:k,rfId:a,onError:S,edgeTypes:s,disableKeyboardA11y:w},$))]})}P1.displayName="EdgeRenderer";const q5=z.memo(P1),K5=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Y5({children:e}){const n=Fe(K5);return c.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:n},children:e})}function V5(e){const n=Zf(),a=z.useRef(!1);z.useEffect(()=>{!a.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),a.current=!0)},[e,n.viewportInitialized])}const W5=e=>e.panZoom?.syncViewport;function X5(e){const n=Fe(W5),a=nt();return z.useEffect(()=>{e&&(n?.(e),a.setState({transform:[e.x,e.y,e.zoom]}))},[e,n]),null}function Z5(e){return e.connection.inProgress?{...e.connection,to:Ai(e.connection.to,e.transform)}:{...e.connection}}function Q5(e){return Z5}function J5(e){const n=Q5();return Fe(n,tt)}const eT=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function tT({containerStyle:e,style:n,type:a,component:s}){const{nodesConnectable:i,width:l,height:d,isValid:p,inProgress:f}=Fe(eT,tt);return!(l&&i&&f)?null:c.jsx("svg",{style:e,width:l,height:d,className:"react-flow__connectionline react-flow__container",children:c.jsx("g",{className:ft(["react-flow__connection",Hb(p)]),children:c.jsx(H1,{style:n,type:a,CustomComponent:s,isValid:p})})})}const H1=({style:e,type:n=Zo.Bezier,CustomComponent:a,isValid:s})=>{const{inProgress:i,from:l,fromNode:d,fromHandle:p,fromPosition:f,to:h,toNode:g,toHandle:x,toPosition:b,pointer:v}=J5();if(!i)return;if(a)return c.jsx(a,{connectionLineType:n,connectionLineStyle:e,fromNode:d,fromHandle:p,fromX:l.x,fromY:l.y,toX:h.x,toY:h.y,fromPosition:f,toPosition:b,connectionStatus:Hb(s),toNode:g,toHandle:x,pointer:v});let k="";const w={sourceX:l.x,sourceY:l.y,sourcePosition:f,targetX:h.x,targetY:h.y,targetPosition:b};switch(n){case Zo.Bezier:[k]=e1(w);break;case Zo.SimpleBezier:[k]=N1(w);break;case Zo.Step:[k]=kf({...w,borderRadius:0});break;case Zo.SmoothStep:[k]=kf(w);break;default:[k]=n1(w)}return c.jsx("path",{d:k,fill:"none",className:"react-flow__connection-path",style:e})};H1.displayName="ConnectionLine";const nT={};function kx(e=nT){z.useRef(e),nt(),z.useEffect(()=>{},[e])}function oT(){nt(),z.useRef(!1),z.useEffect(()=>{},[])}function U1({nodeTypes:e,edgeTypes:n,onInit:a,onNodeClick:s,onEdgeClick:i,onNodeDoubleClick:l,onEdgeDoubleClick:d,onNodeMouseEnter:p,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:g,onSelectionContextMenu:x,onSelectionStart:b,onSelectionEnd:v,connectionLineType:k,connectionLineStyle:w,connectionLineComponent:j,connectionLineContainerStyle:T,selectionKeyCode:E,selectionOnDrag:S,selectionMode:M,multiSelectionKeyCode:$,panActivationKeyCode:A,zoomActivationKeyCode:_,deleteKeyCode:F,onlyRenderVisibleElements:B,elementsSelectable:G,defaultViewport:O,translateExtent:K,minZoom:V,maxZoom:P,preventScrolling:N,defaultMarkerColor:D,zoomOnScroll:U,zoomOnPinch:q,panOnScroll:W,panOnScrollSpeed:oe,panOnScrollMode:I,zoomOnDoubleClick:L,panOnDrag:Z,onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:he,onPaneScroll:H,onPaneContextMenu:ce,paneClickDistance:Q,nodeClickDistance:ge,onEdgeContextMenu:xe,onEdgeMouseEnter:J,onEdgeMouseMove:ye,onEdgeMouseLeave:Ee,reconnectRadius:Ie,onReconnect:ze,onReconnectStart:Nt,onReconnectEnd:mt,noDragClassName:vt,noWheelClassName:mn,noPanClassName:tn,disableKeyboardA11y:hn,nodeExtent:kt,rfId:Ha,viewport:Pn,onViewportChange:yo}){return kx(e),kx(n),oT(),V5(a),X5(Pn),c.jsx(x5,{onPaneClick:ae,onPaneMouseEnter:pe,onPaneMouseMove:me,onPaneMouseLeave:he,onPaneContextMenu:ce,onPaneScroll:H,paneClickDistance:Q,deleteKeyCode:F,selectionKeyCode:E,selectionOnDrag:S,selectionMode:M,onSelectionStart:b,onSelectionEnd:v,multiSelectionKeyCode:$,panActivationKeyCode:A,zoomActivationKeyCode:_,elementsSelectable:G,zoomOnScroll:U,zoomOnPinch:q,zoomOnDoubleClick:L,panOnScroll:W,panOnScrollSpeed:oe,panOnScrollMode:I,panOnDrag:Z,defaultViewport:O,translateExtent:K,minZoom:V,maxZoom:P,onSelectionContextMenu:x,preventScrolling:N,noDragClassName:vt,noWheelClassName:mn,noPanClassName:tn,disableKeyboardA11y:hn,onViewportChange:yo,isControlledViewport:!!Pn,children:c.jsxs(Y5,{children:[c.jsx(q5,{edgeTypes:n,onEdgeClick:i,onEdgeDoubleClick:d,onReconnect:ze,onReconnectStart:Nt,onReconnectEnd:mt,onlyRenderVisibleElements:B,onEdgeContextMenu:xe,onEdgeMouseEnter:J,onEdgeMouseMove:ye,onEdgeMouseLeave:Ee,reconnectRadius:Ie,defaultMarkerColor:D,noPanClassName:tn,disableKeyboardA11y:hn,rfId:Ha}),c.jsx(tT,{style:w,type:k,component:j,containerStyle:T}),c.jsx("div",{className:"react-flow__edgelabel-renderer"}),c.jsx(j5,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:l,onNodeMouseEnter:p,onNodeMouseMove:f,onNodeMouseLeave:h,onNodeContextMenu:g,nodeClickDistance:ge,onlyRenderVisibleElements:B,noPanClassName:tn,noDragClassName:vt,disableKeyboardA11y:hn,nodeExtent:kt,rfId:Ha}),c.jsx("div",{className:"react-flow__viewport-portal"})]})})}U1.displayName="GraphView";const aT=z.memo(U1),wx=({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:d,fitViewOptions:p,minZoom:f=.5,maxZoom:h=2,nodeOrigin:g,nodeExtent:x,zIndexMode:b="basic"}={})=>{const v=new Map,k=new Map,w=new Map,j=new Map,T=s??n??[],E=a??e??[],S=g??[0,0],M=x??fi;s1(w,j,T);const $=Sf(E,v,k,{nodeOrigin:S,nodeExtent:M,zIndexMode:b});let A=[0,0,1];if(d&&i&&l){const _=Ti(v,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:F,y:B,zoom:G}=Gf(_,i,l,f,h,p?.padding??.1);A=[F,B,G]}return{rfId:"1",width:i??0,height:l??0,transform:A,nodes:E,nodesInitialized:$,nodeLookup:v,parentLookup:k,edges:T,edgeLookup:j,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:a!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:f,maxZoom:h,translateExtent:fi,nodeExtent:M,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Bs.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:d??!1,fitViewOptions:p,fitViewResolver:null,connection:{...Pb},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:yE,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Bb,zIndexMode:b,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},sT=({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:d,fitViewOptions:p,minZoom:f,maxZoom:h,nodeOrigin:g,nodeExtent:x,zIndexMode:b})=>kj((v,k)=>{async function w(){const{nodeLookup:j,panZoom:T,fitViewOptions:E,fitViewResolver:S,width:M,height:$,minZoom:A,maxZoom:_}=k();T&&(await hE({nodes:j,width:M,height:$,panZoom:T,minZoom:A,maxZoom:_},E),S?.resolve(!0),v({fitViewResolver:null}))}return{...wx({nodes:e,edges:n,width:i,height:l,fitView:d,fitViewOptions:p,minZoom:f,maxZoom:h,nodeOrigin:g,nodeExtent:x,defaultNodes:a,defaultEdges:s,zIndexMode:b}),setNodes:j=>{const{nodeLookup:T,parentLookup:E,nodeOrigin:S,elevateNodesOnSelect:M,fitViewQueued:$,zIndexMode:A}=k(),_=Sf(j,T,E,{nodeOrigin:S,nodeExtent:x,elevateNodesOnSelect:M,checkEquality:!0,zIndexMode:A});$&&_?(w(),v({nodes:j,nodesInitialized:_,fitViewQueued:!1,fitViewOptions:void 0})):v({nodes:j,nodesInitialized:_})},setEdges:j=>{const{connectionLookup:T,edgeLookup:E}=k();s1(T,E,j),v({edges:j})},setDefaultNodesAndEdges:(j,T)=>{if(j){const{setNodes:E}=k();E(j),v({hasDefaultNodes:!0})}if(T){const{setEdges:E}=k();E(T),v({hasDefaultEdges:!0})}},updateNodeInternals:j=>{const{triggerNodeChanges:T,nodeLookup:E,parentLookup:S,domNode:M,nodeOrigin:$,nodeExtent:A,debug:_,fitViewQueued:F,zIndexMode:B}=k(),{changes:G,updatedInternals:O}=LE(j,E,S,M,$,A,B);O&&(OE(E,S,{nodeOrigin:$,nodeExtent:A,zIndexMode:B}),F?(w(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),G?.length>0&&(_&&console.log("React Flow: trigger node changes",G),T?.(G)))},updateNodePositions:(j,T=!1)=>{const E=[];let S=[];const{nodeLookup:M,triggerNodeChanges:$,connection:A,updateConnection:_,onNodesChangeMiddlewareMap:F}=k();for(const[B,G]of j){const O=M.get(B),K=!!(O?.expandParent&&O?.parentId&&G?.position),V={id:B,type:"position",position:K?{x:Math.max(0,G.position.x),y:Math.max(0,G.position.y)}:G.position,dragging:T};if(O&&A.inProgress&&A.fromNode.id===O.id){const P=Ia(O,A.fromHandle,Se.Left,!0);_({...A,from:P})}K&&O.parentId&&E.push({id:B,parentId:O.parentId,rect:{...G.internals.positionAbsolute,width:G.measured.width??0,height:G.measured.height??0}}),S.push(V)}if(E.length>0){const{parentLookup:B,nodeOrigin:G}=k(),O=Xf(E,M,B,G);S.push(...O)}for(const B of F.values())S=B(S);$(S)},triggerNodeChanges:j=>{const{onNodesChange:T,setNodes:E,nodes:S,hasDefaultNodes:M,debug:$}=k();if(j?.length){if(M){const A=Hj(j,S);E(A)}$&&console.log("React Flow: trigger node changes",j),T?.(j)}},triggerEdgeChanges:j=>{const{onEdgesChange:T,setEdges:E,edges:S,hasDefaultEdges:M,debug:$}=k();if(j?.length){if(M){const A=Uj(j,S);E(A)}$&&console.log("React Flow: trigger edge changes",j),T?.(j)}},addSelectedNodes:j=>{const{multiSelectionActive:T,edgeLookup:E,nodeLookup:S,triggerNodeChanges:M,triggerEdgeChanges:$}=k();if(T){const A=j.map(_=>Ta(_,!0));M(A);return}M(Ds(S,new Set([...j]),!0)),$(Ds(E))},addSelectedEdges:j=>{const{multiSelectionActive:T,edgeLookup:E,nodeLookup:S,triggerNodeChanges:M,triggerEdgeChanges:$}=k();if(T){const A=j.map(_=>Ta(_,!0));$(A);return}$(Ds(E,new Set([...j]))),M(Ds(S,new Set,!0))},unselectNodesAndEdges:({nodes:j,edges:T}={})=>{const{edges:E,nodes:S,nodeLookup:M,triggerNodeChanges:$,triggerEdgeChanges:A}=k(),_=j||S,F=T||E,B=[];for(const O of _){if(!O.selected)continue;const K=M.get(O.id);K&&(K.selected=!1),B.push(Ta(O.id,!1))}const G=[];for(const O of F)O.selected&&G.push(Ta(O.id,!1));$(B),A(G)},setMinZoom:j=>{const{panZoom:T,maxZoom:E}=k();T?.setScaleExtent([j,E]),v({minZoom:j})},setMaxZoom:j=>{const{panZoom:T,minZoom:E}=k();T?.setScaleExtent([E,j]),v({maxZoom:j})},setTranslateExtent:j=>{k().panZoom?.setTranslateExtent(j),v({translateExtent:j})},resetSelectedElements:()=>{const{edges:j,nodes:T,triggerNodeChanges:E,triggerEdgeChanges:S,elementsSelectable:M}=k();if(!M)return;const $=T.reduce((_,F)=>F.selected?[..._,Ta(F.id,!1)]:_,[]),A=j.reduce((_,F)=>F.selected?[..._,Ta(F.id,!1)]:_,[]);E($),S(A)},setNodeExtent:j=>{const{nodes:T,nodeLookup:E,parentLookup:S,nodeOrigin:M,elevateNodesOnSelect:$,nodeExtent:A,zIndexMode:_}=k();j[0][0]===A[0][0]&&j[0][1]===A[0][1]&&j[1][0]===A[1][0]&&j[1][1]===A[1][1]||(Sf(T,E,S,{nodeOrigin:M,nodeExtent:j,elevateNodesOnSelect:$,checkEquality:!1,zIndexMode:_}),v({nodeExtent:j}))},panBy:j=>{const{transform:T,width:E,height:S,panZoom:M,translateExtent:$}=k();return BE({delta:j,panZoom:M,transform:T,translateExtent:$,width:E,height:S})},setCenter:async(j,T,E)=>{const{width:S,height:M,maxZoom:$,panZoom:A}=k();if(!A)return Promise.resolve(!1);const _=typeof E?.zoom<"u"?E.zoom:$;return await A.setViewport({x:S/2-j*_,y:M/2-T*_,zoom:_},{duration:E?.duration,ease:E?.ease,interpolate:E?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{v({connection:{...Pb}})},updateConnection:j=>{v({connection:j})},reset:()=>v({...wx()})}},Object.is);function rT({initialNodes:e,initialEdges:n,defaultNodes:a,defaultEdges:s,initialWidth:i,initialHeight:l,initialMinZoom:d,initialMaxZoom:p,initialFitViewOptions:f,fitView:h,nodeOrigin:g,nodeExtent:x,zIndexMode:b,children:v}){const[k]=z.useState(()=>sT({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,width:i,height:l,fitView:h,minZoom:d,maxZoom:p,fitViewOptions:f,nodeOrigin:g,nodeExtent:x,zIndexMode:b}));return c.jsx(wj,{value:k,children:c.jsx(Yj,{children:v})})}function iT({children:e,nodes:n,edges:a,defaultNodes:s,defaultEdges:i,width:l,height:d,fitView:p,fitViewOptions:f,minZoom:h,maxZoom:g,nodeOrigin:x,nodeExtent:b,zIndexMode:v}){return z.useContext(au)?c.jsx(c.Fragment,{children:e}):c.jsx(rT,{initialNodes:n,initialEdges:a,defaultNodes:s,defaultEdges:i,initialWidth:l,initialHeight:d,fitView:p,initialFitViewOptions:f,initialMinZoom:h,initialMaxZoom:g,nodeOrigin:x,nodeExtent:b,zIndexMode:v,children:e})}const lT={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function cT({nodes:e,edges:n,defaultNodes:a,defaultEdges:s,className:i,nodeTypes:l,edgeTypes:d,onNodeClick:p,onEdgeClick:f,onInit:h,onMove:g,onMoveStart:x,onMoveEnd:b,onConnect:v,onConnectStart:k,onConnectEnd:w,onClickConnectStart:j,onClickConnectEnd:T,onNodeMouseEnter:E,onNodeMouseMove:S,onNodeMouseLeave:M,onNodeContextMenu:$,onNodeDoubleClick:A,onNodeDragStart:_,onNodeDrag:F,onNodeDragStop:B,onNodesDelete:G,onEdgesDelete:O,onDelete:K,onSelectionChange:V,onSelectionDragStart:P,onSelectionDrag:N,onSelectionDragStop:D,onSelectionContextMenu:U,onSelectionStart:q,onSelectionEnd:W,onBeforeDelete:oe,connectionMode:I,connectionLineType:L=Zo.Bezier,connectionLineStyle:Z,connectionLineComponent:ae,connectionLineContainerStyle:pe,deleteKeyCode:me="Backspace",selectionKeyCode:he="Shift",selectionOnDrag:H=!1,selectionMode:ce=mi.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:ge=gi()?"Meta":"Control",zoomActivationKeyCode:xe=gi()?"Meta":"Control",snapToGrid:J,snapGrid:ye,onlyRenderVisibleElements:Ee=!1,selectNodesOnDrag:Ie,nodesDraggable:ze,autoPanOnNodeFocus:Nt,nodesConnectable:mt,nodesFocusable:vt,nodeOrigin:mn=x1,edgesFocusable:tn,edgesReconnectable:hn,elementsSelectable:kt=!0,defaultViewport:Ha=Oj,minZoom:Pn=.5,maxZoom:yo=2,translateExtent:oa=fi,preventScrolling:yu=!0,nodeExtent:Ua,defaultMarkerColor:xu="#b1b1b7",zoomOnScroll:bu=!0,zoomOnPinch:aa=!0,panOnScroll:Dt=!1,panOnScrollSpeed:En=.5,panOnScrollMode:zt=Da.Free,zoomOnDoubleClick:vu=!0,panOnDrag:ku=!0,onPaneClick:wu,onPaneMouseEnter:Ga,onPaneMouseMove:qa,onPaneMouseLeave:Ka,onPaneScroll:Hn,onPaneContextMenu:Ya,paneClickDistance:sa=1,nodeClickDistance:Su=0,children:$i,onReconnect:Zs,onReconnectStart:ra,onReconnectEnd:Mu,onEdgeContextMenu:Fi,onEdgeDoubleClick:Ii,onEdgeMouseEnter:Li,onEdgeMouseMove:Qs,onEdgeMouseLeave:Js,reconnectRadius:Bi=10,onNodesChange:Pi,onEdgesChange:jn,noDragClassName:ht="nodrag",noWheelClassName:At="nowheel",noPanClassName:Un="nopan",fitView:Va,fitViewOptions:Hi,connectOnClick:Cu,attributionPosition:Ui,proOptions:ia,defaultEdgeOptions:er,elevateNodesOnSelect:xo=!0,elevateEdgesOnSelect:bo=!1,disableKeyboardA11y:vo=!1,autoPanOnConnect:ko,autoPanOnNodeDrag:it,autoPanSpeed:Gi,connectionRadius:qi,isValidConnection:Gn,onError:wo,style:Eu,id:tr,nodeDragThreshold:Ki,connectionDragThreshold:ju,viewport:Wa,onViewportChange:Xa,width:gn,height:Ot,colorMode:Yi="light",debug:Tu,onScroll:Za,ariaLabelConfig:Vi,zIndexMode:la="basic",...Nu},$t){const ca=tr||"1",Wi=Lj(Yi),nr=z.useCallback(qn=>{qn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Za?.(qn)},[Za]);return c.jsx("div",{"data-testid":"rf__wrapper",...Nu,onScroll:nr,style:{...Eu,...lT},ref:$t,className:ft(["react-flow",i,Wi]),id:tr,role:"application",children:c.jsxs(iT,{nodes:e,edges:n,width:gn,height:Ot,fitView:Va,fitViewOptions:Hi,minZoom:Pn,maxZoom:yo,nodeOrigin:mn,nodeExtent:Ua,zIndexMode:la,children:[c.jsx(aT,{onInit:h,onNodeClick:p,onEdgeClick:f,onNodeMouseEnter:E,onNodeMouseMove:S,onNodeMouseLeave:M,onNodeContextMenu:$,onNodeDoubleClick:A,nodeTypes:l,edgeTypes:d,connectionLineType:L,connectionLineStyle:Z,connectionLineComponent:ae,connectionLineContainerStyle:pe,selectionKeyCode:he,selectionOnDrag:H,selectionMode:ce,deleteKeyCode:me,multiSelectionKeyCode:ge,panActivationKeyCode:Q,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Ee,defaultViewport:Ha,translateExtent:oa,minZoom:Pn,maxZoom:yo,preventScrolling:yu,zoomOnScroll:bu,zoomOnPinch:aa,zoomOnDoubleClick:vu,panOnScroll:Dt,panOnScrollSpeed:En,panOnScrollMode:zt,panOnDrag:ku,onPaneClick:wu,onPaneMouseEnter:Ga,onPaneMouseMove:qa,onPaneMouseLeave:Ka,onPaneScroll:Hn,onPaneContextMenu:Ya,paneClickDistance:sa,nodeClickDistance:Su,onSelectionContextMenu:U,onSelectionStart:q,onSelectionEnd:W,onReconnect:Zs,onReconnectStart:ra,onReconnectEnd:Mu,onEdgeContextMenu:Fi,onEdgeDoubleClick:Ii,onEdgeMouseEnter:Li,onEdgeMouseMove:Qs,onEdgeMouseLeave:Js,reconnectRadius:Bi,defaultMarkerColor:xu,noDragClassName:ht,noWheelClassName:At,noPanClassName:Un,rfId:ca,disableKeyboardA11y:vo,nodeExtent:Ua,viewport:Wa,onViewportChange:Xa}),c.jsx(Ij,{nodes:e,edges:n,defaultNodes:a,defaultEdges:s,onConnect:v,onConnectStart:k,onConnectEnd:w,onClickConnectStart:j,onClickConnectEnd:T,nodesDraggable:ze,autoPanOnNodeFocus:Nt,nodesConnectable:mt,nodesFocusable:vt,edgesFocusable:tn,edgesReconnectable:hn,elementsSelectable:kt,elevateNodesOnSelect:xo,elevateEdgesOnSelect:bo,minZoom:Pn,maxZoom:yo,nodeExtent:Ua,onNodesChange:Pi,onEdgesChange:jn,snapToGrid:J,snapGrid:ye,connectionMode:I,translateExtent:oa,connectOnClick:Cu,defaultEdgeOptions:er,fitView:Va,fitViewOptions:Hi,onNodesDelete:G,onEdgesDelete:O,onDelete:K,onNodeDragStart:_,onNodeDrag:F,onNodeDragStop:B,onSelectionDrag:N,onSelectionDragStart:P,onSelectionDragStop:D,onMove:g,onMoveStart:x,onMoveEnd:b,noPanClassName:Un,nodeOrigin:mn,rfId:ca,autoPanOnConnect:ko,autoPanOnNodeDrag:it,autoPanSpeed:Gi,onError:wo,connectionRadius:qi,isValidConnection:Gn,selectNodesOnDrag:Ie,nodeDragThreshold:Ki,connectionDragThreshold:ju,onBeforeDelete:oe,debug:Tu,ariaLabelConfig:Vi,zIndexMode:la}),c.jsx(Rj,{onSelectionChange:V}),$i,c.jsx(Nj,{proOptions:ia,position:Ui}),c.jsx(Tj,{rfId:ca,disableKeyboardA11y:vo})]})})}v1(cT);function uT({dimensions:e,lineWidth:n,variant:a,className:s}){return c.jsx("path",{strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ft(["react-flow__background-pattern",a,s])})}function dT({radius:e,className:n}){return c.jsx("circle",{cx:e,cy:e,r:e,className:ft(["react-flow__background-pattern","dots",n])})}var ea;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ea||(ea={}));const pT={[ea.Dots]:1,[ea.Lines]:1,[ea.Cross]:6},fT=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function G1({id:e,variant:n=ea.Dots,gap:a=20,size:s,lineWidth:i=1,offset:l=0,color:d,bgColor:p,style:f,className:h,patternClassName:g}){const x=z.useRef(null),{transform:b,patternId:v}=Fe(fT,tt),k=s||pT[n],w=n===ea.Dots,j=n===ea.Cross,T=Array.isArray(a)?a:[a,a],E=[T[0]*b[2]||1,T[1]*b[2]||1],S=k*b[2],M=Array.isArray(l)?l:[l,l],$=j?[S,S]:E,A=[M[0]*b[2]||1+$[0]/2,M[1]*b[2]||1+$[1]/2],_=`${v}${e||""}`;return c.jsxs("svg",{className:ft(["react-flow__background",h]),style:{...f,...ru,"--xy-background-color-props":p,"--xy-background-pattern-color-props":d},ref:x,"data-testid":"rf__background",children:[c.jsx("pattern",{id:_,x:b[0]%E[0],y:b[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${A[0]},-${A[1]})`,children:w?c.jsx(dT,{radius:S/2,className:g}):c.jsx(uT,{dimensions:$,lineWidth:i,variant:n,className:g})}),c.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${_})`})]})}G1.displayName="Background";z.memo(G1);function mT(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:c.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function hT(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:c.jsx("path",{d:"M0 0h32v4.2H0z"})})}function gT(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:c.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function yT(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:c.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function xT(){return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:c.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function mc({children:e,className:n,...a}){return c.jsx("button",{type:"button",className:ft(["react-flow__controls-button",n]),...a,children:e})}const bT=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function q1({style:e,showZoom:n=!0,showFitView:a=!0,showInteractive:s=!0,fitViewOptions:i,onZoomIn:l,onZoomOut:d,onFitView:p,onInteractiveChange:f,className:h,children:g,position:x="bottom-left",orientation:b="vertical","aria-label":v}){const k=nt(),{isInteractive:w,minZoomReached:j,maxZoomReached:T,ariaLabelConfig:E}=Fe(bT,tt),{zoomIn:S,zoomOut:M,fitView:$}=Zf(),A=()=>{S(),l?.()},_=()=>{M(),d?.()},F=()=>{$(i),p?.()},B=()=>{k.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),f?.(!w)},G=b==="horizontal"?"horizontal":"vertical";return c.jsxs(su,{className:ft(["react-flow__controls",G,h]),position:x,style:e,"data-testid":"rf__controls","aria-label":v??E["controls.ariaLabel"],children:[n&&c.jsxs(c.Fragment,{children:[c.jsx(mc,{onClick:A,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:T,children:c.jsx(mT,{})}),c.jsx(mc,{onClick:_,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:j,children:c.jsx(hT,{})})]}),a&&c.jsx(mc,{className:"react-flow__controls-fitview",onClick:F,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:c.jsx(gT,{})}),s&&c.jsx(mc,{className:"react-flow__controls-interactive",onClick:B,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:w?c.jsx(xT,{}):c.jsx(yT,{})}),g]})}q1.displayName="Controls";z.memo(q1);function vT({id:e,x:n,y:a,width:s,height:i,style:l,color:d,strokeColor:p,strokeWidth:f,className:h,borderRadius:g,shapeRendering:x,selected:b,onClick:v}){const{background:k,backgroundColor:w}=l||{},j=d||k||w;return c.jsx("rect",{className:ft(["react-flow__minimap-node",{selected:b},h]),x:n,y:a,rx:g,ry:g,width:s,height:i,style:{fill:j,stroke:p,strokeWidth:f},shapeRendering:x,onClick:v?T=>v(T,e):void 0})}const kT=z.memo(vT),wT=e=>e.nodes.map(n=>n.id),Qp=e=>e instanceof Function?e:()=>e;function ST({nodeStrokeColor:e,nodeColor:n,nodeClassName:a="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:l=kT,onClick:d}){const p=Fe(wT,tt),f=Qp(n),h=Qp(e),g=Qp(a),x=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return c.jsx(c.Fragment,{children:p.map(b=>c.jsx(CT,{id:b,nodeColorFunc:f,nodeStrokeColorFunc:h,nodeClassNameFunc:g,nodeBorderRadius:s,nodeStrokeWidth:i,NodeComponent:l,onClick:d,shapeRendering:x},b))})}function MT({id:e,nodeColorFunc:n,nodeStrokeColorFunc:a,nodeClassNameFunc:s,nodeBorderRadius:i,nodeStrokeWidth:l,shapeRendering:d,NodeComponent:p,onClick:f}){const{node:h,x:g,y:x,width:b,height:v}=Fe(k=>{const w=k.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const j=w.internals.userNode,{x:T,y:E}=w.internals.positionAbsolute,{width:S,height:M}=go(j);return{node:j,x:T,y:E,width:S,height:M}},tt);return!h||h.hidden||!Vb(h)?null:c.jsx(p,{x:g,y:x,width:b,height:v,style:h.style,selected:!!h.selected,className:s(h),color:n(h),borderRadius:i,strokeColor:a(h),strokeWidth:l,shapeRendering:d,onClick:f,id:h.id})}const CT=z.memo(MT);var ET=z.memo(ST);const jT=200,TT=150,NT=e=>!e.hidden,AT=e=>{const n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:e.nodeLookup.size>0?Yb(Ti(e.nodeLookup,{filter:NT}),n):n,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},_T="react-flow__minimap-desc";function K1({style:e,className:n,nodeStrokeColor:a,nodeColor:s,nodeClassName:i="",nodeBorderRadius:l=5,nodeStrokeWidth:d,nodeComponent:p,bgColor:f,maskColor:h,maskStrokeColor:g,maskStrokeWidth:x,position:b="bottom-right",onClick:v,onNodeClick:k,pannable:w=!1,zoomable:j=!1,ariaLabel:T,inversePan:E,zoomStep:S=1,offsetScale:M=5}){const $=nt(),A=z.useRef(null),{boundingRect:_,viewBB:F,rfId:B,panZoom:G,translateExtent:O,flowWidth:K,flowHeight:V,ariaLabelConfig:P}=Fe(AT,tt),N=e?.width??jT,D=e?.height??TT,U=_.width/N,q=_.height/D,W=Math.max(U,q),oe=W*N,I=W*D,L=M*W,Z=_.x-(oe-_.width)/2-L,ae=_.y-(I-_.height)/2-L,pe=oe+L*2,me=I+L*2,he=`${_T}-${B}`,H=z.useRef(0),ce=z.useRef();H.current=W,z.useEffect(()=>{if(A.current&&G)return ce.current=WE({domNode:A.current,panZoom:G,getTransform:()=>$.getState().transform,getViewScale:()=>H.current}),()=>{ce.current?.destroy()}},[G]),z.useEffect(()=>{ce.current?.update({translateExtent:O,width:K,height:V,inversePan:E,pannable:w,zoomStep:S,zoomable:j})},[w,j,E,S,O,K,V]);const Q=v?J=>{const[ye,Ee]=ce.current?.pointer(J)||[0,0];v(J,{x:ye,y:Ee})}:void 0,ge=k?z.useCallback((J,ye)=>{const Ee=$.getState().nodeLookup.get(ye).internals.userNode;k(J,Ee)},[]):void 0,xe=T??P["minimap.ariaLabel"];return c.jsx(su,{position:b,style:{...e,"--xy-minimap-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof g=="string"?g:void 0,"--xy-minimap-mask-stroke-width-props":typeof x=="number"?x*W:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-width-props":typeof d=="number"?d:void 0},className:ft(["react-flow__minimap",n]),"data-testid":"rf__minimap",children:c.jsxs("svg",{width:N,height:D,viewBox:`${Z} ${ae} ${pe} ${me}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":he,ref:A,onClick:Q,children:[xe&&c.jsx("title",{id:he,children:xe}),c.jsx(ET,{onClick:ge,nodeColor:s,nodeStrokeColor:a,nodeBorderRadius:l,nodeClassName:i,nodeStrokeWidth:d,nodeComponent:p}),c.jsx("path",{className:"react-flow__minimap-mask",d:`M${Z-L},${ae-L}h${pe+L*2}v${me+L*2}h${-pe-L*2}z
|
|
18
|
+
M${F.x},${F.y}h${F.width}v${F.height}h${-F.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}K1.displayName="MiniMap";z.memo(K1);const DT=e=>n=>e?`${Math.max(1/n.transform[2],1)}`:void 0,zT={[Gs.Line]:"right",[Gs.Handle]:"bottom-right"};function RT({nodeId:e,position:n,variant:a=Gs.Handle,className:s,style:i=void 0,children:l,color:d,minWidth:p=10,minHeight:f=10,maxWidth:h=Number.MAX_VALUE,maxHeight:g=Number.MAX_VALUE,keepAspectRatio:x=!1,resizeDirection:b,autoScale:v=!0,shouldResize:k,onResizeStart:w,onResize:j,onResizeEnd:T}){const E=M1(),S=typeof e=="string"?e:E,M=nt(),$=z.useRef(null),A=a===Gs.Handle,_=Fe(z.useCallback(DT(A&&v),[A,v]),tt),F=z.useRef(null),B=n??zT[a];z.useEffect(()=>{if(!(!$.current||!S))return F.current||(F.current=cj({domNode:$.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:O,transform:K,snapGrid:V,snapToGrid:P,nodeOrigin:N,domNode:D}=M.getState();return{nodeLookup:O,transform:K,snapGrid:V,snapToGrid:P,nodeOrigin:N,paneDomNode:D}},onChange:(O,K)=>{const{triggerNodeChanges:V,nodeLookup:P,parentLookup:N,nodeOrigin:D}=M.getState(),U=[],q={x:O.x,y:O.y},W=P.get(S);if(W&&W.expandParent&&W.parentId){const oe=W.origin??D,I=O.width??W.measured.width??0,L=O.height??W.measured.height??0,Z={id:W.id,parentId:W.parentId,rect:{width:I,height:L,...Wb({x:O.x??W.position.x,y:O.y??W.position.y},{width:I,height:L},W.parentId,P,oe)}},ae=Xf([Z],P,N,D);U.push(...ae),q.x=O.x?Math.max(oe[0]*I,O.x):void 0,q.y=O.y?Math.max(oe[1]*L,O.y):void 0}if(q.x!==void 0&&q.y!==void 0){const oe={id:S,type:"position",position:{...q}};U.push(oe)}if(O.width!==void 0&&O.height!==void 0){const I={id:S,type:"dimensions",resizing:!0,setAttributes:b?b==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};U.push(I)}for(const oe of K){const I={...oe,type:"position"};U.push(I)}V(U)},onEnd:({width:O,height:K})=>{const V={id:S,type:"dimensions",resizing:!1,dimensions:{width:O,height:K}};M.getState().triggerNodeChanges([V])}})),F.current.update({controlPosition:B,boundaries:{minWidth:p,minHeight:f,maxWidth:h,maxHeight:g},keepAspectRatio:x,resizeDirection:b,onResizeStart:w,onResize:j,onResizeEnd:T,shouldResize:k}),()=>{F.current?.destroy()}},[B,p,f,h,g,x,w,j,T,k]);const G=B.split("-");return c.jsx("div",{className:ft(["react-flow__resize-control","nodrag",...G,a,s]),ref:$,style:{...i,scale:_,...d&&{[A?"backgroundColor":"borderColor"]:d}},children:l})}z.memo(RT);const OT=typeof localStorage<"u"?localStorage.getItem("modular-theme"):null,Pc=qt((e,n)=>({theme:OT==="light"?"light":"dark",toggleTheme:()=>{const a=n().theme==="dark"?"light":"dark";localStorage.setItem("modular-theme",a),e({theme:a})}})),$T={bg:"#111114",surface:"rgba(28, 28, 32, 0.9)",surfaceOpaque:"#1c1c20",surfaceElevated:"#25252a",surfaceHover:"#1f1f24",border:"#2a2a30",borderSubtle:"#222226",textPrimary:"#f0f0f0",textSecondary:"#888",textMuted:"#666",textDim:"#555",textFaint:"#444",inputBg:"#141417",badgeBg:"#25252a",dotGrid:"#222228",minimapBg:"#111114",minimapMask:"rgba(17,17,20,0.8)",minimapNode:"#25252a",controlsBg:"#1c1c20",controlsBorder:"#2a2a30",tileActiveBg:"#25252a",tileHoverBg:"#1f1f24",tileBg:"#1c1c20",tileBorderHover:"#3a3a40",agentBg:"#151210",agentBorder:"#2d2720",agentLabel:"#9a8e82",agentMeta:"#6d6058",agentArrow:"#6d6058",agentLineNum:"#2d2720",agentText:"#8a7e72",tokenLabel:"#999",tokenDivider:"#777",tokenTrackBg:"#25252a",jackRingBase:"#0a0a0a",jackLabelOnRing:"#999",jackLabelBeside:"#666",cableShadow:"rgba(0,0,0,0.4)",cableHighlight:"rgba(255,255,255,0.06)",responseBg:"rgba(28, 28, 32, 0.9)",responseText:"#bbb",statusSuccess:"#00ff88",statusError:"#ff3344",statusWarning:"#ffaa00",statusInfo:"#3498db",statusSuccessBg:"rgba(0,255,136,0.07)",statusErrorBg:"rgba(255,51,68,0.08)",statusWarningBg:"rgba(255,170,0,0.08)",statusSuccessGlow:"0 0 6px rgba(0,255,136,0.5)",statusErrorGlow:"0 0 6px rgba(255,51,68,0.5)",statusWarningGlow:"0 0 6px rgba(255,170,0,0.5)",cableSkills:"#f1c40f",cableMcp:"#2ecc71",cableKnowledge:"#e74c3c"},FT={bg:"#f0f1f3",surface:"rgba(255,255,255,0.95)",surfaceOpaque:"#ffffff",surfaceElevated:"#eeeef2",surfaceHover:"#f5f5f8",border:"#ccccd4",borderSubtle:"#dddde2",textPrimary:"#1a1a20",textSecondary:"#3a3a45",textMuted:"#555560",textDim:"#5c5c66",textFaint:"#71717a",inputBg:"#f5f5f8",badgeBg:"#e5e5ea",dotGrid:"#d0d0d8",minimapBg:"#f0f1f3",minimapMask:"rgba(240,241,243,0.8)",minimapNode:"#dddde2",controlsBg:"#ffffff",controlsBorder:"#ccccd4",tileActiveBg:"#e8e8ee",tileHoverBg:"#f0f0f5",tileBg:"#ffffff",tileBorderHover:"#bbbbc4",agentBg:"#f8f8fa",agentBorder:"#dddde2",agentLabel:"#555560",agentMeta:"#888890",agentArrow:"#888890",agentLineNum:"#ccccd4",agentText:"#666670",tokenLabel:"#555560",tokenDivider:"#888890",tokenTrackBg:"#dddde2",jackRingBase:"#e8e8ee",jackLabelOnRing:"#555",jackLabelBeside:"#777",cableShadow:"rgba(0,0,0,0.12)",cableHighlight:"rgba(255,255,255,0.3)",responseBg:"rgba(255,255,255,0.95)",responseText:"#444",statusSuccess:"#16a34a",statusError:"#dc2626",statusWarning:"#ca8a04",statusInfo:"#2563eb",statusSuccessBg:"rgba(22,163,74,0.08)",statusErrorBg:"rgba(220,38,38,0.08)",statusWarningBg:"rgba(202,138,4,0.08)",statusSuccessGlow:"0 0 6px rgba(22,163,74,0.3)",statusErrorGlow:"0 0 6px rgba(220,38,38,0.3)",statusWarningGlow:"0 0 6px rgba(202,138,4,0.3)",cableSkills:"#B45309",cableMcp:"#16a34a",cableKnowledge:"#dc2626"};function we(){const e=Pc(a=>a.theme);return{...e==="dark"?$T:FT,isDark:e==="dark"}}const $s=z.forwardRef(function({label:n,error:a,className:s="",style:i,...l},d){const p=we();return c.jsxs("div",{className:"flex flex-col gap-1",children:[n&&c.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:p.textMuted,fontFamily:"'Geist Mono', monospace"},children:n}),c.jsx("input",{ref:d,className:`w-full px-3 py-2 rounded-md outline-none nodrag ${s}`,style:{background:p.inputBg,border:`1px solid ${a?p.statusError:p.border}`,color:p.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:16,lineHeight:1.5,...i},...l}),a&&c.jsx("span",{className:"text-[13px]",style:{color:p.statusError},children:a})]})}),Aa=z.forwardRef(function({label:n,error:a,showCount:s,maxChars:i,value:l,className:d="",style:p,...f},h){const g=we(),x=typeof l=="string"?l.length:0;return c.jsxs("div",{className:"flex flex-col gap-1",children:[(n||s)&&c.jsxs("div",{className:"flex items-center justify-between",children:[n&&c.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:g.textMuted,fontFamily:"'Geist Mono', monospace"},children:n}),s&&c.jsxs("span",{className:"text-[13px]",style:{color:i&&x>i?g.statusError:g.textFaint},children:[x,i?` / ${i}`:""]})]}),c.jsx("textarea",{ref:h,value:l,className:`w-full px-3 py-2.5 rounded-md outline-none resize-none nowheel nodrag ${d}`,style:{background:g.inputBg,border:`1px solid ${a?g.statusError:g.border}`,color:g.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:16,lineHeight:1.5,minHeight:64,...p},...f}),a&&c.jsx("span",{className:"text-[13px]",style:{color:g.statusError},children:a})]})});const Y1=(...e)=>e.filter((n,a,s)=>!!n&&n.trim()!==""&&s.indexOf(n)===a).join(" ").trim();const IT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const LT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,a,s)=>s?s.toUpperCase():a.toLowerCase());const Sx=e=>{const n=LT(e);return n.charAt(0).toUpperCase()+n.slice(1)};var BT={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const PT=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const HT=z.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:i="",children:l,iconNode:d,...p},f)=>z.createElement("svg",{ref:f,...BT,width:n,height:n,stroke:e,strokeWidth:s?Number(a)*24/Number(n):a,className:Y1("lucide",i),...!l&&!PT(p)&&{"aria-hidden":"true"},...p},[...d.map(([h,g])=>z.createElement(h,g)),...Array.isArray(l)?l:[l]]));const fe=(e,n)=>{const a=z.forwardRef(({className:s,...i},l)=>z.createElement(HT,{ref:l,iconNode:n,className:Y1(`lucide-${IT(Sx(e))}`,`lucide-${e}`,s),...i}));return a.displayName=Sx(e),a};const UT=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ef=fe("activity",UT);const GT=[["path",{d:"M12 6v16",key:"nqf5sj"}],["path",{d:"m19 13 2-1a9 9 0 0 1-18 0l2 1",key:"y7qv08"}],["path",{d:"M9 11h6",key:"1fldmi"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}]],qT=fe("anchor",GT);const KT=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],YT=fe("arrow-down-right",KT);const VT=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],WT=fe("arrow-down",VT);const XT=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],ZT=fe("arrow-right-left",XT);const QT=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Mx=fe("arrow-up-right",QT);const JT=[["path",{d:"M16 7h.01",key:"1kdx03"}],["path",{d:"M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20",key:"oj1oa8"}],["path",{d:"m20 7 2 .5-2 .5",key:"12nv4d"}],["path",{d:"M10 18v3",key:"1yea0a"}],["path",{d:"M14 17.75V21",key:"1pymcb"}],["path",{d:"M7 18a6 6 0 0 0 3.84-10.61",key:"1npnn0"}]],eN=fe("bird",JT);const tN=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Jf=fe("book-open",tN);const nN=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],_i=fe("bot",nN);const oN=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],em=fe("box",oN);const aN=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Di=fe("brain",aN);const sN=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],rN=fe("bug",sN);const iN=[["path",{d:"M12 5c.67 0 1.35.09 2 .26 1.78-2 5.03-2.84 6.42-2.26 1.4.58-.42 7-.42 7 .57 1.07 1 2.24 1 3.44C21 17.9 16.97 21 12 21s-9-3-9-7.56c0-1.25.5-2.4 1-3.44 0 0-1.89-6.42-.5-7 1.39-.58 4.72.23 6.5 2.23A9.04 9.04 0 0 1 12 5Z",key:"x6xyqk"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M11.25 16.25h1.5L12 17l-.75-.75Z",key:"12kq1m"}]],lN=fe("cat",iN);const cN=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],tm=fe("chart-column",cN);const uN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],jt=fe("check",uN);const dN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ln=fe("chevron-down",dN);const pN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ba=fe("chevron-right",pN);const fN=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],V1=fe("chevron-up",fN);const mN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],nm=fe("circle-alert",mN);const hN=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Hc=fe("circle-check-big",hN);const gN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],xi=fe("circle-x",gN);const yN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],xN=fe("circle",yN);const bN=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]],vN=fe("clipboard-list",bN);const kN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],wN=fe("clock",kN);const SN=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],MN=fe("cloud",SN);const CN=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],W1=fe("code",CN);const EN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],jN=fe("compass",EN);const TN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],X1=fe("copy",TN);const NN=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],zi=fe("cpu",NN);const AN=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ri=fe("database",AN);const _N=[["path",{d:"M11.25 16.25h1.5L12 17z",key:"w7jh35"}],["path",{d:"M16 14v.5",key:"1lajdz"}],["path",{d:"M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309",key:"u7s9ue"}],["path",{d:"M8 14v.5",key:"1nzgdb"}],["path",{d:"M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5",key:"v8hric"}]],DN=fe("dog",_N);const zN=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],lu=fe("download",zN);const RN=[["path",{d:"M10 11h.01",key:"d2at3l"}],["path",{d:"M14 6h.01",key:"k028ub"}],["path",{d:"M18 6h.01",key:"1v4wsw"}],["path",{d:"M6.5 13.1h.01",key:"1748ia"}],["path",{d:"M22 5c0 9-4 12-6 12s-6-3-6-12c0-2 2-3 6-3s6 1 6 3",key:"172yzv"}],["path",{d:"M17.4 9.9c-.8.8-2 .8-2.8 0",key:"1obv0w"}],["path",{d:"M10.1 7.1C9 7.2 7.7 7.7 6 8.6c-3.5 2-4.7 3.9-3.7 5.6 4.5 7.8 9.5 8.4 11.2 7.4.9-.5 1.9-2.1 1.9-4.7",key:"rqjl8i"}],["path",{d:"M9.1 16.5c.3-1.1 1.4-1.7 2.4-1.4",key:"1mr6wy"}]],ON=fe("drama",RN);const $N=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Z1=fe("external-link",$N);const FN=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],IN=fe("eye-off",FN);const LN=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],BN=fe("eye",LN);const PN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],HN=fe("file-code",PN);const UN=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Ws=fe("file-text",UN);const GN=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],Q1=fe("flame",GN);const qN=[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]],KN=fe("folder-git-2",qN);const YN=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],om=fe("folder-open",YN);const VN=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],WN=fe("folder",VN);const XN=[["path",{d:"M10.5 3 8 9l4 13 4-13-2.5-6",key:"b3dvk1"}],["path",{d:"M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z",key:"7w4byz"}],["path",{d:"M2 9h20",key:"16fsjt"}]],ZN=fe("gem",XN);const QN=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],La=fe("git-branch",QN);const JN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],J1=fe("globe",JN);const e3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],t3=fe("grid-3x3",e3);const n3=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],o3=fe("grip-vertical",n3);const a3=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],ev=fe("hard-drive",a3);const s3=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],r3=fe("hash",s3);const i3=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],l3=fe("heart",i3);const c3=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],u3=fe("hexagon",c3);const d3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],p3=fe("image",d3);const f3=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],m3=fe("info",f3);const h3=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],g3=fe("key-round",h3);const y3=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],x3=fe("layers",y3);const b3=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],tv=fe("layout-grid",b3);const v3=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],nv=fe("library",v3);const k3=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Uc=fe("lightbulb",k3);const w3=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Cx=fe("list-ordered",w3);const S3=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pt=fe("loader-circle",S3);const M3=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],C3=fe("mail",M3);const E3=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],j3=fe("map",E3);const T3=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],N3=fe("maximize-2",T3);const A3=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],_3=fe("message-square",A3);const D3=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],z3=fe("mic",D3);const R3=[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]],O3=fe("microscope",R3);const $3=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],ov=fe("minimize-2",$3);const F3=[["path",{d:"M5 12h14",key:"1ays0h"}]],I3=fe("minus",F3);const L3=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],B3=fe("monitor",L3);const P3=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],av=fe("moon",P3);const H3=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],sv=fe("package",H3);const U3=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],rv=fe("palette",U3);const G3=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],q3=fe("panels-top-left",G3);const K3=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],iv=fe("pen-tool",K3);const Y3=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Ex=fe("pencil-line",Y3);const V3=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],lv=fe("play",V3);const W3=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],cv=fe("plug-zap",W3);const X3=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],na=fe("plug",X3);const Z3=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],bt=fe("plus",Z3);const Q3=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],J3=fe("presentation",Q3);const e4=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],t4=fe("rocket",e4);const n4=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],am=fe("rotate-ccw",n4);const o4=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],jx=fe("rotate-cw",o4);const a4=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],sm=fe("save",a4);const s4=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],cu=fe("search",s4);const r4=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],i4=fe("send",r4);const l4=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],c4=fe("server",l4);const u4=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],rm=fe("settings",u4);const d4=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],im=fe("shield",d4);const p4=[["path",{d:"M16 10a4 4 0 0 1-8 0",key:"1ltviw"}],["path",{d:"M3.103 6.034h17.794",key:"awc11p"}],["path",{d:"M3.4 5.467a2 2 0 0 0-.4 1.2V20a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6.667a2 2 0 0 0-.4-1.2l-2-2.667A2 2 0 0 0 17 2H7a2 2 0 0 0-1.6.8z",key:"o988cm"}]],f4=fe("shopping-bag",p4);const m4=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],Pa=fe("sparkles",m4);const h4=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],uv=fe("square",h4);const g4=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],y4=fe("star",g4);const x4=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],dv=fe("sun",x4);const b4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],uu=fe("target",b4);const v4=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Ks=fe("terminal",v4);const k4=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],du=fe("trash-2",k4);const w4=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],pv=fe("triangle-alert",w4);const S4=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],M4=fe("triangle",S4);const C4=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],fv=fe("upload",C4);const E4=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],mv=fe("users",E4);const j4=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],T4=fe("wand-sparkles",j4);const N4=[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]],A4=fe("waves",N4);const _4=[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]],D4=fe("waypoints",_4);const z4=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],R4=fe("workflow",z4);const O4=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],hv=fe("wrench",O4);const $4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Tt=fe("x",$4);const F4=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],pn=fe("zap",F4);function Rn({options:e,value:n,onChange:a,label:s,placeholder:i="Select...",size:l="md"}){const d=we(),[p,f]=z.useState(!1),[h,g]=z.useState({x:0,y:0,w:0}),x=z.useRef(null),b=e.find(w=>w.value===n),v={sm:28,md:32};z.useEffect(()=>{if(!p)return;const w=()=>f(!1);return document.addEventListener("click",w),()=>document.removeEventListener("click",w)},[p]);const k=()=>{if(!x.current)return;const w=x.current.getBoundingClientRect();g({x:w.left,y:w.bottom+4,w:w.width}),f(!p)};return c.jsxs("div",{className:"flex flex-col gap-1",children:[s&&c.jsx("label",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:d.textMuted,fontFamily:"'Geist Mono', monospace"},children:s}),c.jsxs("button",{ref:x,type:"button",onClick:w=>{w.stopPropagation(),k()},className:"flex items-center justify-between gap-2 w-full rounded-lg cursor-pointer border outline-none nodrag",style:{height:v[l],padding:"0 10px",fontSize:13,fontFamily:"'Geist Mono', monospace",background:d.inputBg,borderColor:d.border,color:b?d.textPrimary:d.textMuted},children:[c.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[b?.icon,b?.label||i]}),c.jsx(Ln,{size:12,style:{color:d.textDim,transform:p?"rotate(180deg)":"none",transition:"transform 0.15s"}})]}),p&&ou.createPortal(c.jsx("div",{className:"fixed z-[250] rounded-lg overflow-hidden py-1",style:{left:h.x,top:h.y,width:h.w,background:d.surfaceElevated,border:`1px solid ${d.border}`,boxShadow:`0 8px 24px ${d.isDark?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.12)"}`,maxHeight:200,overflowY:"auto"},onClick:w=>w.stopPropagation(),children:e.map(w=>c.jsxs("button",{type:"button",onClick:()=>{a(w.value),f(!1)},className:"flex items-center gap-2 w-full px-3 py-1.5 text-[13px] text-left cursor-pointer border-none bg-transparent",style:{fontFamily:"'Geist Mono', monospace",color:w.value===n?"#FE5000":d.textSecondary,background:w.value===n?"#FE500008":"transparent"},onMouseEnter:j=>j.currentTarget.style.background=d.isDark?"#ffffff08":"#00000005",onMouseLeave:j=>j.currentTarget.style.background=w.value===n?"#FE500008":"transparent",children:[w.icon,c.jsx("span",{className:"flex-1 truncate",children:w.label}),w.value===n&&c.jsx(jt,{size:10})]},w.value))}),document.body)]})}const fo=[{id:"anthropic",name:"Claude",authMethod:"api-key",status:"disconnected",baseUrl:"https://api.anthropic.com/v1",models:[],docsUrl:"https://docs.anthropic.com/en/api",keyPageUrl:"https://console.anthropic.com/settings/keys",pricingUrl:"https://www.anthropic.com/pricing",icon:"Bot",color:"#D4A574",authHeader:"x-api-key",headerNote:"Uses x-api-key header (not Bearer)"},{id:"openai",name:"OpenAI",authMethod:"api-key",status:"disconnected",baseUrl:"https://api.openai.com/v1",models:[],docsUrl:"https://platform.openai.com/docs",keyPageUrl:"https://platform.openai.com/api-keys",pricingUrl:"https://openai.com/pricing",icon:"Sparkles",color:"#10A37F",authHeader:"bearer"},{id:"google",name:"Google AI",authMethod:"api-key",status:"disconnected",baseUrl:"https://generativelanguage.googleapis.com/v1beta",models:[],docsUrl:"https://ai.google.dev/docs",keyPageUrl:"https://aistudio.google.com/app/apikey",pricingUrl:"https://ai.google.dev/pricing",icon:"Gem",color:"#4285F4",authHeader:"query-param",headerNote:"Uses ?key= query parameter"},{id:"claude-agent-sdk",name:"Claude (Agent SDK)",authMethod:"claude-agent-sdk",status:"disconnected",baseUrl:"",apiKey:"",models:[],docsUrl:"https://docs.anthropic.com/en/docs/claude-code/sdk",keyPageUrl:"",icon:"Terminal",color:"#D4A574",authHeader:"bearer",headerNote:"Zero-config — authenticates via Claude Code login"},{id:"openrouter",name:"OpenRouter",authMethod:"api-key",status:"disconnected",baseUrl:"https://openrouter.ai/api/v1",models:[],docsUrl:"https://openrouter.ai/docs",keyPageUrl:"https://openrouter.ai/keys",pricingUrl:"https://openrouter.ai/models",icon:"Route",color:"#6366F1",authHeader:"bearer",headerNote:"HTTP-Referer header recommended"}],gv="modular-providers";function Tx(e){const n=e instanceof Error?e.message:String(e);return/failed to fetch|networkerror|load failed/i.test(n)?"Cannot reach backend API. Start server with `npm run server` (port 4800).":n}function I4(e,n){const a=(n||"").trim().replace(/\/+$/,"");return a&&((e==="openai"||a.includes("api.openai.com"))&&!a.endsWith("/v1")?`${a}/v1`:a)}let Vr=null,Jp=0;const L4=3e4,za=new Set,ef=new Map;let tf=!1;async function bi(){const e=Date.now();if(Vr!==null&&e-Jp<L4)return Vr;try{Vr=(await fetch(`${Ae}/providers`,{method:"GET",signal:AbortSignal.timeout(2e3)})).ok,Jp=e}catch{Vr=!1,Jp=e}return Vr}async function lm(e){if(!await bi()){za.add(e.id);return}const a=e.id.includes("anthropic")||e.id==="claude-agent-sdk"?"anthropic":e.id.includes("google")?"google":e.id.includes("openrouter")?"openrouter":e.id.includes("openai")?"openai":"custom",s=l=>!l||/^[•]+$/.test(l),i={baseUrl:e.baseUrl,authMethod:e.authMethod,name:e.name,type:a};s(e.apiKey)||(i.apiKey=e.apiKey),s(e.accessToken)||(i.accessToken=e.accessToken),await fetch(`${Ae}/providers/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),za.delete(e.id)}function hc(e,n){const a=ef.get(n);a&&clearTimeout(a);const s=setTimeout(()=>{const i=e.find(l=>l.id===n);i&&lm(i).catch(()=>{za.add(n)}).finally(()=>{ef.delete(n)})},400);ef.set(n,s)}async function jf(e){if(!(tf||za.size===0)){tf=!0;try{if(!await bi())return;const a=[...za];for(const s of a){const i=e.find(l=>l.id===s);if(!i){za.delete(s);continue}try{await lm(i)}catch{}}}finally{tf=!1}}}function B4(){try{const e=localStorage.getItem(gv);if(!e)return fo;const n=JSON.parse(e);return fo.map(a=>{const s=n.find(l=>l.id===a.id);if(!s)return a;const i=s.authMethod??a.authMethod;return{...a,authMethod:i,apiKey:a.apiKey,accessToken:a.accessToken,baseUrl:s.baseUrl??a.baseUrl,status:s.status??a.status}}).concat(n.filter(a=>!fo.some(s=>s.id===a.id)).map(a=>{const s=a.authMethod??"api-key";return{...fo[fo.length-1],...a,authMethod:s,apiKey:"",accessToken:"",id:a.id??"custom-"+Date.now(),name:a.name??"Custom",status:a.status??"disconnected",models:a.models??[{id:"custom-model",label:"Custom Model"}]}}))}catch{return fo}}const P4=new Set(fo.map(e=>e.id));function Et(e){const n=e.map(a=>{const s=P4.has(a.id);return{id:a.id,name:a.name,baseUrl:a.baseUrl,status:a.status,authMethod:a.authMethod,models:s?void 0:a.models,authHeader:s?void 0:a.authHeader,icon:s?void 0:a.icon,color:s?void 0:a.color,docsUrl:s?void 0:a.docsUrl,keyPageUrl:s?void 0:a.keyPageUrl,headerNote:s?void 0:a.headerNote}});localStorage.setItem(gv,JSON.stringify(n))}const Je=qt((e,n)=>({providers:B4(),selectedProviderId:"",testing:{},setProviderKey:(a,s)=>{e(i=>{const l=i.providers.map(d=>{if(d.id!==a)return d;const p=!!s.trim(),f=d.authMethod==="oauth"?d.status:p?"configured":"disconnected";return{...d,apiKey:s,status:f}});return Et(l),hc(l,a),{providers:l}})},setProviderAccessToken:(a,s)=>{e(i=>{const l=i.providers.map(d=>d.id===a?{...d,accessToken:s,status:s.trim()?"configured":d.status}:d);return Et(l),hc(l,a),{providers:l}})},setProviderAuthMethod:(a,s)=>{e(i=>{const l=i.providers.map(d=>{if(d.id!==a)return d;const p=!!d.apiKey?.trim();return{...d,authMethod:s,status:s==="oauth"||p?"configured":"disconnected",lastError:void 0}});return Et(l),hc(l,a),{providers:l}})},setProviderBaseUrl:(a,s)=>{e(i=>{const l=I4(a,s),d=i.providers.map(p=>p.id===a?{...p,baseUrl:l}:p);return Et(d),hc(d,a),{providers:d}})},setProviderStatus:(a,s)=>{e(i=>{const l=i.providers.map(d=>d.id===a?{...d,status:s}:d);return Et(l),{providers:l}})},setProviderModels:(a,s)=>{e(i=>{const l=i.providers.map(d=>d.id===a?{...d,models:s}:d);return Et(l),{providers:l}})},getProviderForModel:a=>n().providers.find(s=>(Array.isArray(s.models)?s.models:[]).some(i=>i.id===a)),getActiveProvider:()=>n().providers.find(a=>a.id===n().selectedProviderId),getAllModels:()=>n().providers.flatMap(a=>{const s=Array.isArray(a.models)?a.models:[];return s.length===0?[]:a.status==="connected"||a.status==="configured"?s.map(i=>({id:i.id,label:i.label,providerId:a.id,providerName:a.name,providerColor:a.color})):[]}),selectProvider:a=>e({selectedProviderId:a}),testConnection:async a=>{e(s=>({testing:{...s.testing,[a]:!0}}));try{const s=n().providers.find(l=>l.id===a);if(s?.authMethod==="oauth"&&!s.apiKey?.trim()){const l='Codex sign-in not completed yet. Use "Sign in with Codex" first.';return e(d=>({testing:{...d.testing,[a]:!1},providers:d.providers.map(p=>p.id===a?{...p,status:"error",lastError:l}:p)})),Et(n().providers),{ok:!1,error:l}}if(s?.authMethod==="claude-agent-sdk")try{const l=await fetch(`${Ae}/agent-sdk/status`);if(l.status===429)return e(x=>({testing:{...x.testing,[a]:!1}})),{ok:!1,error:"Rate limited — try again in a moment"};const d=await l.json(),p=d?.data,f=p?.authenticated===!0,h=f&&p?.email?`${p.displayName||"User"} (${p.email})`:void 0,g=Array.isArray(p?.models)?p.models.map(x=>({id:x,label:x})):[];return e(x=>({testing:{...x.testing,[a]:!1},providers:x.providers.map(b=>b.id===a?{...b,status:f?"connected":"error",models:g.length>0?g:b.models,lastError:f?h:p?.error||"Not authenticated"}:b)})),Et(n().providers),f?{ok:!0,models:g.map(x=>x.id)}:{ok:!1,error:d?.data?.error||"Not authenticated — run `claude` in your terminal first"}}catch(l){const d=Tx(l);return e(p=>({testing:{...p.testing,[a]:!1},providers:p.providers.map(f=>f.id===a?{...f,status:"error",lastError:d}:f)})),Et(n().providers),{ok:!1,error:d}}if(await bi()){const l=n().providers.find(g=>g.id===a),d=l?.apiKey&&!/^[•]+$/.test(l.apiKey);l&&d&&await fetch(`${Ae}/providers/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l.apiKey,baseUrl:l.baseUrl})});const p={baseUrl:l?.baseUrl||""};d&&(p.apiKey=l.apiKey);const h=await(await fetch(`${Ae}/providers/${a}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)})).json();if(h.status==="ok"){const g=h.data?.models??h.models??[],x=g.map(b=>({id:b,label:b}));return e(b=>({testing:{...b.testing,[a]:!1},providers:b.providers.map(v=>v.id===a?{...v,status:"connected",models:x.length?x:v.models,lastError:void 0}:v)})),Et(n().providers),{ok:!0,models:g}}else return e(g=>({testing:{...g.testing,[a]:!1},providers:g.providers.map(x=>x.id===a?{...x,status:"error",lastError:h.error}:x)})),Et(n().providers),{ok:!1,error:h.error}}else return n().providers.find(d=>d.id===a)?.apiKey?(e(d=>({testing:{...d.testing,[a]:!1},providers:d.providers.map(p=>p.id===a?{...p,status:"connected",lastError:void 0}:p)})),Et(n().providers),{ok:!0}):(e(d=>({testing:{...d.testing,[a]:!1}})),{ok:!1,error:"No API key configured"})}catch(s){const i=Tx(s);return e(l=>({testing:{...l.testing,[a]:!1},providers:l.providers.map(d=>d.id===a?{...d,status:"error",lastError:i}:d)})),Et(n().providers),{ok:!1,error:i}}},saveProvider:async a=>{const s=n().providers,i=s.find(l=>l.id===a);if(i){Et(s);try{await lm(i)}catch{za.add(a)}jf(n().providers).catch(()=>{})}},deleteProvider:a=>{e(s=>{const i=s.providers.filter(l=>l.id!==a);return Et(i),{providers:i}}),bi().then(s=>{s&&fetch(`${Ae}/providers/${a}`,{method:"DELETE"}).catch(()=>{})})},addCustomProvider:()=>{const s={id:"custom-"+Date.now(),name:"Custom Provider",authMethod:"api-key",status:"disconnected",baseUrl:"http://localhost:11434/v1",models:[{id:"custom-model",label:"Custom Model"}],docsUrl:"",keyPageUrl:"",icon:"Server",color:"#888888",authHeader:"bearer",headerNote:"For Ollama, vLLM, or any OpenAI-compatible API"};e(i=>{const l=[...i.providers,s];return Et(l),{providers:l}})},loadFromBackend:async()=>{try{const a=await fetch(`${Ae}/providers`);if(!a.ok)return;const s=await a.json(),i=Array.isArray(s)?s:Array.isArray(s?.data)?s.data:[];if(i.length>0){const l=fo.map(v=>{const k=i.find(T=>T.id===v.id);if(!k)return v;const w=!!k.hasStoredKey,j=!!k.hasStoredAccessToken;return{...v,...k,name:v.id==="anthropic"?"Claude":k.name||v.name,apiKey:w?"":v.apiKey,accessToken:j?"":v.accessToken,_hasStoredKey:w,_hasStoredAccessToken:j,status:w||j?"configured":k.status||v.status,models:Array.isArray(k.models)?k.models:v.models}}),d=i.filter(v=>!fo.some(k=>k.id===v.id)).map(v=>({...v,models:Array.isArray(v.models)?v.models:[]})),p=[...l,...d],f=n().selectedProviderId,h=p.find(v=>v.id===f),g=!!(h&&(h.status==="connected"||h.status==="configured")&&Array.isArray(h.models)&&h.models.length>0),x=p.find(v=>(v.status==="connected"||v.status==="configured")&&Array.isArray(v.models)&&v.models.length>0),b=g?f:x?.id||"";e({providers:p,selectedProviderId:b}),Et(n().providers),await jf(n().providers)}}catch{}}}));bi().then(e=>{e&&(Je.getState().loadFromBackend(),jf(Je.getState().providers).catch(()=>{}))});function pu(){const e=re.getState(),n=[];e.agentMeta.name&&n.push(`Agent: ${e.agentMeta.name}`),e.agentMeta.description&&n.push(`Description: ${e.agentMeta.description}`),e.instructionState.persona&&n.push(`Persona: ${e.instructionState.persona}`),e.instructionState.objectives.primary&&n.push(`Primary objective: ${e.instructionState.objectives.primary}`),e.instructionState.constraints.scopeDefinition&&n.push(`Scope: ${e.instructionState.constraints.scopeDefinition}`);const a=e.skills.filter(i=>i.enabled).map(i=>i.name);a.length&&n.push(`Skills: ${a.join(", ")}`);const s=e.mcpServers.filter(i=>i.enabled).map(i=>i.name);return s.length&&n.push(`MCP servers: ${s.join(", ")}`),n.join(`
|
|
19
|
+
`)}const cm={workflow:`You are an expert AI agent architect. Given the agent context below, generate a workflow — a sequence of 3-8 steps the agent should follow for every request.
|
|
20
|
+
|
|
21
|
+
Output ONLY a JSON array:
|
|
22
|
+
[{"label": "<step name>", "action": "<what the agent does>", "condition": false, "loop": false}]
|
|
23
|
+
|
|
24
|
+
Rules:
|
|
25
|
+
- Each step should be concrete and actionable
|
|
26
|
+
- Include verification/review steps where appropriate
|
|
27
|
+
- If the agent uses tools, reference them in the action text
|
|
28
|
+
- Steps should form a logical flow (gather → analyze → synthesize → verify → output)`,memory:`You are an expert AI agent architect. Given the agent context below, generate memory configuration and initial facts.
|
|
29
|
+
|
|
30
|
+
Output ONLY a JSON object:
|
|
31
|
+
{
|
|
32
|
+
"maxMessages": <10-50>,
|
|
33
|
+
"summarizeAfter": <5-25>,
|
|
34
|
+
"summarizeEnabled": <true|false>,
|
|
35
|
+
"suggestedFacts": ["<pre-loaded fact relevant to the agent's domain>"]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Rules:
|
|
39
|
+
- Conversational agents need higher maxMessages and summarization
|
|
40
|
+
- One-shot tools can have lower limits and no summarization
|
|
41
|
+
- Facts should be domain-relevant knowledge the agent should always have
|
|
42
|
+
- Generate 2-5 facts that help the agent do its job better`,knowledge:`You are an expert AI agent architect. Given the agent context below, suggest knowledge sources this agent should have access to.
|
|
43
|
+
|
|
44
|
+
Output ONLY a JSON array:
|
|
45
|
+
[{"name": "<source name>", "type": "<ground-truth|signal|evidence|framework|hypothesis|artifact>", "description": "<what it contains>"}]
|
|
46
|
+
|
|
47
|
+
Rules:
|
|
48
|
+
- Suggest 3-6 knowledge sources
|
|
49
|
+
- Use appropriate types: ground-truth for authoritative docs, signal for real-time data, evidence for research, framework for methodologies
|
|
50
|
+
- Be specific to the agent's domain`};async function fu(e,n){const a=Je.getState(),s=a.providers.find(l=>l.id===a.selectedProviderId);if(!s)throw new Error("No provider configured — add one in Settings");const i=typeof s.models?.[0]=="object"?s.models[0].id:s.models?.[0]||"claude-sonnet-4-20250514";return s.authMethod==="claude-agent-sdk"?Vc({prompt:n,model:i,systemPrompt:e,maxTurns:1}):Yc({providerId:s.id,model:i,messages:[{role:"system",content:e},{role:"user",content:n}],temperature:.4,maxTokens:2048})}function mu(e){try{return JSON.parse(e)}catch{}const n=e.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)try{return JSON.parse(n[1].trim())}catch{}const a=e.match(/[\[{][\s\S]*[\]}]/);if(a)try{return JSON.parse(a[0])}catch{}throw new Error("Could not parse LLM response as JSON")}async function H4(e){const n=pu(),a=e.map((l,d)=>`${d+1}. ${l}`).join(`
|
|
51
|
+
`),s=`You are an expert AI agent architect. The user has sketched out workflow steps for their agent. Refine them into proper, actionable workflow steps.
|
|
52
|
+
|
|
53
|
+
User's draft steps:
|
|
54
|
+
${a}
|
|
55
|
+
|
|
56
|
+
Agent context:
|
|
57
|
+
${n||"(no agent identity set yet)"}
|
|
58
|
+
|
|
59
|
+
Output ONLY a JSON array:
|
|
60
|
+
[{"label": "<clear step name>", "action": "<specific what the agent does>", "condition": false, "loop": false}]
|
|
61
|
+
|
|
62
|
+
Rules:
|
|
63
|
+
- Keep the user's intent and ordering — don't add unrelated steps
|
|
64
|
+
- Make labels concise and action-oriented
|
|
65
|
+
- Fill in the "action" field with specific details about HOW the step works
|
|
66
|
+
- You may split or merge steps if it makes the flow clearer
|
|
67
|
+
- Add verification/output steps if the user forgot them`,i=await fu(s,a);return mu(i)}async function um(){const e=pu();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await fu(cm.workflow,e);return mu(n)}async function yv(){const e=pu();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await fu(cm.memory,e);return mu(n)}async function U4(){const e=pu();if(!e)throw new Error("Add agent identity/persona first — the generator needs context");const n=await fu(cm.knowledge,e);return mu(n)}const G4=Object.freeze(Object.defineProperty({__proto__:null,generateKnowledge:U4,generateMemoryConfig:yv,generateWorkflow:um,refineWorkflowSteps:H4},Symbol.toStringTag,{value:"Module"}));function xv(e){if(e.length===0)return"";const n=["## Workflow","Follow these steps for every request:",""];return e.forEach((a,s)=>{const i=s+1,l=a.label||`Step ${i}`;let d=`${i}. **${l}:** ${a.action}`;if(a.condition==="if"&&a.conditionText?d+=` *(if ${a.conditionText})*`:a.condition==="unless"&&a.conditionText&&(d+=` *(unless ${a.conditionText})*`),a.tool&&(d+=` [tool: ${a.tool}]`),a.loopTarget){const p=e.findIndex(f=>f.id===a.loopTarget);p>=0&&(d+=` → loop to step ${p+1} (max ${a.loopMax}×)`)}n.push(d)}),n.join(`
|
|
68
|
+
`)}z.memo(function(){const n=we(),[a,s]=z.useState(null),[i,l]=z.useState(null),d=re(A=>A.workflowSteps),p=re(A=>A.updateWorkflowSteps),[f,h]=z.useState(!1),g=z.useCallback(async()=>{if(!f){h(!0);try{const _=(await um()).map((F,B)=>({id:`gen-${Date.now()}-${B}`,label:F.label,action:F.action,tool:"",condition:F.condition?"if":"always",conditionText:"",loopTarget:"",loopMax:F.loop?3:0}));p(_)}catch{}finally{h(!1)}}},[f,p]),b=Xe(A=>A.servers).filter(A=>A.status==="connected"),v=re(A=>A.channels),k=z.useMemo(()=>v.filter(A=>A.type==="skill"),[v]),w=[{value:"",label:"-- no tool --"},...b.map(A=>({value:`mcp:${A.id}`,label:`${A.name}`})),...k.map(A=>({value:`skill:${A.name}`,label:`${A.name}`}))],j=z.useCallback((A,_)=>{const F=[...d];F[A]={...F[A],..._},p(F)},[d,p]),T=z.useCallback(A=>{p(d.filter((_,F)=>F!==A)),i===A&&l(null)},[d,p,i]),E=z.useCallback(()=>{const A={id:`step-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:"",action:"",tool:"",condition:"always",conditionText:"",loopTarget:"",loopMax:3};p([...d,A]),l(d.length)},[d,p]),S=z.useCallback((A,_)=>{if(_<0||_>=d.length)return;const F=[...d],[B]=F.splice(A,1);F.splice(_,0,B),p(F)},[d,p]),M={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Mono', monospace",fontSize:13},$={width:8,height:8,border:"none",borderRadius:"50%"};return c.jsxs("div",{className:"rounded-lg overflow-visible",style:{background:n.surfaceOpaque,border:`1px solid ${n.border}`,boxShadow:`0 2px 12px ${n.isDark?"rgba(0,0,0,0.5)":"rgba(0,0,0,0.08)"}`,width:"100%"},children:[c.jsx(qs,{type:"target",position:Se.Left,id:"workflow-in",style:{...$,background:"#e67e22",top:"50%",left:-4}}),c.jsx(qs,{type:"source",position:Se.Right,id:"workflow-out",style:{...$,background:"#9b59b6",top:"50%",right:-4}}),c.jsxs("div",{className:"flex flex-col overflow-visible rounded-lg",children:[c.jsxs("div",{className:"flex items-center gap-2 px-5 shrink-0 select-none",style:{height:40,background:n.surfaceElevated,borderBottom:`1px solid ${n.border}`},children:[c.jsx(Cx,{size:13,style:{color:"#e67e22"}}),c.jsx("span",{className:"text-[12px] font-bold tracking-widest uppercase",style:{fontFamily:"'Geist Mono', monospace",color:n.textPrimary},children:"Workflow"}),c.jsxs("span",{className:"text-[13px] ml-1",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:[d.length," ",d.length===1?"step":"steps"]}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{type:"button",onClick:g,disabled:f,className:"flex items-center gap-1 text-[13px] px-2 py-0.5 rounded cursor-pointer border-none nodrag",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:f?.6:1},children:[f?c.jsx(pt,{size:9,className:"animate-spin motion-reduce:animate-none"}):c.jsx(Pa,{size:9}),"Generate"]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto nowheel nodrag",style:{maxHeight:700},children:c.jsxs("div",{className:"flex flex-col items-center py-3 px-5",children:[c.jsx("div",{className:"flex items-center justify-center rounded-full mb-1",style:{width:28,height:28,background:"#e67e2215",border:"2px solid #e67e2240"},children:c.jsx(WT,{size:12,style:{color:"#e67e22"}})}),d.map((A,_)=>{const F=i===_,B=A.condition!=="always",G=!!A.tool,O=!!A.loopTarget,K=O?d.findIndex(V=>V.id===A.loopTarget):-1;return c.jsxs("div",{className:"flex flex-col items-center w-full",children:[c.jsx("div",{style:{width:2,height:16,background:"#e67e2230"}}),c.jsxs("div",{className:"relative w-full rounded-lg",style:{background:a===_?"#FE500008":n.surfaceElevated,border:`1.5px solid ${F?"#e67e2260":n.borderSubtle}`,maxWidth:310},children:[c.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 cursor-pointer",onClick:()=>l(F?null:_),style:{borderBottom:F?`1px solid ${n.borderSubtle}`:"none"},children:[c.jsx("button",{type:"button",className:"p-0 border-none bg-transparent cursor-grab nodrag",style:{color:n.textDim},draggable:!0,onDragStart:V=>{V.stopPropagation(),s(_)},onDragEnd:()=>s(null),onDragOver:V=>{V.preventDefault(),a!==null&&a!==_&&S(a,_)},onClick:V=>V.stopPropagation(),children:c.jsx(o3,{size:11})}),c.jsx("span",{className:"text-[12px] shrink-0 w-5 h-5 flex items-center justify-center rounded-full font-bold",style:{background:"#e67e2218",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontSize:13},children:_+1}),c.jsx("span",{className:"flex-1 text-[13px] font-semibold truncate",style:{color:A.label?n.textPrimary:n.textMuted,fontFamily:"'Geist Sans', sans-serif"},children:A.label||`Step ${_+1}`}),B&&c.jsxs("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#3498db15",color:"#3498db"},children:[c.jsx(La,{size:8}),A.condition]}),G&&c.jsx("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#2ecc7115",color:"#2ecc71"},children:c.jsx(hv,{size:8})}),O&&c.jsx("span",{className:"flex items-center gap-0.5 text-[12px] px-1.5 py-0.5 rounded",style:{background:"#9b59b615",color:"#9b59b6"},children:c.jsx(jx,{size:8})}),c.jsx("button",{type:"button",onClick:V=>{V.stopPropagation(),T(_)},className:"p-0.5 border-none bg-transparent cursor-pointer nodrag",style:{color:n.textDim},children:c.jsx(Tt,{size:10})})]}),!F&&A.action&&c.jsx("div",{className:"px-2.5 pb-1.5",children:c.jsx("span",{className:"text-[12px]",style:{color:n.textMuted},children:A.action})}),F&&c.jsxs("div",{className:"flex flex-col gap-1.5 px-2.5 py-2 nodrag",children:[c.jsx($s,{value:A.label,onChange:V=>j(_,{label:V.target.value}),placeholder:`Step ${_+1} label`}),c.jsx(Aa,{value:A.action,onChange:V=>j(_,{action:V.target.value}),placeholder:"What the agent does in this step...",style:{minHeight:40}}),c.jsxs("div",{className:"flex gap-1.5",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Rn,{options:w,value:A.tool,onChange:V=>j(_,{tool:V}),size:"sm"})}),c.jsx("div",{style:{width:90},children:c.jsx(Rn,{options:[{value:"always",label:"Always"},{value:"if",label:"If..."},{value:"unless",label:"Unless..."}],value:A.condition,onChange:V=>j(_,{condition:V}),size:"sm"})})]}),A.condition!=="always"&&c.jsx($s,{value:A.conditionText,onChange:V=>j(_,{conditionText:V.target.value}),placeholder:`${A.condition==="if"?"If":"Unless"} condition...`}),d.length>1&&c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx(jx,{size:9,style:{color:n.textDim}}),c.jsx("div",{className:"flex-1",children:c.jsx(Rn,{options:[{value:"",label:"No loop"},...d.filter((V,P)=>P!==_).map(V=>({value:V.id,label:`Step ${d.indexOf(V)+1}${V.label?`: ${V.label}`:""}`}))],value:A.loopTarget||"",onChange:V=>j(_,{loopTarget:V}),size:"sm"})}),A.loopTarget&&c.jsxs("span",{className:"flex items-center gap-0.5 text-[13px]",style:{color:n.textDim},children:["max ",c.jsx($s,{type:"number",min:1,max:10,value:A.loopMax,onChange:V=>j(_,{loopMax:parseInt(V.target.value)||3}),style:{width:32,textAlign:"center",padding:"2px 2px",...M,fontSize:13}}),"x"]})]})]}),O&&K>=0&&K<_&&c.jsx("div",{className:"absolute flex items-center justify-center",style:{right:-28,top:"50%",transform:"translateY(-50%)",width:22,height:22,borderRadius:"50%",background:"#9b59b610",border:"1px dashed #9b59b640"},children:c.jsxs("span",{className:"text-[7px] font-bold",style:{color:"#9b59b6",fontFamily:"'Geist Mono', monospace"},children:[A.loopMax,"x"]})})]})]},A.id)}),d.length>0&&c.jsx("div",{style:{width:2,height:16,background:"#e67e2230"}}),c.jsxs("button",{type:"button",onClick:E,className:"flex items-center justify-center gap-1.5 text-[12px] px-5 py-3 rounded-lg cursor-pointer border-none nodrag",style:{background:"#e67e2210",border:"1.5px dashed #e67e2240",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[c.jsx(bt,{size:12})," ADD STEP"]}),d.length===0&&c.jsxs("div",{className:"px-4 py-4 text-center text-[12px]",style:{color:n.textFaint},children:[c.jsx(Cx,{size:18,style:{margin:"0 auto 6px",opacity:.3}}),c.jsx("div",{children:"Define step-by-step reasoning plan"}),c.jsx("div",{style:{color:n.textMuted,marginTop:4,fontSize:13},children:"Visual flowchart builder"})]}),d.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{style:{width:2,height:10,background:"#e67e2220"}}),c.jsx("div",{className:"flex items-center justify-center rounded-full",style:{width:20,height:20,background:"#e67e2210",border:"2px solid #e67e2230"},children:c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#e67e2240"}})})]})]})})]})]})});function Ye(e){if(!e)return 0;const n=e.match(/```[\s\S]*?```/g),a=n?n.reduce((i,l)=>i+l.length,0):0,s=e.length-a;return Math.ceil(s/4+a/2.5)}function Tf(e){const n=e.match(/^[^\n]*?[.!?](?:\s|$)/);return n?n[0].trim():e.split(`
|
|
69
|
+
`)[0].slice(0,200)}function Nf(e){const n=e.split(/\n\s*\n/)[0];return n?n.trim().slice(0,1e3):""}function Ys(e,n){return`n${e}-${n}`}function vi(e){let n=e.tokens;for(const a of e.children)n+=vi(a);return e.totalTokens=n,n}function hu(e){let n=1;for(const a of e.children)n+=hu(a);return n}function Vs(e,n){const a=n.split(`
|
|
70
|
+
`);let s=0;const i={nodeId:Ys(0,s++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]},l=[i];let d=[],p=0;function f(g){const x=d.join(`
|
|
71
|
+
`).trim(),b=l[l.length-1];b.text=x,b.tokens=Ye(x),b.meta?(b.meta.lineEnd=g,b.meta.firstSentence=Tf(x),b.meta.firstParagraph=Nf(x)):x&&(b.meta={lineStart:p,lineEnd:g,firstSentence:Tf(x),firstParagraph:Nf(x),sourceType:"markdown"}),d=[]}const h=/^(#{1,6})\s+(.+)$/;for(let g=0;g<a.length;g++){const x=a[g],b=h.exec(x);if(b){f(g-1);const v=b[1].length,k=b[2].trim(),w={nodeId:Ys(v,s++),title:k,depth:v,text:"",tokens:0,totalTokens:0,children:[],meta:{lineStart:g,lineEnd:g,firstSentence:"",firstParagraph:"",sourceType:"markdown"}};for(;l.length>1&&l[l.length-1].depth>=v;)l.pop();l[l.length-1].children.push(w),l.push(w),p=g+1}else d.push(x)}return f(a.length-1),vi(i),{source:e,sourceType:"markdown",root:i,totalTokens:i.totalTokens,nodeCount:hu(i),created:Date.now()}}function q4(e,n,a="structured"){let s=0;const i={nodeId:Ys(0,s++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]},l=new Map;for(const d of n){const p=d.group||"default";l.has(p)||l.set(p,[]),l.get(p).push(d)}for(const[d,p]of l){const f=p.map(g=>`${g.label}: ${g.value}`).join(`
|
|
72
|
+
`),h={nodeId:Ys(1,s++),title:d==="default"?e:d,depth:1,text:f,tokens:Ye(f),totalTokens:0,children:[],meta:{firstSentence:p[0]?`${p[0].label}: ${p[0].value}`:"",firstParagraph:f.slice(0,1e3),sourceType:a,fieldGroup:d}};i.children.push(h)}return vi(i),{source:e,sourceType:a,root:i,totalTokens:i.totalTokens,nodeCount:hu(i),created:Date.now()}}function K4(e,n,a="chronological",s=10){let i=0;const l={nodeId:Ys(0,i++),title:e,depth:0,text:"",tokens:0,totalTokens:0,children:[]};if(n.length===0)return vi(l),{source:e,sourceType:a,root:l,totalTokens:0,nodeCount:1,created:Date.now()};const d=s*60*1e3;let p=[n[0]];const f=[];for(let h=1;h<n.length;h++)n[h].timestamp-n[h-1].timestamp>d&&(f.push(p),p=[]),p.push(n[h]);f.push(p);for(const h of f){const x=`${new Date(h[0].timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`,b=h.map(k=>k.speaker?`${k.speaker}: ${k.text}`:k.text).join(`
|
|
73
|
+
`),v={nodeId:Ys(1,i++),title:x,depth:1,text:b,tokens:Ye(b),totalTokens:0,children:[],meta:{firstSentence:h[0].text.slice(0,200),firstParagraph:b.slice(0,1e3),sourceType:a,timestamp:h[0].timestamp}};l.children.push(v)}return vi(l),{source:e,sourceType:a,root:l,totalTokens:l.totalTokens,nodeCount:hu(l),created:Date.now()}}function Nx(e,n,a="flat"){const s={nodeId:"n0-0",title:e,depth:0,text:n.trim(),tokens:Ye(n),totalTokens:Ye(n),children:[],meta:{firstSentence:Tf(n),firstParagraph:Nf(n),sourceType:a}};return{source:e,sourceType:a,root:s,totalTokens:s.totalTokens,nodeCount:1,created:Date.now()}}const Y4=300*1e3,wn=qt((e,n)=>({indexes:{},loading:{},errors:{},indexFile:async a=>{const s=n(),i=s.indexes[a];if(i&&!i.stale&&Date.now()-i.fetchedAt<Y4)return i.index;if(s.loading[a])return i?.index??null;e(l=>({loading:{...l.loading,[a]:!0},errors:{...l.errors,[a]:""}}));try{const d=await(await fetch(`${Ae}/knowledge/read?path=${encodeURIComponent(a)}`)).json();if(d.status!=="ok"||!d.data)throw new Error(d.error??"Failed to read file");const p=Vs(a,d.data.content),f={index:p,fetchedAt:Date.now(),stale:!1};return e(h=>({indexes:{...h.indexes,[a]:f},loading:{...h.loading,[a]:!1}})),p}catch(l){const d=l instanceof Error?l.message:"Index failed";return e(p=>({loading:{...p.loading,[a]:!1},errors:{...p.errors,[a]:d}})),null}},getIndex:a=>n().indexes[a]?.index??null,indexFiles:async a=>{await Promise.allSettled(a.map(s=>n().indexFile(s)))},invalidate:a=>{e(s=>{const i=s.indexes[a];return i?{indexes:{...s.indexes,[a]:{...i,stale:!0}}}:s})},clearAll:()=>e({indexes:{},loading:{},errors:{}})}));function bv(e,n,a){if(n===4&&e.depth>0||n===3&&e.depth>a)return null;let s="",i=!1;n===0?s=e.text:n===1?e.children.length===0&&e.meta?.firstParagraph?(s=e.meta.firstParagraph,i=e.text.length>s.length):s=e.text:n===2?(s=e.meta?.firstSentence??"",i=e.text.length>s.length):s="";const l=[];for(const d of e.children){const p=bv(d,n,a);p&&l.push(p)}return{nodeId:e.nodeId,title:e.title,depth:e.depth,text:s,tokens:Ye(s),children:l,truncated:i}}function vv(e){let n=e.tokens+Ye(e.title);for(const a of e.children)n+=vv(a);return n}function ki(e,n,a){const s=Math.max(0,Math.min(4,n));let l=bv(e.root,s,2);l||(l={nodeId:e.root.nodeId,title:e.root.title,depth:0,text:"",tokens:0,children:[],truncated:!0});let d=vv(l);return{source:e.source,filtered:l,totalTokens:d,depthLevel:s,budgetUsed:d,budgetLimit:1/0}}function wi(e){const n=[];e.depth>0&&n.push(`${"#".repeat(e.depth)} ${e.title}`),e.text&&n.push(e.text),e.truncated&&e.depth>0&&n.push(`_[${e.title}: truncated at this depth level]_`);for(const a of e.children)n.push(wi(a));return n.join(`
|
|
74
|
+
|
|
75
|
+
`)}function V4(e,n,a){const s=[],i=e.filter(v=>v.enabled),l=re.getState(),d=l.instructionState,p=l.workflowSteps,f=l.agentMeta,h=[];if(f.name||a?.name){const v=[];v.push(`Name: ${f.name||a?.name||"Assistant"}`),(f.description||a?.description)&&v.push(`Description: ${f.description||a?.description}`),f.avatar&&v.push(`Avatar: ${f.avatar}`),f.tags&&f.tags.length>0&&v.push(`Tags: ${f.tags.join(", ")}`),h.push(`<identity>
|
|
76
|
+
${v.join(`
|
|
77
|
+
`)}
|
|
78
|
+
</identity>`)}if(d.persona||d.objectives.primary){const v=[];if(d.persona&&v.push(`Persona: ${d.persona}`),d.tone!=="neutral"&&v.push(`Tone: ${d.tone}`),d.expertise!==3){const k=["Beginner","Novice","Intermediate","Advanced","Expert"];v.push(`Expertise Level: ${k[d.expertise-1]} (${d.expertise}/5)`)}d.objectives.primary&&(v.push(`Primary Objective: ${d.objectives.primary}`),d.objectives.successCriteria.length>0&&v.push(`Success Criteria:
|
|
79
|
+
${d.objectives.successCriteria.map(k=>`- ${k}`).join(`
|
|
80
|
+
`)}`),d.objectives.failureModes.length>0&&v.push(`Failure Modes to Avoid:
|
|
81
|
+
${d.objectives.failureModes.map(k=>`- ${k}`).join(`
|
|
82
|
+
`)}`)),h.push(`<instructions>
|
|
83
|
+
${v.join(`
|
|
84
|
+
|
|
85
|
+
`)}
|
|
86
|
+
</instructions>`)}const g=[];if(d.constraints.neverMakeUp&&g.push("Never fabricate information or make up facts"),d.constraints.askBeforeActions&&g.push("Ask for permission before taking significant actions"),d.constraints.stayInScope&&g.push(`Stay within the defined scope: ${d.constraints.scopeDefinition||"as specified"}`),d.constraints.useOnlyTools&&g.push("Only use tools and capabilities that are explicitly provided"),d.constraints.limitWords&&g.push(`Keep responses under ${d.constraints.wordLimit} words`),d.constraints.customConstraints&&g.push(`Additional constraints: ${d.constraints.customConstraints}`),g.length>0&&h.push(`<constraints>
|
|
87
|
+
${g.map(v=>`- ${v}`).join(`
|
|
88
|
+
`)}
|
|
89
|
+
</constraints>`),p.length>0){const v=xv(p);h.push(`<workflow>
|
|
90
|
+
${v}
|
|
91
|
+
</workflow>`)}if(i.length>0){const v={},k=["ground-truth","signal","evidence","framework","hypothesis","guideline"];for(const T of i)v[T.knowledgeType]||(v[T.knowledgeType]=[]),v[T.knowledgeType].push(T);const w=wn.getState(),j=[];for(const T of k){const E=v[T];if(!E||E.length===0)continue;const S=Qo[T],M=[];for(const $ of E){const A=Fs[$.depth],_=w.getIndex($.path);if(_){const F=ki(_,0),B=wi(F.filtered);B.trim()?M.push(`<source name="${$.name}" type="${S.label}" depth="${A.label}" tokens="${F.totalTokens}">
|
|
92
|
+
${B}
|
|
93
|
+
</source>`):M.push(`- ${$.name} (${A.label}, title only) [${$.path}]`)}else M.push(`- ${$.name} (${A.label}, ~${Math.round($.baseTokens*A.pct).toLocaleString()} tokens) [${$.path}]`)}j.push(`[${S.label.toUpperCase()}] ${S.instruction}
|
|
94
|
+
${M.join(`
|
|
95
|
+
`)}`)}h.push(`<knowledge>
|
|
96
|
+
${j.join(`
|
|
97
|
+
|
|
98
|
+
`)}
|
|
99
|
+
</knowledge>`)}const x=Xe.getState().getConnectedTools(),b=l.skills.filter(v=>v.enabled);if(x.length>0||b.length>0){const v=[];x.length>0&&(v.push("MCP Tools:"),v.push(...x.map(k=>`- ${k.name}: ${k.description||"No description"}`))),b.length>0&&(v.length>0&&v.push(""),v.push("Skills:"),v.push(...b.map(k=>`- ${k.name}: ${k.description||"No description"}`))),h.push(`<tools>
|
|
100
|
+
${v.join(`
|
|
101
|
+
`)}
|
|
102
|
+
</tools>`)}return h.length>0&&s.push({role:"system",content:h.join(`
|
|
103
|
+
|
|
104
|
+
`)}),s.push({role:"user",content:n||"(no prompt provided)"}),s}const Ax=/(?:^|[\s`"'([<{])([A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)+\.[A-Za-z0-9._-]+)(?=$|[\s`"')\]}>:,;.!?])/g;function dm(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")}function W4(e){const n=dm(e),a=n.lastIndexOf("/");return a>0?n.slice(0,a):n}function Af(e,n){Ax.lastIndex=0;let a;for(;(a=Ax.exec(e))!==null;){const s=a[1].replace(/^\.?\//,"");s.includes("/")&&n.add(s)}}function kv(e,n){Af(e.title,n),e.text&&Af(e.text,n);for(const a of e.children)kv(a,n)}function X4(e){const n=new Map;for(const a of e){const s=dm(a).replace(/^\.?\//,"");if(!s.includes("/"))continue;const i=s.split("/").filter(Boolean);if(i.length<2)continue;const l=i.length>=3?`${i[0]}/${i[1]}/`:`${i[0]}/`,d=i.length>=3?`${i[2]}${i.length>3?"/":""}`:i[1];n.has(l)||n.set(l,new Set),n.get(l).add(d)}return[...n.entries()].sort(([a],[s])=>a.localeCompare(s)).slice(0,14).map(([a,s])=>{const i=[...s].sort(),l=i.slice(0,8),d=i.length>l.length?", ...":"";return` ${a} -> ${l.join(", ")}${d}`})}function Z4(e){const n=e.filter(s=>s.enabled&&s.repoMeta);if(n.length===0)return"";const a=[];for(const s of n){const i=s.repoMeta,l=i.features;if(l.length===0)continue;const d=l[0],f=`src/${d.toLowerCase().replace(/\s+/g,"-")}/index.ts`,h=[`### Example: answering a question about ${i.name}`,`Q: "How does ${d} work?"`,`1. Check Data Flow in "${d}" section → see what files import/depend on each other`,"2. Check Key Files → exports and types tell you the API surface without opening files",`3. Need actual implementation? → \`get_file_contents("${f}")\``];i.baseUrl&&h.push(`4. Need to share a link? → \`${i.baseUrl}{exact_file_path}\``),a.push(h.join(`
|
|
105
|
+
`))}return a.length===0?"":a.join(`
|
|
106
|
+
|
|
107
|
+
`)}function wv(e,n){const a=e.filter(g=>g.enabled),s=[],i=a.filter(g=>g.repoMeta);for(const g of i){const x=g.repoMeta,b=g.path?W4(g.path):"",v=b?a.filter(j=>j.path&&dm(j.path).startsWith(`${b}/`)):[g],k=new Set;for(const j of v){if(j.content&&Af(j.content,k),!j.path)continue;const T=n(j.path);T&&kv(T.root,k)}const w=X4([...k]);s.push(`## ${x.name}`),x.stack.length>0&&s.push(`- Stack: ${x.stack.join(", ")}`),x.baseUrl&&s.push(`- Base URL: ${x.baseUrl}`),s.push(`- ${x.totalFiles} files, key features: ${x.features.join(", ")}`),x.baseUrl&&w.length>0&&(s.push(`- File lookup table (${k.size} paths): use \`${x.baseUrl}{filePath}\``),s.push(...w)),s.push("- You can explore this codebase in depth — read files, trace dependencies, check implementations."),s.push("")}const l=a.filter(g=>!g.repoMeta&&g.content);for(const g of l){const x=Qo[g.knowledgeType],b=x?x.label:g.knowledgeType;s.push(`## Document: ${g.name}`),s.push(`- Type: ${b}`),s.push("")}if(s.length===0)return"";const d=`You have access to the following codebases and knowledge sources:
|
|
108
|
+
`,p=Z4(e),f=p?`
|
|
109
|
+
## How to Use This Knowledge
|
|
110
|
+
${p}
|
|
111
|
+
`:"";return`<orientation>
|
|
112
|
+
${d}
|
|
113
|
+
${s.join(`
|
|
114
|
+
`)}
|
|
115
|
+
${f}Approach:
|
|
116
|
+
- Your knowledge about these codebases is already loaded in your context below. Use it directly.
|
|
117
|
+
- For file contents not in your context, use get_file_contents or read_file tools — NOT the knowledge graph.
|
|
118
|
+
- Do NOT call search_nodes or read_graph to find basic structure — that information is already here.
|
|
119
|
+
- Use each repo's base URL + file path from the lookup table to build exact file links.
|
|
120
|
+
- Explore files and trace dependencies BEFORE asking the user for information.
|
|
121
|
+
</orientation>`}function Sv(e){const{frame:n,orientationBlock:a,hasRepos:s,knowledgeFormatGuide:i,frameworkBlock:l,memoryBlock:d,knowledgeBlock:p}=e,f=[n];if(a&&f.push(a),s&&f.push(i),l&&f.push(l),d&&f.push(d),p){const h=Q4(p);f.push(h)}return f.filter(Boolean).join(`
|
|
122
|
+
|
|
123
|
+
`)}function Q4(e){if(!e.includes("<knowledge>"))return e;const n=e.match(/<knowledge[^>]*>(.*?)<\/knowledge>/s);if(!n)return e;const a=n[1],s=/<source[^>]*type="([^"]*)"[^>]*>(.*?)<\/source>/gs,i=[],l=[],d={"ground-truth":0,"Ground Truth":0,guideline:1,Guideline:1,framework:2,Framework:2,hypothesis:3,Hypothesis:3,signal:4,Signal:4,evidence:5,Evidence:5};let p=0,f;for(;(f=s.exec(a))!==null;){if(f.index>p){const k=a.slice(p,f.index).trim();k&&l.push(k)}const b=f[1],v=d[b]??3;i.push({type:b,fullMatch:f[0],order:v}),p=f.index+f[0].length}if(p<a.length){const b=a.slice(p).trim();b&&l.push(b)}i.sort((b,v)=>b.order-v.order);const h=[];l.length>0&&h.push(...l),i.length>0&&h.push(...i.map(b=>b.fullMatch));const g=e.match(/<knowledge[^>]*>/);return`${g?g[0]:"<knowledge>"}
|
|
124
|
+
${h.join(`
|
|
125
|
+
|
|
126
|
+
`)}
|
|
127
|
+
</knowledge>`}const J4={agentMeta:{name:"React Code Reviewer",description:"Senior React engineer specializing in code quality, TypeScript best practices, and accessibility compliance",icon:"search",category:"coding",tags:["react","code-review","typescript","accessibility"],avatar:"bug"},instructionState:{persona:"You are a senior React engineer with 8+ years of experience in building production-ready applications. You have deep expertise in TypeScript, modern React patterns, performance optimization, and web accessibility standards.",tone:"formal",expertise:5,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"Always provide specific line numbers and actionable suggestions",scopeDefinition:"Code review for React/TypeScript applications with focus on quality, performance, and accessibility"},objectives:{primary:"Provide thorough, actionable code reviews that improve code quality and maintainability",successCriteria:["Identify potential bugs and performance issues","Suggest accessibility improvements","Maintain consistency with React/TypeScript best practices","Provide specific, actionable feedback with examples"],failureModes:["Generic or vague feedback without specific suggestions","Missing critical accessibility issues","Approving code with TypeScript type safety violations","Ignoring performance implications"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-analyze-diff",label:"Analyze Code Changes",action:"Read and understand the code diff, identifying the scope and purpose of changes",tool:"",condition:"always",conditionValue:""},{id:"step-style-check",label:"Check Code Style",action:"Verify code follows React/TypeScript best practices and coding standards",tool:"skill:clean-code",condition:"always",conditionValue:""},{id:"step-accessibility",label:"Review Accessibility",action:"Check for accessibility violations and suggest improvements for screen readers and keyboard navigation",tool:"",condition:"always",conditionValue:""},{id:"step-categorize-issues",label:"Categorize Issues",action:"Classify identified issues by severity: critical (blocking), major (important), minor (nice-to-have)",tool:"",condition:"always",conditionValue:""},{id:"step-write-review",label:"Write Comprehensive Review",action:"Compose detailed review with specific line references, code examples, and actionable suggestions",tool:"",condition:"always",conditionValue:""}],channels:[{sourceId:"react-style-guide",name:"React Style Guide",path:"docs/react-style-guide.md",category:"knowledge",knowledgeType:"framework",enabled:!0,depth:2,baseTokens:1500},{sourceId:"accessibility-checklist",name:"Accessibility Checklist",path:"docs/accessibility-checklist.md",category:"knowledge",knowledgeType:"evidence",enabled:!0,depth:3,baseTokens:800}],skills:[{id:"clean-code",name:"Clean Code",icon:"✨",enabled:!0,added:!0,description:"Pragmatic coding standards - concise, direct, no over-engineering",category:"development"}],mcpServers:[{id:"github",name:"GitHub",icon:"🐙",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"development",description:"Access GitHub repositories, PRs, and issues"}]},eA={agentMeta:{name:"Senior PM",description:"Senior Product Manager specializing in discovery synthesis, product strategy, and opportunity analysis. Turns messy brainstorms into clear product strategy.",icon:"user",category:"strategy",tags:["discovery","strategy","synthesis","prioritization"],avatar:"target"},instructionState:{persona:"You are a Senior Product Manager with 10+ years building B2B SaaS products. You excel at discovery work, synthesizing messy conversations into clear product strategy, and translating customer/team insights into prioritized roadmap decisions.",tone:"formal",expertise:5,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"Strategic but practical — connect dots between insights and execution. Framework-driven — use opportunity solution trees, RICE, impact mapping. Hypothesis-oriented — frame everything as assumptions to validate. Trade-off aware — always consider what we are NOT doing. Customer-outcome focused — start with customer value, not features.",scopeDefinition:"Discovery synthesis, product strategy, opportunity analysis, roadmap prioritization"},objectives:{primary:"Synthesize product team discussions into clear, prioritized product opportunities with actionable next steps",successCriteria:["TL;DR with top 3 takeaways","Key opportunities grouped by theme","Customer pain points identified","Prioritization using RICE or similar framework","Discovery plan with validation steps"],failureModes:["Listing features without strategic context","Missing underlying customer needs behind surface requests","No prioritization or all items marked equal priority","Skipping hypothesis formation and validation planning"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-tldr",label:"TL;DR",action:"Extract top 3 takeaways in one sentence each",tool:"",condition:"always"},{id:"step-opportunities",label:"Key Opportunities",action:"Identify product ideas/improvements discussed, grouped by theme",tool:"",condition:"always"},{id:"step-pain-points",label:"Customer Pain Points",action:"Extract problems being solved and underlying needs",tool:"",condition:"always"},{id:"step-strategic",label:"Strategic Implications",action:"Analyze how findings affect roadmap and positioning",tool:"",condition:"always"},{id:"step-hypotheses",label:"Assumptions & Hypotheses",action:"Frame beliefs that need validation with evidence and signals",tool:"",condition:"always"},{id:"step-prioritize",label:"Prioritization",action:"Recommend what to tackle first using RICE (Reach, Impact, Confidence, Effort)",tool:"",condition:"always"},{id:"step-discovery-plan",label:"Discovery Plan",action:"Define how to validate key hypotheses — research needed, experiments",tool:"",condition:"always"},{id:"step-risks",label:"Dependencies & Risks",action:"Flag technical, organizational, and market blockers",tool:"",condition:"always"},{id:"step-next-steps",label:"Next Steps",action:"List concrete actions with owners and timelines",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-products",name:"Products",path:"00 - Knowledge/Products/",category:"knowledge",knowledgeType:"ground-truth",enabled:!0,depth:0,baseTokens:16e3},{sourceId:"knowledge-products-feedback",name:"Feedback",path:"00 - Knowledge/Products/Feedback/",category:"knowledge",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4800},{sourceId:"signals-odfjell",name:"User feedback / Odfjell",path:"07 - Signals/User feedback/odfjell/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:6800},{sourceId:"signals-kcc",name:"User feedback / KCC",path:"07 - Signals/User feedback/kcc/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:5200},{sourceId:"signals-general",name:"User feedback / General",path:"07 - Signals/User feedback/general/",category:"intel",knowledgeType:"signal",enabled:!0,depth:1,baseTokens:7500},{sourceId:"discovery-eu-ets",name:"EU ETS Cost Layer",path:"01 - Discovery/EU ETS Cost Layer/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:3200},{sourceId:"discovery-weather-routing",name:"Weather Routing v2",path:"01 - Discovery/Weather Routing v2/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:4100},{sourceId:"discovery-fleet-dashboard",name:"Fleet Dashboard",path:"01 - Discovery/Fleet Dashboard/",category:"discovery",knowledgeType:"hypothesis",enabled:!0,depth:2,baseTokens:3500},{sourceId:"roadmap",name:"03 - Roadmap",path:"03 - Roadmap/",category:"knowledge",knowledgeType:"framework",enabled:!0,depth:1,baseTokens:12e3}],skills:[{id:"feedback-analyzer",name:"Feedback Analyzer",icon:"📊",enabled:!0,added:!0,description:"Extract insights from customer feedback",category:"analysis"},{id:"roadmap-builder",name:"Roadmap Builder",icon:"🗺️",enabled:!0,added:!0,description:"Create strategic product roadmaps with OKRs",category:"content"}],mcpServers:[{id:"notion",name:"Notion",icon:"📓",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"productivity",description:"Read and write Notion pages and databases"},{id:"slack",name:"Slack",icon:"💬",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"communication",description:"Read and post Slack messages"}]},tA={agentMeta:{name:"Feedback Manager",description:"Feedback lifecycle specialist — organizes, challenges, and maintains the single source of truth for user feedback. Monitors Gmail, connects feedback to product features, proposes improvements.",icon:"inbox",category:"feedback",tags:["feedback","triage","patterns","improvement"],avatar:"chart"},instructionState:{persona:"You are a specialized Product Manager focused on feedback management and intelligence. You maintain the single source of truth for all user feedback, ensuring it's organized, challenged, contextualized with current product features, and continuously refined.",tone:"neutral",expertise:4,constraints:{neverMakeUp:!0,askBeforeActions:!0,stayInScope:!0,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:`Curious and probing — always ask "why?" and "what's the underlying need?". Pattern-oriented — look for recurring themes. Feature-aware — reference specific product capabilities. Actionable — turn feedback into concrete improvement proposals. Organized — maintain clean, accessible feedback repository.`,scopeDefinition:"Feedback triage, pattern recognition, improvement proposals, repository maintenance"},objectives:{primary:"Process and organize user feedback into actionable insights, maintaining a clean feedback repository with pattern detection and improvement proposals",successCriteria:["New feedback triaged within workflow","Patterns detected across feedback sources","Improvement proposals with rationale and priority","Feedback connected to current product capabilities","Repository organized and deduplicated"],failureModes:["Taking feedback at face value without probing deeper","Missing recurring patterns across sources","No connection between feedback and existing product features","Feedback stored without actionable improvement proposals"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-initial-analysis",label:"Initial Analysis",action:"Quick pattern detection, sentiment analysis, theme identification, extract key quotes using feedback-analyzer skill",tool:"skill:feedback-analyzer",condition:"always"},{id:"step-triage",label:"Triage",action:"Ask clarifying questions: which product/feature, user role, frequency/severity, blocking vs inconvenient",tool:"",condition:"always"},{id:"step-deep-dive",label:"Deep Dive",action:"Uncover real pain point, identify job-to-be-done, find behavioral patterns, challenge assumptions",tool:"",condition:"always"},{id:"step-strategic-synthesis",label:"Strategic Synthesis",action:"Alignment with product strategy, opportunity sizing, prioritization recommendation",tool:"",condition:"always"},{id:"step-contextualize",label:"Contextualize with Product",action:"Check if capability exists, identify gap/enhancement/misunderstanding, find related features",tool:"",condition:"always"},{id:"step-categorize",label:"Categorize & Store",action:"Tag by product, type (Bug/Enhancement/Feature), user type, severity, frequency, status",tool:"",condition:"always"},{id:"step-patterns",label:"Pattern Recognition",action:"Check against existing patterns, update PATTERNS.md if new theme, flag recurring issues",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-products-feedback",name:"Feedback",path:"00 - Knowledge/Products/Feedback/",category:"knowledge",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4800},{sourceId:"signals-odfjell",name:"User feedback / Odfjell",path:"07 - Signals/User feedback/odfjell/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:6800},{sourceId:"signals-kcc",name:"User feedback / KCC",path:"07 - Signals/User feedback/kcc/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:5200},{sourceId:"signals-baru",name:"User feedback / Baru",path:"07 - Signals/User feedback/baru/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:4500},{sourceId:"signals-general",name:"User feedback / General",path:"07 - Signals/User feedback/general/",category:"intel",knowledgeType:"signal",enabled:!0,depth:0,baseTokens:7500},{sourceId:"intel-feedback",name:"04 - Feedback Synthesis",path:"05 - Intel/04 - Feedback Synthesis/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:1,baseTokens:4800}],skills:[{id:"feedback-analyzer",name:"Feedback Analyzer",icon:"📊",enabled:!0,added:!0,description:"Extract insights from customer feedback — patterns, sentiment, priorities",category:"analysis"}],mcpServers:[{id:"gmail",name:"Gmail",icon:"📧",connected:!0,enabled:!0,added:!0,capabilities:["input"],category:"communication",description:"Read Gmail OnWatch label for captain feedback"},{id:"notion",name:"Notion",icon:"📓",connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:"productivity",description:"CSM Team Hub and feedback databases"},{id:"slack",name:"Slack",icon:"💬",connected:!0,enabled:!0,added:!0,capabilities:["output"],category:"communication",description:"Send critical feedback alerts"}]},nA={agentMeta:{name:"Competitor Feature Scraper",description:"Systematically scrapes competitor product pages to extract features, claims, screenshots, and target users. Produces structured feature profiles for competitive comparison.",icon:"search",category:"intel",tags:["competitors","scraping","features","intel"],avatar:"microscope"},instructionState:{persona:"You are a specialized competitive intelligence agent that systematically scrapes competitor websites to extract product features, claims, metrics, and screenshots. You produce structured feature profiles that feed into the competitive comparison matrix.",tone:"neutral",expertise:4,constraints:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!0,limitWords:!1,wordLimit:500,customConstraints:'Only extract factual claims from competitor pages — never infer or embellish. Mark unverified claims as "Claimed". Save raw scrape data for re-processing. Respect rate limits (max 10 parallel scrapes).',scopeDefinition:"Competitor product page scraping, feature extraction, structured profile generation"},objectives:{primary:"Scrape competitor websites and produce structured FEATURES.md profiles with feature names, descriptions, claims, screenshots, and taxonomy mapping",successCriteria:["All discoverable product pages scraped","Each feature has name, description, and source URL","Screenshots downloaded for key features","Features mapped to taxonomy categories","Raw scrape data saved for re-processing"],failureModes:["Missing product pages due to incomplete site discovery","Inferring features not actually claimed by competitor","No screenshots captured for visual comparison","Features not mapped to standard taxonomy"]},rawPrompt:"",autoSync:!0},workflowSteps:[{id:"step-setup",label:"Setup",action:"Verify Firecrawl is available, create output directories for competitor",tool:"bash",condition:"always"},{id:"step-discover",label:"Discover Pages",action:"Use Firecrawl map to find all product/feature pages, filter for relevant URLs",tool:"skill:firecrawl",condition:"always"},{id:"step-scrape",label:"Scrape Pages",action:"Scrape each feature page for content + screenshot (up to 10 concurrent)",tool:"skill:firecrawl",condition:"always"},{id:"step-extract",label:"Extract Features",action:"Extract feature name, description, key claims, metrics, target user, screenshot URL",tool:"",condition:"always"},{id:"step-taxonomy",label:"Map to Taxonomy",action:"Read _FEATURE_TAXONOMY.md and map each feature to taxonomy categories",tool:"",condition:"always"},{id:"step-write",label:"Write Profile",action:"Generate structured FEATURES.md with summary table and detailed feature sections",tool:"",condition:"always"}],channels:[{sourceId:"knowledge-competitors",name:"Competitors",path:"00 - Knowledge/Competitors/",category:"knowledge",knowledgeType:"evidence",enabled:!0,depth:0,baseTokens:22e3},{sourceId:"intel-competitive",name:"01 - Competitive Intel",path:"05 - Intel/01 - Competitive Intel/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:0,baseTokens:12e3},{sourceId:"cmo-competitive-intel",name:"05 - Competitive Intel",path:"CMO-Handoff/05 - Competitive Intel/",category:"intel",knowledgeType:"evidence",enabled:!0,depth:1,baseTokens:5800}],skills:[{id:"web-search",name:"Web Search",icon:"🔎",enabled:!0,added:!0,description:"Search the web for competitor information",category:"analysis"}],mcpServers:[{id:"firecrawl",name:"Firecrawl",icon:"🔥",connected:!0,enabled:!0,added:!0,capabilities:["input"],category:"data",description:"Web scraping, crawling, and site mapping"}]},oA={"senior-pm":eA,"feedback-manager":tA,"competitor-scraper":nA};let Wo;function nf(e){return e==="coding"?"development":e==="research"?"analysis":e==="design"||e==="writing"?"content":e==="domain"?"domain":"content"}function _x(e){return e==="coding"?"development":e==="research"?"data":e==="writing"?"productivity":"data"}function Dx(e,n){return e.map(a=>a.id===n?{...a,enabled:!a.enabled}:a)}function zx(e,n){return e.map(a=>a.id===n?{...a,added:!0,enabled:!0}:a)}function Rx(e,n){return e.map(a=>a.id===n?{...a,added:!1,enabled:!1}:a)}function Mv(e){if(!e.enabled)return 0;const n=Fs[e.depth]??Fs[0];return Math.round(e.baseTokens*n.pct)}const re=qt()(vS((e,n)=>({channels:[],prompt:"",selectedModel:"claude-opus-4",selectedPreset:"",outputFormat:"markdown",outputFormats:["markdown"],tokenBudget:2e5,navigationMode:"tree-aware",running:!1,showFilePicker:!1,showMcpPicker:!1,showSkillPicker:!1,showSaveModal:!1,showConnectorPicker:!1,showMarketplace:!1,activeMarketplaceTab:"skills",showSettings:!1,activeSettingsTab:"providers",response:"",exportTarget:"claude",registrySkills:kc.map(a=>({...a})),registryMcpServers:jS.map(a=>({...a})),agentConfig:{...h0},agentMeta:{name:"",description:"",icon:"brain",category:"general",tags:[],avatar:"bot"},mcpServers:[],skills:kc.filter(a=>a.installed).map(a=>({id:a.id,name:a.name,icon:a.icon,enabled:!1,added:!1,description:a.description,category:nf(a.category)})),agents:[],connectors:[],pendingKnowledge:[],suggestedSkills:[],instructionState:{persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0},workflowSteps:[],outputTemplateConfig:{},agentPattern:"prompt-chain",verification:{enabled:!1,strategy:"none",rules:[],crossRefSources:[],confidenceRequired:!1,autoRetryOnFail:!1,maxRetries:2},errorHandling:{onStepFailure:"abort",retryCount:1,fallbackAction:"",checkpointEnabled:!1,timeoutSeconds:0,gracefulDegradation:!1},evaluation:{enabled:!1,criteria:[],expectedOutputFormat:"",qualityRubric:""},totalTokens:()=>{const{channels:a,prompt:s}=n(),i=a.reduce((d,p)=>d+Mv(p),0),l=Math.ceil(s.length/4);return i+l},loadPreset:a=>{const s=CS.find(d=>d.id===a);if(!s)return;const i=s.channels.map(d=>({...d,enabled:!0})),l={...h0,...s.agentConfig};e({channels:i,selectedPreset:a,response:"",agentConfig:l})},setOutputFormat:a=>e({outputFormat:a,outputFormats:[a]}),toggleOutputFormat:a=>{const s=n().outputFormats,i=s.includes(a)?s.filter(l=>l!==a):[...s,a];i.length!==0&&e({outputFormats:i,outputFormat:i[0]})},cycleKnowledgeType:a=>{const s=["ground-truth","signal","evidence","framework","hypothesis","guideline"];e({channels:n().channels.map(i=>{if(i.sourceId!==a)return i;const l=s.indexOf(i.knowledgeType);return{...i,knowledgeType:s[(l+1)%s.length]}})})},addChannel:a=>{const{channels:s}=n();if(s.some(l=>l.sourceId===a.sourceId))return;const i={...a};if(a.path){const l=df(a.path,a.content);(!a.knowledgeType||a.knowledgeType==="evidence")&&(i.knowledgeType=l.knowledgeType),(a.depth===void 0||a.depth===null)&&(i.depth=l.depth)}e({channels:[...s,{...i,enabled:!0}],selectedPreset:""})},removeChannel:a=>{e({channels:n().channels.filter(s=>s.sourceId!==a),selectedPreset:""})},toggleChannel:a=>{e({channels:n().channels.map(s=>s.sourceId===a?{...s,enabled:!s.enabled}:s)})},setChannelDepth:(a,s)=>{e({channels:n().channels.map(i=>i.sourceId===a?{...i,depth:Math.max(0,Math.min(4,s))}:i)})},setPrompt:a=>{const s=MS(a);e({prompt:a,outputFormat:s})},setModel:a=>e(s=>({selectedModel:a,agentConfig:{...s.agentConfig,model:a}})),setTokenBudget:a=>e({tokenBudget:a}),setNavigationMode:a=>e({navigationMode:a}),setShowFilePicker:a=>e({showFilePicker:a}),setShowMcpPicker:a=>e({showMcpPicker:a}),setShowSkillPicker:a=>e({showSkillPicker:a}),setShowSaveModal:a=>e({showSaveModal:a}),setShowConnectorPicker:a=>e({showConnectorPicker:a}),setShowMarketplace:(a,s)=>e({showMarketplace:a,...s?{activeMarketplaceTab:s}:{}}),setShowSettings:(a,s)=>e({showSettings:a,...s?{activeSettingsTab:s}:{}}),setAgentMeta:a=>e({agentMeta:{...n().agentMeta,...a}}),setChannelKnowledgeType:(a,s)=>{const i=["ground-truth","signal","evidence","framework","hypothesis","guideline"],l=i[Math.max(0,Math.min(i.length-1,s))];e({channels:n().channels.map(d=>d.sourceId===a?{...d,knowledgeType:l}:d)})},reorderChannels:(a,s)=>{const i=[...n().channels],[l]=i.splice(a,1);i.splice(s,0,l),e({channels:i,selectedPreset:""})},run:()=>{const{running:a,prompt:s,channels:i}=n();if(a){n().cancelRun();return}const d=Je.getState().getActiveProvider(),p=d?.authMethod==="claude-agent-sdk";if(!p&&!d?.apiKey){e({response:"Error: No API key configured. Open Settings → Providers to add your API key."});return}e({running:!0,response:""});const f=V4(i,s),h=n().agentConfig.model;let g="";if(p){const b=f.filter(w=>w.role==="system").map(w=>w.content),v=f.filter(w=>w.role==="user").map(w=>w.content).join(`
|
|
128
|
+
`);Wo=ib({prompt:v||s,model:h,systemPrompt:b.join(`
|
|
129
|
+
`)||void 0,onChunk:w=>{g+=w,e({response:g})},onDone:()=>{e({running:!1}),Wo=void 0},onError:w=>{e({running:!1,response:`Error: ${w.message}`}),Wo=void 0}});return}Wo=lb({providerId:d?.id||"",model:h,messages:f,onChunk:b=>{g+=b,e({response:g})},onDone:()=>{e({running:!1}),Wo=void 0},onError:b=>{e({running:!1,response:`Error: ${b.message}`}),Wo=void 0}})},cancelRun:()=>{const a=Wo;a&&a.abort(),e({running:!1}),Wo=void 0},clearChannels:()=>e({channels:[],selectedPreset:"",response:""}),setAgentModel:a=>e({agentConfig:{...n().agentConfig,model:a}}),setAgentTemperature:a=>e({agentConfig:{...n().agentConfig,temperature:a}}),setAgentSystemPrompt:a=>e({agentConfig:{...n().agentConfig,systemPrompt:a}}),setAgentPlanningMode:a=>e({agentConfig:{...n().agentConfig,planningMode:a}}),setAgentMaxTokens:a=>e({agentConfig:{...n().agentConfig,maxTokens:a}}),toggleMcp:a=>{e({mcpServers:Dx(n().mcpServers,a)})},addMcp:a=>{e({mcpServers:zx(n().mcpServers,a)})},removeMcp:a=>{e({mcpServers:Rx(n().mcpServers,a)})},upsertMcpServer:a=>{if(n().mcpServers.find(i=>i.id===a.id)){e({mcpServers:n().mcpServers.map(i=>i.id===a.id?{...i,name:a.name,description:a.description??i.description,connected:a.connected??i.connected}:i)});return}e({mcpServers:[...n().mcpServers,{id:a.id,name:a.name,icon:"plug",connected:a.connected??!1,enabled:!1,added:!1,capabilities:["input","output"],category:"data",description:a.description??"Custom MCP server"}]})},removeMcpServer:a=>{e({mcpServers:n().mcpServers.filter(s=>s.id!==a)})},toggleSkill:a=>{e({skills:Dx(n().skills,a)})},addSkill:a=>{e({skills:zx(n().skills,a)})},removeSkill:a=>{e({skills:Rx(n().skills,a)})},upsertSkill:a=>{if(n().skills.find(i=>i.id===a.id)){e({skills:n().skills.map(i=>i.id===a.id?{...i,name:a.name||i.name,description:a.description&&a.description.length>0?a.description:i.description,skillUrl:a.skillUrl??i.skillUrl,installedFrom:a.installedFrom??i.installedFrom,installs:a.installs??i.installs}:i)});return}e({skills:[...n().skills,{id:a.id,name:a.name,icon:"zap",enabled:!1,added:!1,description:a.description??"Installed from skills.sh",category:"development",skillUrl:a.skillUrl,installedFrom:a.installedFrom,installs:a.installs}]})},loadAgent:a=>{(async()=>{try{const s=await fetch(`${Ae}/agents/${encodeURIComponent(a)}`);if(!s.ok)return;const i=await s.json(),l=i.data??i;n().restoreFullState(l)}catch{}})()},restoreFullState:a=>{const s={};a.agentMeta&&(s.agentMeta=a.agentMeta),a.instructionState&&(s.instructionState=a.instructionState),a.workflowSteps&&(s.workflowSteps=a.workflowSteps),a.mcpServers&&(s.mcpServers=a.mcpServers),a.skills&&(s.skills=a.skills),a.connectors&&(s.connectors=a.connectors),a.agentConfig&&(s.agentConfig=a.agentConfig),a.exportTarget&&(s.exportTarget=a.exportTarget),a.outputFormat&&(s.outputFormat=a.outputFormat),a.outputFormats&&(s.outputFormats=a.outputFormats),a.tokenBudget&&(s.tokenBudget=a.tokenBudget),a.prompt&&(s.prompt=a.prompt),a.channels&&(s.channels=a.channels),s.selectedPreset="",s.response="",e(s),a.mcpServers&&(async()=>{try{const{useMcpStore:i}=await ta(async()=>{const{useMcpStore:l}=await Promise.resolve().then(()=>_S);return{useMcpStore:l}},void 0);await i.getState().syncFromConfig()}catch{}})()},setInstructionState:a=>{e({instructionState:a})},setWorkflowSteps:a=>{e({workflowSteps:a})},toggleConnector:a=>{e({connectors:n().connectors.map(s=>s.id===a?{...s,enabled:!s.enabled}:s)})},addConnector:a=>{const{connectors:s}=n();s.some(i=>i.id===a.id)||e({connectors:[...s,a]})},removeConnector:a=>{e({connectors:n().connectors.filter(s=>s.id!==a)})},updateConnectorScope:(a,s)=>{e({connectors:n().connectors.map(i=>i.id===a?{...i,hint:s}:i)})},setExportTarget:a=>e({exportTarget:a}),addPendingKnowledge:a=>{e({pendingKnowledge:[...n().pendingKnowledge,a]})},acceptPendingKnowledge:a=>{const s=n().pendingKnowledge.find(l=>l.id===a);if(!s)return;const i={sourceId:`feedback-${a}`,name:s.name,path:"",category:"knowledge",knowledgeType:s.type||"evidence",enabled:!0,depth:0,baseTokens:500};e({channels:[...n().channels,i],pendingKnowledge:n().pendingKnowledge.filter(l=>l.id!==a)})},dismissPendingKnowledge:a=>{e({pendingKnowledge:n().pendingKnowledge.filter(s=>s.id!==a)})},addSuggestedSkill:a=>{e({suggestedSkills:[...n().suggestedSkills,a]})},acceptSuggestedSkill:a=>{e({suggestedSkills:n().suggestedSkills.map(s=>s.id===a?{...s,installing:!0}:s)}),setTimeout(()=>{n().suggestedSkills.find(i=>i.id===a)&&(e({suggestedSkills:n().suggestedSkills.map(i=>i.id===a?{...i,installing:!1,installed:!0}:i)}),setTimeout(()=>{e({suggestedSkills:n().suggestedSkills.filter(i=>i.id!==a)})},1200))},1500)},dismissSuggestedSkill:a=>{e({suggestedSkills:n().suggestedSkills.filter(s=>s.id!==a)})},installRegistrySkill:(a,s,i)=>{const l=n().registrySkills.find(h=>h.id===a),d=n().registrySkills.map(h=>h.id===a?{...h,installed:!0,installedTarget:s,installedScope:i}:h),f=n().skills.some(h=>h.id===a)?n().skills:l?[...n().skills,{id:l.id,name:l.name,icon:l.icon,enabled:!0,added:!0,description:l.description,category:nf(l.category)}]:n().skills;e({registrySkills:d,skills:f})},installRegistryMcp:a=>{const s=n().registryMcpServers.find(p=>p.id===a),i=n().registryMcpServers.map(p=>p.id===a?{...p,installed:!0,configured:!0}:p),d=n().mcpServers.some(p=>p.id===a)?n().mcpServers:s?[...n().mcpServers,{id:s.id,name:s.name,icon:s.icon,connected:!0,enabled:!0,added:!0,capabilities:["input","output"],category:_x(s.category),description:s.description}]:n().mcpServers;e({registryMcpServers:i,mcpServers:d})},addFileChannel:a=>{const{channels:s}=n(),i=`file:${a.path}`;if(s.some(p=>p.sourceId===i))return;const l=df(a.path,a.content),d={sourceId:i,name:a.path.split("/").pop()??a.path,path:a.path,category:"knowledge",knowledgeType:a.knowledgeType||l.knowledgeType,enabled:!0,depth:l.depth,baseTokens:a.tokenEstimate};e({channels:[...s,d],selectedPreset:""})},setInstructionPersona:a=>{e({instructionState:{...n().instructionState,persona:a}})},setInstructionTone:a=>{e({instructionState:{...n().instructionState,tone:a}})},setInstructionExpertise:a=>{e({instructionState:{...n().instructionState,expertise:Math.max(1,Math.min(5,a))}})},setInstructionConstraints:a=>{e({instructionState:{...n().instructionState,constraints:{...n().instructionState.constraints,...a}}})},setInstructionObjectives:a=>{e({instructionState:{...n().instructionState,objectives:{...n().instructionState.objectives,...a}}})},setInstructionRawPrompt:a=>{e({instructionState:{...n().instructionState,rawPrompt:a}})},setInstructionAutoSync:a=>{e({instructionState:{...n().instructionState,autoSync:a}})},addWorkflowStep:a=>{const s={...a,id:`step-${Date.now()}-${Math.random().toString(36).substr(2,9)}`};e({workflowSteps:[...n().workflowSteps,s]})},updateWorkflowStep:(a,s)=>{e({workflowSteps:n().workflowSteps.map(i=>i.id===a?{...i,...s}:i)})},removeWorkflowStep:a=>{e({workflowSteps:n().workflowSteps.filter(s=>s.id!==a)})},reorderWorkflowSteps:(a,s)=>{const i=[...n().workflowSteps],[l]=i.splice(a,1);i.splice(s,0,l),e({workflowSteps:i})},updateInstruction:a=>{e({instructionState:{...n().instructionState,...a}})},updateWorkflowSteps:a=>{const s=a.map((i,l)=>({...i,id:i.id||`step-${Date.now()}-${l}-${Math.random().toString(36).substr(2,5)}`}));e({workflowSteps:s})},setAgentPattern:a=>e({agentPattern:a}),updateVerification:a=>e({verification:{...n().verification,...a}}),updateErrorHandling:a=>e({errorHandling:{...n().errorHandling,...a}}),updateEvaluation:a=>e({evaluation:{...n().evaluation,...a}}),setOutputTemplateConfig:(a,s)=>{e({outputTemplateConfig:{...n().outputTemplateConfig,[a]:s}})},removeOutputTemplateConfig:a=>{const s={...n().outputTemplateConfig};delete s[a],e({outputTemplateConfig:s})},hydrateFromGenerated:a=>{e({agentMeta:{name:a.agentMeta.name||"",description:a.agentMeta.description||"",icon:"brain",category:"general",tags:a.agentMeta.tags||[],avatar:a.agentMeta.avatar||"bot"}}),e({instructionState:{persona:a.instructionState.persona||"",tone:a.instructionState.tone||"neutral",expertise:a.instructionState.expertise||3,constraints:{neverMakeUp:a.instructionState.constraints?.neverMakeUp??!0,askBeforeActions:a.instructionState.constraints?.askBeforeActions??!1,stayInScope:a.instructionState.constraints?.stayInScope??!0,useOnlyTools:a.instructionState.constraints?.useOnlyTools??!1,limitWords:a.instructionState.constraints?.limitWords??!1,wordLimit:a.instructionState.constraints?.wordLimit??0,customConstraints:(a.instructionState.constraints?.customConstraints||[]).join(`
|
|
130
|
+
`),scopeDefinition:a.instructionState.constraints?.scopeDefinition||""},objectives:{primary:a.instructionState.objectives?.primary||"",successCriteria:a.instructionState.objectives?.successCriteria||[],failureModes:a.instructionState.objectives?.failureModes||[]},rawPrompt:"",autoSync:!0}});const s=(a.workflowSteps||[]).map((f,h)=>({id:`gen-step-${h}-${Date.now()}`,label:f.label,action:f.action,tool:"",condition:f.condition?"if":"always",loop:f.loop,maxIterations:f.loop?3:0}));e({workflowSteps:s});const i=(a.mcpServerIds||[]).map(f=>{const h=Kc.find(g=>g.id===f);return h?{id:h.id,name:h.name,icon:h.icon||"server",connected:!1,enabled:!0,added:!0,capabilities:[],category:_x(h.category),description:h.description}:null}).filter(Boolean);e({mcpServers:i});const l=(a.skillIds||[]).map(f=>{const h=kc.find(g=>g.id===f);return h?{id:h.id,name:h.name,icon:h.icon,enabled:!0,added:!0,description:h.description,category:nf(h.category)}:null}).filter(Boolean);e({skills:l});const d=["ground-truth","signal","evidence","framework","hypothesis","guideline"],p=n().channels;if(a.knowledgeSelections&&a.knowledgeSelections.length>0){const f=p.map(h=>{const g=a.knowledgeSelections.find(k=>k.sourceId===h.sourceId);if(!g)return{...h,enabled:!1};const x=d.indexOf(g.type),b=x>=0?d[x]:h.knowledgeType||"evidence",v=typeof g.depth=="number"&&g.depth>=0&&g.depth<=4?g.depth:h.depth;return{...h,enabled:!0,knowledgeType:b,depth:v}});e({channels:f})}else if(a.knowledgeSuggestions&&a.knowledgeSuggestions.length>0){const f=a.knowledgeSuggestions.map((h,g)=>{const x=d.indexOf(h.type),b=x>=0?d[x]:"evidence";return{sourceId:`gen-knowledge-${g}-${Date.now()}`,name:h.name,path:"",category:"knowledge",knowledgeType:b,enabled:!0,depth:0,baseTokens:2e3}});e({channels:f})}e({response:"",selectedPreset:""})},loadDemoPreset:a=>{if(!a){const i=J4;e({agentMeta:{...i.agentMeta},instructionState:{...i.instructionState},workflowSteps:[...i.workflowSteps],channels:[...i.channels],skills:[...i.skills],mcpServers:[...i.mcpServers],selectedPreset:"",response:""});return}const s=oA[a];s&&e({agentMeta:{...s.agentMeta},instructionState:{...s.instructionState},workflowSteps:[...s.workflowSteps],channels:[...s.channels],skills:[...s.skills],mcpServers:[...s.mcpServers],selectedPreset:"",response:""})},resetAgent:()=>{e({agentMeta:{name:"",description:"",icon:"brain",category:"general",tags:[],avatar:"bot"},instructionState:{persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0},workflowSteps:[]})},collectContextState:()=>({channels:n().channels,mcpServers:n().mcpServers,skills:n().skills,connectors:n().connectors}),restoreContextState:a=>{e({channels:a.channels,mcpServers:a.mcpServers,skills:a.skills,connectors:a.connectors})}}),{name:"modular-console",partialize:e=>({channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,connectors:e.connectors,agentMeta:e.agentMeta,instructionState:e.instructionState,workflowSteps:e.workflowSteps,selectedModel:e.selectedModel,outputFormat:e.outputFormat,tokenBudget:e.tokenBudget,agentConfig:e.agentConfig}),version:1}));function pm(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")||"modular-agent"}function fm(){const e=re.getState();return{id:pm(e.agentMeta.name),version:"1.0.0",savedAt:new Date().toISOString(),agentMeta:{...e.agentMeta},instructionState:{...e.instructionState},workflowSteps:e.workflowSteps.map(a=>({...a})),channels:e.channels.map(a=>({...a})),mcpServers:e.mcpServers.map(a=>({...a})),skills:e.skills.map(a=>({...a})),connectors:e.connectors.map(a=>({...a})),agentConfig:{...e.agentConfig},exportTarget:e.exportTarget,outputFormat:e.outputFormat,outputFormats:[...e.outputFormats],tokenBudget:e.tokenBudget,prompt:e.prompt}}const Cv=Object.freeze(Object.defineProperty({__proto__:null,agentNameToId:pm,collectFullState:fm,getEffectiveTokens:Mv,useConsoleStore:re},Symbol.toStringTag,{value:"Module"}));function aA({value:e,onChange:n,children:a,t:s,ariaLabel:i}){return c.jsx("select",{value:e,onChange:l=>n(l.target.value),"aria-label":i,className:"appearance-none cursor-pointer outline-none text-[14px] h-8 pl-3 pr-7 rounded-lg",style:{fontFamily:"'Geist Sans', sans-serif",background:s.surfaceOpaque,border:`1px solid ${s.border}`,color:s.isDark?s.textSecondary:"#1a1a20",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M0 2l4 4 4-4' fill='none' stroke='%23${s.isDark?"555":"999"}' stroke-width='1.5'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},children:a})}function sA({onSettingsClick:e}){const n=re(b=>b.selectedModel),a=re(b=>b.setModel),s=re(b=>b.running),i=re(b=>b.run),l=Pc(b=>b.toggleTheme),d=we(),p=re(b=>b.setShowMarketplace),f=Je(b=>b.getAllModels),h=Je(b=>b.providers),g=z.useMemo(()=>f(),[f,h]),x=g.length>0;return c.jsxs("div",{className:"flex items-center h-[48px] px-4 gap-3 shrink-0 border-b select-none",style:{background:d.surface,backdropFilter:"blur(12px)",borderColor:d.border},children:[c.jsxs("div",{className:"flex items-center gap-2 mr-4",children:[c.jsx("div",{className:"w-2 h-2 rounded-full",style:{background:"#FE5000",boxShadow:"0 0 8px rgba(254,80,0,0.4)"}}),c.jsx("span",{className:"text-[17px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:d.textPrimary},children:"MODULAR"})]}),c.jsxs(aA,{value:x?`${Je.getState().selectedProviderId}::${n}`:"__no_models__",onChange:b=>{if(b==="__no_models__")return;const[v,...k]=b.split("::"),w=k.join("::");Je.getState().selectProvider(v),a(w)},t:d,ariaLabel:"Select AI model",children:[!x&&c.jsx("option",{value:"__no_models__",children:"Authenticate a provider to load models"}),g.map(b=>c.jsxs("option",{value:`${b.providerId}::${b.id}`,children:[b.providerName," — ",b.label]},`${b.providerId}-${b.id}`))]}),!x&&c.jsx("span",{className:"text-[12px]",style:{color:d.textDim},children:"No models loaded — connect a model source in settings"}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:b=>{b.currentTarget.style.background="#FE500025"},onMouseLeave:b=>{b.currentTarget.style.background="#FE500012"},"aria-label":"Open Marketplace",children:[c.jsx(f4,{size:13}),"Marketplace"]}),c.jsx("button",{type:"button",onClick:e,className:"flex items-center justify-center w-11 h-11 rounded-md cursor-pointer border-none bg-transparent hover-accent-text focus-visible:outline focus-visible:outline-2",style:{color:d.textDim},"aria-label":"LLM settings",children:c.jsx(rm,{size:14})}),c.jsx("button",{type:"button",onClick:l,className:"flex items-center justify-center w-11 h-11 rounded-md cursor-pointer border-none bg-transparent hover-accent-text focus-visible:outline focus-visible:outline-2",style:{color:d.textDim},"aria-label":d.isDark?"Switch to light mode":"Switch to dark mode",children:d.isDark?c.jsx(dv,{size:14}):c.jsx(av,{size:14})}),c.jsxs("button",{type:"button",onClick:i,className:"flex items-center justify-center gap-1.5 h-8 px-4 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:s?"#CC4000":"#FE5000",color:"#fff",boxShadow:s?"0 0 12px rgba(254,80,0,0.5)":"0 0 8px rgba(254,80,0,0.25)",opacity:s?.8:1,animation:s?"run-pulse-ring 1.5s ease infinite":"none",transition:"background 0.2s ease, opacity 0.2s ease"},children:[s?c.jsx(uv,{size:12,fill:"white"}):c.jsx(lv,{size:12,fill:"white"}),s?"Stop":"Run",c.jsx("span",{className:"text-[13px] opacity-60 tracking-normal font-normal ml-1",children:s?"click to cancel":"Ctrl+Enter"})]})]})}function rA(){const e=re(d=>d.totalTokens),n=re(d=>d.tokenBudget),a=we(),s=e(),i=Math.min(s/n*100,100);let l=a.statusSuccess;return i>80?l=a.statusError:i>55&&(l=a.statusWarning),c.jsxs("div",{className:"w-full px-4 py-2 flex items-center gap-3 shrink-0 border-t",style:{background:a.surfaceOpaque,borderColor:a.border},children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase shrink-0 font-medium",style:{fontFamily:"'Geist Mono', monospace",color:a.tokenLabel},children:"Token Budget"}),c.jsx("div",{className:"flex-1 h-[6px] rounded-full overflow-hidden",style:{background:a.tokenTrackBg},children:c.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${i}%`,background:`linear-gradient(90deg, ${l}cc, ${l})`,boxShadow:`0 0 6px ${l}30`}})}),c.jsx("span",{className:"text-[13px] shrink-0 tabular-nums",style:{fontFamily:"'Geist Mono', monospace",color:l,minWidth:56,textAlign:"right",whiteSpace:"nowrap"},children:s>=1e3?`${(s/1e3).toFixed(1)}K`:s}),c.jsxs("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:a.tokenDivider,minWidth:64,whiteSpace:"nowrap"},children:["/ ",n>=1e3?`${(n/1e3).toFixed(0)}K`:n]})]})}const Ox=`${Ae}/knowledge`,of=qt(e=>({tree:[],loaded:!1,scanning:!1,error:null,lastDir:"",scanDirectory:async n=>{e({scanning:!0,error:null});try{const s=await(await fetch(`${Ox}/scan?dir=${encodeURIComponent(n)}&depth=3`)).json();s.status==="ok"&&s.data?e({tree:s.data,loaded:!0,scanning:!1,lastDir:n}):e({scanning:!1,error:s.error??"Scan failed"})}catch(a){e({scanning:!1,error:a instanceof Error?a.message:"Network error"})}},readFile:async n=>{try{const s=await(await fetch(`${Ox}/read?path=${encodeURIComponent(n)}`)).json();return s.status==="ok"&&s.data?s.data:null}catch{return null}}}));function iA(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function Ev(e,n){if(!n)return!0;const a=n.toLowerCase();return!!(e.name.toLowerCase().includes(a)||e.path.toLowerCase().includes(a)||e.children?.some(s=>Ev(s,n)))}function jv({node:e,depth:n,onAdd:a,filter:s}){const[i,l]=z.useState(n<1||!!s),d=e.type==="directory"&&e.children&&e.children.length>0,p=we();return Ev(e,s)?c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-2 rounded cursor-pointer transition-colors",style:{paddingLeft:8+n*16},onMouseEnter:f=>{f.currentTarget.style.background=p.surfaceHover},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[d?c.jsx("button",{type:"button",onClick:()=>l(!i),className:"w-4 h-4 flex items-center justify-center text-[12px] cursor-pointer border-none bg-transparent",style:{color:p.textMuted},"aria-label":i?"Collapse folder":"Expand folder",children:i?"▼":"▶"}):c.jsx("span",{className:"w-4"}),c.jsx("div",{className:"w-[6px] h-[6px] rounded-full shrink-0",style:{background:e.type==="directory"?"#f1c40f":"#3498db"}}),c.jsx("span",{className:"flex-1 text-[13px] truncate",style:{fontFamily:"'Geist Mono', monospace",color:p.textPrimary},children:e.name}),e.tokenEstimate&&c.jsx("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim},children:iA(e.tokenEstimate)}),e.type==="file"&&c.jsx("button",{type:"button",onClick:()=>a(e),className:"px-2 py-0.5 rounded text-[12px] tracking-[1px] uppercase cursor-pointer border transition-colors shrink-0",style:{fontFamily:"'Geist Mono', monospace",background:"transparent",borderColor:p.border,color:p.textMuted},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.borderColor=p.border,f.currentTarget.style.color=p.textMuted},"aria-label":`Add ${e.name}`,children:"+ ADD"})]}),d&&i&&e.children.map(f=>c.jsx(jv,{node:f,depth:n+1,onAdd:a,filter:s},f.path))]}):null}function lA(){const e=re(S=>S.showFilePicker),n=re(S=>S.setShowFilePicker),a=re(S=>S.addFileChannel),{tree:s,loaded:i,scanning:l,scanDirectory:d}=of(),p=of(S=>S.readFile),f=of(S=>S.lastDir),[h,g]=z.useState(""),[x,b]=z.useState(""),v=z.useRef(null),k=z.useRef(null),w=we();z.useEffect(()=>{e&&(g(""),b(f),setTimeout(()=>v.current?.focus(),100))},[e,f]),z.useEffect(()=>{if(!e)return;const S=M=>{M.key==="Escape"&&n(!1)};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[e,n]);const j=z.useCallback(S=>{if(S.key!=="Tab"||!k.current)return;const M=k.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(M.length===0)return;const $=M[0],A=M[M.length-1];S.shiftKey?document.activeElement===$&&(S.preventDefault(),A.focus()):document.activeElement===A&&(S.preventDefault(),$.focus())},[]);if(!e)return null;const T=async S=>{if(S.type!=="file")return;const M=f.replace(/\\/g,"/")+"/"+S.path,$=await p(M);$&&a($)},E=()=>{x.trim()&&d(x.trim())};return c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>n(!1),children:[c.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.7)"}}),c.jsxs("div",{ref:k,role:"dialog","aria-modal":"true","aria-label":"Add Knowledge Source",className:"relative w-[560px] max-h-[70vh] flex flex-col rounded-lg overflow-hidden",style:{background:w.surfaceOpaque,border:`1px solid ${w.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.8)",animation:"modal-in 0.2s ease-out"},onClick:S=>S.stopPropagation(),onKeyDown:j,children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b",style:{borderColor:w.border},children:[c.jsx("span",{className:"text-[13px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:w.textPrimary},children:"ADD KNOWLEDGE SOURCE"}),c.jsx("button",{type:"button",onClick:()=>n(!1),className:"text-[17px] cursor-pointer border-none bg-transparent",style:{color:w.textMuted},onMouseEnter:S=>{S.currentTarget.style.color="#FE5000"},onMouseLeave:S=>{S.currentTarget.style.color=w.textMuted},"aria-label":"Close file picker",children:"✕"})]}),c.jsxs("div",{className:"px-4 py-2 border-b flex items-center gap-2",style:{borderColor:w.border},children:[c.jsx("input",{type:"text",value:x,onChange:S=>b(S.target.value),onKeyDown:S=>{S.key==="Enter"&&E()},placeholder:"Directory path to scan...",className:"flex-1 outline-none text-[13px]",style:{background:w.inputBg,border:`1px solid ${w.border}`,borderRadius:4,color:w.textPrimary,fontFamily:"'Geist Mono', monospace",padding:"6px 10px"},"aria-label":"Directory path to scan"}),c.jsx("button",{type:"button",onClick:E,disabled:l,className:"px-3 py-1 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",opacity:l?.6:1},"aria-label":"Scan directory",children:l?"Scanning...":"Scan"})]}),c.jsx("div",{className:"px-4 py-2 border-b",style:{borderColor:w.borderSubtle},children:c.jsx("input",{ref:v,type:"text",value:h,onChange:S=>g(S.target.value),placeholder:"Filter results...",className:"w-full outline-none text-[13px]",style:{background:w.inputBg,border:`1px solid ${w.border}`,borderRadius:4,color:w.textPrimary,fontFamily:"'Geist Mono', monospace",padding:"6px 10px"},onFocus:S=>{S.currentTarget.style.borderColor="#FE500050"},onBlur:S=>{S.currentTarget.style.borderColor=w.border},"aria-label":"Filter knowledge sources"})}),c.jsx("div",{className:"flex-1 overflow-y-auto py-2 px-1",children:i&&s.length>0?s.map(S=>c.jsx(jv,{node:S,depth:0,onAdd:M=>{T(M)},filter:h},S.path)):i&&s.length===0?c.jsx("div",{className:"flex items-center justify-center py-8",children:c.jsx("span",{className:"text-[13px]",style:{color:w.textDim},children:"No files found. Try scanning a directory."})}):c.jsx("div",{className:"flex items-center justify-center py-8",children:c.jsx("span",{className:"text-[13px]",style:{color:w.textDim},children:"Enter a directory path and click Scan to browse files."})})})]})]})}const mm={presentation:J3,mic:z3,cloud:MN,code:W1,"bar-chart-3":tm,anchor:qT,"git-branch":La,palette:rv,search:cu,image:p3,"book-open":Jf,hexagon:u3,workflow:R4,map:j3,sparkles:Pa,compass:jN,waves:A4,box:em,layout:q3,wrench:hv,cpu:zi,triangle:M4,"pen-tool":iv,mail:C3,hash:r3,github:La,"file-text":Ws,flame:Q1,database:Ri,globe:J1,folder:WN,target:uu,"clipboard-list":vN,"hard-drive":ev,shield:im,brain:Di};function cA({icon:e,size:n=14,...a}){const s=mm[e];return s?c.jsx(s,{size:n,...a}):c.jsx(na,{size:n,...a})}function uA({icon:e,size:n=14,...a}){const s=mm[e];return s?c.jsx(s,{size:n,...a}):c.jsx(pn,{size:n,...a})}const dA={notion:Jf,slack:_3,hubspot:mv,granola:Ws,github:La,"google-drive":ev,custom:na};function $x({service:e,size:n=14,...a}){const s=dA[e];return s?c.jsx(s,{size:n,...a}):c.jsx(na,{size:n,...a})}function Tv({icon:e,size:n=14,...a}){const s=mm[e];return s?c.jsx(s,{size:n,...a}):c.jsx(pn,{size:n,...a})}function hm({open:e,onClose:n,title:a,searchPlaceholder:s,width:i=520,hideSearch:l,children:d}){const[p,f]=z.useState(""),h=z.useRef(null),g=z.useRef(null),x=we();z.useEffect(()=>{e&&(f(""),setTimeout(()=>h.current?.focus(),100))},[e]),z.useEffect(()=>{if(!e)return;const v=k=>{k.key==="Escape"&&n()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e,n]);const b=z.useCallback(v=>{if(v.key!=="Tab"||!g.current)return;const k=g.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(k.length===0)return;const w=k[0],j=k[k.length-1];v.shiftKey?document.activeElement===w&&(v.preventDefault(),j.focus()):document.activeElement===j&&(v.preventDefault(),w.focus())},[]);return e?ou.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center",onClick:n,children:[c.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.6)",backdropFilter:"blur(4px)"}}),c.jsxs("div",{ref:g,role:"dialog","aria-modal":"true","aria-label":a,className:"relative max-h-[70vh] flex flex-col rounded-xl overflow-hidden",style:{width:i,background:x.surfaceOpaque,border:`1px solid ${x.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.6)",animation:"modal-in 0.2s ease-out"},onClick:v=>v.stopPropagation(),onKeyDown:b,children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:`1px solid ${x.border}`},children:[c.jsx("span",{className:"text-[17px] font-semibold",style:{color:x.textPrimary},children:a}),c.jsx("button",{type:"button",onClick:n,className:"p-1 rounded-md cursor-pointer border-none bg-transparent",style:{color:x.textDim},"aria-label":"Close",children:c.jsx(Tt,{size:16})})]}),!l&&c.jsx("div",{className:"px-5 py-3",style:{borderBottom:`1px solid ${x.borderSubtle}`},children:c.jsxs("div",{className:"relative",children:[c.jsx(cu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2",style:{color:x.textDim}}),c.jsx("input",{ref:h,type:"text",value:p,onChange:v=>f(v.target.value),placeholder:s??"Search...",className:"w-full outline-none text-[17px] pl-9 pr-3 py-2 rounded-lg",style:{background:x.inputBg,border:`1px solid ${x.border}`,color:x.textPrimary,fontFamily:"'Geist Sans', sans-serif"},"aria-label":"Search"})]})}),c.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:d(p)})]})]}),document.body):null}const pA={communication:"Communication",development:"Development",data:"Data",productivity:"Productivity"},fA=["communication","development","data","productivity"];function mA(){const e=re(p=>p.showMcpPicker),n=re(p=>p.setShowMcpPicker),a=re(p=>p.mcpServers),s=re(p=>p.addMcp),i=Xe(p=>p.addServer),l=we(),d=async p=>{s(p);const f=a.find(h=>h.id===p);f&&await i({id:f.id,name:f.name,command:"",args:[],env:{}})};return c.jsx(hm,{open:e,onClose:()=>n(!1),title:"Add MCP Server",searchPlaceholder:"Search servers...",children:p=>{const f=a.filter(g=>{if(!p)return!0;const x=p.toLowerCase();return g.name.toLowerCase().includes(x)||g.description.toLowerCase().includes(x)});return fA.map(g=>({category:g,label:pA[g],servers:f.filter(x=>x.category===g)})).filter(g=>g.servers.length>0).map(g=>c.jsxs("div",{children:[c.jsx("div",{className:"px-5 py-1.5",children:c.jsx("span",{className:"text-[12px] font-medium tracking-wider uppercase",style:{color:l.textDim},children:g.label})}),g.servers.map(x=>c.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 hover-row cursor-default",children:[c.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:l.surfaceElevated},children:c.jsx(cA,{icon:x.icon,size:16,style:{color:l.textSecondary}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[17px] font-medium",style:{color:l.textPrimary},children:x.name}),c.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:x.connected?l.statusSuccess:l.statusError,boxShadow:x.connected?l.statusSuccessGlow:l.statusErrorGlow}})]}),c.jsx("span",{className:"text-[14px]",style:{color:l.textDim},children:x.description})]}),x.added?c.jsxs("span",{className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md",style:{color:l.statusSuccess,background:l.statusSuccessBg},children:[c.jsx(jt,{size:12})," Added"]}):c.jsxs("button",{type:"button",onClick:()=>d(x.id),className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{color:"#FE5000",background:"#FE500012",transition:"background 0.15s ease"},onMouseEnter:b=>{b.currentTarget.style.background="#FE500025"},onMouseLeave:b=>{b.currentTarget.style.background="#FE500012"},"aria-label":`Add ${x.name}`,children:[c.jsx(bt,{size:12})," Add"]})]},x.id))]},g.category))}})}const gc=qt((e,n)=>({skills:[],loaded:!1,loading:!1,error:void 0,loadSkills:async()=>{if(!n().loading){e({loading:!0,error:void 0});try{const a=await fetch(`${Ae}/claude-config/skills`);if(!a.ok){e({loaded:!0,loading:!1,error:`Failed to load skills (${a.status})`});return}const i=(await a.json())?.data??[];e({skills:i.map(l=>({...l,enabled:!0})),loaded:!0,loading:!1})}catch{e({loaded:!0,loading:!1,error:"Backend unavailable. Start the server with `npm run server` on port 4800."})}}},toggleSkill:a=>{e({skills:n().skills.map(s=>s.id===a?{...s,enabled:!s.enabled}:s)})}})),Wr=new Map;function hA(e){return e==="Pass"?"#2ecc71":e==="Fail"?"#e74c3c":"#888"}const Fx={GEN:"Gen Agent Trust Hub",SOC:"Socket",SNK:"Snyk"};function gm({skillPath:e}){const n=we(),[a,s]=z.useState(()=>Wr.get(e)??null),[i,l]=z.useState(null);z.useEffect(()=>{if(Wr.has(e)){s(Wr.get(e));return}let p=!1;return fetch(`${Ae}/skills/audit/${e}`).then(f=>f.json()).then(f=>{p||(Wr.set(e,f),s(f))}).catch(()=>{if(p)return;const f={gen:"Pending",socket:"Pending",snyk:"Pending"};Wr.set(e,f),s(f)}),()=>{p=!0}},[e]);const d=[{key:"gen",label:"GEN",value:a?.gen??null},{key:"soc",label:"SOC",value:a?.socket??null},{key:"snk",label:"SNK",value:a?.snyk??null}];return c.jsx("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:3},children:d.map(p=>{const f=a===null,h=f?"#888":hA(p.value),g=f?`${Fx[p.label]}: Loading...`:`${Fx[p.label]}: ${p.value??"Pending"}`;return c.jsxs("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:2,cursor:"default"},onMouseEnter:()=>l(p.key),onMouseLeave:()=>l(null),children:[f?c.jsx(pt,{size:8,style:{color:"#888"},className:"animate-spin"}):c.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:h,flexShrink:0}}),c.jsx("span",{style:{fontSize:12,fontFamily:"'Geist Mono', monospace",fontWeight:600,color:h,lineHeight:1},children:p.label}),i===p.key&&c.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:4,background:n.surfaceOpaque,border:`1px solid ${n.border}`,borderRadius:4,padding:"2px 6px",whiteSpace:"nowrap",fontSize:12,color:n.textPrimary,boxShadow:"0 4px 12px rgba(0,0,0,0.4)",zIndex:100,pointerEvents:"none"},children:g})]},p.key)})})}const gA={content:"Content",analysis:"Analysis",development:"Development",domain:"Domain"},yA=["content","analysis","development","domain"];function xA(e,n){const a=`${e} ${n}`.toLowerCase();return/analysis|insight|research|intel|feedback/.test(a)?"analysis":/code|dev|api|build|test|automation|github/.test(a)?"development":/content|write|presentation|slides|copy/.test(a)?"content":"domain"}function bA(){const e=re(x=>x.showSkillPicker),n=re(x=>x.setShowSkillPicker),a=re(x=>x.skills),s=re(x=>x.addSkill),i=re(x=>x.upsertSkill),l=gc(x=>x.skills),d=gc(x=>x.loaded),p=gc(x=>x.loading),f=gc(x=>x.loadSkills),h=we();z.useEffect(()=>{e&&!d&&!p&&f()},[e,d,p,f]),z.useEffect(()=>{if(l.length!==0)for(const x of l)i({id:x.id,name:x.name,description:x.description||"Installed skill"})},[l,i]);const g=z.useMemo(()=>{const x=new Set(a.filter(v=>v.added).map(v=>v.id)),b=new Map(a.map(v=>[v.id,v]));for(const v of l)b.has(v.id)||b.set(v.id,{id:v.id,name:v.name,icon:"zap",enabled:v.enabled,added:x.has(v.id),description:v.description||"Installed skill",category:xA(v.name,v.description||"")});return Array.from(b.values())},[a,l]);return c.jsx(hm,{open:e,onClose:()=>n(!1),title:"Add Skill",searchPlaceholder:"Search skills...",children:x=>{const b=g.filter(k=>{if(!x)return!0;const w=x.toLowerCase();return k.name.toLowerCase().includes(w)||k.description.toLowerCase().includes(w)});return yA.map(k=>({category:k,label:gA[k],skills:b.filter(w=>w.category===k)})).filter(k=>k.skills.length>0).map(k=>c.jsxs("div",{children:[c.jsx("div",{className:"px-5 py-1.5",children:c.jsx("span",{className:"text-[12px] font-medium tracking-wider uppercase",style:{color:h.textDim},children:k.label})}),k.skills.map(w=>c.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 hover-row cursor-default",children:[c.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:h.surfaceElevated},children:c.jsx(uA,{icon:w.icon,size:16,style:{color:h.textSecondary}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[17px] font-medium",style:{color:h.textPrimary},children:w.name}),w.skillUrl?.startsWith("https://skills.sh/")&&c.jsx(gm,{skillPath:w.skillUrl.replace("https://skills.sh/","")})]}),c.jsx("span",{className:"text-[14px]",style:{color:h.textDim},children:w.description})]}),w.added?c.jsxs("span",{className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md",style:{color:h.statusSuccess,background:h.statusSuccessBg},children:[c.jsx(jt,{size:12})," Added"]}):c.jsxs("button",{type:"button",onClick:()=>s(w.id),className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{color:"#FE5000",background:"#FE500012",transition:"background 0.15s ease"},onMouseEnter:j=>{j.currentTarget.style.background="#FE500025"},onMouseLeave:j=>{j.currentTarget.style.background="#FE500012"},"aria-label":`Add ${w.name}`,children:[c.jsx(bt,{size:12})," Add"]})]},w.id))]},k.category))}})}function Si({content:e,children:n,position:a="top",delay:s=300}){const i=we(),[l,d]=z.useState(!1),[p,f]=z.useState({x:0,y:0}),h=z.useRef(void 0),g=z.useRef(null),x=()=>{h.current=setTimeout(()=>{if(!g.current)return;const k=g.current.getBoundingClientRect();f({x:k.left+k.width/2,y:a==="top"?k.top-8:k.bottom+8}),d(!0)},s)},b=()=>{clearTimeout(h.current),d(!1)},v=i.isDark?"#333":"#222";return c.jsxs(c.Fragment,{children:[c.jsx("span",{ref:g,onMouseEnter:x,onMouseLeave:b,className:"inline-flex",children:n}),l&&ou.createPortal(c.jsxs("div",{className:"fixed z-[300] pointer-events-none px-2.5 py-1.5 rounded text-[12px]",style:{left:p.x,top:p.y,transform:a==="top"?"translate(-50%, -100%)":"translate(-50%, 0)",background:v,color:"#fff",fontFamily:"'Geist Mono', monospace",boxShadow:"0 2px 8px rgba(0,0,0,0.3)",maxWidth:250,whiteSpace:"normal",lineHeight:1.4},children:[e,c.jsx("div",{style:{position:"absolute",left:"50%",transform:"translateX(-50%)",...a==="top"?{bottom:-4,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`5px solid ${v}`}:{top:-4,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderBottom:`5px solid ${v}`},width:0,height:0}})]}),document.body)]})}function vA(){const e=re(Q=>Q.showMarketplace),n=re(Q=>Q.activeMarketplaceTab),a=re(Q=>Q.setShowMarketplace),s=re(Q=>Q.registrySkills),i=re(Q=>Q.registryMcpServers),l=re(Q=>Q.installRegistrySkill),d=re(Q=>Q.installRegistryMcp),p=re(Q=>Q.upsertSkill),f=re(Q=>Q.skills),[h,g]=z.useState(""),[x,b]=z.useState("all"),[v,k]=z.useState(null),[w,j]=z.useState(null),[T,E]=z.useState(()=>new Set),[S,M]=z.useState([]),[$,A]=z.useState(!1),[_,F]=z.useState(null),[B,G]=z.useState(null),[O,K]=z.useState(null),V=z.useRef(null),P=z.useRef(null),N=we(),D=new Set(Array.isArray(f)?f.filter(Q=>Q.added).map(Q=>Q.id??""):[]),U=z.useCallback(Q=>{if(Q.key!=="Tab"||!P.current)return;const ge=P.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(ge.length===0)return;const xe=ge[0],J=ge[ge.length-1];Q.shiftKey?document.activeElement===xe&&(Q.preventDefault(),J.focus()):document.activeElement===J&&(Q.preventDefault(),xe.focus())},[]);z.useEffect(()=>{e&&(g(""),b("all"),k(null),j(null),M([]),A(!1),F(null),G(null),K(null),setTimeout(()=>V.current?.focus(),100))},[e]),z.useEffect(()=>{if(!e)return;const Q=ge=>{ge.key==="Escape"&&a(!1)};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[e,a]);const q=z.useCallback(Q=>{a(!0,Q),g(""),b("all"),M([]),F(null),A(!1)},[a]),W=z.useCallback((Q,ge,xe)=>{k(Q),G(null),setTimeout(()=>{l(Q,ge,xe),k(null)},1200)},[l]),oe=z.useCallback(async Q=>{j(Q.id);try{const ge=await fetch(`${Ae}/skills/install`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({skillId:Q.id})});if(!ge.ok)throw new Error(`HTTP ${ge.status}`);E(xe=>new Set(xe).add(Q.id)),p({id:Q.id,name:Q.name,description:`Installed from skills.sh (${Q.repo})`,skillUrl:Q.url})}catch(ge){F(ge instanceof Error?ge.message:"Install failed")}finally{j(null)}},[p]),I=z.useCallback(async(Q,ge)=>{k(Q);const xe=i.find(ye=>ye.id===Q);if(!xe){k(null);return}const J=await Xe.getState().addServer({id:xe.id,name:xe.name,command:xe.command,args:xe.defaultArgs,env:ge});J&&await Xe.getState().connectServer(J.id),d(Q),k(null),K(null)},[d,i]);z.useEffect(()=>{if(!e||n!=="skills"){A(!1),M([]),F(null);return}const Q=h.trim();if(Q.length<2){A(!1),M([]),F(null);return}const ge=new AbortController,xe=setTimeout(async()=>{A(!0),F(null);try{const J=await fetch(`${Ae}/skills/search?q=${encodeURIComponent(Q)}`,{signal:ge.signal});if(!J.ok)throw new Error(`HTTP ${J.status}`);const ye=await J.json();M(Array.isArray(ye.data)?ye.data:[]),F(ye.error??null)}catch(J){if(ge.signal.aborted)return;M([]),F(J instanceof Error?J.message:"Search failed")}finally{ge.signal.aborted||A(!1)}},300);return()=>{ge.abort(),clearTimeout(xe)}},[n,h,e]);const L=()=>{if(typeof window>"u")return 4;const Q=window.innerWidth;return Q<=1024?2:Q<=1440?3:4},[Z,ae]=z.useState(L);if(z.useEffect(()=>{const Q=()=>ae(L());return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[]),!e)return null;const pe=(Q,ge)=>{if(!h)return!0;const xe=h.toLowerCase();return Q.toLowerCase().includes(xe)||ge.toLowerCase().includes(xe)},me=s.filter(Q=>pe(Q.name,Q.description)&&(x==="all"||Q.category===x)),he=i.filter(Q=>pe(Q.name,Q.description)&&(x==="all"||Q.category===x)),H=TS.filter(Q=>pe(Q.name,Q.description)),ce={display:"grid",gridTemplateColumns:`repeat(${Z}, 1fr)`,gap:12,padding:16,alignContent:"start"};return c.jsx(c.Fragment,{children:c.jsxs("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>a(!1),children:[c.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.90)",backdropFilter:"blur(4px)"}}),c.jsxs("div",{ref:P,role:"dialog","aria-modal":"true","aria-label":"Marketplace",style:{position:"relative",display:"flex",flexDirection:"column",borderRadius:6,overflow:"hidden",isolation:"isolate",zIndex:1,width:"90vw",maxWidth:1600,height:"80vh",background:N.surfaceOpaque,border:`1px solid ${N.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.6)",animation:"modal-in 0.2s ease-out"},onClick:Q=>Q.stopPropagation(),onKeyDown:U,children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 16px",borderBottom:`1px solid ${N.border}`},children:[c.jsx("span",{style:{fontSize:17,fontWeight:600,flexShrink:0,color:N.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Marketplace"}),c.jsxs("div",{style:{position:"relative",width:240,flexShrink:0},children:[c.jsx(cu,{size:13,style:{position:"absolute",left:10,top:"50%",transform:"translateY(-50%)",color:N.textDim}}),c.jsx("input",{ref:V,type:"text",value:h,onChange:Q=>g(Q.target.value),placeholder:"Search...",style:{width:"100%",outline:"none",fontSize:14,paddingLeft:32,paddingRight:12,paddingTop:6,paddingBottom:6,borderRadius:6,background:N.inputBg,border:`1px solid ${N.border}`,color:N.textPrimary,fontFamily:"'Geist Sans', sans-serif"}})]}),c.jsx("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",borderBottom:`1px solid ${N.borderSubtle}`},children:["skills","mcp","presets"].map(Q=>c.jsx("button",{type:"button",onClick:()=>q(Q),style:{padding:"6px 12px",fontSize:13,fontWeight:500,letterSpacing:"0.025em",textTransform:"uppercase",cursor:"pointer",border:"none",color:n===Q?"#FE5000":N.textDim,borderBottom:n===Q?"2px solid #FE5000":"2px solid transparent",background:"transparent",marginBottom:-1,transition:"color 150ms ease"},children:Q==="mcp"?"MCP Servers":Q==="presets"?"Presets":"Skills"},Q))}),c.jsx(Si,{content:"Close marketplace (Esc)",children:c.jsx("button",{type:"button",onClick:()=>a(!1),style:{padding:4,borderRadius:6,cursor:"pointer",border:"none",background:"transparent",flexShrink:0,color:N.textDim},"aria-label":"Close marketplace",children:c.jsx(Tt,{size:16})})})]}),n==="skills"&&c.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 16px",borderBottom:`1px solid ${N.borderSubtle}`,gap:12,flexWrap:"wrap"},children:[c.jsx("div",{style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap",flex:1},children:g0.map(Q=>c.jsx("button",{type:"button",onClick:()=>b(Q.id),style:{fontSize:12,padding:"2px 10px",borderRadius:9999,cursor:"pointer",border:"none",fontWeight:500,background:x===Q.id?"#FE5000":N.surfaceElevated,color:x===Q.id?"#fff":N.textSecondary,transition:"background 150ms ease, color 150ms ease"},children:Q.label},Q.id))}),c.jsx("div",{style:{display:"flex",alignItems:"center",gap:12,flexShrink:0},children:Object.entries(zs).map(([Q,ge])=>c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:13,color:N.textDim},children:[c.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:ge.color,display:"inline-block",flexShrink:0}}),ge.label]},Q))})]}),n==="mcp"&&c.jsx("div",{style:{display:"flex",alignItems:"center",padding:"8px 16px",gap:4,flexWrap:"wrap",borderBottom:`1px solid ${N.borderSubtle}`},children:g0.map(Q=>c.jsx("button",{type:"button",onClick:()=>b(Q.id),style:{fontSize:12,padding:"2px 10px",borderRadius:9999,cursor:"pointer",border:"none",fontWeight:500,background:x===Q.id?"#FE5000":N.surfaceElevated,color:x===Q.id?"#fff":N.textSecondary,transition:"background 150ms ease, color 150ms ease"},children:Q.label},Q.id))}),c.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[n==="skills"&&c.jsxs(c.Fragment,{children:[me.length>0&&c.jsx("div",{style:ce,children:me.map(Q=>c.jsx(kA,{skill:Q,isInLibrary:D.has(Q.id),installing:v===Q.id,dropdownOpen:B===Q.id,onToggleDropdown:()=>G(B===Q.id?null:Q.id),onInstall:W,t:N},Q.id))}),me.length===0&&!$&&!_&&S.length===0&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 0"},children:c.jsx("span",{style:{fontSize:14,color:N.textFaint},children:"No skills match your search"})}),(h.trim().length>=2||$||_||S.length>0)&&c.jsx("div",{style:{padding:"16px 16px 8px",borderTop:`1px solid ${N.borderSubtle}`},children:c.jsx("span",{style:{fontSize:12,letterSpacing:"0.05em",textTransform:"uppercase",color:N.textDim,fontFamily:"'Geist Mono', monospace"},children:"From skill.sh"})}),$&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 0"},children:c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:13,color:N.textDim},children:[c.jsx(pt,{size:12,style:{animation:"spin 1s linear infinite"}}),"Searching skill.sh..."]})}),!$&&_&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 16px"},children:c.jsx("span",{style:{fontSize:13,color:N.statusError},children:"skill.sh search unavailable"})}),!$&&!_&&S.length>0&&c.jsx("div",{style:{...ce,paddingTop:0},children:S.map(Q=>c.jsx(wA,{skill:Q,installing:w===Q.id,installed:T.has(Q.id),onInstall:()=>oe(Q),t:N},Q.id))}),!$&&!_&&h.trim().length>=2&&S.length===0&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"24px 16px"},children:c.jsx("span",{style:{fontSize:13,color:N.textFaint},children:"No results from skill.sh"})})]}),n==="mcp"&&c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[he.map(Q=>c.jsx(SA,{mcp:Q,installing:v===Q.id,configuringOpen:O===Q.id,onToggleConfigure:()=>K(O===Q.id?null:Q.id),onInstall:I,t:N},Q.id)),he.length===0&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 0"},children:c.jsx("span",{style:{fontSize:14,color:N.textFaint},children:"No MCP servers match your search"})})]}),n==="presets"&&c.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[H.map(Q=>c.jsx(CA,{preset:Q,t:N,onLoad:()=>a(!1)},Q.id)),H.length===0&&c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 0"},children:c.jsx("span",{style:{fontSize:14,color:N.textFaint},children:"No presets match your search"})})]})]})]})]})})}function kA({skill:e,isInLibrary:n,installing:a,dropdownOpen:s,onToggleDropdown:i,onInstall:l,t:d}){const[p,f]=z.useState(!1),[h,g]=z.useState("claude"),[x,b]=z.useState("project"),v=n||e.installed;return c.jsxs("div",{style:{background:d.surfaceElevated,border:`1px solid ${v?d.borderSubtle:d.border}`,borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:5,opacity:v?.55:1,position:"relative",transition:"border-color 150ms ease",minHeight:120},onMouseEnter:k=>{v||(k.currentTarget.style.borderColor="#FE500050")},onMouseLeave:k=>{k.currentTarget.style.borderColor=v?d.borderSubtle:d.border},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[c.jsx("span",{style:{fontSize:13,fontWeight:600,color:d.textPrimary,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),c.jsxs("span",{style:{fontSize:13,color:d.textDim,background:d.badgeBg,borderRadius:3,padding:"1px 4px",whiteSpace:"nowrap",flexShrink:0,fontFamily:"'Geist Mono', monospace"},children:[e.installs>=1e3?`${(e.installs/1e3).toFixed(1)}k`:e.installs,"↓"]})]}),c.jsx("span",{style:{fontSize:12,color:d.textDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"'Geist Sans', sans-serif"},children:e.author}),c.jsxs("div",{style:{flex:1},children:[c.jsx("span",{style:{fontSize:12,color:d.textMuted,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.4,display:p?"block":"-webkit-box",WebkitLineClamp:p?"unset":2,WebkitBoxOrient:"vertical",overflow:p?"visible":"hidden"},children:e.description}),c.jsx("button",{type:"button",onClick:()=>f(!p),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:d.textDim,display:"inline-flex",alignItems:"center",marginTop:1},children:p?c.jsx(V1,{size:9}):c.jsx(Ln,{size:9})})]}),c.jsx(gm,{skillPath:e.id}),c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:2},children:[c.jsx("div",{style:{display:"flex",gap:4,alignItems:"center"},children:e.runtimes.map(k=>c.jsx("span",{title:zs[k].label,style:{width:7,height:7,borderRadius:"50%",background:zs[k].color,display:"inline-block",flexShrink:0}},k))}),v?c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:d.statusSuccess,background:d.statusSuccessBg,borderRadius:4,padding:"2px 6px"},children:[c.jsx(jt,{size:9})," In Library"]}):a?c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:"#FE5000",background:"#FE500010",borderRadius:4,padding:"2px 6px"},children:[c.jsx(pt,{size:9,className:"animate-spin"})," Installing"]}):c.jsxs("button",{type:"button",onClick:i,style:{fontSize:13,padding:"2px 8px",borderRadius:4,cursor:"pointer",border:`1px solid ${s?"#FE5000":d.border}`,color:s?"#FE5000":d.textSecondary,background:"transparent",display:"inline-flex",alignItems:"center",gap:3,transition:"border-color 150ms ease, color 150ms ease"},onMouseEnter:k=>{k.currentTarget.style.borderColor="#FE5000",k.currentTarget.style.color="#FE5000"},onMouseLeave:k=>{s||(k.currentTarget.style.borderColor=d.border,k.currentTarget.style.color=d.textSecondary)},children:["Install ",c.jsx(Ln,{size:8})]})]}),s&&c.jsxs("div",{style:{position:"absolute",right:0,bottom:"calc(100% + 4px)",background:d.surfaceOpaque,border:`1px solid ${d.border}`,boxShadow:"0 8px 24px rgba(0,0,0,0.5)",borderRadius:6,padding:10,zIndex:20,width:220,display:"flex",flexDirection:"column",gap:8},children:[c.jsxs("div",{children:[c.jsx("span",{style:{fontSize:13,fontWeight:600,color:d.textDim,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Target"}),c.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:["all",...e.runtimes].map(k=>c.jsx("button",{type:"button",onClick:()=>g(k),style:{fontSize:13,padding:"2px 6px",borderRadius:4,cursor:"pointer",border:"none",background:h===k?"#FE5000":d.surfaceElevated,color:h===k?"#fff":d.textSecondary,fontWeight:500},children:k==="all"?"All":zs[k].label},k))})]}),c.jsxs("div",{children:[c.jsx("span",{style:{fontSize:13,fontWeight:600,color:d.textDim,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Scope"}),c.jsx("div",{style:{display:"flex",gap:4,marginTop:4},children:["project","global"].map(k=>c.jsx("button",{type:"button",onClick:()=>b(k),style:{fontSize:13,padding:"2px 6px",borderRadius:4,cursor:"pointer",border:"none",background:x===k?"#FE5000":d.surfaceElevated,color:x===k?"#fff":d.textSecondary,fontWeight:500,textTransform:"capitalize"},children:k},k))})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,background:d.inputBg,borderRadius:4,padding:"4px 6px"},children:[c.jsx(Ks,{size:9,style:{color:d.textDim,flexShrink:0}}),c.jsxs("code",{style:{fontSize:12,color:d.textMuted,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.installCmd," --target ",h," --scope ",x]})]}),c.jsx("button",{type:"button",onClick:()=>l(e.id,h,x),style:{width:"100%",padding:"6px",borderRadius:4,border:"none",background:"#FE5000",color:"#fff",fontSize:12,fontWeight:600,cursor:"pointer"},children:"Confirm Install"})]})]})}function wA({skill:e,installing:n,installed:a,onInstall:s,t:i}){const[l,d]=z.useState(!1),p=e.url.replace("https://skills.sh/","");return c.jsxs("div",{style:{background:i.surfaceElevated,border:`1px solid ${i.border}`,borderRadius:6,padding:"10px 12px",display:"flex",flexDirection:"column",gap:5,position:"relative",transition:"border-color 150ms ease",minHeight:120},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE500050"},onMouseLeave:f=>{f.currentTarget.style.borderColor=i.border},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[c.jsx("span",{style:{fontSize:13,fontWeight:600,color:i.textPrimary,fontFamily:"'Geist Mono', monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),c.jsxs("span",{style:{fontSize:13,color:i.textDim,background:i.badgeBg,borderRadius:3,padding:"1px 4px",whiteSpace:"nowrap",flexShrink:0,fontFamily:"'Geist Mono', monospace"},children:[e.installs,"↓"]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx("span",{style:{fontSize:12,color:i.textDim,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,fontFamily:"'Geist Sans', sans-serif"},children:e.repo}),c.jsx(Si,{content:"View on skills.sh",children:c.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:i.textDim,flexShrink:0,display:"inline-flex"},"aria-label":`Open ${e.name} on skills.sh`,onMouseEnter:f=>{f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.color=i.textDim},children:c.jsx(Z1,{size:10})})})]}),c.jsxs("div",{style:{flex:1},children:[c.jsx("span",{style:{fontSize:12,color:i.textMuted,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.4,display:l?"block":"-webkit-box",WebkitLineClamp:l?"unset":2,WebkitBoxOrient:"vertical",overflow:l?"visible":"hidden"},children:e.url}),c.jsx("button",{type:"button",onClick:()=>d(!l),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:i.textDim,display:"inline-flex",alignItems:"center",marginTop:1},children:l?c.jsx(V1,{size:9}):c.jsx(Ln,{size:9})})]}),c.jsx(gm,{skillPath:p}),c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:2},children:[c.jsx(pn,{size:10,style:{color:i.textDim}}),a?c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:i.statusSuccess,background:i.statusSuccessBg,borderRadius:4,padding:"2px 6px"},children:[c.jsx(jt,{size:9})," Installed"]}):n?c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:13,color:"#FE5000",background:"#FE500010",borderRadius:4,padding:"2px 6px"},children:[c.jsx(pt,{size:9,className:"animate-spin"})," Installing"]}):c.jsxs("button",{type:"button",onClick:s,style:{fontSize:13,padding:"2px 8px",borderRadius:4,cursor:"pointer",border:`1px solid ${i.border}`,color:"#FE5000",background:"#FE500010",display:"inline-flex",alignItems:"center",gap:3},children:[c.jsx(lu,{size:9})," Install"]})]})]})}function SA({mcp:e,installing:n,configuringOpen:a,onToggleConfigure:s,onInstall:i,t:l}){const d=Xe(f=>f.servers),p=e.installed||d.some(f=>f.name===e.name);return c.jsxs("div",{style:{position:"relative",borderBottom:`1px solid ${l.borderSubtle}`},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 16px",height:48,transition:"background 100ms ease"},onMouseEnter:f=>{f.currentTarget.style.background=l.surfaceHover},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:[c.jsx("div",{style:{width:20,height:20,borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:l.surfaceElevated},children:c.jsx(Tv,{icon:e.icon,size:13,style:{color:l.textSecondary}})}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c.jsx("span",{style:{fontSize:14,fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:l.textPrimary},spellCheck:!1,children:e.name}),c.jsx("span",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:l.textDim},children:e.author})]}),c.jsxs("div",{style:{display:"flex",gap:2,marginTop:2},children:[e.runtimes.map(f=>c.jsx("div",{style:{borderRadius:2,width:16,height:3,background:zs[f].color},title:zs[f].label},f)),c.jsx("span",{style:{fontSize:12,marginLeft:4,textTransform:"uppercase",color:e.transport==="stdio"?l.statusInfo:l.statusWarning,fontFamily:"'Geist Mono', monospace"},children:e.transport})]})]}),c.jsx("span",{style:{fontSize:13,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,color:l.textMuted,maxWidth:200},title:e.description,spellCheck:!1,children:e.description}),p?c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,padding:"4px 8px",borderRadius:6,flexShrink:0,color:l.statusSuccess,background:l.statusSuccessBg},children:[c.jsx(jt,{size:10})," Installed"]}):n?c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,fontSize:12,padding:"4px 8px",borderRadius:6,flexShrink:0,color:"#FE5000",background:"#FE500010"},children:[c.jsx(pt,{size:10,style:{animation:"spin 1s linear infinite"}})," Configuring"]}):c.jsx("button",{type:"button",onClick:s,style:{fontSize:12,padding:"4px 8px",borderRadius:6,cursor:"pointer",flexShrink:0,background:"transparent",border:`1px solid ${l.border}`,color:l.textSecondary,transition:"border-color 150ms ease, color 150ms ease"},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{a||(f.currentTarget.style.borderColor=l.border,f.currentTarget.style.color=l.textSecondary)},children:"Configure"})]}),a&&c.jsx(MA,{mcp:e,onInstall:i,t:l})]})}function MA({mcp:e,onInstall:n,t:a}){const[s,i]=z.useState({});return c.jsxs("div",{style:{position:"absolute",right:16,marginTop:0,borderRadius:6,padding:12,zIndex:10,display:"flex",flexDirection:"column",gap:8,background:a.surfaceOpaque,border:`1px solid ${a.border}`,boxShadow:"0 8px 24px rgba(0,0,0,0.4)",width:260,top:48},children:[e.configFields.length>0?e.configFields.map(l=>c.jsxs("div",{children:[c.jsx("label",{style:{fontSize:12,fontWeight:500,color:a.textDim,fontFamily:"'Geist Mono', monospace"},children:l.label}),c.jsx("input",{type:l.type==="password"?"password":"text",placeholder:l.placeholder,value:s[l.key]||"",onChange:d=>i({...s,[l.key]:d.target.value}),style:{width:"100%",fontSize:13,padding:"4px 8px",borderRadius:6,outline:"none",marginTop:2,background:a.inputBg,border:`1px solid ${a.border}`,color:a.textPrimary}})]},l.key)):c.jsx("span",{style:{fontSize:13,color:a.textMuted},children:"No configuration needed"}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderRadius:6,background:a.inputBg},children:[c.jsx(Ks,{size:9,style:{color:a.textDim}}),c.jsx("code",{style:{fontSize:13,color:a.textMuted,fontFamily:"'Geist Mono', monospace"},children:e.installCmd})]}),c.jsx("button",{type:"button",onClick:()=>n(e.id,s),style:{width:"100%",padding:"6px 0",borderRadius:6,fontSize:13,fontWeight:500,cursor:"pointer",border:"none",background:"#FE5000",color:"#fff"},children:"Save & Install"})]})}function CA({preset:e,t:n,onLoad:a}){return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"0 16px",minHeight:56,borderBottom:`1px solid ${n.borderSubtle}`,transition:"background 100ms ease"},onMouseEnter:s=>{s.currentTarget.style.background=n.surfaceHover},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[c.jsx("div",{style:{width:24,height:24,borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:"#FE500010"},children:c.jsx(Tv,{icon:e.icon,size:14,style:{color:"#FE5000"}})}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:n.textPrimary},children:e.name}),c.jsx("div",{style:{fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:2,color:n.textMuted},title:e.description,spellCheck:!1,children:e.description}),c.jsxs("div",{style:{display:"flex",gap:4,marginTop:2},children:[e.skills.slice(0,3).map(s=>c.jsx("span",{style:{fontSize:12,padding:"0 4px",borderRadius:2,color:n.cableSkills,background:n.cableSkills+"10"},children:s},s)),e.mcpServers.slice(0,2).map(s=>c.jsx("span",{style:{fontSize:12,padding:"0 4px",borderRadius:2,color:n.cableMcp,background:n.cableMcp+"10"},children:s},s))]})]}),c.jsx("button",{type:"button",onClick:a,style:{fontSize:12,padding:"4px 8px",borderRadius:6,cursor:"pointer",flexShrink:0,background:"transparent",border:`1px solid ${n.border}`,color:n.textSecondary,whiteSpace:"nowrap",minWidth:80,transition:"border-color 150ms ease, color 150ms ease, background 150ms ease"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#FE5000",s.currentTarget.style.color="#fff",s.currentTarget.style.background="#FE5000"},onMouseLeave:s=>{s.currentTarget.style.borderColor=n.border,s.currentTarget.style.color=n.textSecondary,s.currentTarget.style.background="transparent"},children:"Load Preset"})]})}async function EA(){return(await(await fetch(`${Ae}/connectors/auth`)).json()).data||{}}async function jA(e){const n=await fetch(`${Ae}/mcp/oauth/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverUrl:e})});if(!n.ok){const s=await n.json().catch(()=>({error:"Request failed"}));throw new Error(s.error||`HTTP ${n.status}`)}const{authUrl:a}=await n.json();return new Promise((s,i)=>{const l=window.open(a,"mcp-oauth","width=600,height=700,popup=yes");if(!l){i(new Error("Popup blocked — allow popups for this site"));return}const d=()=>{window.removeEventListener("message",p),clearInterval(f),clearTimeout(h)},p=g=>{const x=g.data;x?.type&&(x.type==="mcp-oauth-success"?(d(),s()):x.type==="mcp-oauth-error"&&(d(),i(new Error(x.error||"OAuth flow failed"))))};window.addEventListener("message",p);const f=setInterval(()=>{l.closed&&(d(),i(new Error("OAuth flow cancelled")))},500),h=setTimeout(()=>{d(),l.close(),i(new Error("OAuth flow timed out"))},3e5)})}async function TA(e){const n=await fetch(`${Ae}/mcp/oauth/status?serverUrl=${encodeURIComponent(e)}`);return n.ok?await n.json():{connected:!1}}const Ix=[{service:"notion",name:"Notion",mcpServerId:"notion",description:"Read and write Notion pages and databases",directions:["read","write","both"]},{service:"slack",name:"Slack",mcpServerId:"slack",description:"Read channels and send messages",directions:["read","write","both"]},{service:"hubspot",name:"HubSpot",mcpServerId:"HubSpotDev",description:"CRM contacts, companies, and deals",directions:["read","write","both"]},{service:"granola",name:"Granola",mcpServerId:"granola",description:"Meeting transcripts and notes",directions:["read"]},{service:"github",name:"GitHub",mcpServerId:"mcp-github",description:"Repos, issues, and pull requests",directions:["read","write","both"]},{service:"google-drive",name:"Google Drive",mcpServerId:"mcp-gdrive",description:"Documents, sheets, and files",directions:["read","write","both"]}],Dn={read:{color:"#6aafe6",bg:"#3498db10",bgHover:"#3498db1a"},write:{color:"#ff8c55",bg:"#FE500010",bgHover:"#FE50001a"},both:{color:"#b88ad4",bg:"#9b59b610",bgHover:"#9b59b61a"}};function NA({auth:e}){const n=e?.status==="connected"?"#00cc66":e?.hasApiKey?"#ffaa00":"#555";return c.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:n,flexShrink:0},title:e?.status==="connected"?"Connected":e?.hasApiKey?"API key stored":"Not configured"})}function Lx({label:e,t:n}){return c.jsx("div",{className:"px-5 pt-3 pb-1 text-[11px] tracking-[0.12em] uppercase",style:{color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:e})}function AA(){const e=re(G=>G.showConnectorPicker),n=re(G=>G.setShowConnectorPicker),a=re(G=>G.connectors),s=re(G=>G.addConnector),i=we(),[l,d]=z.useState({}),[p,f]=z.useState({}),[h,g]=z.useState({}),[x,b]=z.useState({}),v=Xe(G=>G.servers),k=Kc.filter(G=>G.authMethod==="oauth"&&!!G.url);z.useEffect(()=>{e&&(EA().then(d).catch(()=>{}),k.forEach(G=>{TA(G.url).then(O=>{if(f(K=>({...K,[G.url]:O.connected})),O.connected){const K=G.id;re.getState().connectors.some(V=>V.service===K)||s({id:`conn-${G.id}-oauth`,service:K,name:G.name,mcpServerId:G.id,direction:"both",enabled:!0,config:{},status:"connected",authMethod:"oauth"})}}).catch(()=>{})}))},[e]);const w=new Set(Ix.map(G=>G.mcpServerId)),j=v.filter(G=>!w.has(G.id)).map(G=>({service:G.id,name:G.name,mcpServerId:G.id,description:G.command||`MCP server: ${G.id}`,directions:["read","write","both"]})),T=j.filter(G=>v.find(O=>O.id===G.mcpServerId)?.status==="connected"),E=[...Ix,...j.filter(G=>v.find(O=>O.id===G.mcpServerId)?.status!=="connected")],S=(G,O)=>{const K=`conn-${G.service}-${Date.now()}`;s({id:K,service:G.service,name:G.name,mcpServerId:G.mcpServerId,direction:O,enabled:!0,config:{},status:"configured",authMethod:"api-key"})},M=G=>a.some(O=>O.service===G),$=async G=>{g(O=>({...O,[G.url]:!0})),b(O=>({...O,[G.url]:""}));try{await jA(G.url),f(K=>({...K,[G.url]:!0}));const O=G.id;await Xe.getState().addServer({id:G.id,name:G.name,type:"http",command:"",args:[],env:{},url:G.url,headers:{},autoConnect:!0}),a.some(K=>K.service===O)||s({id:`conn-${G.id}-oauth-${Date.now()}`,service:O,name:G.name,mcpServerId:G.id,direction:"both",enabled:!0,config:{},status:"connected",authMethod:"oauth"})}catch(O){b(K=>({...K,[G.url]:O.message}))}finally{g(O=>({...O,[G.url]:!1}))}},A=G=>{const O=p[G.url]??!1,K=h[G.url]??!1,V=x[G.url],P=M(G.id);return c.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 hover-row cursor-default",children:[c.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:i.surfaceElevated},children:c.jsx($x,{service:G.id,size:16,style:{color:i.textSecondary}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:O?"#00cc66":"#555",flexShrink:0}}),c.jsx("span",{className:"text-[17px] font-medium",style:{color:i.textPrimary},children:G.name}),c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full uppercase",style:{background:"#FE500010",color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:"OAuth"})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-[14px]",style:{color:i.textDim},children:G.description}),V&&c.jsx("span",{className:"text-[12px] ml-2",style:{color:"#ff4444"},children:V})]})]}),P?c.jsxs("span",{className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md",style:{color:i.statusSuccess,background:i.statusSuccessBg},children:[c.jsx(jt,{size:12})," Connected"]}):c.jsxs("button",{type:"button",onClick:()=>$(G),disabled:K,className:"flex items-center gap-1.5 text-[13px] px-3 py-1 rounded-md cursor-pointer border-none",style:{background:"#FE500018",color:"#FE5000",fontWeight:600,opacity:K?.7:1},children:[K?c.jsx(pt,{size:12,className:"animate-spin"}):c.jsx(bt,{size:12}),K?"Connecting...":"Connect"]})]},G.id)},_=G=>{const O=l[G.service],K=v.find(V=>V.id===G.mcpServerId)?.status==="connected";return O?.status==="connected"||K},F=()=>{re.getState().setShowSettings(!0),n(!1)},B=G=>{const O=M(G.service),K=l[G.service],V=_(G);return c.jsxs("div",{className:"flex items-center gap-3 px-5 py-2.5 hover-row cursor-default",children:[c.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center shrink-0",style:{background:i.surfaceElevated},children:c.jsx($x,{service:G.service,size:16,style:{color:i.textSecondary}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(NA,{auth:K}),c.jsx("span",{className:"text-[17px] font-medium",style:{color:i.textPrimary},children:G.name}),c.jsx("div",{className:"flex gap-1",children:G.directions.map(P=>c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full uppercase",style:{background:Dn[P].bg,color:Dn[P].color,fontFamily:"'Geist Mono', monospace",fontWeight:600},children:P},P))})]}),c.jsx("span",{className:"text-[14px]",style:{color:i.textDim},children:G.description})]}),O?c.jsxs("span",{className:"flex items-center gap-1 text-[14px] px-2.5 py-1 rounded-md",style:{color:i.statusSuccess,background:i.statusSuccessBg},children:[c.jsx(jt,{size:12})," Added"]}):V?c.jsxs("div",{className:"flex gap-1",children:[G.directions.filter(P=>P!=="both").map(P=>c.jsxs("button",{type:"button",onClick:()=>S(G,P),className:"flex items-center gap-1 text-[13px] px-2 py-0.5 rounded-md cursor-pointer border-none uppercase",style:{color:Dn[P].color,background:Dn[P].bg,fontWeight:600,letterSpacing:"0.05em",transition:"background 0.15s ease"},onMouseEnter:N=>{N.currentTarget.style.background=Dn[P].bgHover},onMouseLeave:N=>{N.currentTarget.style.background=Dn[P].bg},"aria-label":`Add ${G.name} as ${P}`,children:[c.jsx(bt,{size:10})," ",P]},P)),G.directions.includes("both")&&c.jsxs("button",{type:"button",onClick:()=>S(G,"both"),className:"flex items-center gap-1 text-[13px] px-2 py-0.5 rounded-md cursor-pointer border-none uppercase",style:{color:Dn.both.color,background:Dn.both.bg,fontWeight:600,letterSpacing:"0.05em",transition:"background 0.15s ease"},onMouseEnter:P=>{P.currentTarget.style.background=Dn.both.bgHover},onMouseLeave:P=>{P.currentTarget.style.background=Dn.both.bg},"aria-label":`Add ${G.name} as both`,children:[c.jsx(bt,{size:10})," Both"]})]}):c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-[12px]",style:{color:i.textFaint},children:"Setup required"}),c.jsx("button",{type:"button",onClick:F,className:"text-[12px] px-2 py-0.5 rounded cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000"},children:"Configure in Settings"})]})]},G.service)};return c.jsx(hm,{open:e,onClose:()=>n(!1),title:"Add Connector",searchPlaceholder:"Search connectors...",children:G=>{const O=G?.toLowerCase()??"",K=q=>!O||q.name.toLowerCase().includes(O)||q.description.toLowerCase().includes(O),V=q=>!O||q.name.toLowerCase().includes(O)||q.description.toLowerCase().includes(O),P=T.filter(K),N=E.filter(K),D=k.filter(q=>p[q.url]&&V(q)),U=k.filter(q=>!p[q.url]&&V(q));return c.jsxs(c.Fragment,{children:[(P.length>0||D.length>0)&&c.jsxs(c.Fragment,{children:[c.jsx(Lx,{label:"Connected Services",t:i}),D.map(A),P.map(B)]}),(N.length>0||U.length>0)&&c.jsxs(c.Fragment,{children:[c.jsx(Lx,{label:"Available Connectors",t:i}),U.map(A),N.map(B)]})]})}})}const _A=[{id:"providers",label:"Providers"},{id:"mcp",label:"MCP Servers"},{id:"general",label:"General"}];function Gc(e,n){switch(e){case"connected":return n.statusSuccess;case"configured":return n.statusWarning;case"error":return n.statusError;default:return n.textMuted}}function DA({provider:e}){const n=we(),[a,s]=z.useState(!1),[i,l]=z.useState(!1),[d,p]=z.useState(e.apiKey||""),[f,h]=z.useState(e.baseUrl),[g,x]=z.useState(null),b=Je(O=>O.setProviderKey),v=Je(O=>O.setProviderAuthMethod),k=Je(O=>O.setProviderBaseUrl),w=Je(O=>O.testConnection),j=Je(O=>O.testing[e.id]),T=Je(O=>O.deleteProvider),E=Je(O=>O.saveProvider),S=e.id.startsWith("custom-"),M=e.id==="openai",$=M&&e.authMethod==="oauth",A=e.id==="anthropic"?"Claude":e.name,_=Array.isArray(e.models)?e.models:[];z.useEffect(()=>{e.apiKey&&e.apiKey.trim().length>0&&p(e.apiKey),h(e.baseUrl)},[e.apiKey,e.baseUrl]);const F=z.useCallback(()=>{b(e.id,d),k(e.id,f),E(e.id)},[e.id,d,f,b,k,E]),B=z.useCallback(async()=>{F();const O=await w(e.id);x(O)},[e.id,F,w]),G={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return c.jsxs("div",{style:{background:a?n.surfaceElevated:"transparent",borderBottom:`1px solid ${n.borderSubtle}`},children:[c.jsxs("div",{role:"button",tabIndex:0,className:"nodrag nowheel w-full flex items-center gap-3 px-4 py-3 cursor-pointer border-none bg-transparent text-left",onClick:()=>s(!a),style:{color:n.textPrimary},children:[c.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Gc(e.status,n),boxShadow:`0 0 6px ${Gc(e.status,n)}40`}}),c.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center shrink-0",style:{background:e.color+"20"},children:c.jsx(zi,{size:14,style:{color:e.color}})}),c.jsx("span",{className:"text-[14px] font-semibold flex-1",style:{fontFamily:"'Geist Mono', monospace"},children:A}),c.jsx("span",{className:"text-[12px]",style:{color:n.textMuted},children:e.status==="connected"?`${_.length} models`:e.status})]}),a&&c.jsxs("div",{className:"px-4 pb-4 flex flex-col gap-3",children:[M&&c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Auth Mode"}),c.jsxs("select",{value:e.authMethod,onChange:O=>v(e.id,O.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:G,children:[c.jsx("option",{value:"api-key",children:"API Key"}),c.jsx("option",{value:"oauth",children:"Local Session (experimental)"})]})]}),e.authMethod==="claude-agent-sdk"?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2.5 rounded-lg",style:{background:n.badgeBg,border:`1px solid ${n.borderSubtle}`},children:[c.jsx(Ks,{size:14,style:{color:e.color}}),c.jsx("span",{style:{color:n.textSecondary},children:"Authenticates via your Claude Code login — no API key needed."})]}),e.status==="connected"&&c.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:n.statusSuccessBg,border:`1px solid ${n.statusSuccess}30`,color:n.statusSuccess},children:[c.jsx(Hc,{size:14}),c.jsxs("span",{children:["Authenticated",e.lastError?` — ${e.lastError}`:" via Claude Code"]})]}),e.status==="error"&&c.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:n.statusErrorBg,border:`1px solid ${n.statusError}30`,color:n.statusError},children:[c.jsx(xi,{size:14}),c.jsx("span",{children:e.lastError||"Not authenticated — install Claude Code and run claude login"})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Available Models"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:_.map(O=>c.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:e.color+"15",color:e.color,fontFamily:"'Geist Mono', monospace"},children:O.label},O.id))})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsxs("button",{type:"button",onClick:B,disabled:j,className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:j?.6:1},children:[j?c.jsx(pt,{size:12,className:"animate-spin"}):c.jsx(cv,{size:12}),"Check Status"]}),c.jsx("button",{type:"button",onClick:B,disabled:j,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.textSecondary,background:n.badgeBg,opacity:j?.6:1},children:"Refresh Models"})]})]}):c.jsxs(c.Fragment,{children:[$?c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"flex items-start gap-2 text-[14px] px-3 py-2.5 rounded-lg",style:{background:n.badgeBg,border:`1px solid ${n.borderSubtle}`},children:[c.jsx(Ks,{size:14,style:{color:e.color,marginTop:1}}),c.jsx("span",{style:{color:n.textSecondary},children:"Codex browser sign-in (guided): open OpenAI dashboard, create key, and complete login flow."})]}),c.jsx("button",{type:"button",onClick:async()=>{try{const K=await(await fetch(`${Ae}/auth/codex/start`,{method:"POST"})).json(),V=K?.data?.sessionId,P=K?.data?.authUrl;if(!V||!P)return;window.open(P,"_blank","noopener,noreferrer");const N=window.prompt("Paste your OpenAI API key to complete Codex login");if(!N)return;const q=(await(await fetch(`${Ae}/auth/codex/complete/${V}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:N.trim()})})).json())?.data?.apiKey;if(!q)return;b(e.id,q),p(q),k(e.id,f),E(e.id),await B()}catch{}},className:"nodrag nowheel flex items-center justify-center gap-1.5 text-[14px] px-3 py-2 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff"},children:"Sign in with Codex"})]}):c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"API Key"}),c.jsxs("div",{className:"relative",children:[c.jsx("input",{type:i?"text":"password",value:d,onChange:O=>p(O.target.value),onBlur:F,placeholder:e._hasStoredKey?"Key stored on server":"sk-...",className:"nodrag nowheel w-full text-[14px] px-3 py-2 pr-9 rounded-lg outline-none",style:G}),c.jsx("button",{type:"button",onClick:()=>l(!i),className:"nodrag nowheel absolute right-2 top-1/2 -translate-y-1/2 cursor-pointer border-none bg-transparent p-0.5",style:{color:n.textDim},children:i?c.jsx(IN,{size:14}):c.jsx(BN,{size:14})})]})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Base URL"}),c.jsx("input",{type:"text",value:f,onChange:O=>h(O.target.value),onBlur:F,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:G})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsxs("button",{type:"button",onClick:B,disabled:j,className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:j?.6:1},children:[j?c.jsx(pt,{size:12,className:"animate-spin"}):c.jsx(na,{size:12}),"Test Connection"]}),c.jsx("button",{type:"button",onClick:B,disabled:j,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.textSecondary,background:n.badgeBg,opacity:j?.6:1},children:"Refresh Models"}),e.keyPageUrl&&!$&&c.jsxs("a",{href:e.keyPageUrl,target:"_blank",rel:"noopener noreferrer",className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2 py-1.5 rounded-lg no-underline",style:{color:n.textSecondary,background:n.badgeBg},children:[c.jsx(Z1,{size:10}),"Get API Key"]}),S&&c.jsxs("button",{type:"button",onClick:()=>T(e.id),className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2 py-1.5 rounded-lg cursor-pointer border-none ml-auto",style:{color:n.statusError,background:n.statusErrorBg},children:[c.jsx(du,{size:10}),"Remove"]})]}),g&&c.jsxs("div",{className:"flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg",style:{background:g.ok?n.statusSuccessBg:n.statusErrorBg,border:`1px solid ${g.ok?n.statusSuccess+"30":n.statusError+"30"}`,color:g.ok?n.statusSuccess:n.statusError},children:[g.ok?c.jsx(Hc,{size:14}):c.jsx(xi,{size:14}),g.ok?`Connected${g.models?` — ${g.models.length} models available`:""}`:g.error||"Connection failed"]})]}),e.headerNote&&c.jsx("span",{className:"text-[12px]",style:{color:n.textFaint},children:e.headerNote})]})]})}function zA(){const e=we(),n=Je(s=>s.providers),a=Je(s=>s.addCustomProvider);return c.jsxs("div",{className:"flex flex-col",children:[c.jsx("div",{className:"flex flex-col",children:n.map(s=>c.jsx(DA,{provider:s},s.id))}),c.jsx("div",{className:"p-4",children:c.jsxs("button",{type:"button",onClick:a,className:"nodrag nowheel flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg cursor-pointer w-full justify-center",style:{border:`1px dashed ${e.border}`,background:"transparent",color:e.textMuted},children:[c.jsx(bt,{size:12}),"Add Custom Provider"]})})]})}function RA({server:e}){const n=we(),[a,s]=z.useState(!1),[i,l]=z.useState(e.name),[d,p]=z.useState(e.command),[f,h]=z.useState(e.args.join(`
|
|
131
|
+
`)),[g,x]=z.useState(Object.entries(e.env).map(([B,G])=>`${B}=${G}`).join(`
|
|
132
|
+
`)),[b,v]=z.useState(!1),[k,w]=z.useState(!1),j=Xe(B=>B.connectServer),T=Xe(B=>B.disconnectServer),E=Xe(B=>B.updateServer),S=Xe(B=>B.removeServer),M=re(B=>B.upsertMcpServer),$=re(B=>B.removeMcpServer);z.useEffect(()=>{l(e.name),p(e.command),h(e.args.join(`
|
|
133
|
+
`)),x(Object.entries(e.env).map(([B,G])=>`${B}=${G}`).join(`
|
|
134
|
+
`))},[e.name,e.command,e.args,e.env]);const A=z.useCallback(()=>{e.status==="connected"?T(e.id):j(e.id)},[e.id,e.status,j,T]),_=z.useCallback(async()=>{v(!0),w(!1);const B=f.split(`
|
|
135
|
+
`).map(V=>V.trim()).filter(Boolean),G={};for(const V of g.split(`
|
|
136
|
+
`)){const[P,...N]=V.split("=");P?.trim()&&N.length>0&&(G[P.trim()]=N.join("=").trim())}const O=e.status==="connected",K=await E(e.id,{name:i.trim(),command:d.trim(),args:B,env:G});K&&(M({id:K.id,name:K.name,description:K.command,connected:K.status==="connected"}),O&&await j(e.id),w(!0),setTimeout(()=>w(!1),1500)),v(!1)},[f,d,g,i,e.id,e.status,E,M,j]),F={background:n.inputBg,border:`1px solid ${n.border}`,color:n.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return c.jsxs("div",{style:{background:a?n.surfaceElevated:"transparent",borderBottom:`1px solid ${n.borderSubtle}`},children:[c.jsxs("div",{role:"button",tabIndex:0,className:"nodrag nowheel w-full flex items-center gap-3 px-4 py-3 cursor-pointer border-none bg-transparent text-left",onClick:()=>s(!a),style:{color:n.textPrimary},children:[c.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{background:Gc(e.status,n),boxShadow:`0 0 6px ${Gc(e.status,n)}40`}}),c.jsx(c4,{size:14,style:{color:n.textDim}}),c.jsxs("div",{className:"flex-1",children:[c.jsxs("div",{className:"text-[14px] font-semibold",style:{color:n.textPrimary,fontFamily:"'Geist Mono', monospace"},children:[e.name,e.mcpStatus&&e.mcpStatus!=="enabled"&&c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded ml-2 uppercase",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:e.mcpStatus==="deferred"?n.statusWarningBg:n.statusErrorBg,color:e.mcpStatus==="deferred"?n.statusWarning:n.statusError},children:e.mcpStatus})]}),c.jsx("div",{className:"text-[12px]",style:{color:n.textMuted},children:e.status==="connected"?`${e.tools.length} tools available`:e.status==="error"?e.lastError||"Connection error":"Not connected"})]}),c.jsxs("button",{type:"button",onClick:B=>{B.stopPropagation(),A()},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-lg cursor-pointer border-none",style:{background:e.status==="connected"?n.statusErrorBg:n.statusSuccessBg,color:e.status==="connected"?n.statusError:n.statusSuccess},children:[e.status==="connecting"?c.jsx(pt,{size:10,className:"animate-spin"}):e.status==="connected"?c.jsx(cv,{size:10}):c.jsx(na,{size:10}),e.status==="connecting"?"Connecting...":e.status==="connected"?"Disconnect":"Connect"]}),c.jsx(rm,{size:12,style:{color:n.textDim}})]}),a&&c.jsxs("div",{className:"px-4 pb-4 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Name"}),c.jsx("input",{type:"text",value:i,onChange:B=>l(B.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:F})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Command"}),c.jsx("input",{type:"text",value:d,onChange:B=>p(B.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:F})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Arguments (one per line)"}),c.jsx("textarea",{value:f,onChange:B=>h(B.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...F,minHeight:"60px"},rows:3})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Environment (key=value, one per line)"}),c.jsx("textarea",{value:g,onChange:B=>x(B.target.value),className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...F,minHeight:"60px"},rows:3})]}),e.tools.length>0&&c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:n.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Available Tools"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(B=>c.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:B.name},B.name))})]}),c.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[c.jsx("button",{type:"button",onClick:_,disabled:b,className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:"#fff",background:"#FE5000",opacity:b?.7:1},children:b?"Saving...":k?"Saved":"Save"}),c.jsxs("button",{type:"button",onClick:()=>{S(e.id),$(e.id)},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1.5 rounded-lg cursor-pointer border-none",style:{color:n.statusError,background:n.statusErrorBg},children:[c.jsx(du,{size:10}),"Delete"]})]})]})]})}function OA(){const e=we(),n=Xe(A=>A.servers),a=Xe(A=>A.loaded),s=Xe(A=>A.loading),i=Xe(A=>A.loadServers),l=Xe(A=>A.addServer),d=Xe(A=>A.error),p=re(A=>A.upsertMcpServer),[f,h]=z.useState(!1),[g,x]=z.useState(""),[b,v]=z.useState(""),[k,w]=z.useState(""),[j,T]=z.useState(""),[E,S]=z.useState(!1);z.useEffect(()=>{!a&&!s&&i()},[a,s,i]),z.useEffect(()=>{for(const A of n)p({id:A.id,name:A.name,description:A.command,connected:A.status==="connected"})},[n,p]);const M=z.useCallback(async()=>{if(!(!g.trim()||!b.trim())){S(!0);try{const A=k.split(`
|
|
137
|
+
`).filter(B=>B.trim()).map(B=>B.trim()),_={};j.split(`
|
|
138
|
+
`).forEach(B=>{const[G,...O]=B.split("=");G?.trim()&&O.length>0&&(_[G.trim()]=O.join("=").trim())});const F=await l({name:g.trim(),command:b.trim(),args:A,env:_});F&&p({id:F.id,name:F.name,description:F.command,connected:F.status==="connected"}),x(""),v(""),w(""),T(""),h(!1)}finally{S(!1)}}},[g,b,k,j,l,p]),$={background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"};return c.jsxs("div",{className:"flex flex-col",children:[s&&c.jsxs("div",{className:"px-4 py-8 text-center text-[14px]",style:{color:e.textMuted},children:[c.jsx(pt,{size:16,className:"animate-spin mx-auto mb-2"}),"Loading MCP servers..."]}),d&&c.jsx("div",{className:"mx-4 mt-3 px-3 py-2 rounded-lg text-[14px]",style:{background:e.statusErrorBg,color:e.statusError,border:`1px solid ${e.statusError}30`},children:d}),a&&n.map(A=>c.jsx(RA,{server:A},A.id)),a&&n.length===0&&!f&&c.jsx("div",{className:"px-4 py-8 text-center text-[14px]",style:{color:e.textMuted},children:"No MCP servers configured. Add a server below."}),f&&c.jsxs("div",{className:"p-4",style:{borderTop:`1px solid ${e.borderSubtle}`,background:e.surfaceElevated},children:[c.jsx("div",{className:"text-[14px] font-semibold mb-3",style:{color:e.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Add MCP Server"}),c.jsxs("div",{className:"flex flex-col gap-3",children:[c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Name"}),c.jsx("input",{type:"text",value:g,onChange:A=>x(A.target.value),placeholder:"My MCP Server",className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:$})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Command"}),c.jsx("input",{type:"text",value:b,onChange:A=>v(A.target.value),placeholder:"uv",className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none",style:$})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Arguments (one per line)"}),c.jsx("textarea",{value:k,onChange:A=>w(A.target.value),placeholder:`tool
|
|
139
|
+
run
|
|
140
|
+
--python
|
|
141
|
+
/path/to/server.py`,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...$,minHeight:"60px"},rows:3})]}),c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("label",{className:"text-[12px] tracking-wider uppercase",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Environment (key=value, one per line)"}),c.jsx("textarea",{value:j,onChange:A=>T(A.target.value),placeholder:`API_KEY=your_key
|
|
142
|
+
DEBUG=1`,className:"nodrag nowheel w-full text-[14px] px-3 py-2 rounded-lg outline-none resize-none",style:{...$,minHeight:"60px"},rows:3})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("button",{type:"button",onClick:M,disabled:E||!g.trim()||!b.trim(),className:"nodrag nowheel flex items-center gap-1.5 text-[14px] px-3 py-1.5 rounded-lg cursor-pointer font-semibold border-none",style:{background:"#FE5000",color:"#fff",opacity:E||!g.trim()||!b.trim()?.6:1},children:[E?c.jsx(pt,{size:12,className:"animate-spin"}):c.jsx(bt,{size:12}),"Add Server"]}),c.jsx("button",{type:"button",onClick:()=>h(!1),className:"nodrag nowheel text-[14px] px-3 py-1.5 rounded-lg cursor-pointer border-none",style:{color:e.textMuted,background:e.badgeBg},children:"Cancel"})]})]})]}),a&&!f&&c.jsx("div",{className:"p-4",children:c.jsxs("button",{type:"button",onClick:()=>h(!0),className:"nodrag nowheel flex items-center gap-2 text-[14px] px-3 py-2 rounded-lg cursor-pointer w-full justify-center",style:{border:`1px dashed ${e.border}`,background:"transparent",color:e.textMuted},children:[c.jsx(bt,{size:12}),"Add MCP Server"]})})]})}function $A(){const e=we(),n=Pc(E=>E.theme),a=Pc(E=>E.toggleTheme),[s,i]=z.useState(()=>localStorage.getItem("modular-edge-style")||"smoothstep"),[l,d]=z.useState(()=>localStorage.getItem("modular-grid-snap")!=="false"),[p,f]=z.useState(()=>localStorage.getItem("modular-minimap")!=="false"),[h,g]=z.useState(()=>localStorage.getItem("modular-bg-style")||"dots"),x=(E,S)=>localStorage.setItem(E,S),b=[{id:"system",label:"System",icon:B3},{id:"light",label:"Light",icon:dv},{id:"dark",label:"Dark",icon:av}],v=[{id:"smoothstep",label:"SmoothStep",icon:D4},{id:"bezier",label:"Bezier",icon:La},{id:"step",label:"Step",icon:YT}],k=[{id:"dots",label:"Dots"},{id:"lines",label:"Lines"},{id:"none",label:"None"}],w={color:e.textMuted,fontFamily:"'Geist Mono', monospace"},j={borderBottom:`1px solid ${e.borderSubtle}`},T=E=>{(E==="light"?"light":"dark")!==n&&a(),x("modular-theme",E)};return c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:j,children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Theme"}),c.jsx("div",{className:"flex gap-1",children:b.map(E=>{const S=E.id==="system"&&n==="dark"&&localStorage.getItem("modular-theme")==="system"||E.id===n;return c.jsxs("button",{type:"button",onClick:()=>T(E.id),className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:S?"#FE500020":e.badgeBg,color:S?"#FE5000":e.textDim},children:[c.jsx(E.icon,{size:11}),E.label]},E.id)})})]}),c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:j,children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Edge Routing"}),c.jsx("div",{className:"flex gap-1",children:v.map(E=>c.jsxs("button",{type:"button",onClick:()=>{i(E.id),x("modular-edge-style",E.id)},className:"nodrag nowheel flex items-center gap-1 text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:s===E.id?"#FE500020":e.badgeBg,color:s===E.id?"#FE5000":e.textDim},children:[c.jsx(E.icon,{size:11}),E.label]},E.id))})]}),c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:j,children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:"Grid Snap"}),c.jsx("button",{type:"button",onClick:()=>{const E=!l;d(E),x("modular-grid-snap",String(E))},className:"nodrag nowheel w-9 h-5 rounded-full cursor-pointer border-none relative transition-colors",style:{background:l?"#FE5000":e.badgeBg},children:c.jsx("div",{className:"absolute top-0.5 w-4 h-4 rounded-full transition-transform",style:{background:"#fff",left:l?"18px":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:j,children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(ov,{size:11})," Minimap"]})}),c.jsx("button",{type:"button",onClick:()=>{const E=!p;f(E),x("modular-minimap",String(E))},className:"nodrag nowheel w-9 h-5 rounded-full cursor-pointer border-none relative transition-colors",style:{background:p?"#FE5000":e.badgeBg},children:c.jsx("div",{className:"absolute top-0.5 w-4 h-4 rounded-full transition-transform",style:{background:"#fff",left:p?"18px":"2px",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),c.jsxs("div",{className:"flex items-center justify-between px-4 py-3",style:j,children:[c.jsx("span",{className:"text-[12px] tracking-wider uppercase",style:w,children:c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(t3,{size:11})," Background"]})}),c.jsx("div",{className:"flex gap-1",children:k.map(E=>c.jsx("button",{type:"button",onClick:()=>{g(E.id),x("modular-bg-style",E.id)},className:"nodrag nowheel text-[13px] px-2.5 py-1 rounded-md cursor-pointer border-none",style:{background:h===E.id?"#FE500020":e.badgeBg,color:h===E.id?"#FE5000":e.textDim},children:E.label},E.id))})]})]})}function FA({open:e,onClose:n}){const a=we(),s=re(f=>f.activeSettingsTab),[i,l]=z.useState(s||"providers");z.useEffect(()=>{e&&s&&l(s)},[e,s]);const d=z.useRef(null),p=z.useCallback(f=>{if(f.key!=="Tab"||!d.current)return;const h=d.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(h.length===0)return;const g=h[0],x=h[h.length-1];f.shiftKey?document.activeElement===g&&(f.preventDefault(),x.focus()):document.activeElement===x&&(f.preventDefault(),g.focus())},[]);return z.useEffect(()=>{if(!e)return;const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e,n]),e?c.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",onClick:n,children:[c.jsx("div",{className:"absolute inset-0",style:{background:a.isDark?"rgba(0,0,0,0.7)":"rgba(0,0,0,0.35)",backdropFilter:"blur(12px)"}}),c.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-label":"Settings",className:"relative w-[560px] max-h-[80vh] rounded-xl overflow-hidden flex flex-col",style:{background:a.surfaceOpaque,border:`1px solid ${a.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.4)"},onClick:f=>f.stopPropagation(),onKeyDown:p,children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",style:{borderColor:a.borderSubtle},children:[c.jsx("span",{className:"text-[14px] tracking-wider uppercase flex-1 font-bold",style:{color:a.textPrimary,fontFamily:"'Geist Mono', monospace"},children:"Settings"}),c.jsx("button",{type:"button",onClick:n,className:"nodrag nowheel cursor-pointer border-none bg-transparent p-1 rounded-md",style:{color:a.textDim},"aria-label":"Close settings",children:c.jsx(Tt,{size:14})})]}),c.jsx("div",{className:"flex gap-1 px-4 pt-2 border-b shrink-0 overflow-x-auto",style:{borderColor:a.borderSubtle,scrollbarWidth:"none"},children:_A.map(f=>c.jsx("button",{type:"button",onClick:()=>l(f.id),className:"nodrag nowheel text-[13px] tracking-wider uppercase px-3 py-2 cursor-pointer border-none bg-transparent font-semibold",style:{color:i===f.id?"#FE5000":a.textDim,borderBottom:i===f.id?"2px solid #FE5000":"2px solid transparent",fontFamily:"'Geist Mono', monospace",marginBottom:"-1px"},children:f.label},f.id))}),c.jsxs("div",{className:"flex-1 overflow-y-auto",style:{scrollbarWidth:"thin"},children:[i==="providers"&&c.jsx(zA,{}),i==="mcp"&&c.jsx(OA,{}),i==="general"&&c.jsx($A,{})]})]})]}):null}const Nv="modular-agent-library-v1";function af(){return`${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function IA(){try{const e=localStorage.getItem(Nv);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function Bx(e){try{localStorage.setItem(Nv,JSON.stringify(e))}catch{}}const LA=qt((e,n)=>({agents:[],agentLibrary:IA(),sharedFacts:[],edges:[],activeAgentId:null,addAgent:a=>e(s=>({agents:[...s.agents,{...a,factIds:[],knowledgeSourceIds:[],mcpServerIds:[],skillIds:[]}]})),addAgentFromLibrary:a=>{const s=n().agentLibrary.find(l=>l.id===a);if(!s)return;n().addAgent({id:`${s.id}-${Date.now()}`,name:s.name,description:s.description,avatar:s.avatar,version:s.version});const i=n().agents[n().agents.length-1]?.id;i&&n().updateAgent(i,{mcpServerIds:s.mcpServerIds,skillIds:s.skillIds})},addAgentFromBackend:a=>{(async()=>{try{const s=await fetch(`${Ae}/agents/${encodeURIComponent(a)}`);if(!s.ok)return;const i=await s.json(),l=i.data??i,d=l.agentMeta??{};n().addAgent({id:`${a}-${Date.now()}`,name:d.name||a,description:d.description||"",avatar:d.avatar||"bot",version:l.version||"1.0.0"});const p=n().agents[n().agents.length-1]?.id;if(!p)return;n().updateAgent(p,{mcpServerIds:(l.mcpServers??[]).map(f=>f.id),skillIds:(l.skills??[]).map(f=>f.id)})}catch{}})()},upsertLibraryAgent:a=>e(s=>{const i=s.agentLibrary.some(l=>l.id===a.id)?s.agentLibrary.map(l=>l.id===a.id?a:l):[...s.agentLibrary,a];return Bx(i),{agentLibrary:i}}),removeLibraryAgent:a=>e(s=>{const i=s.agentLibrary.filter(l=>l.id!==a);return Bx(i),{agentLibrary:i}}),removeAgent:a=>e(s=>({agents:s.agents.filter(i=>i.id!==a),edges:s.edges.filter(i=>i.fromAgentId!==a&&i.toAgentId!==a)})),updateAgent:(a,s)=>e(i=>({agents:i.agents.map(l=>l.id===a?{...l,...s}:l)})),setActiveAgent:a=>e({activeAgentId:a}),addSharedFact:(a,s,i,l=[])=>{const d=`sf-${af()}`;return e(p=>({sharedFacts:[...p.sharedFacts,{id:d,content:a,scope:s,originAgentId:i,sharedWith:[],tags:l,timestamp:Date.now()}]})),d},removeSharedFact:a=>e(s=>({sharedFacts:s.sharedFacts.filter(i=>i.id!==a)})),propagateFact:(a,s)=>e(i=>({sharedFacts:i.sharedFacts.map(l=>l.id===a?{...l,sharedWith:[...new Set([...l.sharedWith,...s])]}:l),edges:[...i.edges,...s.filter(l=>!i.edges.some(d=>d.type==="fact_propagation"&&d.fromAgentId===i.sharedFacts.find(p=>p.id===a)?.originAgentId&&d.toAgentId===l)).map(l=>({id:`edge-${af()}`,fromAgentId:i.sharedFacts.find(d=>d.id===a)?.originAgentId||"",toAgentId:l,type:"fact_propagation",label:"shared fact"}))]})),markFactPromoted:(a,s,i)=>e(l=>({sharedFacts:l.sharedFacts.map(d=>d.id===a?{...d,promotedTo:{agentId:s,target:i,at:Date.now()}}:d)})),addEdge:a=>e(s=>({edges:[...s.edges,{...a,id:`edge-${af()}`}]})),removeEdge:a=>e(s=>({edges:s.edges.filter(i=>i.id!==a)})),getAgentFacts:a=>n().sharedFacts.filter(s=>s.originAgentId===a),getSharedFactsForAgent:a=>n().sharedFacts.filter(s=>s.scope==="global"||s.originAgentId===a||s.sharedWith.includes(a))}));function BA(e){return{...e}}const PA={"claude-opus-4":"claude-opus-4","claude-sonnet-4":"claude-sonnet-4","claude-haiku-3.5":"claude-haiku-3.5","gpt-4o":"gpt-4o","gpt-4.1":"gpt-4.1"};function Av(e,n){if(!e||!e.persona&&!e.objectives.primary&&!e.constraints.customConstraints)return n||"You are an analyst combining multiple knowledge sources to produce structured output.";const a=[];e.persona&&a.push(`You are ${e.persona}.`),e.tone!=="neutral"&&a.push(`Use a ${e.tone} tone.`),e.objectives.primary&&a.push(`
|
|
143
|
+
Primary objective: ${e.objectives.primary}`),e.objectives.successCriteria.length>0&&a.push("Success criteria: "+e.objectives.successCriteria.join("; "));const s=[];return e.constraints.neverMakeUp&&s.push("Never make up information"),e.constraints.askBeforeActions&&s.push("Ask before taking actions"),e.constraints.stayInScope&&s.push(`Stay in scope${e.constraints.scopeDefinition?": "+e.constraints.scopeDefinition:""}`),e.constraints.useOnlyTools&&s.push("Only use provided tools"),e.constraints.limitWords&&s.push(`Keep responses under ${e.constraints.wordLimit} words`),e.constraints.customConstraints&&s.push(e.constraints.customConstraints),s.length>0&&a.push(`
|
|
144
|
+
Constraints:
|
|
145
|
+
`+s.map(i=>`- ${i}`).join(`
|
|
146
|
+
`)),n&&a.push(`
|
|
147
|
+
`+n),a.join(`
|
|
148
|
+
`)}function Xs(e){const n=e.channels.filter(T=>T.enabled),a=PA[e.selectedModel]??e.selectedModel,s=e.agentMeta.name||ZA(e.prompt,n),i=e.agentMeta.description||QA(e.prompt,n),l=e.skills.filter(T=>T.enabled&&T.added),d=e.mcpServers.filter(T=>T.enabled&&T.added),p=l.map(T=>T.name),f=d.map(T=>({name:T.name,transport:"stdio",command:`npx @${T.name.toLowerCase().replace(/\s+/g,"")}hq/mcp`})),h=n.map(T=>T.path),g=e.outputFormats.length>0?e.outputFormats:[e.outputFormat],x=[],b=Av(e.instructionState,e.prompt);x.push(b);const v=e.agentConfig?.temperature??.7,k=e.agentConfig?.planningMode??"single-shot",w=(e.connectors??[]).filter(T=>T.enabled&&T.direction==="read").map(T=>({service:T.service,config:T.config})),j=(e.connectors??[]).filter(T=>T.enabled&&T.direction==="write").map(T=>({service:T.service,config:T.config}));return{name:s,description:i,model:a,icon:e.agentMeta.icon||"brain",category:e.agentMeta.category||"general",temperature:v,planningMode:k,tools:p,mcp_servers:f,reads:h,output_format:g,token_budget:e.tokenBudget,prompt:e.prompt,system:x.join(`
|
|
149
|
+
|
|
150
|
+
`),connectors:{read:w,write:j}}}function $n(e){return e.includes(`
|
|
151
|
+
`)||e.includes(":")||e.includes("#")||e.includes('"')?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e}function HA(e){const n=["---"];if(n.push(`name: ${$n(e.name)}`),n.push(`description: ${$n(e.description)}`),n.push(`model: ${e.model}`),n.push(`temperature: ${e.temperature}`),n.push(`icon: ${e.icon}`),n.push(`category: ${e.category}`),e.tools.length>0){n.push("tools:");for(const a of e.tools)n.push(` - ${a}`)}if(e.mcp_servers.length>0){n.push("mcp_servers:");for(const a of e.mcp_servers)n.push(` - name: ${$n(a.name)}`),n.push(` transport: ${a.transport}`),a.command&&n.push(` command: ${$n(a.command)}`)}if(e.reads.length>0){n.push("reads:");for(const a of e.reads)n.push(` - ${$n(a)}`)}if(e.output_format.length>0){n.push("output_format:");for(const a of e.output_format)n.push(` - ${a}`)}return n.push(`token_budget: ${e.token_budget}`),n.push("---"),n.join(`
|
|
152
|
+
`)}function UA(e,n){const a=n.channels.filter(p=>p.enabled),s=n.instructionState,i=n.workflowSteps,l=[""];if(s?.persona&&(l.push("## Persona"),l.push(s.persona),s.tone!=="neutral"&&l.push(`
|
|
153
|
+
Tone: ${s.tone}`),s.expertise!==3&&l.push(`Expertise level: ${s.expertise}/5`),l.push("")),l.push("## Role"),l.push(e.system),l.push(""),s?.objectives.primary){if(l.push("## Objectives"),l.push(`**Primary:** ${s.objectives.primary}`),s.objectives.successCriteria.length>0){l.push(`
|
|
154
|
+
**Success Criteria:**`);for(const p of s.objectives.successCriteria)l.push(`- ${p}`)}if(s.objectives.failureModes.length>0){l.push(`
|
|
155
|
+
**Failure Modes:**`);for(const p of s.objectives.failureModes)l.push(`- ${p}`)}l.push("")}if(s){const p=[];if(s.constraints.neverMakeUp&&p.push("Never make up information"),s.constraints.askBeforeActions&&p.push("Ask before taking actions"),s.constraints.stayInScope&&p.push(`Stay in scope${s.constraints.scopeDefinition?": "+s.constraints.scopeDefinition:""}`),s.constraints.useOnlyTools&&p.push("Only use provided tools"),s.constraints.limitWords&&p.push(`Keep responses under ${s.constraints.wordLimit} words`),s.constraints.customConstraints&&p.push(s.constraints.customConstraints),p.length>0){l.push("## Constraints");for(const f of p)l.push(`- ${f}`);l.push("")}}if(e.prompt&&(l.push("## Default Prompt"),l.push(e.prompt),l.push("")),l.push("## Workflow"),i&&i.length>0)i.forEach((p,f)=>{const h=`${f+1}. ${p.label}`,g=p.action?` — ${p.action}`:"",x=p.condition!=="always"&&p.conditionText?` (${p.condition} ${p.conditionText})`:"";l.push(`${h}${g}${x}`)});else if(a.length>0){l.push("1. Read all knowledge sources");const p=new Map;for(const h of a){const g=h.knowledgeType;p.has(g)||p.set(g,[]),p.get(g).push(h)}let f=2;for(const[h,g]of p){const x=Qo[h];if(x){const b=g.map(v=>v.name).join(", ");l.push(`${f}. Process ${x.label.toLowerCase()} sources: ${b}`),f++}}l.push(`${f}. Synthesize findings`),l.push(`${f+1}. Generate output`)}else l.push("1. Analyze the provided context"),l.push("2. Identify patterns and key insights"),l.push("3. Synthesize findings"),l.push("4. Generate output");l.push("");const d=n.outputFormats.map(p=>sb.find(h=>h.id===p)?.label??p);return l.push("## Output Format"),l.push(d.length>0?d.join(", "):"Markdown"),l.push(""),l.join(`
|
|
156
|
+
`)}function _v(e){const n=Xs(e),a=HA(n),s=UA(n,e);return a+`
|
|
157
|
+
`+s}function GA(e){const n=Xs(e),a=[];if(a.push(`name: ${$n(n.name)}`),a.push(`model: ${n.model}`),n.tools.length>0){a.push("tools:");for(const i of n.tools)a.push(` - ${i}`)}if(n.mcp_servers.length>0){a.push("mcp:");for(const i of n.mcp_servers)a.push(` ${i.name.toLowerCase().replace(/\s+/g,"-")}:`),i.command&&a.push(` command: ${$n(i.command)}`)}if(n.reads.length>0){a.push("context_files:");for(const i of n.reads)a.push(` - ${$n(i)}`)}const s=Av(e.instructionState,e.prompt);if(s){a.push("instructions: |");for(const i of s.split(`
|
|
158
|
+
`))a.push(` ${i}`)}return a.join(`
|
|
159
|
+
`)+`
|
|
160
|
+
`}function qA(e){const n=Xs(e),a={name:n.name,model:n.model,instructions:n.system,tools:n.tools,mcp_servers:n.mcp_servers.map(s=>({name:s.name,transport:s.transport})),context_files:n.reads};return JSON.stringify(a,null,2)}function KA(e){const n=Xs(e),a={};for(const i of n.mcp_servers)a[i.name.toLowerCase().replace(/\s+/g,"-")]={command:i.command||""};const s={template:n.name,agent:"claude-code",context_files:n.reads,mcp_config:a,tools:n.tools,output_format:n.output_format};return JSON.stringify(s,null,2)}function YA(e){const n=Xs(e),a=n.name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),s=[];if(s.push("agents:"),s.push(` ${a}:`),s.push(` model: ${n.model}`),s.push(` temperature: ${n.temperature}`),n.tools.length>0){s.push(" skills:");for(const i of n.tools)s.push(` - ${i}`)}if(n.mcp_servers.length>0){s.push(" mcp:"),s.push(" servers:");for(const i of n.mcp_servers){const l=i.name.toLowerCase().replace(/\s+/g,"-");s.push(` ${l}:`),i.command&&s.push(` command: ${$n(i.command)}`)}}if(n.reads.length>0){s.push(" context:");for(const i of n.reads)s.push(` - ${$n(i)}`)}return s.join(`
|
|
161
|
+
`)+`
|
|
162
|
+
`}function VA(e){const n=Xs(e),a=e.outputTemplateConfig?Object.fromEntries(Object.entries(e.outputTemplateConfig).map(([i,l])=>[i,BA(l)])):void 0,s={modular_version:"1.0",agent:{name:n.name,description:n.description,model:n.model,temperature:n.temperature,system_prompt:n.system,planning_mode:n.planningMode,knowledge:n.reads.map(i=>({path:i})),skills:n.tools,mcp_servers:n.mcp_servers,output_formats:n.output_format,token_budget:n.token_budget,connectors:n.connectors,...e.instructionState?{instructionState:e.instructionState}:{},...e.workflowSteps&&e.workflowSteps.length>0?{workflowSteps:e.workflowSteps}:{},...a&&Object.keys(a).length>0?{output:{templates:a}}:{}}};return JSON.stringify(s,null,2)}function WA(e){return _v(e)}function ri(e,n){switch(e){case"claude":return _v(n);case"amp":return GA(n);case"codex":return qA(n);case"vibe-kanban":return KA(n);case"openclaw":return YA(n);case"generic":return VA(n)}}const Dv={claude:{name:"Claude Code",ext:".md",mime:"text/markdown"},amp:{name:"Amp",ext:".yaml",mime:"text/yaml"},codex:{name:"Codex",ext:".json",mime:"application/json"},"vibe-kanban":{name:"Vibe Kanban",ext:".json",mime:"application/json"},openclaw:{name:"OpenClaw",ext:".yaml",mime:"text/yaml"},generic:{name:"Generic JSON",ext:".json",mime:"application/json"}};function gu(e,n,a=".md"){const s={".md":"text/markdown",".json":"application/json",".yaml":"text/yaml"},i=new Blob([e],{type:s[a]||"text/plain"}),l=URL.createObjectURL(i),d=document.createElement("a");d.href=l,d.download=`${n}${a}`,document.body.appendChild(d),d.click(),document.body.removeChild(d),URL.revokeObjectURL(l)}function XA(e){const n=(e.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),a=["claude","amp","codex","vibe-kanban","openclaw","generic"];for(const s of a){const i=ri(s,e),l=Dv[s],d=s==="claude"?n:`${n}-${s}`;gu(i,d,l.ext)}}function ZA(e,n){if(e){const a=e.split(/\s+/).slice(0,4).join("-").toLowerCase().replace(/[^a-z0-9-]/g,"");if(a.length>3)return a}return n.length>0?n[0].name.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""):"modular-agent"}function QA(e,n){return e&&e.length>10?e.length>80?e.slice(0,77)+"...":e:`Analysis using ${n.length} sources via Modular`}function JA(){const e=re.getState();Xe.getState();const n={version:"1.0",kind:"agent",identity:{name:e.agentMeta.name||"modular-agent",display_name:e.agentMeta.name||void 0,description:e.agentMeta.description||void 0,avatar:e.agentMeta.avatar||void 0,author:"Modular Studio",tags:e.agentMeta.tags?.length>0?e.agentMeta.tags:void 0,agent_version:"1.0.0"},instructions:{},context:{}},a={};e.instructionState.persona&&(a.persona=e.instructionState.persona),e.instructionState.tone!=="neutral"&&(a.tone=e.instructionState.tone),e.instructionState.expertise!==3&&(a.expertise=e.instructionState.expertise);const s=[];e.instructionState.constraints.neverMakeUp&&s.push("Never fabricate information or make up facts"),e.instructionState.constraints.askBeforeActions&&s.push("Ask for permission before taking significant actions"),e.instructionState.constraints.stayInScope&&s.push(`Stay within defined scope: ${e.instructionState.constraints.scopeDefinition||"as specified"}`),e.instructionState.constraints.useOnlyTools&&s.push("Only use explicitly provided tools and capabilities"),e.instructionState.constraints.limitWords&&s.push(`Keep responses under ${e.instructionState.constraints.wordLimit} words`),e.instructionState.constraints.customConstraints&&s.push(e.instructionState.constraints.customConstraints),s.length>0&&(a.constraints=s),e.instructionState.objectives.primary&&(a.objectives={primary:e.instructionState.objectives.primary},e.instructionState.objectives.successCriteria.length>0&&(a.objectives.success_criteria=e.instructionState.objectives.successCriteria),e.instructionState.objectives.failureModes.length>0&&(a.objectives.failure_modes=e.instructionState.objectives.failureModes)),e.instructionState.constraints.scopeDefinition&&(a.scope=e.instructionState.constraints.scopeDefinition),n.instructions=a;const i={},l=e.channels.filter(f=>f.enabled);l.length>0&&(i.knowledge=l.map(f=>({type:"file",ref:f.path||f.name,knowledge_type:f.knowledgeType,depth:f.depth})));const d=e.skills.filter(f=>f.enabled);d.length>0&&(i.skills=d.map(f=>({ref:f.name,source:"registry"})));const p=e.mcpServers.filter(f=>f.enabled);return p.length>0&&(i.mcp_servers=p.map(f=>({name:f.name,description:f.description,transport:"stdio",command:void 0,env:void 0}))),n.context=i,e.workflowSteps.length>0&&(n.workflow={steps:e.workflowSteps.map(f=>({id:f.id,action:f.action,tool:f.tool||void 0,condition:f.condition!=="always"?f.condition:void 0}))}),jc(n)}function jc(e,n=0){const a=" ".repeat(n);return Array.isArray(e)?e.map(s=>`${a}- ${jc(s,0).trim()}`).join(`
|
|
163
|
+
`):typeof e=="object"&&e!==null?Object.entries(e).filter(([,s])=>s!=null).map(([s,i])=>{if(Array.isArray(i))return i.length===0?null:`${a}${s}:
|
|
164
|
+
${jc(i,n+1)}`;if(typeof i=="object")return`${a}${s}:
|
|
165
|
+
${jc(i,n+1)}`;{const l=typeof i=="string"&&(i.includes(`
|
|
166
|
+
`)||i.includes(":")||i.includes("#"))?`"${i.replace(/"/g,'\\"')}"`:String(i);return`${a}${s}: ${l}`}}).filter(Boolean).join(`
|
|
167
|
+
`):String(e)}const Px=[{id:"brain",Icon:Di},{id:"code",Icon:W1},{id:"search",Icon:cu},{id:"bar-chart-3",Icon:tm},{id:"pen-tool",Icon:iv},{id:"file-text",Icon:Ws},{id:"globe",Icon:J1},{id:"layers",Icon:x3},{id:"zap",Icon:pn},{id:"database",Icon:Ri},{id:"shield",Icon:im},{id:"settings",Icon:rm},{id:"sparkles",Icon:Pa},{id:"target",Icon:uu},{id:"book-open",Icon:Jf},{id:"lightbulb",Icon:Uc},{id:"terminal",Icon:Ks},{id:"box",Icon:em},{id:"layout-grid",Icon:tv},{id:"cpu",Icon:zi}],e_=["coding","research","analysis","writing","data","design","domain-specific","general"],Hx=[{id:"claude",name:"Claude Code",ext:".md",Icon:Ks},{id:"amp",name:"Amp",ext:".yaml",Icon:pn},{id:"codex",name:"Codex",ext:".json",Icon:zi},{id:"vibe-kanban",name:"Vibe Kanban",ext:".json",Icon:tv},{id:"openclaw",name:"OpenClaw",ext:".yaml",Icon:sv},{id:"generic",name:"Generic JSON",ext:".json",Icon:em}];function t_(){const e=re(L=>L.showSaveModal),n=re(L=>L.setShowSaveModal),a=re(L=>L.agentMeta),s=re(L=>L.setAgentMeta),i=re(L=>L.channels),l=re(L=>L.selectedModel),d=re(L=>L.outputFormat),p=re(L=>L.outputFormats),f=re(L=>L.prompt),h=re(L=>L.tokenBudget),g=re(L=>L.mcpServers),x=re(L=>L.skills),b=re(L=>L.exportTarget),v=re(L=>L.setExportTarget),k=re(L=>L.agentConfig),w=re(L=>L.connectors),j=re(L=>L.instructionState),T=re(L=>L.workflowSteps),E=LA(L=>L.upsertLibraryAgent),[S,M]=z.useState(!1),[$,A]=z.useState(!1),[_,F]=z.useState(!0),B=z.useRef(null),G=z.useRef(null),O=we(),K=z.useCallback(L=>{if(L.key!=="Tab"||!G.current)return;const Z=G.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(Z.length===0)return;const ae=Z[0],pe=Z[Z.length-1];L.shiftKey?document.activeElement===ae&&(L.preventDefault(),pe.focus()):document.activeElement===pe&&(L.preventDefault(),ae.focus())},[]);z.useEffect(()=>{e?(A(!0),setTimeout(()=>B.current?.focus(),100)):A(!1)},[e]),z.useEffect(()=>{if(!e)return;const L=Z=>{Z.key==="Escape"&&n(!1)};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[e,n]);const V=z.useMemo(()=>({channels:i,selectedModel:l,outputFormat:d,outputFormats:p,prompt:f,tokenBudget:h,mcpServers:g,skills:x,agentMeta:a,agentConfig:k,connectors:w,instructionState:j,workflowSteps:T}),[i,l,d,p,f,h,g,x,a,k,w,j,T]),P=z.useMemo(()=>ri(b,V),[V,b]),N=L=>{F(!1),v(L),setTimeout(()=>F(!0),30)},D=()=>{const L=a.name||"modular-agent",Z=L.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");E({id:Z,name:L,description:a.description||"Saved from builder",avatar:a.avatar||"bot",version:"1.0.0",mcpServerIds:g.filter(me=>me.added).map(me=>me.id),skillIds:x.filter(me=>me.added).map(me=>me.id)});const ae=fm();fetch(`${Ae}/agents/${encodeURIComponent(Z)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(ae)}).catch(()=>{});const pe=Dv[b];gu(P,Z,pe.ext)},U=async()=>{await navigator.clipboard.writeText(P),M(!0),setTimeout(()=>M(!1),2e3)},q=()=>{XA(V)},W=()=>{const L=JA(),ae=(a.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,""),pe=new Blob([L],{type:"text/yaml;charset=utf-8"}),me=URL.createObjectURL(pe),he=document.createElement("a");he.href=me,he.download=`${ae}.yaml`,document.body.appendChild(he),he.click(),document.body.removeChild(he),URL.revokeObjectURL(me)};if(!e)return null;const oe=Px.find(L=>L.id===a.icon),I=Hx.find(L=>L.id===b);return c.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>n(!1),children:[c.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)",opacity:$?1:0,transition:"opacity 0.15s ease"}}),c.jsxs("div",{ref:G,role:"dialog","aria-modal":"true","aria-label":"Save as agent",className:"relative flex flex-col rounded-xl overflow-hidden",style:{width:880,maxHeight:"85vh",background:O.surface,border:`1px solid ${O.border}`,boxShadow:"0 24px 48px rgba(0,0,0,0.4)",opacity:$?1:0,transform:$?"scale(1)":"scale(0.97)",transition:"opacity 0.15s ease, transform 0.15s ease"},onClick:L=>L.stopPropagation(),onKeyDown:K,children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{borderBottom:`1px solid ${O.borderSubtle}`},children:[c.jsx("span",{className:"text-[14px] font-bold tracking-[3px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:O.textPrimary},children:"SAVE AS AGENT"}),c.jsx("button",{type:"button",onClick:()=>n(!1),className:"p-1 rounded-md cursor-pointer border-none",style:{background:"transparent",color:O.textMuted},"aria-label":"Close",children:c.jsx(Tt,{size:16})})]}),c.jsx("div",{className:"flex gap-2 px-5 py-3",style:{borderBottom:`1px solid ${O.borderSubtle}`},children:Hx.map(L=>{const Z=b===L.id;return c.jsxs("button",{type:"button",onClick:()=>N(L.id),className:"flex flex-col items-center gap-1 rounded-lg cursor-pointer border-none",style:{width:80,padding:"8px 4px",background:Z?"#FE500012":"transparent",border:Z?"1.5px solid #FE5000":`1.5px solid ${O.borderSubtle}`,transition:"all 0.12s ease"},children:[c.jsx(L.Icon,{size:18,style:{color:Z?"#FE5000":O.textMuted}}),c.jsx("span",{className:"text-[12px] font-semibold leading-tight text-center",style:{fontFamily:"'Geist Mono', monospace",color:Z?"#FE5000":O.textSecondary},children:L.name}),c.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:Z?"#FE500020":O.badgeBg,color:Z?"#FE5000":O.textDim},children:L.ext})]},L.id)})}),c.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[c.jsxs("div",{className:"flex flex-col",style:{width:340,borderRight:`1px solid ${O.borderSubtle}`},children:[c.jsxs("div",{className:"flex-1 overflow-y-auto p-5 flex flex-col gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:O.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Agent Name"}),c.jsx("input",{ref:B,type:"text",value:a.name,onChange:L=>s({name:L.target.value}),placeholder:"my-analysis-agent",className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 nodrag",style:{background:O.inputBg,border:`1px solid ${O.border}`,color:O.textPrimary,fontFamily:"'Geist Sans', sans-serif"}})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:O.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Description"}),c.jsx("textarea",{value:a.description,onChange:L=>s({description:L.target.value}),placeholder:"Deep research and synthesis agent...",className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 resize-none",rows:3,style:{background:O.inputBg,border:`1px solid ${O.border}`,color:O.textPrimary,fontFamily:"'Geist Sans', sans-serif",lineHeight:1.5}})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:O.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Icon"}),c.jsx("div",{className:"grid grid-cols-10 gap-1",children:Px.map(({id:L,Icon:Z})=>c.jsx("button",{type:"button",onClick:()=>s({icon:L}),className:"flex items-center justify-center w-7 h-7 rounded-md cursor-pointer border-none",style:{background:a.icon===L?"#FE500020":"transparent",border:a.icon===L?"1px solid #FE500040":"1px solid transparent",color:a.icon===L?"#FE5000":O.textMuted,transition:"all 0.1s ease"},children:c.jsx(Z,{size:14})},L))})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("label",{className:"text-[13px] font-semibold uppercase tracking-wider",style:{color:O.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Category"}),c.jsx("select",{value:a.category,onChange:L=>s({category:L.target.value}),className:"w-full outline-none text-[17px] rounded-lg px-3 py-2 cursor-pointer",style:{background:O.inputBg,border:`1px solid ${O.border}`,color:O.textPrimary,fontFamily:"'Geist Sans', sans-serif"},children:e_.map(L=>c.jsx("option",{value:L,children:L.charAt(0).toUpperCase()+L.slice(1).replace("-"," ")},L))})]})]}),c.jsxs("div",{className:"flex flex-col gap-2 px-5 py-4",style:{borderTop:`1px solid ${O.borderSubtle}`},children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:D,className:"flex items-center justify-center gap-1.5 flex-1 py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",boxShadow:"0 0 8px rgba(254,80,0,0.25)"},children:[c.jsx(lu,{size:13}),"Download"]}),c.jsxs("button",{type:"button",onClick:U,className:"flex items-center justify-center gap-1.5 flex-1 py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${O.border}`,color:S?O.statusSuccess:O.textSecondary,transition:"color 0.15s ease"},children:[S?c.jsx(jt,{size:13}):c.jsx(X1,{size:13}),S?"Copied":"Copy"]})]}),c.jsxs("button",{type:"button",onClick:q,className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${O.borderSubtle}`,color:O.textMuted},children:[c.jsx(sv,{size:13}),"Export All Targets"]}),c.jsxs("button",{type:"button",onClick:W,className:"flex items-center justify-center gap-1.5 w-full py-2 rounded-lg text-[14px] font-semibold tracking-wider uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${O.borderSubtle}`,color:O.textMuted},children:[c.jsx(Ws,{size:13}),"Export as YAML"]})]})]}),c.jsxs("div",{className:"flex flex-col flex-1",style:{background:O.isDark?"#0d0d10":"#f5f5f8"},children:[c.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{borderBottom:`1px solid ${O.borderSubtle}`},children:[c.jsxs("div",{className:"flex items-center gap-2",children:[oe&&c.jsx(oe.Icon,{size:14,style:{color:"#FE5000"}}),c.jsx("span",{className:"text-[14px] font-bold tracking-[2px] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:O.textMuted},children:"Preview"}),c.jsxs("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:"#FE500018",color:"#FE5000"},children:[I.name," ",I.ext]})]}),c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:O.textDim},children:[P.split(`
|
|
168
|
+
`).length," lines"]})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4",style:{opacity:_?1:0,transition:"opacity 0.12s ease"},children:c.jsx("pre",{className:"text-[14px] leading-relaxed whitespace-pre-wrap break-all m-0",style:{fontFamily:"'Geist Mono', monospace",color:O.textSecondary},children:P.split(`
|
|
169
|
+
`).map((L,Z)=>c.jsxs("div",{className:"flex",children:[c.jsx("span",{className:"inline-block text-right select-none shrink-0",style:{width:32,color:O.textFaint,marginRight:12},children:Z+1}),c.jsx("span",{style:{color:n_(L,b,O)},children:L||" "})]},Z))})})]})]})]})]})}function n_(e,n,a){return e.trim()?n==="codex"||n==="vibe-kanban"||n==="generic"?/^\s*"\w[\w_-]*"\s*:/.test(e)?"#67d4e8":/:\s*"[^"]*"\s*,?$/.test(e)?"#a8d4a0":/:\s*(\d+\.?\d*|true|false|null)\s*,?$/.test(e)?"#d4a86a":a.textSecondary:e==="---"?"#FE5000":e.startsWith("##")||e.startsWith("# ")?a.textPrimary:/^\s*#/.test(e)?a.isDark?"#666":"#999":/^\s*\w[\w_-]*\s*:/.test(e)?"#67d4e8":/^\s+-\s/.test(e)||/^\d+\./.test(e)?a.textSecondary:a.textMuted:a.textMuted}function o_(){const e=re.getState();return{channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,instructionState:{...e.instructionState},workflowSteps:[...e.workflowSteps],agentConfig:{...e.agentConfig},prompt:e.prompt,selectedModel:e.selectedModel}}function Ux(e,n){const a=[];e.instructionState.persona!==n.instructionState.persona&&n.instructionState.persona.length>0&&a.push({type:"major",category:"instruction",description:"Persona updated"}),e.instructionState.objectives.primary!==n.instructionState.objectives.primary&&a.push({type:"major",category:"instruction",description:"Primary objective changed"}),e.selectedModel!==n.selectedModel&&a.push({type:"major",category:"model",description:`Model → ${n.selectedModel}`}),e.instructionState.tone!==n.instructionState.tone&&a.push({type:"major",category:"instruction",description:`Tone → ${n.instructionState.tone}`});const s=e.channels.filter(E=>E.enabled).map(E=>E.sourceId),i=n.channels.filter(E=>E.enabled).map(E=>E.sourceId),l=i.filter(E=>!s.includes(E)),d=s.filter(E=>!i.includes(E));l.length>0&&a.push({type:"minor",category:"knowledge",description:`+${l.length} knowledge source(s)`}),d.length>0&&a.push({type:"minor",category:"knowledge",description:`-${d.length} knowledge source(s)`});const p=e.skills.filter(E=>E.added).map(E=>E.id),f=n.skills.filter(E=>E.added).map(E=>E.id),h=f.filter(E=>!p.includes(E)),g=p.filter(E=>!f.includes(E));h.length>0&&a.push({type:"minor",category:"skill",description:`+${h.length} skill(s)`}),g.length>0&&a.push({type:"minor",category:"skill",description:`-${g.length} skill(s)`});const x=e.mcpServers.filter(E=>E.added).map(E=>E.id),b=n.mcpServers.filter(E=>E.added).map(E=>E.id),v=b.filter(E=>!x.includes(E)),k=x.filter(E=>!b.includes(E));if(v.length>0&&a.push({type:"minor",category:"mcp",description:`+${v.length} MCP server(s)`}),k.length>0&&a.push({type:"minor",category:"mcp",description:`-${k.length} MCP server(s)`}),n.workflowSteps.length!==e.workflowSteps.length){const E=n.workflowSteps.length-e.workflowSteps.length;a.push({type:"minor",category:"workflow",description:`${E>0?"+":""}${E} workflow step(s)`})}const w=e.instructionState.objectives.successCriteria.length,j=n.instructionState.objectives.successCriteria.length;j!==w&&a.push({type:"minor",category:"instruction",description:`Success criteria ${j>w?"added":"removed"}`});const T=["neverMakeUp","askBeforeActions","stayInScope","useOnlyTools","limitWords"];for(const E of T)e.instructionState.constraints[E]!==n.instructionState.constraints[E]&&a.push({type:"patch",category:"instruction",description:`Constraint "${E}" toggled`});e.instructionState.constraints.customConstraints!==n.instructionState.constraints.customConstraints&&a.push({type:"patch",category:"instruction",description:"Custom constraints updated"}),e.instructionState.expertise!==n.instructionState.expertise&&a.push({type:"patch",category:"instruction",description:`Expertise level → ${n.instructionState.expertise}`}),e.prompt!==n.prompt&&a.push({type:"patch",category:"prompt",description:"Prompt text changed"});for(const E of n.channels){const S=e.channels.find(M=>M.sourceId===E.sourceId);S&&S.depth!==E.depth&&a.push({type:"patch",category:"knowledge",description:`"${E.name}" depth changed`})}if(n.workflowSteps.length===e.workflowSteps.length)for(let E=0;E<n.workflowSteps.length;E++){const S=e.workflowSteps[E],M=n.workflowSteps[E];if(S&&M&&(S.label!==M.label||S.action!==M.action||S.tool!==M.tool||S.condition!==M.condition)){a.push({type:"patch",category:"workflow",description:`Step "${M.label||E+1}" modified`});break}}return e.agentConfig.temperature!==n.agentConfig.temperature&&a.push({type:"patch",category:"config",description:`Temperature → ${n.agentConfig.temperature}`}),e.agentConfig.maxTokens!==n.agentConfig.maxTokens&&a.push({type:"patch",category:"config",description:`Max tokens → ${n.agentConfig.maxTokens}`}),a}function a_(e,n){const[a,s,i]=e.split(".").map(Number),l=n.some(f=>f.type==="major"),d=n.some(f=>f.type==="minor");if(l){const f={major:a+1,minor:0,patch:0};return{...f,version:`${f.major}.${f.minor}.${f.patch}`}}if(d){const f={major:a,minor:s+1,patch:0};return{...f,version:`${f.major}.${f.minor}.${f.patch}`}}const p={major:a,minor:s,patch:i+1};return{...p,version:`${p.major}.${p.minor}.${p.patch}`}}function s_(e){if(e.length===0)return"No changes";if(e.length===1)return e[0].description;const n=[...new Set(e.map(a=>a.category))];return`${e.length} changes (${n.join(", ")})`}const Ra=qt((e,n)=>({versions:[],currentVersion:"0.1.0",dirty:!1,autoVersion:!0,maxVersions:50,latestVersion:()=>{const a=n().versions;return a.length>0?a[a.length-1]:void 0},getVersion:a=>n().versions.find(s=>s.version===a),checkpoint:a=>{const s=o_(),i=n().latestVersion()?.snapshot,l=i?Ux(i,s):[{type:"minor",category:"init",description:"Initial version"}];if(i&&l.length===0)return;const d=i?a_(n().currentVersion,l):{major:0,minor:1,patch:0,version:"0.1.0"},p={id:`v-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,version:d.version,major:d.major,minor:d.minor,patch:d.patch,timestamp:Date.now(),label:a||s_(l),changes:l,snapshot:s},f=[...n().versions,p].slice(-n().maxVersions);e({versions:f,currentVersion:d.version,dirty:!1})},restoreVersion:a=>{const s=n().getVersion(a);if(!s)return;const i=re.getState();i.clearChannels();for(const l of s.snapshot.channels)i.addChannel(l),l.enabled||i.toggleChannel(l.sourceId);i.setPrompt(s.snapshot.prompt),i.setModel(s.snapshot.selectedModel),i.updateInstruction({persona:s.snapshot.instructionState.persona,tone:s.snapshot.instructionState.tone,expertise:s.snapshot.instructionState.expertise,constraints:s.snapshot.instructionState.constraints,objectives:s.snapshot.instructionState.objectives,rawPrompt:s.snapshot.instructionState.rawPrompt,autoSync:s.snapshot.instructionState.autoSync}),i.updateWorkflowSteps(s.snapshot.workflowSteps),e({currentVersion:s.version,dirty:!1})},deleteVersion:a=>e({versions:n().versions.filter(s=>s.id!==a)}),setAutoVersion:a=>e({autoVersion:a}),setDirty:()=>e({dirty:!0}),_detectAndVersion:(a,s)=>{if(Ux(a,s).length===0||(e({dirty:!0}),!n().autoVersion))return;const l=n().latestVersion();l&&Date.now()-l.timestamp<2e3||n().checkpoint()}}));let yc=null,sf=null;re.subscribe(e=>{const n={channels:e.channels,mcpServers:e.mcpServers,skills:e.skills,instructionState:e.instructionState,workflowSteps:e.workflowSteps,agentConfig:e.agentConfig,prompt:e.prompt,selectedModel:e.selectedModel};if(!yc){yc=n;return}sf&&clearTimeout(sf);const a=yc;sf=setTimeout(()=>{Ra.getState()._detectAndVersion(a,n),yc=n},1500)});const r_={full:0,detail:1,summary:2,headlines:3,mention:4},i_={opus:"claude-opus-4",sonnet:"claude-sonnet-4",haiku:"claude-haiku-3.5","claude-opus-4":"claude-opus-4","claude-sonnet-4":"claude-sonnet-4","claude-haiku-3.5":"claude-haiku-3.5","gpt-4o":"gpt-4o","gpt-4.1":"gpt-4.1"},Gx=new Set(["markdown","html-slides","email","code","csv","json","diagram","slack"]);function l_(e){const n=e.trim();return n.startsWith("{")?c_(n):n.startsWith("---")?u_(n):d_(n)}function c_(e){let n;try{n=JSON.parse(e)}catch{return{}}if(n.modular_version&&n.agent){const s=n.agent,i=Jo({...s,system:s.system_prompt,reads:s.knowledge?.map(l=>l.path),output_format:s.output_formats,token_budget:s.token_budget});return i.detectedFormat="generic",s.instructionState&&(i.instructionState=s.instructionState),s.workflowSteps&&(i.workflowSteps=s.workflowSteps),i}if(n.template&&n.context_files){const s=Jo({name:n.template,reads:n.context_files,tools:n.tools,output_format:n.output_format});return s.detectedFormat="vibe-kanban",s}if(n.instructions&&!n.system){const s=Jo({...n,system:n.instructions,reads:n.context_files||n.reads});return s.detectedFormat="codex",s}const a=Jo(n);return a.detectedFormat="generic",a}function u_(e){const{frontmatter:n,body:a}=p_(e),s=Jo(n);if(s.detectedFormat="claude",!s.prompt){const p=a.match(/## Default Prompt\n([\s\S]*?)(?=\n## |$)/);p&&(s.prompt=p[1].trim())}if(!s.prompt){const p=a.match(/(?:##? Role)\n([\s\S]*?)(?=\n##? |$)/);p&&(s.prompt=p[1].trim())}if(!s.channels||s.channels.length===0){const p=m_(a);p.length>0&&(s.channels=p)}const i=a.match(/## Persona\n([\s\S]*?)(?=\n## |$)/),l=a.match(/## Constraints\n([\s\S]*?)(?=\n## |$)/),d=a.match(/## Objectives\n([\s\S]*?)(?=\n## |$)/);return(i||l||d)&&(s.instructionState={persona:i?i[1].trim():"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:l?l[1].trim():"",scopeDefinition:""},objectives:{primary:d?d[1].trim():"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0}),s}function d_(e){const n=zv(e);if(n.agents&&typeof n.agents=="object"&&!Array.isArray(n.agents)){const s=n.agents,i=Object.keys(s)[0];if(i){const l=s[i],d=Jo({name:i.replace(/-/g," "),model:l.model,temperature:l.temperature,tools:l.skills,reads:l.context});return d.detectedFormat="openclaw",d}}if(n.mcp&&typeof n.mcp=="object"&&!Array.isArray(n.mcp)){const s=Jo({...n,system:n.instructions,reads:n.context_files});return s.detectedFormat="amp",s}const a=Jo(n);return a.detectedFormat="amp",a}function Jo(e){const n={},a={name:zn(e.name)||"",description:zn(e.description)||"",icon:zn(e.icon)||"brain",category:zn(e.category)||"general",tags:Array.isArray(e.tags)?e.tags:[],avatar:zn(e.avatar)||""};if(n.agentMeta=a,e.model){const l=zn(e.model);n.selectedModel=i_[l]??l}e.token_budget!==void 0&&(n.tokenBudget=Number(e.token_budget));const s=e.modular;if(s?.tokenBudget!==void 0&&(n.tokenBudget=Number(s.tokenBudget)),Array.isArray(e.output_format)){const l=e.output_format.filter(d=>Gx.has(d));l.length>0&&(n.outputFormat=l[0])}else if(e.output_format){const l=zn(e.output_format);Gx.has(l)&&(n.outputFormat=l)}!n.outputFormat&&s?.outputFormat&&(n.outputFormat=s.outputFormat),Array.isArray(e.reads)&&(n.channels=e.reads.map((l,d)=>{const p=void 0;return{sourceId:p?.id??`imported-${d}`,name:p?.name??l.split("/").filter(Boolean).pop()??l,path:l,category:p?.category??"knowledge",knowledgeType:ni(p?p.path:l),enabled:!0,depth:0,baseTokens:p?.tokenEstimate??5e3}})),!n.channels&&s?.channels&&(n.channels=s.channels.map((l,d)=>{const p=f_(l.type)?l.type:ni(l.path),f=r_[l.depth?.toLowerCase()]??0,h=(l.path,void 0);return{sourceId:h?.id??`imported-${d}`,name:h?.name??l.path.split("/").filter(Boolean).pop()??l.path,path:l.path,category:h?.category??"knowledge",knowledgeType:p,enabled:!0,depth:f,baseTokens:h?.tokenEstimate??5e3}})),!n.prompt&&e.system&&(n.prompt=zn(e.system)),e.prompt&&(n.prompt=zn(e.prompt));const i=zn(e.system);if(i){const l=h_(i);n.instructionState={persona:l.persona,tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:l.constraints,scopeDefinition:""},objectives:{primary:l.objective,successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!0}}return n}function zn(e){return typeof e=="string"?e:e==null?"":String(e)}function p_(e){const n=e.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);return n?{frontmatter:zv(n[1]),body:n[2]}:{frontmatter:{},body:e}}function zv(e){const n={},a=e.split(`
|
|
170
|
+
`);let s="",i=null,l=null,d=null,p="",f=0,h=[];const g=()=>{if(p&&h.length>0){const x=i||n;x[p]=h.join(`
|
|
171
|
+
`),p="",h=[]}};for(const x of a){if(p)if(x.search(/\S/)>=f&&x.trim()!==""){h.push(x.slice(f));continue}else g();const b=x.match(/^(\w[\w_-]*)\s*:\s*(.*)$/);if(b){d&&l&&(l.push(d),d=null),l=null,i=null;const v=b[1],k=b[2].trim();k===""||k==="|"?k==="|"?(p=v,f=2,h=[]):(s=v,i={},n[v]=i):k.startsWith("[")&&k.endsWith("]")?n[v]=k.slice(1,-1).split(",").map(w=>w.trim()).filter(Boolean):n[v]=Ea(k);continue}if(i){const v=x.match(/^ (\w[\w_-]*)\s*:\s*(.*)$/);if(v){d&&l&&(l.push(d),d=null);const k=v[1],w=v[2].trim();w===""||w==="|"?w==="|"?(p=k,f=4,h=[]):(l=[],i[k]=l):(l=null,i[k]=Ea(w));continue}if(l){const k=x.match(/^ - (.+)$/);if(k&&!k[1].includes(":")){d&&(l.push(d),d=null),l.push(Ea(k[1].trim()));continue}}if(l){const k=x.match(/^ - (\w[\w_-]*)\s*:\s*(.*)$/);if(k){d&&l.push(d),d={[k[1]]:Ea(k[2])};continue}const w=x.match(/^ (\w[\w_-]*)\s*:\s*(.*)$/);if(w&&d){d[w[1]]=Ea(w[2]);continue}}}if(!i){const v=x.match(/^ - (.+)$/);if(v&&l){if(!v[1].includes(":"))l.push(Ea(v[1].trim()));else{const w=v[1].match(/^(\w[\w_-]*)\s*:\s*(.*)$/);w&&(d&&l.push(d),d={[w[1]]:Ea(w[2])})}continue}const k=x.match(/^(\w[\w_-]*)\s*:$/);if(k){s=k[1],l=[],n[s]=l;continue}}}return g(),d&&l&&l.push(d),n}function Ea(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function f_(e){return["ground-truth","signal","evidence","framework","hypothesis","guideline"].includes(e)}function m_(e){const n=[],a=e.split(`
|
|
172
|
+
`);let s=0;for(const i of a){const l=i.match(/[-*]\s+(?:\*\*.*?\*\*:?\s*)?([A-Za-z0-9_/-]+(?:\/\*)?)/);if(l){const d=l[1];d.includes("/")&&(n.push({sourceId:`body-${s}`,name:d.split("/").filter(Boolean).pop()??d,path:d,category:"knowledge",knowledgeType:ni(d),enabled:!0,depth:0,baseTokens:5e3}),s++)}}return n}function h_(e){const n=e.replace(/\r\n/g,`
|
|
173
|
+
`).trim();if(!n)return{persona:"",constraints:"",objective:""};const a=n.split(/\n\s*\n/).map(T=>T.trim()).filter(Boolean),i=n.split(`
|
|
174
|
+
`).map(T=>T.trim()).filter(Boolean).map(T=>{const E=T.match(/^[-*]\s+(.+)$/);if(E)return E[1].trim();const S=T.match(/^\d+\.\s+(.+)$/);return S?S[1].trim():""}).filter(Boolean),l=/\b(never|always|must|must not|do not|don't|forbidden|required|only|avoid|without)\b/i,d=/\b(objective|goal|task|deliver|ensure|help|outcome|success|mission)\b/i,p=i.filter(T=>l.test(T)),f=i.filter(T=>!l.test(T)&&d.test(T)),h=n.match(/(?:^|\n)(?:#+\s*)?(?:objective|objectives|goal|goals|mission)\s*:?\s*\n?([\s\S]*?)(?=\n(?:#+\s*)?[A-Za-z][^\n]*:\s*|\n\s*\n|$)/i),g=n.match(/(?:^|\n)(?:#+\s*)?(?:constraint|constraints|guardrails|rules)\s*:?\s*\n?([\s\S]*?)(?=\n(?:#+\s*)?[A-Za-z][^\n]*:\s*|\n\s*\n|$)/i),x=h?.[1]?.split(`
|
|
175
|
+
`).map(T=>T.replace(/^[-*]\s+/,"").trim()).find(Boolean)??"",b=g?.[1]?.split(`
|
|
176
|
+
`).map(T=>T.replace(/^[-*]\s+/,"").trim()).filter(Boolean).join(`
|
|
177
|
+
`)??"",k=(a.find(T=>{const E=T.toLowerCase();return!(/^(constraints?|guardrails?|rules|objectives?|goals?|mission)\s*:/.test(E)||d.test(T)||l.test(T))})??a[0]??"").split(new RegExp("(?<=[.!?])\\s+")).map(T=>T.trim()).find(Boolean)??"",w=x||f[0]||a.find(T=>d.test(T))||"",j=b||p.join(`
|
|
178
|
+
`);return{persona:k,constraints:j,objective:typeof w=="string"?w.trim():""}}const qx={strategy:"summarize_and_recent",windowSize:20,summarizeAfter:10,summaryModel:"same",tokenBudget:2e4,maxMessages:20,summarizeEnabled:!0},g_={enabled:!0,store:"local_sqlite",embeddingModel:"text-embedding-3-small",recall:{strategy:"top_k",k:5,minScore:.7},write:{mode:"auto_extract",extractTypes:["user_preferences","decisions","facts"]},scope:"per_user",maxEntries:1e3,ttl:null,tokenBudget:5e3},y_={enabled:!0,maxTokens:2e3,persist:!1,format:"freeform",content:"",tokenBudget:2e3},x_={isolation:"reset_each_run",allowPromoteToShared:!1,domains:{shared:{enabled:!0},agentPrivate:{enabled:!0},runScratchpad:{enabled:!0}}},We=qt((e,n)=>({session:{...qx},longTerm:{...g_},working:{...y_},facts:[],sandbox:{...x_},sessionMemory:{...qx},longTermMemory:[],workingMemory:"",setSessionConfig:a=>{e(s=>{const i={...s.session,...a};"maxMessages"in a&&(i.windowSize=i.maxMessages),"windowSize"in a&&(i.maxMessages=i.windowSize),"summarizeEnabled"in a&&!i.summarizeEnabled&&(i.strategy="sliding_window"),"strategy"in a&&(i.summarizeEnabled=a.strategy==="summarize_and_recent");const l=i;return{session:l,sessionMemory:l}})},setLongTermConfig:a=>{e(s=>({longTerm:{...s.longTerm,...a}}))},setRecallConfig:a=>{e(s=>({longTerm:{...s.longTerm,recall:{...s.longTerm.recall,...a}}}))},setWriteConfig:a=>{e(s=>({longTerm:{...s.longTerm,write:{...s.longTerm.write,...a}}}))},toggleExtractType:a=>{e(s=>{const i=s.longTerm.write.extractTypes,l=i.includes(a)?i.filter(d=>d!==a):[...i,a];return{longTerm:{...s.longTerm,write:{...s.longTerm.write,extractTypes:l}}}})},setWorkingConfig:a=>{e(s=>({working:{...s.working,...a}}))},updateScratchpad:a=>{e(s=>({working:{...s.working,content:a},workingMemory:a}))},addFact:(a,s=[],i="fact",l="shared",d="fact",p)=>{const f={id:`fact-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,content:a,tags:s,type:i,timestamp:Date.now(),domain:l,granularity:d,embeddingPending:!0,...p&&{ownerAgentId:p}};e(h=>{const g=[...h.facts,f];return{facts:g,longTermMemory:g}})},removeFact:a=>{e(s=>{const i=s.facts.filter(l=>l.id!==a);return{facts:i,longTermMemory:i}})},updateFact:(a,s)=>{e(i=>({facts:i.facts.map(l=>l.id===a?{...l,...s}:l)}))},addEpisode:(a,s=[])=>{const i={id:`episode-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,content:a,tags:s,type:"fact",timestamp:Date.now(),domain:"shared",granularity:"episode",embeddingPending:!0};e(l=>{const d=[...l.facts,i];return{facts:d,longTermMemory:d}})},computeEmbeddings:async()=>{const s=n().facts.filter(i=>i.embeddingPending&&!i.embedding);if(s.length!==0)try{const i=await fetch("/api/knowledge/embed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:s.map(d=>d.content)})});if(!i.ok)return;const l=await i.json();if(!l.embeddings||l.embeddings.length!==s.length)return;e(d=>({facts:d.facts.map(p=>{const f=s.findIndex(h=>h.id===p.id);return f===-1?p:{...p,embedding:l.embeddings[f],embeddingPending:!1}})}))}catch{}},setSandboxConfig:a=>{e(s=>({sandbox:{...s.sandbox,...a}}))},setSandboxDomain:(a,s)=>{e(i=>({sandbox:{...i.sandbox,domains:{...i.sandbox.domains,[a]:{enabled:s}}}}))},getFactsByDomain:a=>n().facts.filter(s=>s.domain===a),getRecallableFacts:a=>{const{facts:s,sandbox:i}=n();return s.filter(l=>l.domain==="run_scratchpad"?!1:l.domain==="agent_private"?i.domains.agentPrivate.enabled?!!a&&l.ownerAgentId===a:!1:l.domain==="shared"?i.domains.shared.enabled:!1)},toYaml:()=>{const{session:a,longTerm:s,working:i,facts:l,sandbox:d}=n();return{memory:{session:{strategy:a.strategy,window_size:a.windowSize,summarize_after:a.summarizeAfter,summary_model:a.summaryModel,token_budget:a.tokenBudget},long_term:{enabled:s.enabled,store:s.store,embedding_model:s.embeddingModel,recall:{strategy:s.recall.strategy,k:s.recall.k,min_score:s.recall.minScore},write:{mode:s.write.mode,extract_types:s.write.extractTypes},scope:s.scope,max_entries:s.maxEntries,ttl:s.ttl,token_budget:s.tokenBudget,...l.length>0?{seed_facts:l.map(p=>({content:p.content,type:p.type,tags:p.tags,domain:p.domain,granularity:p.granularity}))}:{}},working:{enabled:i.enabled,max_tokens:i.maxTokens,persist:i.persist,format:i.format,token_budget:i.tokenBudget},sandbox:{isolation:d.isolation,allow_promote_to_shared:d.allowPromoteToShared,domains:{shared:d.domains.shared.enabled,agent_private:d.domains.agentPrivate.enabled,run_scratchpad:d.domains.runScratchpad.enabled}}}}}}));function ti({checked:e,onChange:n,label:a,size:s="md",disabled:i}){const l=we(),d=s==="sm"?28:36,p=s==="sm"?16:20,f=s==="sm"?12:16;return c.jsxs("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>!i&&n(!e),className:"flex items-center gap-2 cursor-pointer border-none bg-transparent p-0 nodrag",style:{opacity:i?.5:1,cursor:i?"not-allowed":"pointer"},children:[c.jsx("div",{className:"relative rounded-full transition-colors",style:{width:d,height:p,background:e?"#FE5000":l.border},children:c.jsx("div",{className:"absolute top-[2px] rounded-full bg-white transition-transform",style:{width:f,height:f,transform:`translateX(${e?d-f-2:2}px)`,transition:"transform 0.15s ease"}})}),a&&c.jsx("span",{className:"text-[13px]",style:{color:l.textSecondary},children:a})]})}function b_(e,n,a){return`You are an expert AI agent architect. Given a user's rough description of an agent they want to build, produce a COMPLETE agent configuration as JSON.
|
|
179
|
+
|
|
180
|
+
You have access to these MCP servers (pick ONLY from this list):
|
|
181
|
+
<mcp_servers>
|
|
182
|
+
${e}
|
|
183
|
+
</mcp_servers>
|
|
184
|
+
|
|
185
|
+
You have access to these skills (pick ONLY from this list):
|
|
186
|
+
<skills>
|
|
187
|
+
${n}
|
|
188
|
+
</skills>
|
|
189
|
+
|
|
190
|
+
The user has these REAL knowledge sources already connected (indexed repos, documents, files):
|
|
191
|
+
<connected_knowledge>
|
|
192
|
+
${a}
|
|
193
|
+
</connected_knowledge>
|
|
194
|
+
|
|
195
|
+
Produce a JSON response with this EXACT structure:
|
|
196
|
+
{
|
|
197
|
+
"agentMeta": {
|
|
198
|
+
"name": "<short agent name>",
|
|
199
|
+
"description": "<one-line description>",
|
|
200
|
+
"avatar": "<icon id: bot|brain|zap|flame|lightbulb|target|rocket|shield|microscope|chart|palette|file|drama|star|gem|bird|bug|cat|dog|heart>",
|
|
201
|
+
"tags": ["<tag1>", "<tag2>"]
|
|
202
|
+
},
|
|
203
|
+
"instructionState": {
|
|
204
|
+
"persona": "<2-4 sentence persona using 'You are...' framing>",
|
|
205
|
+
"tone": "<formal|neutral|casual>",
|
|
206
|
+
"expertise": <1-5>,
|
|
207
|
+
"constraints": {
|
|
208
|
+
"neverMakeUp": <true|false>,
|
|
209
|
+
"askBeforeActions": <true|false>,
|
|
210
|
+
"stayInScope": <true|false>,
|
|
211
|
+
"useOnlyTools": <true|false>,
|
|
212
|
+
"limitWords": <true|false>,
|
|
213
|
+
"wordLimit": <number or 0>,
|
|
214
|
+
"customConstraints": ["<constraint>"],
|
|
215
|
+
"scopeDefinition": "<what agent handles and does NOT handle>"
|
|
216
|
+
},
|
|
217
|
+
"objectives": {
|
|
218
|
+
"primary": "<primary goal>",
|
|
219
|
+
"successCriteria": ["<criterion>"],
|
|
220
|
+
"failureModes": ["<failure to avoid>"]
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"workflowSteps": [
|
|
224
|
+
{
|
|
225
|
+
"label": "<step name>",
|
|
226
|
+
"action": "<what the agent does>",
|
|
227
|
+
"condition": false,
|
|
228
|
+
"loop": false
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"mcpServerIds": ["<mcp-id from the list above>"],
|
|
232
|
+
"skillIds": ["<skill-id from the list above>"],
|
|
233
|
+
"knowledgeSelections": [
|
|
234
|
+
{
|
|
235
|
+
"sourceId": "<exact sourceId from connected_knowledge>",
|
|
236
|
+
"type": "<ground-truth|signal|evidence|framework|hypothesis|guideline>",
|
|
237
|
+
"depth": <0-4>,
|
|
238
|
+
"reason": "<why this source is relevant>"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"knowledgeGaps": [
|
|
242
|
+
{
|
|
243
|
+
"name": "<what's missing>",
|
|
244
|
+
"type": "<ground-truth|signal|evidence|framework|hypothesis|guideline>",
|
|
245
|
+
"description": "<what the user should connect and why>"
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"memoryConfig": {
|
|
249
|
+
"maxMessages": <10-50>,
|
|
250
|
+
"summarizeAfter": <5-25>,
|
|
251
|
+
"summarizeEnabled": <true|false>,
|
|
252
|
+
"suggestedFacts": ["<pre-loaded fact for long-term memory>"]
|
|
253
|
+
},
|
|
254
|
+
"outputSuggestions": ["<notion|slack|html-slides|email|github|hubspot>"]
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
Rules:
|
|
258
|
+
1. Pick MCP servers and skills ONLY from the provided lists — use exact IDs
|
|
259
|
+
2. Suggest 2-6 MCP servers and 1-4 skills that are genuinely useful for this agent
|
|
260
|
+
3. Generate 3-8 workflow steps that form a coherent process
|
|
261
|
+
4. **Knowledge: select from REAL connected sources using their exact sourceId**
|
|
262
|
+
- Set the appropriate knowledge type (ground-truth for specs, signal for feedback, etc.)
|
|
263
|
+
- Set depth: 0=Full, 1=Detail(75%), 2=Summary(50%), 3=Headlines(25%), 4=Mention(10%)
|
|
264
|
+
- If no connected sources exist or none are relevant, leave knowledgeSelections empty
|
|
265
|
+
5. **Knowledge gaps: suggest what REAL documents/repos the user should connect**
|
|
266
|
+
- Be specific: "Odfjell fleet spec PDF" not "Company documentation"
|
|
267
|
+
- Only suggest gaps that would genuinely improve the agent
|
|
268
|
+
6. Be opinionated — make real choices, don't hedge
|
|
269
|
+
7. Memory config: enable summarization for conversational agents, disable for one-shot tools
|
|
270
|
+
|
|
271
|
+
Output ONLY the JSON object. No markdown fences, no explanation.`}async function v_(e){if(!e.trim())throw new Error("Describe the agent you want to build");const n=Je.getState(),a=n.providers.filter(S=>(S.status==="connected"||S.status==="configured")&&Array.isArray(S.models)&&S.models.length>0),s=n.providers.find(S=>S.id===n.selectedProviderId&&a.includes(S))||a[0];if(!s)throw new Error("No provider with models available. Connect a provider and refresh models in Settings.");const i=s.models[0],l=typeof i=="string"?i:i?.id||"";if(!l)throw new Error(`Provider ${s.name} has no selectable model.`);const d=s.authMethod==="claude-agent-sdk",p=re.getState(),f=p.mcpServers.filter(S=>S.added).map(S=>S.id),h=p.skills.filter(S=>S.added).map(S=>S.id),g=f.length>0?Kc.filter(S=>f.includes(S.id)):[],x=h.length>0?kc.filter(S=>h.includes(S.id)):[],b=g.length>0?g.map(S=>`${S.id}: ${S.description}`).join(`
|
|
272
|
+
`):"none",v=x.length>0?x.map(S=>`${S.id}: ${S.description}`).join(`
|
|
273
|
+
`):"none",k=p.channels,w=k.length>0?k.map(S=>`- sourceId: "${S.sourceId}" | name: "${S.name}" | path: "${S.path||"(no path)"}" | type: ${S.knowledgeType||"unclassified"} | tokens: ${S.baseTokens} | depth: ${S.depth}`).join(`
|
|
274
|
+
`):"No knowledge sources connected yet. Suggest what the user should add in knowledgeGaps.",j=b_(b,v,w),T=d?await Vc({prompt:e,model:l,systemPrompt:j,maxTurns:1}):await Yc({providerId:s.id,model:l,messages:[{role:"system",content:j},{role:"user",content:e}],temperature:.4,maxTokens:4096});let E;try{E=JSON.parse(T)}catch{}if(!E){const S=T.match(/```(?:json)?\s*([\s\S]*?)```/);if(S)try{E=JSON.parse(S[1].trim())}catch{}}if(!E){const S=T.match(/\{[\s\S]*\}/);if(S)try{E=JSON.parse(S[0])}catch{}}if(!E)throw new Error("Could not parse generated agent config");return k_(E),E}function k_(e){const n=re.getState().channels;if(n.length===0)return;function a(d){const p=e.instructionState.constraints.customConstraints;Array.isArray(p)?p.push(d):typeof p=="string"?e.instructionState.constraints.customConstraints=p?`${p}
|
|
275
|
+
${d}`:d:e.instructionState.constraints.customConstraints=[d]}const s=n.filter(d=>d.repoMeta);if(s.length>0){const d=s.map(f=>{const h=f.repoMeta,g=h.stack.length>0?h.stack.join(", "):"unknown stack";return`${h.name} (${g})`});e.instructionState.persona+=` You have deep access to ${d.join(" and ")}.`,a("Explore connected codebases autonomously — read files, check structure, trace dependencies before asking the user for information.");const p=s.flatMap(f=>f.repoMeta.features).filter(Boolean);if(p.length>0){const f=[...new Set(p)];e.instructionState.persona+=` Key capabilities include: ${f.join(", ")}.`}}const i=new Map;for(const d of n){if(!d.knowledgeType)continue;const p=i.get(d.knowledgeType)??[];p.push(d.name),i.set(d.knowledgeType,p)}const l={"ground-truth":d=>`Do not contradict information from: ${d}`,signal:d=>`When interpreting ${d}, look for underlying user needs, not surface requests`,guideline:d=>`Follow the conventions and rules defined in: ${d}`};for(const[d,p]of i){const f=l[d];f&&a(f(p.join(", ")))}}function w_(e){const n=re.getState(),a=[n.agentMeta.name&&`Agent: ${n.agentMeta.name}`,n.agentMeta.description&&`Description: ${n.agentMeta.description}`,n.instructionState.persona&&`Persona: ${n.instructionState.persona.slice(0,200)}`,n.instructionState.objectives.primary&&`Objective: ${n.instructionState.objectives.primary}`,n.instructionState.constraints.customConstraints&&`Constraints: ${n.instructionState.constraints.customConstraints.slice(0,200)}`,n.workflowSteps.length>0&&`Workflow: ${n.workflowSteps.map(i=>i.label).join(" → ")}`,n.channels.filter(i=>i.enabled).length>0&&`Knowledge: ${n.channels.filter(i=>i.enabled).map(i=>i.name).join(", ")}`,n.mcpServers.filter(i=>i.enabled!==!1).length>0&&`MCP: ${n.mcpServers.filter(i=>i.enabled!==!1).map(i=>i.name).join(", ")}`,n.skills.filter(i=>i.enabled!==!1).length>0&&`Skills: ${n.skills.filter(i=>i.enabled!==!1).map(i=>i.name).join(", ")}`].filter(Boolean).join(`
|
|
276
|
+
`),s=e.map((i,l)=>`${l+1}. [${i.id}] "${i.content}" (type: ${i.type}, tags: ${i.tags.join(",")})`).join(`
|
|
277
|
+
`);return`You are an expert agent architect analyzing runtime memory facts to improve an agent's design.
|
|
278
|
+
|
|
279
|
+
<agent_context>
|
|
280
|
+
${a}
|
|
281
|
+
</agent_context>
|
|
282
|
+
|
|
283
|
+
<facts>
|
|
284
|
+
${s}
|
|
285
|
+
</facts>
|
|
286
|
+
|
|
287
|
+
Analyze each fact and determine if it should be PROMOTED from runtime memory into a structured agent component. Facts that encode persistent patterns, preferences, or capabilities should graduate into the agent's design.
|
|
288
|
+
|
|
289
|
+
Promotion targets:
|
|
290
|
+
- "instruction": Fact describes HOW the agent should behave → append to persona or instructions
|
|
291
|
+
- "constraint": Fact is a rule or limitation → add as a constraint
|
|
292
|
+
- "workflow": Fact describes a recurring process → add as a workflow step
|
|
293
|
+
- "knowledge": Fact points to a data source the agent needs → add as knowledge source
|
|
294
|
+
- "mcp": Fact mentions a tool/API the agent should use → suggest MCP server
|
|
295
|
+
- "skill": Fact describes a capability the agent needs → suggest a skill
|
|
296
|
+
- "keep": Fact is volatile/contextual → keep in runtime memory
|
|
297
|
+
|
|
298
|
+
Output ONLY valid JSON:
|
|
299
|
+
{
|
|
300
|
+
"promotions": [
|
|
301
|
+
{
|
|
302
|
+
"factId": "<id from facts list>",
|
|
303
|
+
"factContent": "<the fact text>",
|
|
304
|
+
"target": "<promotion target>",
|
|
305
|
+
"confidence": <0.0-1.0>,
|
|
306
|
+
"suggestion": "<human-readable suggestion>",
|
|
307
|
+
"reason": "<why this promotion improves the agent>",
|
|
308
|
+
"payload": {
|
|
309
|
+
"constraintText": "<if target=constraint>",
|
|
310
|
+
"workflowStep": { "label": "<step name>", "action": "<what to do>" },
|
|
311
|
+
"knowledgeSource": { "name": "<source name>", "type": "<ground-truth|signal|evidence|framework>" },
|
|
312
|
+
"mcpServerId": "<id from MCP registry if target=mcp>",
|
|
313
|
+
"skillId": "<skill id if target=skill>",
|
|
314
|
+
"instructionAppend": "<text to append to persona if target=instruction>"
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
"summary": "<one sentence summary of recommended changes>",
|
|
319
|
+
"versionImpact": "<major|minor|patch|none>"
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
Rules:
|
|
323
|
+
- Only promote facts with confidence >= 0.6
|
|
324
|
+
- Facts that are temporary/contextual should stay as "keep"
|
|
325
|
+
- Prefer fewer high-confidence promotions over many low-confidence ones
|
|
326
|
+
- Include payload fields ONLY for the relevant target (omit others)
|
|
327
|
+
- versionImpact: major if persona/objective changes, minor if adding knowledge/tools/steps, patch if constraints only`}async function S_(e){const n=Je.getState(),a=n.providers.find(i=>i.id===n.selectedProviderId);if(!a)throw new Error("No provider configured — add one in Settings");const s=typeof a.models?.[0]=="object"?a.models[0].id:a.models?.[0]||"claude-sonnet-4-20250514";return a.authMethod==="claude-agent-sdk"?Vc({prompt:e,model:s,maxTurns:1}):Yc({providerId:a.id,model:s,messages:[{role:"user",content:e}],temperature:.3,maxTokens:4096})}function M_(e){try{return JSON.parse(e)}catch{}const n=e.match(/```(?:json)?\s*([\s\S]*?)```/);if(n)try{return JSON.parse(n[1].trim())}catch{}const a=e.match(/\{[\s\S]*\}/);if(a)try{return JSON.parse(a[0])}catch{}throw new Error("Could not parse analysis response")}async function C_(e){if(e.length===0)return{promotions:[],summary:"No facts to analyze",versionImpact:"none"};const n=w_(e),a=await S_(n),s=M_(a);return s.promotions=s.promotions.filter(i=>i.confidence>=.6&&i.target!=="keep").sort((i,l)=>l.confidence-i.confidence),s}function Kx(){return{status:"unknown",latencyMs:null,toolCount:null,errorMessage:null,checkedAt:0}}const Yx=qt((e,n)=>({mcpHealth:{},skillHealth:{},setMcpHealth:(a,s)=>e(i=>({mcpHealth:{...i.mcpHealth,[a]:s}})),setSkillHealth:(a,s)=>e(i=>({skillHealth:{...i.skillHealth,[a]:s}})),setMcpChecking:a=>e(s=>({mcpHealth:{...s.mcpHealth,[a]:{...s.mcpHealth[a]||Kx(),status:"checking"}}})),setSkillChecking:a=>e(s=>({skillHealth:{...s.skillHealth,[a]:{...s.skillHealth[a]||Kx(),status:"checking"}}})),clearHealth:()=>e({mcpHealth:{},skillHealth:{}})})),_f={"ground-truth":.3,guideline:.15,framework:.15,evidence:.2,signal:.12,hypothesis:.08},E_=.03,j_={0:1.5,1:1.2,2:1,3:.6,4:.2};function T_(e,n){if(e.length===0)return[];if(n<=0)return e.map(d=>({name:d.name,knowledgeType:d.knowledgeType,allocatedTokens:0,weight:0,cappedBySize:!1}));const a=new Map;for(const d of e)a.has(d.knowledgeType)||a.set(d.knowledgeType,[]),a.get(d.knowledgeType).push(d);const s=[];for(const[d,p]of a){const f=_f[d],h=p.length;for(const g of p){const x=g.depthMultiplier??1,b=f/h*x,v=Math.max(b,E_);s.push({name:g.name,knowledgeType:g.knowledgeType,allocatedTokens:0,weight:v,cappedBySize:!1})}}const i=s.reduce((d,p)=>d+p.weight,0);if(i>0)for(const d of s)d.weight=d.weight/i;for(const d of s)d.allocatedTokens=Math.round(d.weight*n);const l=new Map(e.map(d=>[d.name,d]));for(let d=0;d<3;d++){let p=0;const f=[];for(const h of s){const g=l.get(h.name);h.allocatedTokens>g.rawTokens?(p+=h.allocatedTokens-g.rawTokens,h.allocatedTokens=g.rawTokens,h.cappedBySize=!0):h.cappedBySize||f.push(h)}if(p>0&&f.length>0){const h=f.reduce((g,x)=>g+x.weight,0);if(h>0)for(const g of f){const x=Math.round(g.weight/h*p);g.allocatedTokens+=x}}else break}return s}function ym({loading:e,onClick:n,label:a="Generate"}){return c.jsxs("button",{type:"button",onClick:s=>{s.stopPropagation(),n()},disabled:e,"aria-label":a,className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:e?.6:1},children:[e?c.jsx(pt,{size:9,className:"animate-spin motion-reduce:animate-none"}):c.jsx(Pa,{size:9}),a]})}function Oi({icon:e,label:n,color:a,badge:s,collapsed:i,onToggle:l,children:d}){const p=we();return c.jsxs("div",{role:"region","aria-label":n,style:{borderBottom:`1px solid ${p.isDark?"#1e1e22":"#e8e8ec"}`},children:[c.jsxs("button",{type:"button",onClick:l,"aria-expanded":!i,className:"flex items-center gap-2 w-full px-5 py-3.5 border-none cursor-pointer select-none",style:{background:"transparent"},children:[c.jsx(e,{size:10,style:{color:a,flexShrink:0}}),i?c.jsx(Ba,{size:12,style:{color:p.textDim}}):c.jsx(Ln,{size:12,style:{color:p.textDim}}),c.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase flex-1 text-left",style:{fontFamily:"'Geist Mono', monospace",color:p.textSecondary},children:n}),s&&c.jsx("span",{className:"text-[13px] px-2 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim,background:p.badgeBg},children:s})]}),!i&&c.jsx("div",{className:"px-5 pb-4",children:d})]})}function N_(){const e=we(),n=re(k=>k.hydrateFromGenerated),a=We(k=>k.setSessionConfig),s=We(k=>k.addFact),[i,l]=z.useState(""),[d,p]=z.useState(!1),[f,h]=z.useState(""),[g,x]=z.useState(null),b=z.useCallback(async()=>{if(!(!i.trim()||d)){p(!0),h("");try{const k=await v_(i);if(x(k),n(k),k.memoryConfig){a({maxMessages:k.memoryConfig.maxMessages,summarizeAfter:k.memoryConfig.summarizeAfter,summarizeEnabled:k.memoryConfig.summarizeEnabled});for(const w of k.memoryConfig.suggestedFacts||[])s(w,["generated"])}}catch(k){h(k instanceof Error?k.message:"Generation failed")}finally{p(!1)}}},[i,d,n,a,s]),v=g?{mcp:g.mcpServerIds?.length||0,skills:g.skillIds?.length||0,steps:g.workflowSteps?.length||0,knowledge:g.knowledgeSelections?.length||g.knowledgeSuggestions?.length||0,gaps:g.knowledgeGaps?.length||0}:null;return c.jsxs("div",{style:{borderBottom:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[c.jsxs("div",{className:"px-5 py-3 flex items-center gap-2",style:{background:e.isDark?"#1a1a1e":"#f0f0f5"},children:[c.jsx(T4,{size:13,style:{color:"#FE5000"}}),c.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textSecondary},children:"Generate Agent"})]}),c.jsxs("div",{className:"px-5 py-3 flex flex-col gap-2",children:[c.jsx("div",{className:"flex flex-wrap gap-1",children:[{label:"Code Review",icon:"🔍",prompt:"A code review agent that uses framework sources for coding standards, ground-truth for API specs, and strict constraints. Reviews PRs for correctness, style, and security."},{label:"Research",icon:"🔬",prompt:"A research agent that uses evidence and signal sources with broad exploration. Synthesizes data from multiple sources, identifies patterns, and generates structured research reports."},{label:"Maritime Ops",icon:"⚓",prompt:"A maritime operations agent with ground-truth for SOLAS/MARPOL regulations, evidence from vessel data, and signal from crew feedback. Supports voyage planning, compliance checks, and operational reporting."},{label:"Writing",icon:"✍️",prompt:"A writing agent that uses framework sources for style guides, ground-truth for facts and references, and hypothesis for draft content. Produces polished documents with consistent voice and accurate citations."}].map(k=>c.jsxs("button",{type:"button",onClick:()=>l(k.prompt),className:"text-[12px] px-2 py-1 rounded-full cursor-pointer",title:k.prompt,style:{fontFamily:"'Geist Mono', monospace",fontWeight:500,background:e.isDark?"#1c1c20":"#eeeef3",color:e.textDim,border:`1px solid ${e.border}`,transition:"border-color 150ms"},onMouseEnter:w=>{w.currentTarget.style.borderColor="#FE5000",w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.borderColor=e.border,w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.borderColor="#FE5000",w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.borderColor=e.border,w.currentTarget.style.color=e.textDim},children:[k.icon," ",k.label]},k.label))}),c.jsx(Aa,{value:i,onChange:k=>l(k.target.value),placeholder:`Describe your agent in plain language...
|
|
328
|
+
|
|
329
|
+
e.g. "A PM agent that tracks competitors, uses GitHub and Notion, and outputs weekly reports to Slack"`,rows:4,style:{minHeight:80}}),f&&c.jsx("div",{role:"alert",className:"text-[12px] px-2 py-1 rounded",style:{background:"#ff000015",color:"#ff4444",border:"1px solid #ff000020"},children:f}),v&&c.jsx("div",{className:"flex flex-wrap gap-1",children:[{label:"MCP",count:v.mcp,color:"#2ecc71"},{label:"Skills",count:v.skills,color:"#f1c40f"},{label:"Steps",count:v.steps,color:"#e67e22"},{label:"Sources",count:v.knowledge,color:"#3498db"},...v.gaps>0?[{label:"Gaps",count:v.gaps,color:"#e74c3c"}]:[]].map(k=>c.jsxs("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:`${k.color}15`,color:k.color,border:`1px solid ${k.color}30`},children:[k.count," ",k.label]},k.label))}),g?.knowledgeGaps&&g.knowledgeGaps.length>0&&c.jsxs("div",{className:"flex flex-col gap-1 px-2 py-2 rounded",style:{background:"#e74c3c10",border:"1px solid #e74c3c20"},children:[c.jsx("span",{className:"text-[13px] font-bold uppercase tracking-wider",style:{color:"#e74c3c",fontFamily:"'Geist Mono', monospace"},children:"Missing Sources"}),g.knowledgeGaps.map((k,w)=>c.jsxs("div",{className:"flex items-start gap-1.5 text-[12px]",style:{color:e.textSecondary},children:[c.jsx(nm,{size:10,style:{color:"#e74c3c",marginTop:2,flexShrink:0}}),c.jsxs("div",{children:[c.jsx("span",{style:{color:e.textPrimary,fontWeight:600},children:k.name}),c.jsxs("span",{style:{color:e.textDim},children:[" (",k.type,")"]}),k.description&&c.jsx("div",{style:{color:e.textDim,fontSize:13,marginTop:1},children:k.description})]})]},w))]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs("button",{type:"button",onClick:b,disabled:d||!i.trim(),className:"flex items-center gap-1.5 px-4 py-2.5 rounded text-[13px] font-semibold tracking-wider uppercase cursor-pointer border-none flex-1 justify-center",style:{background:d?"#CC4000":"#FE5000",color:"#fff",opacity:d||!i.trim()?.6:1,fontFamily:"'Geist Mono', monospace"},children:[d?c.jsx(pt,{size:11,className:"animate-spin motion-reduce:animate-none"}):c.jsx(Pa,{size:11}),d?"Generating...":g?"Regenerate":"Generate"]}),g&&c.jsx("button",{type:"button",onClick:()=>{l(""),x(null),h("")},className:"flex items-center gap-1 px-2 py-2 rounded text-[12px]",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,cursor:"pointer"},children:c.jsx(am,{size:10})})]})]})]})}function A_(){const e=we(),n=re(H=>H.channels),a=re(H=>H.setChannelDepth),s=re(H=>H.removeChannel),i=re(H=>H.addChannel),l=re(H=>H.setChannelKnowledgeType),d=re(H=>H.setShowFilePicker),p=re(H=>H.setShowConnectorPicker),f=re(H=>H.connectors),h=re(H=>H.removeConnector),g=wn(H=>H.indexes),x=wn(H=>H.loading),b=wn(H=>H.errors),[v,k]=z.useState(!1),[w,j]=z.useState(!1),[T,E]=z.useState(!1),[S,M]=z.useState(""),[$,A]=z.useState(!1),[_,F]=z.useState(null),[B,G]=z.useState({}),[O,K]=z.useState(null),V=["Maximum","High","Normal","Low","Minimal"],P=["ground-truth","signal","evidence","framework","hypothesis","guideline"],N=H=>{const ce=new Set(n.filter(ge=>ge.enabled).map(ge=>ge.knowledgeType)),Q=Array.from(ce).reduce((ge,xe)=>ge+(_f[xe]||0),0);return Q>0?Math.round(_f[H]/Q*100):0},D=H=>{const ce=g[H.path];if(ce){const Q=Fs[H.depth];return Math.round(ce.index.totalTokens*Q.pct)}return H.baseTokens??0},U=n.filter(H=>H.enabled).length,q=n.filter(H=>H.enabled&&g[H.path]).length,W=n.filter(H=>H.enabled).reduce((H,ce)=>H+D(ce),0),oe=n.filter(H=>H.enabled&&/\.compressed\.md$/i.test(H.path||"")),I=oe.reduce((H,ce)=>H+(ce.baseTokens||0),0),L=oe.reduce((H,ce)=>H+D(ce),0),Z=I>0?Math.max(0,(I-L)/I*100):0,ae=H=>H>=1e3?`${(H/1e3).toFixed(0)}K`:`${H}`,pe=z.useCallback(async()=>{j(!0);const H=n.filter(ce=>ce.enabled&&ce.path).map(ce=>ce.path);H.length>0&&await wn.getState().indexFiles(H),j(!1)},[n]),me=z.useCallback(async()=>{if(!(!S.trim()||T)){E(!0);try{const H=S.trim(),ce=/github\.com\//i.test(H)||H.endsWith(".git"),Q=ce?`${Ae}/repo/index-github`:`${Ae}/repo/index`,J=await(await fetch(Q,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ce?{url:H,persist:!0}:{path:H})})).json();if(J.status==="ok"&&J.data){const ye=J.data.totalTokens??J.data.scan?.totalTokens??5e3,Ee=J.data.scan,Ie=Array.isArray(Ee?.stack)?Ee.stack:Ee?.stack&&typeof Ee.stack=="object"?Object.values(Ee.stack).filter(ze=>typeof ze=="string"&&ze!=="unknown"&&ze!=="none"):[];for(const ze of J.data.files){const Nt=`${J.data.outputDir}/${ze}`,mt=ze.includes("overview");i({sourceId:`repo-${ze}-${Date.now()}`,name:ze.replace(".compressed.md","").replace(".md","").replace(/^\d+-/,""),path:Nt,category:"knowledge",knowledgeType:"ground-truth",depth:ce?2:1,baseTokens:Math.round(ye/Math.max(J.data.files.length,1)),...mt&&J.data.overviewMarkdown?{content:J.data.overviewMarkdown}:{},...mt&&Ee?{repoMeta:{name:J.data.name??"",stack:Ie,totalFiles:Ee.totalFiles??0,baseUrl:Ee.baseUrl,features:(Ee.features??[]).map(vt=>vt.name)}}:{},...J.data.contentSourceId?{contentSourceId:J.data.contentSourceId}:{}})}A(!1),M(""),await wn.getState().indexFiles(J.data.files.map(ze=>`${J.data.outputDir}/${ze}`)),Ee&&ta(async()=>{const{populateGraphFromScan:ze}=await import("./graphPopulator-C6jg83nL.js");return{populateGraphFromScan:ze}},[]).then(({populateGraphFromScan:ze})=>{ze(J.data.name??S,Ee).catch(()=>{})})}}catch{}E(!1)}},[S,T,i]),he=["#2ecc71","#3498db","#f1c40f","#e67e22","#999"];return z.useEffect(()=>{fetch(`${Ae}/connectors/auth`).then(H=>H.json()).then(H=>{H.data&&G(H.data)}).catch(()=>{})},[]),c.jsxs(Oi,{icon:Ri,label:"Knowledge",color:"#3498db",badge:`${q}/${U} indexed · ${ae(W)} tokens`,collapsed:v,onToggle:()=>k(!v),children:[c.jsx("div",{className:"flex justify-end mb-2",children:c.jsx(ym,{loading:w,onClick:pe,label:"Index"})}),c.jsx("div",{className:"flex flex-col",children:n.map(H=>{const ce=Qo[H.knowledgeType]||Qo.evidence,Q=H.depth??0,ge=/\.compressed\.md$/i.test(H.path||""),xe=(4-Q)/4*100,J=he[Q]||"#999",ye=!!g[H.path],Ee=!!x[H.path],Ie=!!b[H.path],ze=D(H),Nt=O===H.sourceId,mt=N(H.knowledgeType);return c.jsxs("div",{className:"py-1.5",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsxs("div",{style:{position:"relative",flexShrink:0},children:[c.jsx("div",{style:{width:8,height:8,borderRadius:2,background:ce.color}}),ye&&c.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#00ff88"}}),Ee&&c.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#ffaa00"}}),Ie&&c.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:"#ff3344"}})]}),c.jsx("button",{type:"button",onClick:()=>K(Nt?null:H.sourceId),className:"flex-1 truncate text-[13px] text-left border-none bg-transparent cursor-pointer p-0",title:H.name,style:{color:H.enabled?e.textPrimary:e.textDim,lineHeight:1.2},children:H.name}),c.jsx(Si,{content:`${ce.icon} ${ce.label} — ${ce.instruction}
|
|
330
|
+
Budget: ~${mt}% · Detail: ${V[Q]}`,position:"top",children:c.jsx("span",{className:"text-[7px] px-1.5 py-0.5 rounded-full shrink-0 cursor-default select-none",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:`${ce.color}18`,color:ce.color,border:`1px solid ${ce.color}30`},children:ce.label})}),ge&&c.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:"#24292F",background:"#24292F12",border:"1px solid #24292F30"},title:"GitHub indexed & compressed context",children:"GH"}),c.jsx("span",{className:"text-[13px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:ye?e.textPrimary:e.textDim},title:ye?`Indexed: ${g[H.path].index.nodeCount} nodes`:"Estimated",children:ae(ze)}),c.jsx("button",{type:"button","aria-label":`Remove ${H.name}`,onClick:()=>s(H.sourceId),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:e.textFaint,width:20,height:20,padding:0},children:c.jsx(Tt,{size:9})})]}),c.jsxs("div",{className:"flex items-center gap-1 mt-0.5 pl-4",children:[c.jsx("button",{type:"button","aria-label":"Less detail",onClick:()=>a(H.sourceId,Math.min(4,Q+1)),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:Q>=4?e.textFaint:e.textDim,width:20,height:20,padding:0},children:c.jsx(I3,{size:9})}),c.jsx("div",{className:"flex-1",style:{height:4,background:`${J}18`,borderRadius:2,overflow:"hidden"},children:c.jsx("div",{style:{width:`${xe}%`,height:"100%",background:J,borderRadius:2,transition:"width 200ms"}})}),c.jsx("button",{type:"button","aria-label":"More detail",onClick:()=>a(H.sourceId,Math.max(0,Q-1)),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:Q<=0?e.textFaint:e.textDim,width:20,height:20,padding:0},children:c.jsx(bt,{size:9})}),c.jsx("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,width:44,textAlign:"right"},children:V[Q]})]}),Nt&&c.jsxs("div",{className:"mt-1.5 ml-4 px-2.5 py-2 rounded-md",style:{background:e.isDark?"#1a1a1e":"#f5f5f8",border:`1px solid ${e.isDark?"#2a2a30":"#e0e0e5"}`},children:[c.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[c.jsx("span",{className:"text-[12px] tracking-[0.1em] uppercase shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,width:32},children:"Type"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:P.map((vt,mn)=>{const tn=Qo[vt],hn=H.knowledgeType===vt;return c.jsx("button",{type:"button",onClick:()=>l(H.sourceId,mn),className:"text-[7px] px-1.5 py-0.5 rounded-full cursor-pointer border-none",style:{fontFamily:"'Geist Mono', monospace",fontWeight:600,background:hn?`${tn.color}25`:"transparent",color:hn?tn.color:e.textFaint,border:`1px solid ${hn?`${tn.color}40`:"transparent"}`},children:tn.label},vt)})})]}),c.jsxs("div",{className:"flex items-start gap-1.5 mb-2",children:[c.jsx(m3,{size:9,style:{color:ce.color,marginTop:1,flexShrink:0}}),c.jsx("span",{className:"text-[13px]",style:{color:e.textDim,lineHeight:1.3},children:ce.instruction})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Budget: ~",mt,"%"]}),c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Detail: ",V[Q]]}),c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Tokens: ",ae(ze)]})]})]})]},H.sourceId)})}),f.filter(H=>H.enabled&&H.direction!=="write").length>0&&c.jsxs("div",{className:"mt-2 pt-2",style:{borderTop:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Connectors"}),f.filter(H=>H.enabled&&H.direction!=="write").map(H=>{const Q={notion:"#000",slack:"#4A154B",hubspot:"#FF7A59",github:"#24292F",granola:"#8B5CF6","google-drive":"#4285F4"}[H.service]||"#666",ge=B[H.service],xe=ge?.status==="connected",J=_===H.service;return c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 py-2",style:{borderBottom:J?"none":`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsxs("div",{style:{position:"relative",flexShrink:0},children:[c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:Q}}),c.jsx("div",{style:{position:"absolute",top:-2,right:-2,width:4,height:4,borderRadius:"50%",background:xe?"#00ff88":ge?.hasApiKey?"#ffaa00":"#666"}})]}),c.jsx("span",{className:"flex-1 truncate text-[14px]",style:{color:e.textPrimary},children:H.name}),c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full uppercase",style:{fontFamily:"'Geist Mono', monospace",color:H.direction==="both"?"#b88ad4":"#6aafe6",background:H.direction==="both"?"#9b59b610":"#3498db10"},children:H.direction}),c.jsx("button",{type:"button","aria-label":`Configure ${H.name} credentials`,onClick:()=>F(J?null:H.service),className:"border-none bg-transparent cursor-pointer p-2.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:xe?"#00ff88":e.textDim},children:c.jsx(g3,{size:10})}),c.jsx("button",{type:"button","aria-label":`Remove ${H.name}`,onClick:()=>h(H.id),className:"border-none bg-transparent cursor-pointer p-2.5 rounded min-w-[44px] min-h-[44px] flex items-center justify-center hover:bg-[#ff000010]",style:{color:e.textFaint},children:c.jsx(Tt,{size:10})})]}),J&&c.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-4",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsx("span",{className:"text-[13px]",style:{color:e.textDim},children:xe?"✓ Connected":"Authentication required"}),c.jsx("button",{type:"button",onClick:()=>re.getState().setShowSettings(!0),className:"text-[13px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000"},children:"Open Settings"})]})]},H.id)})]}),c.jsxs("div",{className:"flex gap-2 mt-3",children:[c.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:H=>{H.currentTarget.style.borderColor="#FE5000",H.currentTarget.style.color="#FE5000"},onMouseLeave:H=>{H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim},onFocus:H=>{H.currentTarget.style.borderColor="#FE5000",H.currentTarget.style.color="#FE5000"},onBlur:H=>{H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim},children:[c.jsx(bt,{size:10})," Files"]}),c.jsxs("button",{type:"button","aria-label":"Add connector",onClick:()=>p(!0),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2.5 rounded text-[12px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:H=>{H.currentTarget.style.borderColor="#9b59b6",H.currentTarget.style.color="#9b59b6"},onMouseLeave:H=>{H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim},onFocus:H=>{H.currentTarget.style.borderColor="#9b59b6",H.currentTarget.style.color="#9b59b6"},onBlur:H=>{H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim},children:[c.jsx(na,{size:10})," Connect"]}),c.jsxs("button",{type:"button","aria-label":"Index repository",onClick:()=>A(!$),className:"flex items-center justify-center gap-1.5 flex-1 px-2.5 py-2.5 rounded text-[12px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:$?"#24292F15":"transparent",border:`1px solid ${$?"#24292F":e.border}`,color:$?"#24292F":e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:H=>{$||(H.currentTarget.style.borderColor="#24292F",H.currentTarget.style.color="#24292F")},onMouseLeave:H=>{$||(H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim)},onFocus:H=>{$||(H.currentTarget.style.borderColor="#24292F",H.currentTarget.style.color="#24292F")},onBlur:H=>{$||(H.currentTarget.style.borderColor=e.border,H.currentTarget.style.color=e.textDim)},children:[c.jsx(KN,{size:10})," Repo"]})]}),$&&c.jsxs("div",{className:"mt-2 flex gap-1.5",children:[c.jsx("input",{type:"text",value:S,onChange:H=>M(H.target.value),placeholder:"/path/to/repo or https://github.com/org/repo","aria-label":"Repository path",className:"flex-1 px-2.5 py-1.5 rounded text-[13px] outline-none",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"},onKeyDown:H=>{H.key==="Enter"&&me()}}),c.jsx("button",{type:"button",onClick:me,disabled:T||!S.trim(),className:"px-3 py-1.5 rounded text-[12px] font-semibold tracking-wider uppercase cursor-pointer border-none",style:{background:"#24292F",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:T||!S.trim()?.5:1},"aria-label":"Index repository",children:T?c.jsx(pt,{size:10,className:"animate-spin motion-reduce:animate-none"}):"Index"})]}),oe.length>0&&c.jsxs("div",{className:"mt-3 px-2.5 py-2 rounded-lg",style:{border:"1px solid #24292F30",background:"#24292F08"},children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-[13px] tracking-[0.1em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:"#24292F"},children:"GitHub Context Compression"}),c.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"#00A86B"},children:["-",Z.toFixed(1),"%"]})]}),c.jsxs("div",{className:"mt-1 text-[12px]",style:{color:e.textDim},children:["Raw ",ae(I)," → Effective ",ae(L)," tokens (",oe.length," channels)"]})]}),n.length>0&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Context allocation"}),c.jsx("div",{className:"flex gap-0.5 h-1 rounded overflow-hidden",children:Object.entries(Qo).map(([H,ce])=>{const Q=n.filter(xe=>xe.enabled&&xe.knowledgeType===H).reduce((xe,J)=>xe+D(J),0);if(Q===0)return null;const ge=W>0?Q/W*100:0;return c.jsx("div",{style:{width:`${ge}%`,background:ce.color,borderRadius:2}},H)})}),c.jsx("div",{className:"flex justify-between mt-1",children:c.jsxs("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:[ae(W)," used"]})})]})]})}function __(){const e=we(),n=re(E=>E.mcpServers),a=re(E=>E.removeMcp),s=re(E=>E.setShowMcpPicker),i=Xe(E=>E.servers),l=Yx(E=>E.mcpHealth),[d,p]=z.useState(!1),[f,h]=z.useState(!1),g=n.filter(E=>E.added),x=g.length,b=g.filter(E=>l[E.id]?.status==="error").length,v=(E,S)=>i.find(M=>M.id===E)??i.find(M=>M.name===S),k=(E,S)=>{const M=l[E];if(M){if(M.status==="healthy")return"ok";if(M.status==="degraded")return"warn";if(M.status==="error")return"err";if(M.status==="checking")return"warn"}const $=v(E,S);return $?$.status==="connected"?"ok":$.status==="error"?"err":$.status==="connecting"?"warn":"off":"off"},w=z.useCallback(async()=>{h(!0);const{setMcpHealth:E,setMcpChecking:S}=Yx.getState();await Promise.allSettled(g.map(async M=>{const $=v(M.id,M.name);if(!$){E(M.id,{status:"error",latencyMs:0,toolCount:0,tools:[],errorMessage:`Not found: ${M.id}`,checkedAt:Date.now()});return}S(M.id);const A=performance.now();try{const _=await fetch(`${Ae}/health/mcp/${$.id}`,{signal:AbortSignal.timeout(15e3)}),F=Math.round(performance.now()-A),B=await _.json(),G=B.data??B;E(M.id,{status:G.status??"error",latencyMs:F,toolCount:G.toolCount??G.tools?.length??0,tools:G.tools??[],errorMessage:G.errorMessage??G.error??null,checkedAt:Date.now()})}catch(_){E(M.id,{status:"error",latencyMs:Math.round(performance.now()-A),toolCount:0,tools:[],errorMessage:_ instanceof Error?_.message:"Probe failed",checkedAt:Date.now()})}})),h(!1)},[g,i]),j={ok:{bg:"#00ff88",glow:"0 0 6px rgba(0,255,136,0.4)"},warn:{bg:"#ffaa00",glow:"0 0 6px rgba(255,170,0,0.4)"},err:{bg:"#ff3344",glow:"0 0 6px rgba(255,51,68,0.4)"},off:{bg:"#333",glow:"none"}},T=E=>E==null?{active:0,color:e.textFaint}:E<=10?{active:5,color:"#00ff88"}:E<=30?{active:4,color:"#7DFF5A"}:E<=80?{active:3,color:"#FFD84D"}:E<=200?{active:2,color:"#FF9F43"}:{active:1,color:"#FF4D4D"};return c.jsxs(Oi,{icon:na,label:"MCP Servers",color:"#2ecc71",badge:b>0?`${x} active · ${b} error`:`${x} active`,collapsed:d,onToggle:()=>p(!d),children:[x>0&&c.jsx("div",{className:"flex justify-end mb-2",children:c.jsx(ym,{loading:f,onClick:w,label:"Check Health"})}),c.jsx("div",{className:"flex flex-col",children:g.map(E=>{const S=k(E.id,E.name),M=j[S],$=v(E.id,E.name),A=l[E.id],_=A?.toolCount??$?.tools?.length??0;return c.jsxs("div",{style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsxs("div",{className:"flex items-center gap-2.5 py-2.5",children:[c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:M.bg,boxShadow:M.glow,flexShrink:0}}),c.jsx("span",{className:"flex-1 text-[14px]",style:{color:e.textPrimary},children:E.name}),E.type&&c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:e.badgeBg,color:e.textDim},children:E.type}),_>0&&c.jsxs("span",{className:"text-[12px]",style:{color:e.textDim},children:[_," tools"]}),c.jsx("button",{type:"button","aria-label":`Remove ${E.name}`,onClick:()=>a(E.id),className:"border-none bg-transparent cursor-pointer p-2 rounded hover:bg-[#ff000010] min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:c.jsx(Tt,{size:10})})]}),A&&A.status!=="unknown"&&c.jsxs("div",{className:"flex items-center gap-2 pb-1.5 pl-5 text-[13px]",style:{fontFamily:"'Geist Mono', monospace"},children:[A.latencyMs!=null&&c.jsxs("span",{className:"flex items-end gap-[2px]",title:`${A.latencyMs}ms`,children:[Array.from({length:5}).map((F,B)=>{const G=T(A.latencyMs);return c.jsx("span",{style:{width:3,height:4+B*2,borderRadius:1,background:B<G.active?G.color:e.borderSubtle,opacity:B<G.active?1:.5}},`lat-${E.id}-${B}`)}),c.jsxs("span",{style:{color:e.textFaint,marginLeft:4},children:[A.latencyMs,"ms"]})]}),A.tools&&A.tools.length>0&&c.jsxs("span",{className:"truncate",style:{color:e.textFaint,maxWidth:180},title:A.tools.join(", "),children:[A.tools.slice(0,3).join(", "),A.tools.length>3?` +${A.tools.length-3}`:""]}),A.errorMessage&&c.jsx("span",{style:{color:"#e74c3c"},children:A.errorMessage})]})]},E.id)})}),c.jsxs("button",{type:"button","aria-label":"Open MCP Library",onClick:()=>s(!0),className:"flex items-center justify-center gap-1.5 w-full mt-3 px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:E=>{E.currentTarget.style.borderColor="#FE5000",E.currentTarget.style.color="#FE5000"},onMouseLeave:E=>{E.currentTarget.style.borderColor=e.border,E.currentTarget.style.color=e.textDim},onFocus:E=>{E.currentTarget.style.borderColor="#FE5000",E.currentTarget.style.color="#FE5000"},onBlur:E=>{E.currentTarget.style.borderColor=e.border,E.currentTarget.style.color=e.textDim},children:[c.jsx(nv,{size:11})," MCP Library"]})]})}function D_(){const e=we(),n=re(f=>f.skills),a=re(f=>f.removeSkill),s=re(f=>f.setShowSkillPicker),[i,l]=z.useState(!1),d=n.filter(f=>f.added),p=d.length;return c.jsxs(Oi,{icon:pn,label:"Skills",color:"#f1c40f",badge:`${p} active`,collapsed:i,onToggle:()=>l(!i),children:[d.length===0&&c.jsx("div",{className:"text-[12px] py-2",style:{color:e.textFaint},children:"No skills selected for this agent."}),c.jsx("div",{className:"flex flex-col",children:d.map(f=>c.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:`1px solid ${e.isDark?"#1a1a1e":"#eee"}`},children:[c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:"#00ff88",boxShadow:"0 0 6px rgba(0,255,136,0.4)",flexShrink:0}}),c.jsx("span",{className:"flex-1 text-[13px] truncate",style:{color:e.textPrimary},children:f.name}),c.jsx("button",{type:"button","aria-label":`Remove ${f.name}`,onClick:()=>a(f.id),className:"border-none bg-transparent cursor-pointer rounded shrink-0 flex items-center justify-center",style:{color:e.textFaint,width:20,height:20,padding:0},children:c.jsx(Tt,{size:9})})]},f.id))}),c.jsxs("button",{type:"button","aria-label":"Open Skill Library",onClick:()=>s(!0),className:"flex items-center justify-center gap-1.5 w-full mt-3 px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer min-h-[44px] motion-reduce:transition-none",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace",transition:"border-color 150ms, color 150ms"},onMouseEnter:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onMouseLeave:f=>{f.currentTarget.style.borderColor=e.border,f.currentTarget.style.color=e.textDim},onFocus:f=>{f.currentTarget.style.borderColor="#FE5000",f.currentTarget.style.color="#FE5000"},onBlur:f=>{f.currentTarget.style.borderColor=e.border,f.currentTarget.style.color=e.textDim},children:[c.jsx(nv,{size:11})," Skill Library"]})]})}const z_=[{value:"full",label:"Full History"},{value:"sliding_window",label:"Sliding Window"},{value:"summarize_and_recent",label:"Summarize + Recent"},{value:"rag",label:"RAG over History"}],R_=[{value:"local_sqlite",label:"SQLite (local)"},{value:"postgres",label:"PostgreSQL"},{value:"redis",label:"Redis"},{value:"chromadb",label:"ChromaDB"},{value:"pinecone",label:"Pinecone"},{value:"custom",label:"Custom"}],O_=[{value:"text-embedding-3-small",label:"Ada 3 Small"},{value:"text-embedding-3-large",label:"Ada 3 Large"},{value:"voyage-3",label:"Voyage 3"},{value:"custom",label:"Custom"}],$_=[{value:"top_k",label:"Top-K"},{value:"threshold",label:"Threshold"},{value:"hybrid",label:"Hybrid"}],F_=[{value:"auto_extract",label:"Auto Extract"},{value:"explicit",label:"Explicit Only"},{value:"both",label:"Both"}],I_=[{value:"per_user",label:"Per User"},{value:"per_agent",label:"Per Agent"},{value:"global",label:"Global"}],L_=[{value:"user_preferences",label:"Preferences",color:"#3498db"},{value:"decisions",label:"Decisions",color:"#e67e22"},{value:"facts",label:"Facts",color:"#2ecc71"},{value:"feedback",label:"Feedback",color:"#9b59b6"},{value:"entities",label:"Entities",color:"#f1c40f"}],B_=[{value:"reset_each_run",label:"Reset Each Run"},{value:"persistent_sandbox",label:"Persistent Sandbox"},{value:"clone_from_shared",label:"Clone from Shared"}],xc={shared:"#2ecc71",agent_private:"#3498db",run_scratchpad:"#e67e22"},rf={preference:"#3498db",decision:"#e67e22",fact:"#2ecc71",entity:"#f1c40f",custom:"#999"};function ja({children:e}){const n=we();return c.jsx("div",{className:"text-[13px] uppercase tracking-[0.12em] font-semibold mt-2 mb-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim},children:e})}function Xo({label:e,value:n,min:a,max:s,step:i,onChange:l,suffix:d}){const p=we(),f=d==="K"?`${(n/1e3).toFixed(0)}K`:`${n}`;return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] uppercase tracking-wider shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:p.textDim,width:90},children:e}),c.jsx("input",{type:"range",min:a,max:s,step:i,value:n,onChange:h=>l(Number(h.target.value)),"aria-label":e,className:"flex-1",style:{accentColor:"#FE5000"}}),c.jsx("span",{className:"text-[12px] w-10 text-right",style:{fontFamily:"'Geist Mono', monospace",color:p.textSecondary},children:f})]})}function P_(){const e=we(),n=We(N=>N.session),a=We(N=>N.longTerm),s=We(N=>N.working),i=We(N=>N.facts),l=We(N=>N.setSessionConfig),d=We(N=>N.setLongTermConfig),p=We(N=>N.setRecallConfig),f=We(N=>N.setWriteConfig),h=We(N=>N.toggleExtractType),g=We(N=>N.setWorkingConfig),x=We(N=>N.addFact),b=We(N=>N.removeFact),v=We(N=>N.sandbox),k=We(N=>N.setSandboxConfig),w=We(N=>N.setSandboxDomain),[j,T]=z.useState(!1),[E,S]=z.useState(""),[M,$]=z.useState("shared"),[A,_]=z.useState(!1),[F,B]=z.useState(!1),G=z.useCallback(async()=>{_(!0);try{const N=await yv();l({maxMessages:N.maxMessages,summarizeAfter:N.summarizeAfter,summarizeEnabled:N.summarizeEnabled});for(const D of N.suggestedFacts||[])x(D,["generated"])}catch{}_(!1)},[l,x]),O=n.tokenBudget+a.tokenBudget+s.tokenBudget,K=N=>N>=1e3?`${(N/1e3).toFixed(0)}K`:`${N}`,V=[];a.enabled&&V.push("long-term"),s.enabled&&V.push("scratchpad");const P=i.length>0?`${i.length} facts${V.length?" · "+V.join(" · "):""}`:V.length?V.join(" · "):"session only";return c.jsxs(Oi,{icon:Di,label:"Memory",color:"#e74c3c",badge:P,collapsed:j,onToggle:()=>T(!j),children:[c.jsxs("div",{className:"flex items-center justify-between mb-2",children:[c.jsx(ja,{children:"Conversation Window"}),c.jsx(ym,{loading:A,onClick:G,label:"Configure"})]}),c.jsx(Xo,{label:"Messages",value:n.windowSize,min:5,max:100,step:5,onChange:N=>l({windowSize:N})}),c.jsx("div",{className:"mt-1.5",children:c.jsx(ti,{checked:n.summarizeEnabled,onChange:N=>l({summarizeEnabled:N}),label:"Summarize older messages",size:"sm"})}),c.jsx(ja,{children:"Seed Facts"}),c.jsxs("div",{className:"flex flex-col gap-1 mb-2",children:[i.map(N=>{const D=xc[N.domain]||"#999";return c.jsxs("div",{className:"flex items-center gap-1.5 text-[13px] py-1 px-2 rounded",style:{background:e.surfaceElevated,color:e.textSecondary},children:[c.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:rf[N.type]||"#999",flexShrink:0}}),c.jsx("span",{className:"flex-1 truncate",style:{fontFamily:"'Geist Sans', sans-serif"},children:N.content}),c.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded",style:{background:`${D}15`,color:D,fontFamily:"'Geist Mono', monospace",border:`1px solid ${D}30`},children:N.domain.replace("_"," ")}),N.tags.length>0&&N.tags.map(U=>c.jsx("span",{className:"text-[12px] px-1 py-0.5 rounded",style:{background:`${rf[N.type]||"#999"}15`,color:rf[N.type]||"#999",fontFamily:"'Geist Mono', monospace"},children:U},U)),c.jsx("button",{type:"button","aria-label":"Remove fact",onClick:()=>b(N.id),className:"border-none bg-transparent cursor-pointer p-2 rounded shrink-0 hover:bg-[#ff000010] min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:c.jsx(Tt,{size:9})})]},N.id)}),i.length===0&&c.jsx("div",{className:"text-[12px] py-2 text-center",style:{color:e.textFaint},children:"Pre-load facts the agent should always know"})]}),c.jsxs("div",{className:"flex gap-1",children:[c.jsx($s,{value:E,onChange:N=>S(N.target.value),onKeyDown:N=>{N.key==="Enter"&&E.trim()&&(x(E.trim(),[],"fact",M),S(""))},placeholder:"Add a seed fact..."}),c.jsxs("select",{value:M,onChange:N=>$(N.target.value),"aria-label":"Fact domain",className:"text-[13px] px-1 rounded border-none cursor-pointer",style:{background:e.surfaceElevated,color:e.textDim,fontFamily:"'Geist Mono', monospace",width:70},children:[c.jsx("option",{value:"shared",children:"shared"}),c.jsx("option",{value:"agent_private",children:"private"}),c.jsx("option",{value:"run_scratchpad",children:"scratch"})]}),c.jsx("button",{type:"button","aria-label":"Add fact",onClick:()=>{E.trim()&&(x(E.trim(),[],"fact",M),S(""))},className:"px-2 border-none rounded cursor-pointer shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",style:{background:e.surfaceElevated,color:e.textDim},children:c.jsx(bt,{size:12})})]}),c.jsxs("button",{type:"button","aria-expanded":F,onClick:()=>B(!F),className:"flex items-center gap-1 mt-3 text-[13px] tracking-wider uppercase cursor-pointer border-none bg-transparent w-full min-h-[44px] motion-reduce:transition-none",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,padding:"0 8px",transition:"color 150ms"},onMouseEnter:N=>{N.currentTarget.style.color="#FE5000"},onMouseLeave:N=>{N.currentTarget.style.color=e.textDim},onFocus:N=>{N.currentTarget.style.color="#FE5000"},onBlur:N=>{N.currentTarget.style.color=e.textDim},children:[F?c.jsx(Ln,{size:10}):c.jsx(Ba,{size:10}),"Advanced memory config"]}),F&&c.jsxs("div",{className:"mt-2 pt-2 flex flex-col gap-1.5",style:{borderTop:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[c.jsx(ja,{children:"Sandbox Isolation"}),c.jsx(Rn,{options:B_,value:v.isolation,onChange:N=>k({isolation:N}),size:"sm"}),c.jsx("div",{className:"flex flex-col gap-1 mt-1",children:c.jsx(ti,{checked:v.allowPromoteToShared,onChange:N=>k({allowPromoteToShared:N}),label:"Allow promote to shared",size:"sm"})}),c.jsx(ja,{children:"Memory Domains"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:[{key:"shared",label:"Shared",color:xc.shared},{key:"agentPrivate",label:"Agent Private",color:xc.agent_private},{key:"runScratchpad",label:"Run Scratchpad",color:xc.run_scratchpad}].map(N=>{const D=v.domains[N.key].enabled;return c.jsx("button",{type:"button","aria-label":`Toggle ${N.label}`,"aria-pressed":D,onClick:()=>w(N.key,!D),className:"text-[13px] px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",background:D?`${N.color}20`:e.isDark?"#1c1c20":"#f0f0f5",color:D?N.color:e.textDim,border:`1px solid ${D?`${N.color}40`:"transparent"}`},children:N.label},N.key)})}),c.jsx(ja,{children:"Session Strategy"}),c.jsx(Rn,{options:z_,value:n.strategy,onChange:N=>l({strategy:N}),size:"sm"}),n.strategy==="summarize_and_recent"&&c.jsx(Xo,{label:"Summarize at",value:n.summarizeAfter,min:5,max:n.windowSize,step:5,onChange:N=>l({summarizeAfter:N})}),c.jsx(Xo,{label:"Token budget",value:n.tokenBudget,min:1e3,max:6e4,step:1e3,onChange:N=>l({tokenBudget:N}),suffix:"K"}),c.jsx(ja,{children:"Long-Term Memory"}),c.jsx(ti,{checked:a.enabled,onChange:N=>d({enabled:N}),label:"Enabled",size:"sm"}),a.enabled&&c.jsxs("div",{className:"flex flex-col gap-2 mt-1",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Rn,{options:R_,value:a.store,onChange:N=>d({store:N}),size:"sm",label:"Store"})}),c.jsx("div",{className:"flex-1",children:c.jsx(Rn,{options:I_,value:a.scope,onChange:N=>d({scope:N}),size:"sm",label:"Scope"})})]}),c.jsx(Rn,{options:O_,value:a.embeddingModel,onChange:N=>d({embeddingModel:N}),size:"sm",label:"Embedding Model"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("div",{className:"flex-1",children:c.jsx(Rn,{options:$_,value:a.recall.strategy,onChange:N=>p({strategy:N}),size:"sm",label:"Recall"})}),c.jsx("div",{className:"flex-1",children:c.jsx(Xo,{label:"K",value:a.recall.k,min:1,max:20,step:1,onChange:N=>p({k:N})})})]}),c.jsx(Xo,{label:"Min score",value:Math.round(a.recall.minScore*100),min:0,max:100,step:5,onChange:N=>p({minScore:N/100})}),c.jsx(Rn,{options:F_,value:a.write.mode,onChange:N=>f({mode:N}),size:"sm",label:"Write Mode"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:L_.map(N=>{const D=a.write.extractTypes.includes(N.value);return c.jsx("button",{type:"button","aria-label":`Toggle ${N.label}`,"aria-pressed":a.write.extractTypes.includes(N.value),onClick:()=>h(N.value),className:"text-[13px] px-3 py-2 rounded-full cursor-pointer border-none min-h-[44px]",style:{fontFamily:"'Geist Mono', monospace",background:D?`${N.color}20`:e.isDark?"#1c1c20":"#f0f0f5",color:D?N.color:e.textDim,border:`1px solid ${D?`${N.color}40`:"transparent"}`},children:N.label},N.value)})}),c.jsx(Xo,{label:"Max entries",value:a.maxEntries,min:100,max:1e4,step:100,onChange:N=>d({maxEntries:N})}),c.jsx(Xo,{label:"Token budget",value:a.tokenBudget,min:1e3,max:3e4,step:1e3,onChange:N=>d({tokenBudget:N}),suffix:"K"})]}),c.jsx(ja,{children:"Working Memory"}),c.jsx(ti,{checked:s.enabled,onChange:N=>g({enabled:N}),label:"Scratchpad",size:"sm"}),s.enabled&&c.jsx(Xo,{label:"Max tokens",value:s.maxTokens,min:500,max:8e3,step:500,onChange:N=>g({maxTokens:N})})]}),(a.enabled||s.enabled)&&O>0&&c.jsxs("div",{className:"mt-3",children:[c.jsx("div",{className:"text-[13px] tracking-[0.1em] uppercase mb-1.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Memory budget"}),c.jsxs("div",{className:"flex gap-0.5 h-1.5 rounded overflow-hidden",children:[c.jsx("div",{style:{width:`${n.tokenBudget/O*100}%`,background:"#3498db",borderRadius:2},title:`Session: ${K(n.tokenBudget)}`}),a.enabled&&c.jsx("div",{style:{width:`${a.tokenBudget/O*100}%`,background:"#2ecc71",borderRadius:2},title:`Long-term: ${K(a.tokenBudget)}`}),s.enabled&&c.jsx("div",{style:{width:`${s.tokenBudget/O*100}%`,background:"#f1c40f",borderRadius:2},title:`Working: ${K(s.tokenBudget)}`})]}),c.jsxs("div",{className:"flex justify-between mt-1",children:[c.jsx("div",{className:"flex gap-2",children:[{label:"Session",color:"#3498db",tokens:n.tokenBudget},...a.enabled?[{label:"Long-term",color:"#2ecc71",tokens:a.tokenBudget}]:[],...s.enabled?[{label:"Working",color:"#f1c40f",tokens:s.tokenBudget}]:[]].map(N=>c.jsxs("span",{className:"flex items-center gap-1 text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:[c.jsx("div",{style:{width:4,height:4,borderRadius:1,background:N.color}}),N.label]},N.label))}),c.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:K(O)})]})]})]})}const H_={instruction:{icon:_i,color:"#9b59b6",label:"Instruction",verb:"Add to persona"},constraint:{icon:nm,color:"#2ecc71",label:"Constraint",verb:"Add constraint"},workflow:{icon:pn,color:"#e67e22",label:"Workflow",verb:"Add step"},knowledge:{icon:Ri,color:"#3498db",label:"Knowledge",verb:"Add source"},mcp:{icon:na,color:"#2ecc71",label:"MCP Server",verb:"Add server"},skill:{icon:pn,color:"#f1c40f",label:"Skill",verb:"Add skill"}};function U_(){const e=we(),n=We(A=>A.facts),a=We(A=>A.removeFact),s=re(A=>A.updateInstruction),i=re(A=>A.instructionState),l=re(A=>A.addWorkflowStep),d=re(A=>A.addChannel),p=Ra(A=>A.checkpoint),[f,h]=z.useState(!0),[g,x]=z.useState(!1),[b,v]=z.useState(null),[k,w]=z.useState(new Set),[j,T]=z.useState(""),E=z.useCallback(async()=>{if(n.length!==0){x(!0),T(""),w(new Set);try{const A=await C_(n);v(A),f&&h(!1)}catch(A){T(A instanceof Error?A.message:"Analysis failed")}x(!1)}},[n,f]),S=z.useCallback(A=>{const _=A.payload;switch(A.target){case"instruction":if(_.instructionAppend){const F=i.persona;s({persona:F?`${F}
|
|
331
|
+
|
|
332
|
+
${_.instructionAppend}`:_.instructionAppend})}break;case"constraint":if(_.constraintText){const F=i.constraints.customConstraints;s({constraints:{...i.constraints,customConstraints:F?`${F}
|
|
333
|
+
${_.constraintText}`:_.constraintText}})}break;case"workflow":_.workflowStep&&l({label:_.workflowStep.label,action:_.workflowStep.action,tool:"",condition:"always",conditionText:""});break;case"knowledge":_.knowledgeSource&&d({sourceId:`promoted-${crypto.randomUUID().slice(0,8)}`,name:_.knowledgeSource.name,path:"",category:"file",knowledgeType:_.knowledgeSource.type,depth:0,baseTokens:500});break}w(F=>new Set([...F,A.factId])),a(A.factId)},[i,s,l,d,a]),M=z.useCallback(()=>{if(b){for(const A of b.promotions)k.has(A.factId)||S(A);p("Facts promoted to agent design")}},[b,k,S,p]);if(n.length===0&&!b)return null;const $=b?b.promotions.filter(A=>!k.has(A.factId)).length:0;return c.jsxs(Oi,{icon:Uc,label:"Insights",color:"#FE5000",badge:b?`${$} suggestion${$!==1?"s":""}`:`${n.length} facts to analyze`,collapsed:f,onToggle:()=>h(!f),children:[!b&&c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:e.textDim},children:"Analyze your accumulated facts and discover which ones should become permanent parts of your agent — instructions, constraints, workflow steps, or knowledge sources."}),c.jsxs("button",{type:"button",onClick:E,disabled:g||n.length===0,className:"flex items-center justify-center gap-1.5 w-full px-3 py-2.5 rounded text-[13px] tracking-wide uppercase cursor-pointer border-none",style:{background:g?"#CC4000":"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:g||n.length===0?.6:1},children:[g?c.jsx(pt,{size:11,className:"animate-spin motion-reduce:animate-none"}):c.jsx(Uc,{size:11}),g?"Analyzing...":`Analyze ${n.length} fact${n.length!==1?"s":""}`]})]}),j&&c.jsx("div",{role:"alert",className:"text-[12px] px-2 py-1.5 rounded mt-1",style:{background:"#ff000012",color:"#ff4444",border:"1px solid #ff000020"},children:j}),b&&c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("div",{className:"text-[12px] leading-relaxed px-2 py-1.5 rounded",style:{background:"#FE500008",color:e.textSecondary,border:"1px solid #FE500015"},children:[b.summary,b.versionImpact!=="none"&&c.jsxs("span",{className:"text-[12px] ml-1.5 px-1.5 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",background:b.versionImpact==="major"?"#e74c3c20":b.versionImpact==="minor"?"#f1c40f20":"#2ecc7120",color:b.versionImpact==="major"?"#e74c3c":b.versionImpact==="minor"?"#f1c40f":"#2ecc71"},children:[b.versionImpact," bump"]})]}),b.promotions.map(A=>{const _=H_[A.target],F=k.has(A.factId);if(!_)return null;const B=_.icon;return c.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${F?"#2ecc7130":e.border}`,opacity:F?.5:1,transition:"opacity 300ms"},children:[c.jsxs("div",{className:"px-3 py-2 text-[13px]",style:{background:e.surfaceElevated,color:e.textSecondary},children:['"',A.factContent,'"']}),c.jsxs("div",{className:"px-3 py-2 flex items-start gap-2",style:{borderTop:`1px solid ${e.isDark?"#1e1e22":"#eee"}`},children:[c.jsx("div",{className:"mt-0.5",style:{width:16,height:16,borderRadius:4,background:`${_.color}15`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:c.jsx(B,{size:9,style:{color:_.color}})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded-full",style:{fontFamily:"'Geist Mono', monospace",background:`${_.color}15`,color:_.color},children:_.label}),c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:[Math.round(A.confidence*100),"%"]})]}),c.jsx("div",{className:"text-[12px] leading-snug",style:{color:e.textPrimary},children:A.suggestion}),c.jsx("div",{className:"text-[13px] mt-0.5",style:{color:e.textDim},children:A.reason})]}),F?c.jsxs("div",{className:"flex items-center gap-1 text-[13px] px-2 py-1 shrink-0",style:{color:"#2ecc71"},children:[c.jsx(jt,{size:9})," Applied"]}):c.jsxs("button",{type:"button","aria-label":_.verb,onClick:()=>S(A),className:"flex items-center gap-1 text-[13px] px-2 py-1 rounded cursor-pointer border-none shrink-0",style:{background:`${_.color}15`,color:_.color,fontFamily:"'Geist Mono', monospace"},children:[c.jsx(Mx,{size:9}),_.verb]})]})]},A.factId)}),$>0&&c.jsxs("div",{className:"flex gap-2 mt-1",children:[c.jsxs("button",{type:"button",onClick:M,className:"flex items-center justify-center gap-1.5 flex-1 px-3 py-2 rounded text-[12px] tracking-wide uppercase cursor-pointer border-none",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace"},children:[c.jsx(Mx,{size:10})," Apply all (",$,")"]}),c.jsxs("button",{type:"button",onClick:()=>{v(null),w(new Set)},className:"flex items-center gap-1 px-3 py-2 rounded text-[12px] cursor-pointer",style:{background:"transparent",border:`1px solid ${e.border}`,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:[c.jsx(am,{size:9})," Re-analyze"]})]}),$===0&&b.promotions.length>0&&c.jsxs("div",{className:"flex items-center justify-center gap-1.5 py-2 text-[12px]",style:{color:"#2ecc71"},children:[c.jsx(jt,{size:11})," All suggestions applied",c.jsx("button",{type:"button",onClick:()=>{v(null),w(new Set)},className:"ml-2 text-[13px] cursor-pointer border-none bg-transparent underline",style:{color:e.textDim},children:"Re-analyze"})]}),b.promotions.length===0&&c.jsx("div",{className:"text-[12px] text-center py-2",style:{color:e.textDim},children:"All facts are contextual — no promotions suggested"})]})]})}function G_(){const e=we(),{collectContextState:n,restoreContextState:a}=re(),[s,i]=z.useState(""),[l,d]=z.useState(!1),[p,f]=z.useState(!1),[h,g]=z.useState([]);z.useEffect(()=>{const w=[];for(let j=0;j<localStorage.length;j++){const T=localStorage.key(j);T&&T.startsWith("modular-ctx-")&&w.push(T.replace("modular-ctx-",""))}g(w)},[]);const x=()=>{a({channels:[],mcpServers:[],skills:[],connectors:[]})},b=()=>{if(!s.trim())return;const w=n();localStorage.setItem(`modular-ctx-${s}`,JSON.stringify(w)),i(""),d(!1),g(j=>[...new Set([...j,s])])},v=w=>{const j=localStorage.getItem(`modular-ctx-${w}`);j&&a(JSON.parse(j)),f(!1)},k=()=>{window.confirm("Clear all context (channels, MCPs, skills, connectors)?")&&a({channels:[],mcpServers:[],skills:[],connectors:[]})};return c.jsxs("div",{className:"sticky top-0 z-10 px-5 py-2.5 border-b flex items-center gap-2",style:{background:e.surfaceElevated,borderColor:e.border},children:[c.jsx("span",{className:"text-[13px] uppercase tracking-wider font-semibold flex-shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,minWidth:55},children:"Context"}),c.jsx("button",{type:"button","aria-label":"Demo",onClick:x,className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:c.jsx(uu,{size:10})}),c.jsx("button",{type:"button","aria-label":"Save",onClick:()=>d(!0),className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:c.jsx(sm,{size:10})}),c.jsxs("div",{className:"relative",children:[c.jsx("button",{type:"button","aria-label":"Load",onClick:()=>f(!p),className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#FE5000"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#FE5000"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:c.jsx(om,{size:10})}),p&&h.length>0&&c.jsx("div",{className:"absolute top-full mt-1 left-0 rounded shadow-lg z-20 min-w-max",style:{background:e.surfaceElevated,border:`1px solid ${e.border}`},children:h.map(w=>c.jsx("button",{type:"button",onClick:()=>v(w),className:"block w-full text-left px-3 py-1.5 text-[12px] border-none cursor-pointer",style:{background:"transparent",color:e.textSecondary},onMouseEnter:j=>{j.currentTarget.style.background="#FE500010"},onFocus:j=>{j.currentTarget.style.background="#FE500010"},onBlur:j=>{j.currentTarget.style.background="transparent"},children:w},w))})]}),c.jsx("button",{type:"button","aria-label":"Clear",onClick:k,className:"p-1.5 rounded border-none cursor-pointer transition-colors",style:{background:"transparent",color:e.textDim},onMouseEnter:w=>{w.currentTarget.style.color="#ff4444"},onMouseLeave:w=>{w.currentTarget.style.color=e.textDim},onFocus:w=>{w.currentTarget.style.color="#ff4444"},onBlur:w=>{w.currentTarget.style.color=e.textDim},children:c.jsx(du,{size:10})}),l&&c.jsxs("div",{className:"absolute top-12 left-5 rounded shadow-lg p-2 z-20 min-w-max",style:{background:e.surfaceElevated,border:`1px solid ${e.border}`},children:[c.jsx("input",{type:"text",value:s,onChange:w=>i(w.target.value),placeholder:"Context name...",autoFocus:!0,className:"px-2 py-1 rounded text-[12px] outline-none mb-1 block",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary},onKeyDown:w=>{w.key==="Enter"&&b()}}),c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{type:"button",onClick:b,className:"flex-1 px-2 py-1 rounded text-[13px] font-semibold border-none cursor-pointer",style:{background:"#FE5000",color:"#fff"},children:"Save"}),c.jsx("button",{type:"button",onClick:()=>{i(""),d(!1)},className:"flex-1 px-2 py-1 rounded text-[13px] border-none cursor-pointer",style:{background:e.border,color:e.textDim},children:"Cancel"})]})]})]})}function q_(){return c.jsxs("div",{className:"flex flex-col",children:[c.jsx(G_,{}),c.jsx(N_,{}),c.jsx(A_,{}),c.jsx(__,{}),c.jsx(D_,{}),c.jsx(P_,{}),c.jsx(U_,{})]})}const Rv=[{id:"bot",icon:_i},{id:"brain",icon:Di},{id:"zap",icon:pn},{id:"flame",icon:Q1},{id:"lightbulb",icon:Uc},{id:"target",icon:uu},{id:"rocket",icon:t4},{id:"shield",icon:im},{id:"microscope",icon:O3},{id:"chart",icon:tm},{id:"palette",icon:rv},{id:"file",icon:Ws},{id:"drama",icon:ON},{id:"star",icon:y4},{id:"gem",icon:ZN},{id:"bird",icon:eN},{id:"bug",icon:rN},{id:"cat",icon:lN},{id:"dog",icon:DN},{id:"heart",icon:l3}];function K_({avatarId:e,size:n=20}){const a=Rv.find(s=>s.id===e)?.icon??_i;return c.jsx(a,{size:n})}function Y_({open:e,onClose:n,onSave:a,onDelete:s,initial:i="",title:l}){const d=we(),[p,f]=z.useState(i),h=z.useRef(null);z.useEffect(()=>{f(i)},[i,e]),z.useEffect(()=>{e&&h.current&&h.current.focus()},[e]);const g=v=>{v.key==="Escape"&&n()},x=v=>{v.target===v.currentTarget&&n()},b=()=>{a(p),n()};return e?c.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:x,children:c.jsxs("div",{style:{background:d.surfaceOpaque,border:`1px solid ${d.border}`,borderRadius:"12px",width:480,maxHeight:"80vh",overflow:"auto",display:"flex",flexDirection:"column"},onClick:v=>v.stopPropagation(),onKeyDown:g,children:[c.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:`1px solid ${d.border}`},children:[c.jsx("span",{style:{color:d.textPrimary,fontSize:17,fontWeight:600},children:l}),c.jsx("button",{type:"button",onClick:n,className:"border-none bg-transparent cursor-pointer p-1 rounded flex items-center justify-center min-w-[44px] min-h-[44px]",style:{color:d.textDim},"aria-label":"Close",children:c.jsx(Tt,{size:16})})]}),c.jsx("div",{className:"px-6 py-4 flex flex-col gap-3 flex-1",children:c.jsx(Aa,{ref:h,value:p,onChange:v=>f(v.target.value),onKeyDown:g,placeholder:"Enter text...",style:{minHeight:80}})}),c.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:`1px solid ${d.border}`},children:[s?c.jsx("button",{type:"button",onClick:s,className:"text-[16px] px-4 py-2 rounded cursor-pointer border-none",style:{color:"#e74c3c",background:"transparent",border:"1px solid #e74c3c30"},children:"Delete"}):c.jsx("div",{}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"button",onClick:n,className:"text-[16px] px-4 py-2 rounded cursor-pointer border-none",style:{color:d.textPrimary,background:"transparent",border:`1px solid ${d.border}`},children:"Cancel"}),c.jsx("button",{type:"button",onClick:b,className:"text-[16px] px-5 py-2 rounded cursor-pointer border-none",style:{background:"#FE5000",color:"white"},children:"Save"})]})]})]})}):null}function V_({open:e,onClose:n}){const a=we(),s=re(j=>j.workflowSteps),i=re(j=>j.addWorkflowStep),l=re(j=>j.updateWorkflowStep),d=re(j=>j.removeWorkflowStep),p=re(j=>j.updateWorkflowSteps),f=j=>{j.key==="Escape"&&n()},h=j=>{j.target===j.currentTarget&&n()},g=()=>{i({label:"",action:"action",tool:"",condition:"always"})},[x,b]=z.useState(!1),[v,k]=z.useState(""),w=z.useCallback(async()=>{b(!0),k("");try{const j=s.filter(T=>T.label.trim()).map(T=>T.label.trim());if(j.length>0){const{refineWorkflowSteps:T}=await ta(async()=>{const{refineWorkflowSteps:S}=await Promise.resolve().then(()=>G4);return{refineWorkflowSteps:S}},void 0),E=await T(j);E&&p(E)}else{const T=await um();T&&p(T)}}catch(j){k(j instanceof Error?j.message:"Generation failed")}b(!1)},[p,s]);return e?c.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:h,children:c.jsxs("div",{style:{background:a.surfaceOpaque,border:`1px solid ${a.border}`,borderRadius:"12px",width:640,maxHeight:"85vh",overflow:"auto",display:"flex",flexDirection:"column"},onClick:j=>j.stopPropagation(),onKeyDown:f,children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,paddingLeft:20,paddingRight:20,paddingTop:16,paddingBottom:16,borderBottom:`1px solid ${a.border}`},children:[c.jsx("div",{style:{width:4,height:18,borderRadius:2,background:"#e67e22",opacity:.8}}),c.jsx("span",{style:{color:a.textPrimary,fontSize:17,fontWeight:600,flex:1},children:"Workflow Editor"}),c.jsxs("span",{style:{color:a.textMuted,fontSize:13,fontFamily:"'Geist Mono', monospace"},children:[s.length," ",s.length===1?"step":"steps"]}),c.jsx("button",{type:"button",onClick:n,className:"border-none bg-transparent cursor-pointer p-1 rounded flex items-center justify-center min-w-[44px] min-h-[44px]",style:{color:a.textDim},"aria-label":"Close",children:c.jsx(Tt,{size:16})})]}),c.jsx("div",{style:{padding:24,flex:1,overflowY:"auto"},children:s.length===0?c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:200},children:c.jsx("span",{style:{color:a.textMuted,fontSize:16},children:'No workflow steps yet. Click "Add Step" to begin.'})}):c.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((j,T)=>c.jsxs("div",{children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,paddingTop:12,paddingBottom:12},children:[c.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#e67e22",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:c.jsx("span",{style:{color:"white",fontSize:13,fontWeight:600,fontFamily:"'Geist Mono', monospace"},children:T+1})}),c.jsx("div",{style:{flex:1},children:c.jsx("input",{type:"text",value:j.label,onChange:E=>l(j.id,{label:E.target.value}),placeholder:"Step label",className:"w-full px-3 py-2 rounded-md outline-none nodrag",style:{background:a.inputBg,border:`1px solid ${a.border}`,color:a.textPrimary,fontFamily:"'Geist Sans', sans-serif",fontSize:14,lineHeight:1.5}})}),c.jsx("span",{style:{fontSize:13,fontFamily:"'Geist Mono', monospace",fontWeight:600,paddingLeft:8,paddingRight:8,paddingTop:3,paddingBottom:3,borderRadius:4,background:"#e67e2220",color:"#e67e22",textTransform:"uppercase",flexShrink:0},children:j.action||"action"}),c.jsx("button",{type:"button",onClick:()=>d(j.id),className:"border-none bg-transparent cursor-pointer p-1 flex items-center justify-center",style:{color:a.textDim,minWidth:32,minHeight:32},children:c.jsx(Tt,{size:12})})]}),T<s.length-1&&c.jsx("div",{style:{width:2,height:12,background:"#e67e2220",marginLeft:12}})]},j.id))})}),v&&c.jsx("div",{style:{padding:"0 24px 12px"},children:c.jsx("div",{className:"text-[13px] px-3 py-2 rounded",style:{background:"#ff000012",color:"#e74c3c",border:"1px solid #e74c3c20"},children:v})}),c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:20,paddingRight:20,paddingTop:16,paddingBottom:16,borderTop:`1px solid ${a.border}`},children:[c.jsxs("button",{type:"button",onClick:g,className:"flex items-center gap-1 text-[14px] px-3 py-2 rounded cursor-pointer border-none",style:{color:a.textPrimary,background:"transparent",border:`1px solid ${a.border}`},children:[c.jsx(bt,{size:11}),"Add Step"]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[c.jsxs("button",{type:"button",onClick:w,disabled:x,className:"flex items-center gap-1 text-[14px] px-3 py-2 rounded cursor-pointer border-none",style:{color:a.textPrimary,background:"transparent",border:`1px solid ${a.border}`,opacity:x?.6:1},children:[x?c.jsx(pt,{size:11,style:{animation:"spin 1s linear infinite"}}):c.jsx(Pa,{size:11}),"Generate"]}),c.jsxs("button",{type:"button",onClick:n,className:"flex items-center gap-1 text-[14px] px-5 py-2 rounded cursor-pointer border-none",style:{background:"#FE5000",color:"white"},children:[c.jsx(jt,{size:11}),"Done"]})]})]})]})}):null}const W_=`You are an expert prompt engineer. Your job is to take a user's rough brain dump about an AI agent they want to build, and transform it into structured, high-quality agent instructions following Anthropic's prompting best practices.
|
|
334
|
+
|
|
335
|
+
Given the user's rough input, produce a JSON response with this exact structure:
|
|
336
|
+
{
|
|
337
|
+
"persona": "<2-4 sentence persona description. Be specific about expertise, domain, and communication style. Use 'You are...' framing>",
|
|
338
|
+
"tone": "<one of: formal, neutral, casual>",
|
|
339
|
+
"expertise": <1-5 number, where 1=beginner-friendly and 5=expert-level>,
|
|
340
|
+
"constraints": [
|
|
341
|
+
"<clear, actionable constraint in imperative voice>"
|
|
342
|
+
],
|
|
343
|
+
"scopeDefinition": "<one sentence: what the agent handles and what it does NOT handle>",
|
|
344
|
+
"objectives": {
|
|
345
|
+
"primary": "<one clear sentence describing the agent's primary goal>",
|
|
346
|
+
"successCriteria": ["<measurable criterion>"],
|
|
347
|
+
"failureModes": ["<specific failure to avoid>"]
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
Follow these rules:
|
|
352
|
+
1. Be specific — replace vague descriptions with concrete, actionable language
|
|
353
|
+
2. Use XML-tag-friendly language (the output will be assembled into a system prompt)
|
|
354
|
+
3. Infer reasonable constraints from the domain (e.g., a medical agent should cite sources)
|
|
355
|
+
4. Generate 2-4 success criteria and 2-3 failure modes based on the domain
|
|
356
|
+
5. Keep the persona concise but distinctive — give it a clear identity
|
|
357
|
+
6. If the input mentions tools, APIs, or specific capabilities, reference them in constraints
|
|
358
|
+
7. Think step by step about what makes an excellent agent for this use case before writing
|
|
359
|
+
|
|
360
|
+
Output ONLY the JSON object. No markdown fences, no explanation.`;async function X_(e,n){if(!n.trim())throw new Error("Nothing to refine");const a=Je.getState(),s=a.providers.find(g=>g.id===a.selectedProviderId);if(!s)throw new Error("No provider configured — add one in Settings");const i=typeof s.models?.[0]=="object"?s.models[0].id:s.models?.[0]||"claude-sonnet-4-20250514",l=W_,p=s.authMethod==="claude-agent-sdk"?await Vc({prompt:n,model:i,systemPrompt:l,maxTurns:1}):await Yc({providerId:s.id,model:i,messages:[{role:"system",content:l},{role:"user",content:n}],temperature:.3,maxTokens:1024});try{return JSON.parse(p)}catch{}const f=p.match(/```(?:json)?\s*([\s\S]*?)```/);if(f)try{return JSON.parse(f[1].trim())}catch{}const h=p.match(/\{[\s\S]*\}/);if(h)try{return JSON.parse(h[0])}catch{}throw new Error("Could not parse agent structure from LLM response")}function lf(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}const Ov=z.forwardRef(function({variant:n="secondary",size:a="md",icon:s,iconRight:i,loading:l,children:d,className:p="",style:f,disabled:h,...g},x){const b=we(),v={sm:28,md:32},k={sm:"0 8px",md:"0 14px"},w={sm:12,md:13},T={primary:{bg:"#FE5000",color:"#fff",border:"transparent",hoverBg:"#e54700"},secondary:{bg:b.surfaceElevated,color:b.textSecondary,border:b.border,hoverBg:b.isDark?"#2a2a30":"#eee"},ghost:{bg:"transparent",color:b.textSecondary,border:"transparent",hoverBg:b.isDark?"#ffffff08":"#00000008"},danger:{bg:b.statusErrorBg,color:b.statusError,border:"transparent",hoverBg:b.isDark?"#ff4d4f20":"#ff4d4f15"}}[n];return c.jsxs("button",{ref:x,type:"button",disabled:h||l,className:`ds-btn flex items-center justify-center gap-1.5 rounded-lg cursor-pointer border font-semibold tracking-wide uppercase nodrag ${p}`,style:{height:v[a],padding:k[a],fontSize:w[a],fontFamily:"'Geist Mono', monospace",background:T.bg,color:T.color,borderColor:T.border,opacity:h?.5:1,cursor:h?"not-allowed":"pointer",transition:"background 0.15s, opacity 0.15s",...f},onMouseEnter:E=>{h||(E.currentTarget.style.background=T.hoverBg)},onMouseLeave:E=>{E.currentTarget.style.background=T.bg},...g,children:[l?c.jsx("span",{className:"animate-spin text-[12px]",children:"⟳"}):s,d,i]})});function Z_({variant:e="neutral",children:n,dot:a,size:s="sm"}){const i=we(),d={success:{bg:i.statusSuccessBg,fg:i.statusSuccess},warning:{bg:i.statusWarningBg,fg:i.statusWarning},error:{bg:i.statusErrorBg,fg:i.statusError},info:{bg:"#3498db15",fg:"#3498db"},neutral:{bg:i.badgeBg,fg:i.textSecondary}}[e],p=s==="sm"?8:9,f=s==="sm"?"1px 6px":"2px 8px";return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full font-semibold uppercase tracking-wider",style:{background:d.bg,color:d.fg,fontSize:p,padding:f,fontFamily:"'Geist Mono', monospace"},children:[a&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:d.fg}}),n]})}function Q_({open:e,onClose:n,title:a,children:s,footer:i,width:l=520}){const d=we(),p=z.useRef(null);return z.useEffect(()=>{if(!e)return;const f=h=>{h.key==="Escape"&&n()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[e,n]),z.useEffect(()=>{e&&p.current?.focus()},[e]),e?ou.createPortal(c.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center",onClick:n,children:[c.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)"}}),c.jsxs("div",{ref:p,tabIndex:-1,onClick:f=>f.stopPropagation(),className:"relative flex flex-col rounded-xl overflow-hidden outline-none",style:{width:l,maxWidth:"90vw",maxHeight:"80vh",background:d.surfaceOpaque,border:`1px solid ${d.border}`,boxShadow:`0 16px 48px ${d.isDark?"rgba(0,0,0,0.6)":"rgba(0,0,0,0.15)"}`},children:[a&&c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 shrink-0",style:{borderBottom:`1px solid ${d.borderSubtle}`},children:[c.jsx("span",{className:"text-[17px] font-bold",style:{fontFamily:"'Geist Mono', monospace",color:d.textPrimary},children:a}),c.jsx("button",{type:"button",onClick:n,className:"flex items-center justify-center w-7 h-7 rounded-md cursor-pointer border-none bg-transparent",style:{color:d.textDim},children:c.jsx(Tt,{size:14})})]}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:s}),i&&c.jsx("div",{className:"flex items-center justify-end gap-2 px-4 py-3 shrink-0",style:{borderTop:`1px solid ${d.borderSubtle}`},children:i})]})]}),document.body):null}const J_=z.forwardRef(function({icon:n,size:a="md",variant:s="ghost",tooltip:i,active:l,className:d="",style:p,...f},h){const g=we(),x=a==="sm"?24:32,v={ghost:{bg:l?"#FE500020":"transparent",color:l?"#FE5000":g.textDim,hoverBg:g.isDark?"#ffffff10":"#00000008"},secondary:{bg:g.surfaceElevated,color:g.textSecondary,hoverBg:g.isDark?"#2a2a30":"#eee"},danger:{bg:"transparent",color:g.statusError,hoverBg:g.statusErrorBg}}[s];return c.jsx("button",{ref:h,type:"button",title:i,"aria-label":i,className:`ds-icon-btn flex items-center justify-center rounded-md cursor-pointer border-none nodrag ${d}`,style:{width:x,height:x,background:v.bg,color:v.color,transition:"background 0.15s",...p},onMouseEnter:k=>k.currentTarget.style.background=v.hoverBg,onMouseLeave:k=>k.currentTarget.style.background=v.bg,...f,children:n})});function e6({type:e}){const n={major:"#FE5000",minor:"#3498db",patch:"#888"};return c.jsx(xN,{size:6,fill:n[e],stroke:"none"})}function t6({v:e,isCurrent:n,onRestore:a,onDelete:s}){const i=we(),[l,d]=z.useState(!1);return c.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${n?"#FE500040":i.borderSubtle}`,background:n?"#FE500008":"transparent"},children:[c.jsxs("button",{type:"button",onClick:()=>d(!l),className:"w-full min-h-[36px] flex items-center gap-2 px-3 py-2 cursor-pointer border-none bg-transparent text-left",children:[c.jsx(Ba,{size:10,style:{color:i.textDim,transform:l?"rotate(90deg)":"none",transition:"transform 0.15s"}}),c.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[c.jsxs("span",{className:"text-[14px] font-bold shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:n?"#FE5000":i.textPrimary},children:["v",e.version]}),c.jsx("span",{className:"text-[12px] truncate",style:{color:i.textMuted},children:e.label||"Checkpoint"})]}),n&&c.jsx(Z_,{variant:"success",size:"sm",dot:!0,children:"CURRENT"}),c.jsx("span",{className:"text-[13px] shrink-0",style:{color:i.textFaint},children:new Date(e.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),l&&c.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e.changes.length===0&&c.jsx("div",{className:"text-[12px]",style:{color:i.textMuted},children:"No changelog entries recorded for this version."}),e.changes.map((p,f)=>c.jsxs("div",{className:"flex items-center gap-2 text-[12px]",style:{color:i.textSecondary},children:[c.jsx(e6,{type:p.type}),c.jsx("span",{className:"uppercase text-[12px] font-semibold w-14 shrink-0",style:{color:i.textDim},children:p.category}),c.jsx("span",{children:p.description})]},f)),c.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[!n&&c.jsx(Ov,{variant:"secondary",size:"sm",icon:c.jsx(am,{size:10}),onClick:a,children:"Restore"}),c.jsx(J_,{icon:c.jsx(du,{size:11}),variant:"danger",size:"sm",tooltip:"Delete version",onClick:s})]})]})]})}function n6(){const e=we(),{versions:n,currentVersion:a,dirty:s,checkpoint:i}=Ra(),[l,d]=z.useState(!1);return c.jsxs(c.Fragment,{children:[c.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex items-center gap-1.5 px-2 h-8 rounded-lg cursor-pointer border-none",style:{background:s?"#FE500015":"transparent",color:s?"#FE5000":e.textDim,fontFamily:"'Geist Mono', monospace",fontSize:12,fontWeight:600,transition:"background 0.15s"},title:"Version history",children:[c.jsx(La,{size:12}),"v",a,s&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#FE5000] animate-pulse"})]}),c.jsx(Q_,{open:l,onClose:()=>d(!1),title:"Version History",width:480,footer:c.jsx(Ov,{variant:"primary",size:"sm",icon:c.jsx(sm,{size:10}),onClick:()=>{i()},children:"Save Checkpoint"}),children:c.jsxs("div",{className:"flex flex-col gap-1.5 p-3 max-h-[60vh] overflow-y-auto overscroll-contain pr-1",children:[n.length===0&&c.jsxs("div",{className:"py-8 text-center",children:[c.jsx(La,{size:20,style:{margin:"0 auto 8px",color:e.textFaint,opacity:.3}}),c.jsx("div",{className:"text-[12px]",style:{color:e.textFaint},children:"No versions yet"}),c.jsx("div",{className:"text-[12px] mt-1",style:{color:e.textMuted},children:"Make changes to your agent — versions are created automatically"})]}),[...n].reverse().map(p=>c.jsx(t6,{v:p,isCurrent:p.version===a,onRestore:()=>{Ra.getState().restoreVersion(p.version),d(!1)},onDelete:()=>Ra.getState().deleteVersion(p.id)},p.id))]})})]})}function o6({value:e,onChange:n,t:a}){return c.jsx("select",{value:e,onChange:s=>n(s.target.value),className:"appearance-none cursor-pointer outline-none text-[14px] h-8 pl-3 pr-7 rounded-lg",style:{fontFamily:"'Geist Sans', sans-serif",background:a.surfaceOpaque,border:`1px solid ${a.border}`,color:a.isDark?a.textSecondary:"#1a1a20",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath d='M0 2l4 4 4-4' fill='none' stroke='%23${a.isDark?"555":"999"}' stroke-width='1.5'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center"},children:sb.map(s=>c.jsx("option",{value:s.id,children:s.label},s.id))})}function a6(){const e=we(),n=re(N=>N.agentMeta),a=re(N=>N.setAgentMeta),s=re(N=>N.outputFormat),i=re(N=>N.setOutputFormat),l=re(N=>N.loadAgent),d=re(N=>N.resetAgent),p=re(N=>N.channels),f=re(N=>N.selectedModel),h=re(N=>N.outputFormats),g=re(N=>N.prompt),x=re(N=>N.tokenBudget),b=re(N=>N.mcpServers),v=re(N=>N.skills),[k,w]=z.useState([]),[j,T]=z.useState(!1),[E,S]=z.useState(!1),[M,$]=z.useState(""),[A,_]=z.useState(!1),[F,B]=z.useState(!1),G=z.useRef(null);z.useEffect(()=>()=>{G.current&&window.clearTimeout(G.current)},[]);const O=z.useCallback(async()=>{try{const N=await fetch(`${Ae}/agents`);if(!N.ok)return;const D=await N.json();w(D.data??[])}catch{}},[]),K=()=>{const N=re.getState(),D=WA({channels:p,selectedModel:f,outputFormat:s,outputFormats:h,prompt:g,tokenBudget:x,mcpServers:b,skills:v,agentMeta:n,agentConfig:N.agentConfig,connectors:N.connectors,instructionState:N.instructionState,workflowSteps:N.workflowSteps}),U=D.match(/^name:\s*(.+)$/m)?.[1]?.trim()??"modular-agent";gu(D,U)},V=z.useCallback(()=>{B(!0),G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{B(!1)},2e3)},[]),P=z.useCallback(async N=>{const D=(N??n.name).trim();if(!D){$(n.name),S(!0);return}D!==n.name&&a({name:D}),_(!0);try{const U=pm(D),q=fm();if(q.id=U,q.agentMeta={...q.agentMeta,name:D},!(await fetch(`${Ae}/agents/${encodeURIComponent(U)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(q)})).ok)return;S(!1),V()}catch{}finally{_(!1)}},[n.name,a,V]);return c.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 shrink-0 border-b select-none",style:{position:"sticky",top:0,zIndex:10,background:e.surface,borderColor:e.border},children:[c.jsx("span",{className:"text-[14px] font-bold tracking-[0.12em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary,minWidth:"100px"},children:n.name||"New Agent"}),c.jsx(n6,{}),c.jsx(o6,{value:s,onChange:N=>i(N),t:e}),c.jsx("div",{className:"flex-1"}),c.jsxs("button",{type:"button",onClick:()=>d(),className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background="#FE500025"},onMouseLeave:N=>{N.currentTarget.style.background="#FE500012"},title:"Create new agent",children:[c.jsx(bt,{size:13}),"New"]}),c.jsxs("div",{className:"relative",children:[c.jsxs("button",{type:"button",onClick:()=>{T(!j),j||O()},className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background="#FE500025"},onMouseLeave:N=>{N.currentTarget.style.background="#FE500012"},title:"Load saved agent",children:[c.jsx(om,{size:13}),"Load"]}),j&&c.jsx("div",{className:"absolute top-full right-0 mt-1 z-50 min-w-[260px] max-h-[300px] overflow-y-auto rounded-lg shadow-lg",style:{background:e.surface,border:`1px solid ${e.border}`},children:k.length===0?c.jsx("div",{className:"px-3 py-4 text-[14px] text-center",style:{color:e.textDim},children:"No saved agents found"}):k.map(N=>c.jsxs("button",{type:"button",onClick:()=>{l(N.id),T(!1)},className:"w-full text-left px-3 py-2 border-none cursor-pointer block",style:{background:"transparent",color:e.textPrimary},onMouseEnter:D=>{D.currentTarget.style.background=e.surfaceHover},onMouseLeave:D=>{D.currentTarget.style.background="transparent"},children:[c.jsx("div",{className:"text-[14px] font-medium",children:N.agentMeta?.name||N.id}),N.agentMeta?.description&&c.jsx("div",{className:"text-[12px] mt-0.5",style:{color:e.textDim},children:N.agentMeta.description.length>80?N.agentMeta.description.slice(0,80)+"…":N.agentMeta.description})]},N.id))})]}),c.jsxs("button",{type:"button",onClick:()=>{P()},className:"flex items-center justify-center h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:F?"#2ecc7115":"#FE500012",color:F?"#2ecc71":"#FE5000",transition:"background 0.15s",opacity:A?.6:1},onMouseEnter:N=>{F||(N.currentTarget.style.background="#FE500025")},onMouseLeave:N=>{F||(N.currentTarget.style.background="#FE500012")},title:F?"Agent saved":"Save agent",disabled:A,children:[F?c.jsx(jt,{size:13}):c.jsx(sm,{size:13}),"Save"]}),c.jsxs("label",{className:"cursor-pointer",children:[c.jsx("input",{type:"file",accept:".agent.yaml,.agent.yml,.yaml,.yml",style:{display:"none"},onChange:N=>{const D=N.target.files?.[0];if(D){const U=new FileReader;U.onload=()=>{try{console.log("Agent import functionality not implemented yet")}catch(q){console.error("Failed to import agent:",q)}},U.readAsText(D)}}}),c.jsxs("button",{type:"button",className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background="#FE500025"},onMouseLeave:N=>{N.currentTarget.style.background="#FE500012"},title:"Import agent definition",children:[c.jsx(fv,{size:13}),"Import"]})]}),c.jsxs("button",{type:"button",onClick:K,className:"flex items-center justify-center gap-1.5 h-8 px-2.5 rounded-lg text-[14px] font-medium cursor-pointer border-none",style:{background:"#FE500012",color:"#FE5000",transition:"background 0.15s"},onMouseEnter:N=>{N.currentTarget.style.background="#FE500025"},onMouseLeave:N=>{N.currentTarget.style.background="#FE500012"},title:"Export agent definition",children:[c.jsx(lu,{size:13}),"Export"]}),E&&c.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2 rounded-lg",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`},children:[c.jsx("input",{type:"text",value:M,onChange:N=>$(N.target.value),onKeyDown:N=>{N.key==="Enter"&&P(M),N.key==="Escape"&&S(!1)},className:"w-44 h-6 px-2 text-[14px] rounded-md outline-none",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textPrimary},placeholder:"Agent name required",autoFocus:!0}),c.jsx("button",{type:"button",onClick:()=>{P(M)},className:"flex items-center justify-center w-6 h-6 rounded-md border-none cursor-pointer",style:{background:"#FE5000",color:"#fff"},children:c.jsx(jt,{size:12})}),c.jsx("button",{type:"button",onClick:()=>S(!1),className:"flex items-center justify-center w-6 h-6 rounded-md border-none cursor-pointer",style:{background:"transparent",color:e.textDim},children:c.jsx(Tt,{size:12})})]})]})}function Xr({label:e,color:n,collapsed:a,onToggle:s,right:i,t:l}){return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"14px 20px",userSelect:"none",borderTop:`1px solid ${l.isDark?"#222226":"#e8e8ec"}`,background:`${n}08`},children:[c.jsxs("button",{type:"button",onClick:s,"aria-expanded":!a,style:{display:"flex",alignItems:"center",gap:10,flex:1,cursor:"pointer",border:"none",background:"transparent",padding:0,textAlign:"left"},children:[a?c.jsx(Ba,{size:12,style:{color:l.textDim}}):c.jsx(Ln,{size:12,style:{color:l.textDim}}),c.jsx("div",{style:{width:3,height:14,borderRadius:2,background:n,opacity:.8}}),c.jsx("span",{style:{fontSize:12,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Geist Mono', monospace",color:l.textPrimary},children:e})]}),i]})}function cf({loading:e,onClick:n}){return c.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),n()},disabled:e,style:{display:"flex",alignItems:"center",gap:4,fontSize:13,padding:"4px 8px",borderRadius:4,cursor:"pointer",border:"none",background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:[e?c.jsx(pt,{size:9,style:{animation:"spin 1s linear infinite"}}):c.jsx(Pa,{size:9}),"Generate"]})}function s6(){const e=we(),n=re(J=>J.agentMeta),a=re(J=>J.setAgentMeta),s=re(J=>J.instructionState),i=re(J=>J.updateInstruction),l=re(J=>J.workflowSteps),d=re(J=>J.channels),p=re(J=>J.mcpServers),f=re(J=>J.skills),h=re(J=>J.tokenBudget),[g,x]=z.useState(!0),[b,v]=z.useState(!0),[k,w]=z.useState(!1),[j,T]=z.useState(!1),[E,S]=z.useState(!1),[M,$]=z.useState(!1),[A,_]=z.useState(!1),[F,B]=z.useState(null),[G,O]=z.useState(!1),[K,V]=z.useState(null),[P,N]=z.useState(!1),{persona:D,tone:U,expertise:q,constraints:W,objectives:oe,rawPrompt:I,autoSync:L}=s,Z=J=>{if(K){if(K.mode==="constraint")if(K.index!==void 0){const ye=W.customConstraints.split(`
|
|
361
|
+
`).filter(Boolean);ye[K.index]=J,i({constraints:{...W,customConstraints:ye.join(`
|
|
362
|
+
`)}})}else{const ye=W.customConstraints?W.customConstraints+`
|
|
363
|
+
`+J:J;i({constraints:{...W,customConstraints:ye}})}else if(K.mode==="criteria")if(K.index!==void 0){const ye=[...oe.successCriteria];ye[K.index]=J,i({objectives:{...oe,successCriteria:ye}})}else i({objectives:{...oe,successCriteria:[...oe.successCriteria,J]}});O(!1),V(null)}},ae=()=>{if(!(!K||K.index===void 0)){if(K.mode==="constraint"){const J=W.customConstraints.split(`
|
|
364
|
+
`).filter(Boolean);J.splice(K.index,1),i({constraints:{...W,customConstraints:J.join(`
|
|
365
|
+
`)}})}else if(K.mode==="criteria"){const J=oe.successCriteria.filter((ye,Ee)=>Ee!==K.index);i({objectives:{...oe,successCriteria:J}})}O(!1),V(null)}},pe=J=>{a({tags:J.split(",").map(ye=>ye.trim()).filter(Boolean)})},me=z.useCallback(async()=>{B("all");try{const J=await X_("full",D);if(typeof J=="object"&&J!==null){const ye=J;ye.persona&&i({persona:ye.persona}),ye.constraints&&i({constraints:{...W,customConstraints:ye.constraints.join(`
|
|
366
|
+
`)}}),ye.objectives&&i({objectives:{...oe,primary:ye.objectives.primary||oe.primary}})}}catch{}B(null)},[D,d,p,f,W,oe,i]),he={identity:!!(n.name&&n.description),persona:D.length>20,constraints:W.neverMakeUp||W.customConstraints.length>0,workflow:l.length>0},H=Object.values(he).filter(Boolean).length,ce=d.reduce((J,ye)=>J+(ye.effectiveTokens??ye.baseTokens??0),0),Q=Math.ceil(D.length/4)+Math.ceil(W.customConstraints.length/4),ge=l.reduce((J,ye)=>J+Math.ceil(ye.label.length/4),0),xe=ce+Q+ge;return c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:20},children:[c.jsx(a6,{}),c.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:`0 2px 12px ${e.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[c.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{borderBottom:`1px solid ${e.border}`,background:e.surfaceElevated},children:[c.jsx(_i,{size:14,style:{color:"#FE5000"}}),c.jsx(Si,{content:"Build your agent step by step",children:c.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Agent"})}),c.jsx("div",{className:"flex-1"}),c.jsxs("div",{className:"flex items-center gap-1",children:[Object.entries(he).map(([J,ye])=>c.jsx("div",{title:J,style:{width:6,height:6,borderRadius:"50%",background:ye?"#FE5000":e.borderSubtle,transition:"background 200ms"}},J)),c.jsxs("span",{className:"text-[13px] ml-1",style:{color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:[H,"/4"]})]})]}),c.jsx(Xr,{label:"Identity",color:"#FE5000",collapsed:!g,onToggle:()=>x(!g),t:e}),g&&c.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("div",{className:"relative",children:[c.jsx("button",{type:"button","aria-label":"Choose avatar",onClick:()=>$(!M),className:"w-11 h-11 rounded-lg cursor-pointer flex items-center justify-center",style:{background:e.surfaceElevated,border:`1.5px solid ${e.border}`,color:"#FE5000"},children:c.jsx(K_,{avatarId:n.avatar,size:20})}),M&&c.jsx("div",{className:"absolute top-13 left-0 z-50 grid grid-cols-5 gap-0.5 p-2 rounded-lg",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:"0 8px 24px rgba(0,0,0,0.2)",width:185},children:Rv.map(J=>{const ye=J.icon;return c.jsx("button",{type:"button",title:J.id,onClick:()=>{a({avatar:J.id}),$(!1)},className:"w-8 h-8 rounded cursor-pointer flex items-center justify-center border-none",style:{background:n.avatar===J.id?"#FE500020":"transparent",color:n.avatar===J.id?"#FE5000":e.textSecondary},children:c.jsx(ye,{size:15})},J.id)})})]}),c.jsx("div",{className:"flex-1",children:A?c.jsx($s,{value:n.name,onChange:J=>a({name:J.target.value}),onBlur:()=>_(!1),onKeyDown:J=>J.key==="Enter"&&_(!1),autoFocus:!0,style:{fontSize:19,padding:"6px 10px"}}):c.jsx("button",{type:"button",onClick:()=>_(!0),className:"text-left font-semibold cursor-pointer border-none bg-transparent p-0 w-full",style:{color:n.name?e.textPrimary:e.textMuted,fontSize:19,fontFamily:"'Geist Sans', sans-serif"},children:n.name||"Click to name your agent"})})]}),c.jsx(Aa,{label:"Description",value:n.description,onChange:J=>a({description:J.target.value}),placeholder:"One-line summary of what this agent does...",style:{minHeight:40}}),c.jsx($s,{label:"Tags",value:n.tags.join(", "),onChange:J=>pe(J.target.value),placeholder:"pm, analysis, competitor"})]}),c.jsx(Xr,{label:"Persona",color:"#9b59b6",collapsed:!b,onToggle:()=>v(!b),t:e,right:c.jsx(cf,{loading:F==="all",onClick:me})}),b&&c.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[c.jsx(Aa,{label:"Who is this agent?",value:D,onChange:J=>i({persona:J.target.value}),placeholder:"Describe the agent's role, expertise, and personality...",style:{minHeight:64}}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Tone"}),c.jsx("div",{className:"flex rounded-md overflow-hidden",style:{border:`1px solid ${e.border}`},children:["formal","neutral","casual"].map(J=>c.jsx("button",{type:"button",onClick:()=>i({tone:J}),className:"flex-1 text-center text-[13px] py-1.5 cursor-pointer border-none",style:{background:U===J?"#FE5000":"transparent",color:U===J?"#fff":e.textDim,transition:"all 150ms"},children:J.charAt(0).toUpperCase()+J.slice(1)},J))})]}),c.jsxs("div",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Expertise"}),c.jsx("div",{className:"flex rounded-md overflow-hidden",style:{border:`1px solid ${e.border}`},children:[{l:"Junior",v:1},{l:"Mid",v:3},{l:"Senior",v:5}].map(J=>c.jsx("button",{type:"button",onClick:()=>i({expertise:J.v}),className:"flex-1 text-center text-[13px] py-1.5 cursor-pointer border-none",style:{background:q===J.v?"#FE5000":"transparent",color:q===J.v?"#fff":e.textDim,transition:"all 150ms"},children:J.l},J.v))})]})]})]}),c.jsx(Xr,{label:"Constraints",color:"#2ecc71",collapsed:!k,onToggle:()=>w(!k),t:e,right:c.jsx(cf,{loading:F==="constraints",onClick:()=>{}})}),k&&c.jsxs("div",{className:"px-5 py-4 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Safety"}),c.jsx("div",{className:"flex gap-1",children:[{id:"autonomous",label:"Autonomous",desc:"No guardrails",apply:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1}},{id:"balanced",label:"Balanced",desc:"Cite sources, stay in scope",apply:{neverMakeUp:!0,askBeforeActions:!1,stayInScope:!0,useOnlyTools:!1,limitWords:!1}},{id:"careful",label:"Careful",desc:"All guardrails on",apply:{neverMakeUp:!0,askBeforeActions:!0,stayInScope:!0,useOnlyTools:!0,limitWords:!1}}].map(J=>{const ye=J.id==="careful"?W.neverMakeUp&&W.askBeforeActions&&W.stayInScope&&W.useOnlyTools:J.id==="balanced"?W.neverMakeUp&&W.stayInScope&&!W.askBeforeActions&&!W.useOnlyTools:!W.neverMakeUp&&!W.askBeforeActions&&!W.stayInScope&&!W.useOnlyTools;return c.jsx(Si,{content:J.desc,children:c.jsx("button",{type:"button",onClick:()=>i({constraints:{...W,...J.apply}}),className:"text-[13px] px-3 py-1.5 rounded-md cursor-pointer border-none font-medium",style:{background:ye?"#2ecc7120":"transparent",color:ye?"#2ecc71":e.textDim,border:`1px solid ${ye?"#2ecc7140":e.border}`,fontFamily:"'Geist Mono', monospace",transition:"all 0.15s"},children:J.label})},J.id)})})]}),c.jsxs("div",{children:[c.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold block mb-1.5",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Custom Rules"}),W.customConstraints.split(`
|
|
367
|
+
`).filter(Boolean).map((J,ye)=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-1.5",style:{background:e.isDark?"#2e1a0a":"#fdf5ee",border:`1px solid ${e.isDark?"#e67e2230":"#e67e2240"}`},children:[c.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#e67e22",flexShrink:0}}),c.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:J}),c.jsx("button",{type:"button",onClick:()=>{V({mode:"constraint",index:ye,title:"Edit Custom Rule",initial:J}),O(!0)},className:"border-none bg-transparent cursor-pointer p-1 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textDim},"aria-label":"Edit rule",children:c.jsx(Ex,{size:11})})]},ye)),c.jsxs("button",{type:"button",onClick:()=>{V({mode:"constraint",title:"Add Custom Rule"}),O(!0)},className:"flex items-center gap-1 text-[12px] cursor-pointer border-none bg-transparent mt-1.5",style:{color:e.textDim},children:[c.jsx(bt,{size:10})," Add rule"]})]})]}),c.jsx(Xr,{label:"Objectives",color:"#e74c3c",collapsed:!j,onToggle:()=>T(!j),t:e,right:c.jsx(cf,{loading:F==="objectives",onClick:()=>{}})}),j&&c.jsxs("div",{className:"px-5 py-4 flex flex-col gap-4",children:[c.jsx(Aa,{label:"Primary Objective",value:oe.primary,onChange:J=>i({objectives:{...oe,primary:J.target.value}}),placeholder:"What is this agent's main goal?",style:{minHeight:40}}),c.jsxs("div",{children:[c.jsx("span",{className:"text-[13px] tracking-wider uppercase font-semibold block mb-1.5",style:{color:e.textMuted,fontFamily:"'Geist Mono', monospace"},children:"Success Criteria"}),oe.successCriteria.map((J,ye)=>c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-1.5",style:{background:e.isDark?"#1a2e1a":"#f0faf0",border:`1px solid ${e.isDark?"#2ecc7130":"#2ecc7140"}`},children:[c.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#2ecc71",flexShrink:0}}),c.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary,lineHeight:1.4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:J}),c.jsx("button",{type:"button",onClick:()=>{V({mode:"criteria",index:ye,title:"Edit Success Criterion",initial:J}),O(!0)},className:"border-none bg-transparent cursor-pointer p-1 rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textDim},"aria-label":"Edit criterion",children:c.jsx(Ex,{size:11})})]},ye)),c.jsxs("button",{type:"button",onClick:()=>{V({mode:"criteria",title:"Add Success Criterion"}),O(!0)},className:"flex items-center gap-1 text-[12px] cursor-pointer border-none bg-transparent mt-1.5",style:{color:e.textDim},children:[c.jsx(bt,{size:10})," Add criterion"]})]})]}),c.jsx(Xr,{label:"System Prompt",color:"#555",collapsed:!E,onToggle:()=>S(!E),t:e,right:c.jsxs("div",{className:"flex items-center gap-1.5",onClick:J=>J.stopPropagation(),children:[c.jsx(ti,{checked:L,onChange:J=>i({autoSync:J}),label:""}),c.jsx("span",{className:"text-[13px]",style:{color:e.textDim},children:"Auto"})]})}),E&&c.jsx("div",{className:"px-5 py-4",children:c.jsx(Aa,{value:I,onChange:J=>i({rawPrompt:J.target.value}),placeholder:"System prompt will be auto-generated from sections above, or type manually...",style:{minHeight:120,fontFamily:"'Geist Mono', monospace",fontSize:13}})})]}),c.jsx(Y_,{open:G,onClose:()=>{O(!1),V(null)},onSave:Z,onDelete:K?.index!==void 0?ae:void 0,initial:K?.initial,title:K?.title||""}),c.jsx(V_,{open:P,onClose:()=>N(!1)}),c.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,boxShadow:`0 2px 12px ${e.isDark?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.06)"}`},children:[c.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5 select-none",style:{background:e.surfaceElevated},children:[c.jsx("div",{style:{width:3,height:14,borderRadius:2,background:"#e67e22",opacity:.8}}),c.jsx("span",{className:"text-[13px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Workflow"}),c.jsxs("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:[l.length," steps"]})]}),c.jsx("div",{className:"px-5 py-4 flex flex-col items-center",children:l.length===0?c.jsxs("button",{type:"button",onClick:()=>N(!0),className:"flex items-center justify-center gap-1.5 text-[13px] px-4 py-2.5 rounded-lg cursor-pointer border-none",style:{background:"#e67e2215",color:"#e67e22",fontFamily:"'Geist Mono', monospace",fontWeight:600},children:[c.jsx(bt,{size:12})," Define workflow steps"]}):c.jsxs(c.Fragment,{children:[l.map((J,ye)=>c.jsxs("div",{className:"w-full",children:[c.jsxs("div",{className:"flex items-center gap-3 py-2",children:[c.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:e.surfaceElevated,border:"1.5px solid #e67e2230",display:"flex",alignItems:"center",justifyContent:"center"},children:c.jsx("span",{style:{fontFamily:"'Geist Mono', monospace",fontSize:13,fontWeight:700,color:"#e67e22"},children:ye+1})}),c.jsx("span",{style:{flex:1,fontSize:14,color:e.textPrimary},children:J.label||"Unnamed step"}),c.jsx("span",{className:"text-[12px] px-2 py-0.5 rounded",style:{background:e.badgeBg,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:J.action||"action"})]}),ye<l.length-1&&c.jsx("div",{style:{width:2,height:12,background:"#e67e2220",marginLeft:11}})]},J.id)),c.jsx("button",{type:"button",onClick:()=>N(!0),className:"text-[12px] px-3 py-2 mt-3 rounded cursor-pointer border-none",style:{background:e.border,color:e.textDim},children:"Edit workflow"})]})})]}),c.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:e.surfaceOpaque,border:`1px solid ${e.border}`,padding:"16px 20px"},children:[c.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[c.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Context Budget"}),c.jsxs("span",{className:"text-[13px] font-semibold",style:{fontFamily:"'Geist Mono', monospace",color:"#FE5000"},children:[lf(xe)," / ",lf(h)]})]}),c.jsx("div",{style:{height:8,background:e.isDark?"#25252a":"#dddde2",borderRadius:4,overflow:"hidden"},children:c.jsx("div",{style:{width:`${Math.min(xe/h*100,100)}%`,height:"100%",borderRadius:4,background:"linear-gradient(90deg, #FE5000, #ff8c55)",transition:"width 500ms"}})}),c.jsx("div",{className:"flex gap-3 mt-2.5",children:[{label:"Knowledge",tokens:ce,color:"#3498db"},{label:"Instructions",tokens:Q,color:"#9b59b6"},{label:"Workflow",tokens:ge,color:"#e67e22"}].map(J=>c.jsxs("span",{className:"flex items-center gap-1 text-[12px]",style:{color:e.textDim},children:[c.jsx("span",{style:{width:8,height:8,borderRadius:2,background:J.color}}),J.label," ",lf(J.tokens)]},J.label))})]})]})}const po=qt((e,n)=>({panelOpen:!1,panelHeight:40,activeTab:"chat",messages:[],inputText:"",streaming:!1,lastPipelineStats:null,testCases:[],runningTests:!1,setPanelOpen:a=>e({panelOpen:a}),setPanelHeight:a=>e({panelHeight:Math.max(20,Math.min(80,a))}),setActiveTab:a=>e({activeTab:a}),setInputText:a=>e({inputText:a}),addMessage:a=>e({messages:[...n().messages,{...a,id:`msg-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestamp:Date.now()}]}),updateLastAssistant:a=>{const s=[...n().messages];for(let i=s.length-1;i>=0;i--)if(s[i].role==="assistant"){s[i]={...s[i],content:a};break}e({messages:s})},clearMessages:()=>e({messages:[],lastPipelineStats:null}),setStreaming:a=>e({streaming:a}),setLastPipelineStats:a=>e({lastPipelineStats:a}),addTestCase:a=>e({testCases:[...n().testCases,{...a,id:`test-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}]}),updateTestCase:(a,s)=>e({testCases:n().testCases.map(i=>i.id===a?{...i,...s}:i)}),removeTestCase:a=>e({testCases:n().testCases.filter(s=>s.id!==a)}),setRunningTests:a=>e({runningTests:a}),saveCurrentAsTest:(a,s)=>{const l=[...n().messages].reverse().find(d=>d.role==="user");l&&n().addTestCase({name:a,input:l.content,expectedBehavior:s,passed:null})}}));function Tc(e){return e?e.includes(`
|
|
368
|
+
`)?`|
|
|
369
|
+
${e.split(`
|
|
370
|
+
`).map(n=>" "+n).join(`
|
|
371
|
+
`)}`:/[:#"'{}\[\],&*?|>!%@`]/.test(e)?`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:e:'""'}function Vx(e,n=0){const a=" ".repeat(n);return e.map(s=>`${a}- ${Tc(s)}`).join(`
|
|
372
|
+
`)}function r6(e){const n=e.agentMeta,a=e.agentConfig,s=[];return s.push(`name: ${Tc(n.name||"Untitled Agent")}`),n.description&&s.push(`description: ${Tc(n.description)}`),s.push('version: "1.0.0"'),n.tags?.length&&s.push(`tags:
|
|
373
|
+
${Vx(n.tags)}`),n.avatar&&s.push(`avatar: ${n.avatar}`),n.icon&&s.push(`icon: ${n.icon}`),s.push(""),s.push("# Runtime"),s.push(`model: ${Tc(e.selectedModel)}`),a?.temperature!==void 0&&s.push(`temperature: ${a.temperature}`),a?.planningMode&&s.push(`planning: ${a.planningMode}`),s.push(`token_budget: ${e.tokenBudget}`),s.push(""),s.push("# Output"),s.push(`output_format: ${e.outputFormat}`),e.outputFormats.length>1&&s.push(`output_formats:
|
|
374
|
+
${Vx(e.outputFormats)}`),s.join(`
|
|
375
|
+
`)+`
|
|
376
|
+
`}function i6(e){const n=e.instructionState,a=e.agentMeta,s=[];if(s.push(`# ${a.name||"Agent"}`),s.push(""),a.description&&(s.push(a.description),s.push("")),n?.persona&&(s.push("## Persona"),s.push(""),s.push(n.persona),s.push("")),n?.tone&&n.tone!=="neutral"&&(s.push(`**Tone:** ${n.tone}`),s.push("")),n?.expertise&&n.expertise!==3){const i=["Beginner","Novice","Intermediate","Advanced","Expert"];s.push(`**Expertise:** ${i[n.expertise-1]} (${n.expertise}/5)`),s.push("")}return s.join(`
|
|
377
|
+
`)}function l6(e){const n=e.instructionState,a=["# Instructions",""];n?.objectives?.primary&&(a.push("## Objective"),a.push(""),a.push(n.objectives.primary),a.push(""),n.objectives.successCriteria.length>0&&(a.push("### Success Criteria"),a.push(""),n.objectives.successCriteria.forEach(i=>a.push(`- ${i}`)),a.push("")),n.objectives.failureModes.length>0&&(a.push("### Failure Modes to Avoid"),a.push(""),n.objectives.failureModes.forEach(i=>a.push(`- ${i}`)),a.push("")));const s=[];if(n?.constraints){const i=n.constraints;i.neverMakeUp&&s.push("Never fabricate information or make up facts"),i.askBeforeActions&&s.push("Ask for permission before taking significant actions"),i.stayInScope&&s.push(`Stay within scope${i.scopeDefinition?": "+i.scopeDefinition:""}`),i.useOnlyTools&&s.push("Only use tools and capabilities that are explicitly provided"),i.limitWords&&s.push(`Keep responses under ${i.wordLimit} words`),i.customConstraints&&i.customConstraints.split(`
|
|
378
|
+
`).filter(Boolean).forEach(l=>s.push(l.trim()))}return s.length>0&&(a.push("## Constraints"),a.push(""),s.forEach(i=>a.push(`- ${i}`)),a.push("")),e.workflowSteps&&e.workflowSteps.length>0&&(a.push("## Workflow"),a.push(""),e.workflowSteps.forEach((i,l)=>{a.push(`${l+1}. **${i.label}** — ${i.action}`)}),a.push("")),e.prompt&&!n?.persona&&!n?.objectives?.primary&&(a.push("## Additional Instructions"),a.push(""),a.push(e.prompt),a.push("")),a.join(`
|
|
379
|
+
`)}function c6(e){const n=["# Tools",""],a=e.mcpServers.filter(i=>i.enabled&&i.added),s=e.skills.filter(i=>i.enabled&&i.added);return a.length>0&&(n.push("## MCP Servers"),n.push(""),a.forEach(i=>{n.push(`### ${i.name}`),n.push(""),i.description&&n.push(i.description),n.push(""),n.push("```yaml"),n.push(`id: ${i.id}`),n.push("transport: stdio"),n.push("command: npx"),n.push(`args: ["@${i.id}/mcp"]`),n.push("```"),n.push("")})),s.length>0&&(n.push("## Skills"),n.push(""),s.forEach(i=>{n.push(`- **${i.name}**${i.description?" — "+i.description:""}`)}),n.push("")),a.length===0&&s.length===0&&(n.push("No tools configured."),n.push("")),n.join(`
|
|
380
|
+
`)}function u6(e){const n=["# Knowledge",""],a=e.channels.filter(i=>i.enabled),s=(e.connectors??[]).filter(i=>i.enabled);return a.length>0&&(n.push("## Sources"),n.push(""),a.forEach(i=>{const l=i.knowledgeType||"signal";n.push(`### ${i.name||i.path}`),n.push(""),n.push(`- **Path:** \`${i.path}\``),n.push(`- **Type:** ${l}`),i.content&&n.push(`- **Content Preview:** ${i.content.slice(0,100)}${i.content.length>100?"...":""}`),i.hint&&n.push(`- **Hint:** ${i.hint}`),n.push("")})),s.length>0&&(n.push("## Connectors"),n.push(""),s.forEach(i=>{n.push(`- **${i.name}** (${i.service}) — ${i.direction}${i.hint?", scope: "+i.hint:""}`)}),n.push("")),n.push("## Budget"),n.push(""),n.push(`Token budget: ${e.tokenBudget}`),n.push(""),n.join(`
|
|
381
|
+
`)}function d6(e){return["# Memory","","<!-- Initial memory for this agent. Add seed context, key facts, or preferences here. -->",""].join(`
|
|
382
|
+
`)}function $v(e){return{"agent.yaml":r6(e),"SOUL.md":i6(e),"INSTRUCTIONS.md":l6(e),"TOOLS.md":c6(e),"KNOWLEDGE.md":u6(e),"MEMORY.md":d6()}}async function p6(e){const n=$v(e),a=(e.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");try{const s=(await ta(async()=>{const{default:h}=await import("./jszip.min-BlpRodxc.js").then(g=>g.j);return{default:h}},[])).default,i=new s,l=i.folder(a);for(const[h,g]of Object.entries(n))l.file(h,g);const d=await i.generateAsync({type:"blob"}),p=URL.createObjectURL(d),f=document.createElement("a");f.href=p,f.download=`${a}.zip`,f.click(),URL.revokeObjectURL(p)}catch{for(const[s,i]of Object.entries(n)){const l=new Blob([i],{type:"text/plain"}),d=URL.createObjectURL(l),p=document.createElement("a");p.href=d,p.download=s,p.click(),URL.revokeObjectURL(d)}}}function Fv(e){const n={};return e["agent.yaml"]&&(n.agentYaml=Iv(e["agent.yaml"])),e["SOUL.md"]&&(n.soul=e["SOUL.md"]),e["INSTRUCTIONS.md"]&&(n.instructions=e["INSTRUCTIONS.md"]),e["TOOLS.md"]&&(n.tools=e["TOOLS.md"]),e["KNOWLEDGE.md"]&&(n.knowledge=e["KNOWLEDGE.md"]),e["MEMORY.md"]&&(n.memory=e["MEMORY.md"]),n}function Iv(e){const n={};let a=null,s="";for(const i of e.split(`
|
|
383
|
+
`)){const l=i.trim();if(!l||l.startsWith("#"))continue;if(l.startsWith("- ")&&a!==null){a.push(l.slice(2).replace(/^["']|["']$/g,"")),n[s]=a;continue}a=null;const d=l.indexOf(":");if(d===-1)continue;const p=l.slice(0,d).trim();if(p==="__proto__"||p==="constructor"||p==="prototype")continue;const f=l.slice(d+1).trim();if(!f){s=p,a=[];continue}const h=f.replace(/^["']|["']$/g,"");h==="true"?n[p]=!0:h==="false"?n[p]=!1:/^\d+(\.\d+)?$/.test(h)?n[p]=Number(h):n[p]=h}return n}function Lv(e){const n={};if(e.agentYaml){const a=e.agentYaml;n.agentMeta={name:a.name||"",description:a.description||"",avatar:a.avatar||"",icon:a.icon||"",category:a.category||"general",tags:Array.isArray(a.tags)?a.tags:[]},a.model&&(n.selectedModel=a.model),a.token_budget&&(n.tokenBudget=a.token_budget),a.output_format&&(n.outputFormat=a.output_format),n.agentConfig={temperature:a.temperature??.7,planningMode:a.planning??"single-shot",model:a.model??""}}if(e.soul||e.instructions){const a={persona:"",tone:"neutral",expertise:3,constraints:{neverMakeUp:!1,askBeforeActions:!1,stayInScope:!1,useOnlyTools:!1,limitWords:!1,wordLimit:500,customConstraints:"",scopeDefinition:""},objectives:{primary:"",successCriteria:[],failureModes:[]},rawPrompt:"",autoSync:!1};if(e.soul){const s=e.soul.split(`
|
|
384
|
+
`);let i="",l="";for(const d of s){const p=d.trim();p.startsWith("## ")?(i==="persona"&&l.trim()&&(a.persona=l.trim()),i=p.toLowerCase().includes("persona")?"persona":"",l=""):!p.startsWith("#")&&p&&(i||!a.persona)&&(l+=d+`
|
|
385
|
+
`,!a.persona&&!i&&(a.persona=l.trim()))}i==="persona"&&l.trim()&&(a.persona=l.trim())}if(e.instructions){const s=e.instructions.split(`
|
|
386
|
+
`);let i="",l=!1,d=[];for(const p of s){const f=p.trim();if(f.startsWith("## ")){i==="successCriteria"&&d.length>0?a.objectives.successCriteria=d:i==="failureModes"&&d.length>0&&(a.objectives.failureModes=d);const h=f.toLowerCase();h.includes("objective")?i="objective":h.includes("constraint")&&(i="constraints"),l=!1,d=[]}else if(f.startsWith("### ")){const h=f.toLowerCase();h.includes("success")?(i="successCriteria",l=!0,d=[]):h.includes("failure")&&(i="failureModes",l=!0,d=[])}else if(f.startsWith("- ")){if(l)d.push(f.substring(2));else if(i==="constraints"){const h=f.substring(2);if((h.toLowerCase().includes("never fabricate")||h.toLowerCase().includes("never make up"))&&(a.constraints.neverMakeUp=!0),h.toLowerCase().includes("ask")&&h.toLowerCase().includes("permission")&&(a.constraints.askBeforeActions=!0),h.toLowerCase().includes("scope")&&(a.constraints.stayInScope=!0),h.toLowerCase().includes("only use tools")&&(a.constraints.useOnlyTools=!0),h.toLowerCase().includes("word")&&/\d+/.test(h)){a.constraints.limitWords=!0;const g=h.match(/(\d+)/);g&&(a.constraints.wordLimit=parseInt(g[1]))}}}else i==="objective"&&f&&!f.startsWith("#")&&(a.objectives.primary||(a.objectives.primary=f))}i==="successCriteria"&&d.length>0?a.objectives.successCriteria=d:i==="failureModes"&&d.length>0&&(a.objectives.failureModes=d)}n.instructionState=a}return n}async function Bv(e){try{const n=(await ta(async()=>{const{default:b}=await import("./jszip.min-BlpRodxc.js").then(v=>v.j);return{default:b}},[])).default,a=new n,s=10*1024*1024;if(e.size>s)throw new Error(`ZIP file too large (${(e.size/1024/1024).toFixed(1)}MB). Maximum is 10MB.`);const i=await a.loadAsync(e),l=2*1024*1024,d={},p=["agent.yaml","SOUL.md","INSTRUCTIONS.md","TOOLS.md","KNOWLEDGE.md","MEMORY.md"];for(const[b,v]of Object.entries(i.files)){if(v.dir)continue;const k=b.split("/").pop()||"";if(p.includes(k))try{const w=await v.async("text");if(w.length>l){console.warn(`Skipping ${k}: exceeds 2MB limit`);continue}d[k]=w}catch(w){console.warn(`Failed to read ${k}:`,w)}}if(!d["agent.yaml"])throw new Error("agent.yaml is required but not found in the ZIP file");const f=Fv(d),h=Lv(f),{useConsoleStore:g}=await ta(async()=>{const{useConsoleStore:b}=await Promise.resolve().then(()=>Cv);return{useConsoleStore:b}},void 0);g.getState().restoreFullState(h)}catch(n){throw console.error("Import failed:",n),n instanceof Error?n:new Error("Unknown import error")}}const f6=Object.freeze(Object.defineProperty({__proto__:null,agentDirectoryToState:Lv,downloadAgentDirectory:p6,exportAgentDirectory:$v,importAgentFromZip:Bv,parseAgentDirectory:Fv,parseSimpleYaml:Iv},Symbol.toStringTag,{value:"Module"}));function Wx(){return`${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function m6(e){let n=0,a=0,s=0,i=0,l=0;const d=e.map(f=>f.timestamp),p=d.length>=2?Math.max(...d)-Math.min(...d):0;for(const f of e)f.kind==="llm_call"&&(n+=(f.inputTokens||0)+(f.outputTokens||0),a+=f.costUsd||0),f.kind==="tool_call"&&(s++,f.toolError&&i++),f.kind==="retrieval"&&l++;return{totalTokens:n,totalCostUsd:a,toolCalls:s,toolErrors:i,retrievals:l,durationMs:p}}const fn=qt((e,n)=>({traces:[],activeTraceId:null,maxTraces:50,startTrace:(a,s)=>{const i=`trace-${Wx()}`,l={id:i,conversationId:a,agentVersion:s,startedAt:Date.now(),events:[]};return e(d=>({traces:[...d.traces,l].slice(-d.maxTraces),activeTraceId:i})),i},addEvent:(a,s)=>e(i=>({traces:i.traces.map(l=>l.id===a?{...l,events:[...l.events,{...s,id:Wx(),timestamp:Date.now()}]}:l)})),endTrace:a=>e(s=>({traces:s.traces.map(i=>i.id===a?{...i,summary:m6(i.events)}:i),activeTraceId:s.activeTraceId===a?null:s.activeTraceId})),getTrace:a=>n().traces.find(s=>s.id===a),getActiveTrace:()=>{const a=n().activeTraceId;return a?n().traces.find(s=>s.id===a):void 0},clearTraces:()=>e({traces:[],activeTraceId:null})}));function h6(e){const n=e.toLowerCase();return["what is","where is","how does","who is","when did","which","define","explain"].some(i=>n.includes(i))||/["'`].+["'`]/.test(e)||/[A-Z][a-z]+[A-Z]/.test(e)||/[A-Z_]{3,}/.test(e)?"specific":["summarize","summary","overview","what happened","recap","yesterday","last week","last month","today","recently","so far","progress","status update"].some(i=>n.includes(i))?"summary":"exploratory"}const g6={fact:1,episode:.8,raw:.6};function y6(e,n){if(e.length!==n.length||e.length===0)return 0;let a=0,s=0,i=0;for(let d=0;d<e.length;d++)a+=e[d]*n[d],s+=e[d]*e[d],i+=n[d]*n[d];const l=Math.sqrt(s)*Math.sqrt(i);return l===0?0:a/l}async function x6(e){try{const n=await fetch("/api/knowledge/embed",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:[e]})});return n.ok?(await n.json()).embeddings?.[0]??null:null}catch{return null}}async function Pv(e){const n=Date.now(),a=We.getState(),{longTerm:s,sandbox:i}=a;if(!s.enabled)return{facts:[],contextBlock:"",tokenEstimate:0,durationMs:0};let l=a.getRecallableFacts(e.agentId);i.isolation==="reset_each_run"?l=l.filter(_=>_.domain!=="run_scratchpad"):i.isolation==="clone_from_shared"&&(l=l.filter(_=>_.domain==="shared"));const d=h6(e.userMessage),p={specific:{k:3,granularityBoost:{fact:1.3,episode:.7,raw:.5}},summary:{k:5,granularityBoost:{fact:.8,episode:1.3,raw:.6}},exploratory:{k:8,granularityBoost:{fact:1,episode:1,raw:1}}},{k:f,granularityBoost:h}=p[d],g=l.some(_=>_.embedding&&_.embedding.length>0);let x=null;g&&(x=await x6(e.userMessage));const b=l.map(_=>{let F;x&&_.embedding&&_.embedding.length>0?F=y6(x,_.embedding):F=k6(_.content,e.userMessage);const B=g6[_.granularity??"fact"],G=h[_.granularity??"fact"]??1;return{fact:_,score:F*B*G}}),{strategy:v,k,minScore:w}=s.recall,j=Math.min(f,k||f);let T;v==="threshold"?T=b.filter(_=>_.score>=w).sort((_,F)=>F.score-_.score):v==="hybrid"?T=b.filter(_=>_.score>=w).sort((_,F)=>F.score-_.score).slice(0,j):T=b.sort((_,F)=>F.score-_.score).slice(0,j);const E=T.map(_=>_.fact),S=w6(E),M=Math.ceil(S.length/4),$=Date.now()-n;return fn.getState().addEvent(e.traceId,{kind:"memory_recall",sourceName:"memory:pre-recall",memoryFactCount:E.length,memoryFactIds:E.map(_=>_.id),memoryDomain:E.length>0?[...new Set(E.map(_=>_.domain))].join(","):void 0,durationMs:$}),{facts:E,contextBlock:S,tokenEstimate:M,durationMs:$}}function b6(e){const n=Date.now(),a=We.getState(),{longTerm:s,sandbox:i}=a;if(!s.enabled||!e.assistantResponse)return{extracted:[],stored:[],durationMs:0};const{write:l}=s;if(l.mode==="explicit")return{extracted:[],stored:[],durationMs:0};const d=S6(e.assistantResponse,e.userMessage,l.extractTypes),p=j6(i.isolation,e.sandboxRunId),f=[];for(const x of d){if(x.confidence<.5)continue;const b=T6(p,i),k={decisions:"decision",user_preferences:"preference",facts:"fact",feedback:"fact",entities:"entity"}[x.type]||x.type;a.addFact(x.content,[x.type],k,b,"fact",e.agentId);const w=We.getState().facts,j=w[w.length-1];j&&f.push(j)}const h=Date.now()-n;return fn.getState().addEvent(e.traceId,{kind:"memory_write",sourceName:"memory:post-write",memoryFactCount:f.length,memoryFactIds:f.map(x=>x.id),memoryDomain:p,durationMs:h}),{extracted:d,stored:f,durationMs:h}}function v6(){const e=We.getState(),n=e.facts.filter(a=>a.domain==="run_scratchpad").map(a=>a.id);for(const a of n)e.removeFact(a)}function k6(e,n){const a=new Set(e.toLowerCase().split(/\s+/).filter(l=>l.length>2)),s=n.toLowerCase().split(/\s+/).filter(l=>l.length>2);if(s.length===0)return .1;let i=0;for(const l of s)a.has(l)&&i++;return i/s.length}function w6(e){return e.length===0?"":`<memory_recall>
|
|
387
|
+
Relevant facts from memory:
|
|
388
|
+
${e.map(a=>{const s=a.domain!=="shared"?` [${a.domain}]`:"";return`- [${a.type}]${s} ${a.content}`}).join(`
|
|
389
|
+
`)}
|
|
390
|
+
</memory_recall>`}function S6(e,n,a){const s=[],i=e.split(/[.!?\n]+/).map(l=>l.trim()).filter(l=>l.length>10);for(const l of i){const d=l.toLowerCase();a.includes("decisions")&&M6(d)?s.push({content:l,type:"decisions",confidence:.7}):a.includes("user_preferences")&&C6(d,n)?s.push({content:l,type:"user_preferences",confidence:.6}):a.includes("facts")&&E6(d)&&s.push({content:l,type:"facts",confidence:.5})}return s.slice(0,5)}function M6(e){return["decided","will use","chosen","selected","going with","we should","let's go with"].some(a=>e.includes(a))}function C6(e,n){const a=n.toLowerCase();return["prefer","like","want","favorite","always use","rather"].some(i=>a.includes(i)||e.includes(i))}function E6(e){return["is a","are used","works by","consists of","requires","means"].some(a=>e.includes(a))}function j6(e,n){return n||e==="reset_each_run"?"run_scratchpad":e==="clone_from_shared"?"agent_private":"shared"}function T6(e,n){return e==="shared"&&!n.allowPromoteToShared?"agent_private":e}function N6(e){const n=[];if(n.push("<provenance>"),e.sources.length>0)for(const a of e.sources)n.push(` <source path="${a.path}" type="${a.type}" sections="${a.sections}" depth="${a.depth}" />`);if(e.derivations.length>0){n.push(" <derivation>");for(const a of e.derivations)n.push(` <step from="${a.from}" method="${a.method}" to="${a.to}" />`);n.push(" </derivation>")}return n.push("</provenance>"),e.conflictResolution&&(n.push(""),n.push("<context_provenance>"),n.push(e.conflictResolution.instructions),n.push("</context_provenance>")),n.join(`
|
|
391
|
+
`)}function ii(e){const n=re.getState(),{instructionState:a,workflowSteps:s,agentMeta:i}=n,l=[];if(i.name){const f=[`Name: ${i.name}`];i.description&&f.push(`Description: ${i.description}`),i.avatar&&f.push(`Avatar: ${i.avatar}`),i.tags?.length&&f.push(`Tags: ${i.tags.join(", ")}`),l.push(`<identity>
|
|
392
|
+
${f.join(`
|
|
393
|
+
`)}
|
|
394
|
+
</identity>`)}if(a.persona||a.objectives.primary){const f=[];if(a.persona&&f.push(`Persona: ${a.persona}`),a.tone!=="neutral"&&f.push(`Tone: ${a.tone}`),a.expertise!==3){const h=["Beginner","Novice","Intermediate","Advanced","Expert"];f.push(`Expertise Level: ${h[a.expertise-1]} (${a.expertise}/5)`)}a.objectives.primary&&(f.push(`Primary Objective: ${a.objectives.primary}`),a.objectives.successCriteria.length>0&&f.push(`Success Criteria:
|
|
395
|
+
${a.objectives.successCriteria.map(h=>`- ${h}`).join(`
|
|
396
|
+
`)}`),a.objectives.failureModes.length>0&&f.push(`Failure Modes to Avoid:
|
|
397
|
+
${a.objectives.failureModes.map(h=>`- ${h}`).join(`
|
|
398
|
+
`)}`)),l.push(`<instructions>
|
|
399
|
+
${f.join(`
|
|
400
|
+
|
|
401
|
+
`)}
|
|
402
|
+
</instructions>`)}const d=[];if(a.constraints.neverMakeUp&&d.push("Never fabricate information or make up facts"),a.constraints.askBeforeActions&&d.push("Ask for permission before taking significant actions"),a.constraints.stayInScope&&d.push(`Stay within the defined scope: ${a.constraints.scopeDefinition||"as specified"}`),a.constraints.useOnlyTools&&d.push("Only use tools and capabilities that are explicitly provided"),a.constraints.limitWords&&d.push(`Keep responses under ${a.constraints.wordLimit} words`),a.constraints.customConstraints&&d.push(`Additional constraints: ${a.constraints.customConstraints}`),d.length>0&&l.push(`<constraints>
|
|
403
|
+
${d.map(f=>`- ${f}`).join(`
|
|
404
|
+
`)}
|
|
405
|
+
</constraints>`),s.length>0){const f=xv(s);l.push(`<workflow>
|
|
406
|
+
${f}
|
|
407
|
+
</workflow>`)}const p=A6();if(p&&l.push(p),e){const f=N6(e);l.push(f)}return l.join(`
|
|
408
|
+
|
|
409
|
+
`)}function Hv(){return`<knowledge_format>
|
|
410
|
+
The knowledge below is produced by an automated indexing pipeline. Here is how to read it:
|
|
411
|
+
|
|
412
|
+
## Heading Hierarchy = Depth Levels
|
|
413
|
+
- # (H1) = Feature name — top-level grouping
|
|
414
|
+
- ## (H2) = Section: Architecture, Key Files, Data Flow, State Management, Components
|
|
415
|
+
- ### (H3) = Individual file entry with metadata
|
|
416
|
+
|
|
417
|
+
## How to Read a Key File Entry
|
|
418
|
+
Each file under "Key Files" has structured metadata:
|
|
419
|
+
- **Category**: What the file DOES (component=UI, store=state, service=logic, route=endpoint, util=helper, test=tests, config=settings, type=contracts)
|
|
420
|
+
- **Exports**: The public API surface — function/class/constant names this file makes available
|
|
421
|
+
- **Types**: TypeScript interfaces/types defined in this file
|
|
422
|
+
- **Size/Tokens**: File size and estimated token count for budget decisions
|
|
423
|
+
- **Imports**: Direct dependencies of this file
|
|
424
|
+
|
|
425
|
+
## How to Use Data Flow (CRITICAL)
|
|
426
|
+
The "Data Flow" section contains the import graph between files. Each line is:
|
|
427
|
+
source_file → imported_module
|
|
428
|
+
This IS the dependency graph. You do NOT need to open files to trace dependencies.
|
|
429
|
+
Example: if Data Flow shows \`App.tsx → ./providers/AuthProvider\`, you already know App depends on AuthProvider.
|
|
430
|
+
|
|
431
|
+
## Escalation Strategy
|
|
432
|
+
1. **Check the knowledge docs first** — most answers are already here (exports, types, data flow, architecture)
|
|
433
|
+
2. **Use get_file_contents ONLY when you need actual implementation details** — the code itself, not its structure
|
|
434
|
+
3. **Build exact file URLs** using the base URL from orientation + the file path from Key Files
|
|
435
|
+
|
|
436
|
+
## What You Can Answer WITHOUT Reading Files
|
|
437
|
+
- "What does X export?" → Check Exports field
|
|
438
|
+
- "What depends on X?" → Check Data Flow
|
|
439
|
+
- "What state does X manage?" → Check State Management section
|
|
440
|
+
- "What type is X?" → Check Types field
|
|
441
|
+
- "What stack/framework?" → Check Architecture section
|
|
442
|
+
</knowledge_format>`}function A6(){const e=Xe.getState().getConnectedTools(),{skills:n}=re.getState(),a=n.filter(h=>h.enabled),i=re.getState().channels.some(h=>h.enabled&&h.repoMeta);if(e.length===0&&a.length===0)return"";const l=[];if(e.length>0){l.push("## Available MCP Tools");for(const h of e)l.push(`- **${h.name}**: ${h.description||"No description"}`)}if(a.length>0){l.length>0&&l.push(""),l.push("## Available Skills");for(const h of a)l.push(`- **${h.name}**: ${h.description||"No description"}`)}l.push(""),l.push("## Tool Usage Patterns");const d=e.filter(h=>/get_file|read_file|file_content/i.test(h.name));d.length>0&&i&&(l.push("### File Access"),l.push("- **FIRST**: Check your loaded knowledge (Key Files, Data Flow, Exports) — most structural questions are answered there"),l.push("- **THEN**: Use file tools ONLY for actual source code / implementation details"),l.push(`- Tool: \`${d[0].name}\` — pass a single file path, NOT a directory`));const p=e.filter(h=>/search|find|grep|query/i.test(h.name)&&!/search_nodes/i.test(h.name));if(p.length>0){l.push("### Search");for(const h of p)l.push(`- \`${h.name}\`: Use for finding files or symbols not in loaded knowledge`)}return e.filter(h=>/search_nodes|read_graph|knowledge_graph/i.test(h.name)).length>0&&i&&(l.push("### Knowledge Graph (Low Priority)"),l.push("- Your loaded knowledge already contains structure, dependencies, and exports"),l.push("- Do NOT use graph tools to find basic repo structure — it is already in your context"),l.push("- Use graph tools ONLY for cross-repo relationship queries not covered by loaded knowledge")),l.push(""),l.push("## Anti-Patterns (NEVER do these)"),d.length>0&&l.push(`- NEVER pass a directory path to \`${d[0].name}\` — it only accepts single files`),i&&(l.push("- NEVER open a file just to check its exports or types — that information is in your loaded knowledge"),l.push("- NEVER fabricate file URLs — use base URL from orientation + exact file path from Key Files"),l.push("- NEVER call search_nodes/read_graph for structure already in your context")),i&&(l.push(""),l.push("## Recommended Workflow"),l.push("1. Check orientation block → find which repo/feature is relevant"),l.push("2. Check loaded knowledge → exports, data flow, types, architecture"),l.push("3. Need implementation details? → `get_file_contents` with exact file path"),l.push("4. Need something not indexed? → search tools"),l.push("5. Need cross-repo relationships? → graph tools")),`<tool_guide>
|
|
443
|
+
${l.join(`
|
|
444
|
+
`)}
|
|
445
|
+
</tool_guide>`}const _6=[{headingPatterns:[/(naming|branch|commit|file|variable|function|class|component)\s*(naming|convention|format|pattern|rule|standard)/i],contentPatterns:[/\b(format|pattern|example|convention):/i,/\b(feat|fix|chore|docs|refactor|test|style)\//,/\b(camelCase|PascalCase|snake_case|kebab-case|SCREAMING_SNAKE)\b/i],target:"naming"},{headingPatterns:[/^(rules?|constraints?|conventions?|standards?|guidelines?|requirements?|policies?|must|never|always)/i,/^(code\s*style|coding\s*standards?|linting|formatting)/i,/^(security|safety|boundaries)/i],contentPatterns:[/\b(MUST|SHALL|MUST NOT|SHALL NOT|REQUIRED|NEVER|ALWAYS|DO NOT|FORBIDDEN)\b/,/\b(rule|convention|standard|pattern|format):/i,/^[-*]\s*(always|never|do not|must|required|forbidden)/im],target:"constraint"},{headingPatterns:[/^(workflow|process|checklist|steps?|pipeline|review|procedure)/i,/^(before|after)\s*(commit|merge|push|deploy|review|submit)/i,/^(ci|cd|testing|deploy|release)\s*(process|steps|workflow)?/i],contentPatterns:[/\b(step\s*\d|first|then|next|finally|before|after)\b/i,/^\d+\.\s+/m,/^[-*]\s*\[[\sx]?\]/m],target:"workflow"},{headingPatterns:[/^(persona|identity|tone|voice|style|character|vibe)/i,/^(communication|behavior|personality)/i,/^(soul|core\s*truths?|principles?)/i,/who\s*(you|i)\s*a(m|re)/i],contentPatterns:[/\b(tone|voice|style|personality|character):/i,/\bbe\s+(concise|direct|formal|casual|friendly|professional|warm|snarky)/i],target:"persona"},{headingPatterns:[/^(tools?|tooling|stack|tech|preferred\s*stack|dependencies|preferred)/i,/^(use|prefer|recommended)\s*(tools?|frameworks?|libraries?)/i],contentPatterns:[/\b(prefer|use|recommended|required):\s*/i,/\b(npm|yarn|pnpm|pip|cargo|go)\s+(run|install|test|build)\b/i],target:"tool"},{headingPatterns:[/^(output|response|format|template|formatting|structure)/i,/^(how to|writing|documentation)\s*(format|style|write|structure)/i,/^(pr|pull\s*request|commit|changelog|report)\s*(template|format|description)/i],contentPatterns:[/\b(format|template|structure|layout|output|response)\b.*\b(must|should|always)/i,/\b(markdown|json|yaml|table|list|bullet|heading|section)\b/i,/```[\s\S]*?```/],target:"output"}];function D6(e){const n=[],a=e.split(`
|
|
446
|
+
`);let s="",i=0,l=[];for(const d of a){const p=d.match(/^(#{1,6})\s+(.+)/);p?((s||l.length>0)&&n.push({heading:s,level:i,content:l.join(`
|
|
447
|
+
`).trim()}),i=p[1].length,s=p[2],l=[]):l.push(d)}return(s||l.length>0)&&n.push({heading:s,level:i,content:l.join(`
|
|
448
|
+
`).trim()}),n}function z6(e,n){return n.headingPatterns.some(i=>i.test(e.heading))?!0:n.contentPatterns.filter(i=>i.test(e.content)).length>=2}function R6(e){const n=[],a=e.content.split(`
|
|
449
|
+
`);for(const s of a){const i=s.replace(/^[-*]\s*/,"").trim();!i||i.startsWith("#")||i.startsWith("```")||(/\b(MUST|SHALL|NEVER|ALWAYS|DO NOT|FORBIDDEN|REQUIRED|should|must not)\b/i.test(i)||/^(use|prefer|avoid|ensure|keep|maintain|follow|check|run|test|verify|write|create|name)/i.test(i)&&s.match(/^[-*]\s/))&&n.push(i)}return n}function O6(e){const n=[],a=e.content.split(`
|
|
450
|
+
`);for(const s of a){const i=s.trim(),l=i.match(/^\d+\.\s+(.+)/);if(l){n.push(l[1]);continue}const d=i.match(/^[-*]\s*\[[\sx]?\]\s*(.+)/);d&&n.push(d[1])}if(n.length===0)for(const s of a){const i=s.match(/^[-*]\s+(.+)/);i&&i[1].length>10&&n.push(i[1])}return n}function $6(e){const n=[],a=`${e.heading}
|
|
451
|
+
${e.content}`,s=a.match(/branch.*?(?:format|pattern|naming|convention).*?[:`]\s*(.+?)(?:\n|$)/i)||a.match(/(?:feat|fix|chore|hotfix)\/[<\[{]?\w+/);if(s){const p=a.match(/(?:example|e\.g\.|e\.g).*?[:`]\s*(.+?)(?:\n|$)/i);n.push({target:"branch",pattern:s[1]||s[0],example:p?.[1]?.trim()})}const i=a.match(/commit.*?(?:format|pattern|message|convention).*?[:`]\s*(.+?)(?:\n|$)/i)||a.match(/(?:type)\(scope\):\s*description/i);i&&n.push({target:"commit",pattern:i[1]||i[0]});const l=a.match(/file.*?(?:naming|convention|pattern).*?[:`]\s*(.+?)(?:\n|$)/i);l&&n.push({target:"file",pattern:l[1]});const d=a.match(/(?:pr|pull\s*request).*?(?:format|title|naming).*?[:`]\s*(.+?)(?:\n|$)/i);return d&&n.push({target:"pr",pattern:d[1]}),n}function F6(e,n){const a=D6(e),s={constraints:[],workflowSteps:[],personaHints:[],toolHints:[],outputRules:[],namingPatterns:[],residual:"",source:n},i=[];for(const l of a){let d=!1;for(const p of _6)if(z6(l,p)){switch(d=!0,p.target){case"constraint":s.constraints.push(...R6(l));break;case"workflow":s.workflowSteps.push(...O6(l));break;case"persona":l.content.trim()&&s.personaHints.push(l.content.trim());break;case"tool":for(const f of l.content.split(`
|
|
452
|
+
`)){const h=f.match(/^[-*]\s+(.+)/);h&&s.toolHints.push(h[1].trim())}break;case"naming":s.namingPatterns.push(...$6(l));break;case"output":{for(const h of l.content.split(`
|
|
453
|
+
`)){const g=h.match(/^[-*]\s+(.+)/);g&&g[1].length>10&&s.outputRules.push(g[1].trim())}const f=l.content.match(/```[\s\S]*?```/g);if(f)for(const h of f)s.outputRules.push(h);break}}break}!d&&l.content.trim()&&i.push(l.heading?`${"#".repeat(l.level)} ${l.heading}
|
|
454
|
+
${l.content}`:l.content)}return s.residual=i.join(`
|
|
455
|
+
|
|
456
|
+
`),s}function bc(e,n){const a=e.replace(/\b(must|never|always|should|do not|avoid|use|prefer)\b/gi,"").split(/\s+/).filter(i=>i.length>=3),s=new Set(n.replace(/\b(must|never|always|should|do not|avoid|use|prefer)\b/gi,"").split(/\s+/).filter(i=>i.length>=3));return a.some(i=>s.has(i))}function I6(e){const n=e.flatMap(g=>g.constraints),a=e.flatMap(g=>g.workflowSteps),s=e.flatMap(g=>g.personaHints),i=e.flatMap(g=>g.toolHints),l=e.map(g=>g.residual).filter(Boolean),d=[...new Set(n)],p=[];for(let g=0;g<d.length;g++)for(let x=g+1;x<d.length;x++){const b=d[g].toLowerCase(),v=d[x].toLowerCase();(b.includes("must")&&v.includes("never")&&bc(b,v)||b.includes("never")&&v.includes("must")&&bc(b,v)||b.includes("use ")&&v.includes("avoid ")&&bc(b,v)||b.includes("avoid ")&&v.includes("use ")&&bc(b,v))&&p.push(`⚠️ Conflict: "${d[g]}" vs "${d[x]}"`)}const f=e.flatMap(g=>g.namingPatterns).map(g=>{const x=g.example?` (e.g. ${g.example})`:"";return`${g.target} naming: ${g.pattern}${x}`}),h=[...d,...f];return{conflicts:p,constraintsBlock:h.length>0?`<framework_constraints source="guidelines">
|
|
457
|
+
${h.map(g=>`- ${g}`).join(`
|
|
458
|
+
`)}${p.length>0?`
|
|
459
|
+
|
|
460
|
+
Conflicts detected:
|
|
461
|
+
`+p.join(`
|
|
462
|
+
`):""}
|
|
463
|
+
</framework_constraints>`:"",workflowBlock:a.length>0?`<framework_workflow>
|
|
464
|
+
${a.map((g,x)=>`${x+1}. ${g}`).join(`
|
|
465
|
+
`)}
|
|
466
|
+
</framework_workflow>`:"",personaBlock:s.length>0?`<framework_persona>
|
|
467
|
+
${s.join(`
|
|
468
|
+
|
|
469
|
+
`)}
|
|
470
|
+
</framework_persona>`:"",toolHintsBlock:i.length>0?`<tool_hints>
|
|
471
|
+
${i.map(g=>`- ${g}`).join(`
|
|
472
|
+
`)}
|
|
473
|
+
</tool_hints>`:"",outputBlock:e.flatMap(g=>g.outputRules).length>0?`<output_format>
|
|
474
|
+
Format your responses according to these rules:
|
|
475
|
+
${e.flatMap(g=>g.outputRules).map(g=>g.startsWith("```")?g:`- ${g}`).join(`
|
|
476
|
+
`)}
|
|
477
|
+
</output_format>`:"",residualKnowledge:l.length>0?l.join(`
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
`):""}}async function Uv(e,n){const a=wn.getState(),s=fn.getState(),i=new Set(["framework","guideline"]),l=e.filter(x=>i.has(x.knowledgeType)),d=e.filter(x=>!i.has(x.knowledgeType));let p="",f,h="";const g=e.filter(x=>x.path);if(g.length>0){const x=Date.now();await a.indexFiles(g.map(b=>b.path)),s.addEvent(n,{kind:"retrieval",sourceName:"pipeline:fetch",query:`${g.length} sources`,resultCount:g.filter(b=>a.getIndex(b.path)!=null).length,durationMs:Date.now()-x})}if(l.length>0){const x=l.map(b=>{let v=b.path?a.getIndex(b.path):null;if(!v&&b.content){const j=`content://${b.contentSourceId||b.sourceId}`;v=Vs(j,b.content)}if(!v)return null;const k=ki(v,0),w=wi(k.filtered);return w.trim()?F6(w,b.name):null}).filter(b=>b!==null);if(x.length>0){const b=I6(x);p=[b.constraintsBlock,b.workflowBlock,b.personaBlock,b.toolHintsBlock,b.outputBlock].filter(Boolean).join(`
|
|
482
|
+
|
|
483
|
+
`),f={constraints:x.reduce((k,w)=>k+w.constraints.length,0),workflowSteps:x.reduce((k,w)=>k+w.workflowSteps.length,0),personaHints:x.reduce((k,w)=>k+w.personaHints.length,0),toolHints:x.reduce((k,w)=>k+w.toolHints.length,0),outputRules:x.reduce((k,w)=>k+w.outputRules.length,0),namingPatterns:x.reduce((k,w)=>k+w.namingPatterns.length,0),sources:x.map(k=>k.source)},b.residualKnowledge.trim()&&(h=`<knowledge type="framework-residual">
|
|
484
|
+
${b.residualKnowledge}
|
|
485
|
+
</knowledge>`),s.addEvent(n,{kind:"retrieval",sourceName:"pipeline:framework",query:`${x.length} framework sources`,resultCount:x.reduce((k,w)=>k+w.constraints.length+w.workflowSteps.length,0),durationMs:0})}}return{frameworkBlock:p,frameworkSummary:f,regularChannels:d,residualKnowledgeBlock:h}}function xm(e){const n=[];n.push(`Source: ${e.source} (${e.totalTokens} tokens, ${e.nodeCount} nodes)`),n.push("");function a(s,i){if(s.depth===0&&s.children.length>0){for(const h of s.children)a(h,i);return}const l=" ".repeat(i),d=s.totalTokens>0?` [${s.totalTokens} tokens]`:"",p=s.children.length>0?` (${s.children.length} subsections)`:"",f=s.meta?.firstSentence?` — ${s.meta.firstSentence}`:"";n.push(`${l}[${s.nodeId}] ${s.title}${d}${p}${f}`);for(const h of s.children)a(h,i+1)}return a(e.root,0),n.join(`
|
|
486
|
+
`)}function bm(e,n){return`You are selecting which parts of the knowledge base to include in context for a coding task.
|
|
487
|
+
|
|
488
|
+
TASK: ${n.task}
|
|
489
|
+
TOKEN BUDGET: ${n.tokenBudget} tokens available for knowledge
|
|
490
|
+
|
|
491
|
+
Below are the available knowledge sources with their tree structure. Each node shows:
|
|
492
|
+
- [nodeId] Title [total tokens] (subsections) — first sentence
|
|
493
|
+
|
|
494
|
+
YOUR JOB: Select which branches to include and at what depth:
|
|
495
|
+
- depth 0 (Full): Include everything — use for critical sections you need to read carefully
|
|
496
|
+
- depth 1 (Detail): First paragraph per leaf — use for important context
|
|
497
|
+
- depth 2 (Summary): First sentence per section — use for orientation
|
|
498
|
+
- depth 3 (Headlines): Just titles — use for awareness
|
|
499
|
+
- depth 4 (Mention): Skip content — just note it exists
|
|
500
|
+
|
|
501
|
+
RULES:
|
|
502
|
+
- Stay within the token budget (depths reduce tokens: Full=100%, Detail=75%, Summary=50%, Headlines=25%, Mention=10%)
|
|
503
|
+
- Prioritize sections directly relevant to the task
|
|
504
|
+
- Include architectural context at Summary/Headlines even if not directly relevant
|
|
505
|
+
- Be specific about WHY you selected each branch
|
|
506
|
+
|
|
507
|
+
SOURCES:
|
|
508
|
+
${e.join(`
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
`)}
|
|
513
|
+
|
|
514
|
+
Respond with a JSON array of selections:
|
|
515
|
+
[
|
|
516
|
+
{ "nodeId": "n1-0", "depth": 0, "reason": "Need full implementation details for the order store", "priority": 0 },
|
|
517
|
+
{ "nodeId": "n1-3", "depth": 2, "reason": "Architecture context for understanding the module", "priority": 2 },
|
|
518
|
+
...
|
|
519
|
+
]${n.existingContext?`
|
|
520
|
+
|
|
521
|
+
ALREADY IN CONTEXT (don't duplicate):
|
|
522
|
+
${n.existingContext}`:""}`}function Gv(e,n){if(e.nodeId===n)return e;for(const a of e.children){const s=Gv(a,n);if(s)return s}return null}function qv(e,n){const a=[];if(n===4)return"";if(n===3){e.depth>0&&a.push(`${"#".repeat(e.depth)} ${e.title}`);for(const s of e.children)s.depth<=2&&a.push(`${"#".repeat(s.depth)} ${s.title}`);return a.join(`
|
|
523
|
+
`)}e.depth>0&&a.push(`${"#".repeat(e.depth)} ${e.title}`),n===0?e.text&&a.push(e.text):n===1?e.children.length===0&&e.meta?.firstParagraph?a.push(e.meta.firstParagraph):e.text&&a.push(e.text):n===2&&e.meta?.firstSentence&&a.push(e.meta.firstSentence);for(const s of e.children){const i=qv(s,n);i&&a.push(i)}return a.join(`
|
|
524
|
+
|
|
525
|
+
`)}function L6(e,n){const a=[],s=new Map;for(const d of e)s.set(d.source,d);for(const d of n.selections){let p=null;for(const h of e)if(p=Gv(h.root,d.nodeId),p)break;if(!p)continue;const f=qv(p,d.depth);f.trim()&&a.push({priority:d.priority,nodeId:d.nodeId,content:f,tokens:Ye(f),depth:d.depth})}a.sort((d,p)=>d.priority-p.priority);const i=a.map(d=>d.content).join(`
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
`),l=a.map(d=>({nodeId:d.nodeId,tokens:d.tokens,depth:d.depth}));return{content:i,tokens:Ye(i),breakdown:l}}function qc(e){const n=e.match(/\[[\s\S]*\]/);if(!n)return[];try{const a=JSON.parse(n[0]);return Array.isArray(a)?a.filter(s=>s.nodeId&&typeof s.depth=="number").map(s=>({nodeId:s.nodeId,depth:Math.max(0,Math.min(4,s.depth)),reason:s.reason||"",priority:s.priority??2})):[]}catch{return[]}}function B6(e,n){const a=n.length>4e3?n.slice(0,4e3)+"...[truncated]":n;return`You are auditing whether the provided context contains enough information to complete a coding task.
|
|
530
|
+
|
|
531
|
+
TASK: ${e}
|
|
532
|
+
|
|
533
|
+
CURRENT CONTEXT:
|
|
534
|
+
${a}
|
|
535
|
+
|
|
536
|
+
YOUR JOB: Identify what critical information is MISSING from the context to complete this task. Look for:
|
|
537
|
+
- Missing implementation details or code examples
|
|
538
|
+
- Missing architectural context or relationships
|
|
539
|
+
- Missing configuration or setup information
|
|
540
|
+
- Missing error handling or edge case patterns
|
|
541
|
+
|
|
542
|
+
Respond with a JSON array of missing information gaps (maximum 3):
|
|
543
|
+
["Missing error handling patterns for API failures", "Missing database schema for user table", "Missing authentication flow details"]
|
|
544
|
+
|
|
545
|
+
If the context appears complete for the task, respond with: []`}function P6(e){const n=e.match(/\[[\s\S]*?\]/);if(!n)return[];try{const a=JSON.parse(n[0]);return Array.isArray(a)?a.filter(s=>typeof s=="string"&&s.trim().length>0).slice(0,3):[]}catch{return[]}}function H6(e){return`You are writing a hypothetical documentation passage that would perfectly answer this query.
|
|
546
|
+
|
|
547
|
+
QUERY: ${e}
|
|
548
|
+
|
|
549
|
+
Write a comprehensive documentation passage that would ideally exist in a codebase to answer this question. Include:
|
|
550
|
+
- Relevant code examples
|
|
551
|
+
- Implementation details
|
|
552
|
+
- Configuration options
|
|
553
|
+
- Common patterns and best practices
|
|
554
|
+
|
|
555
|
+
Write as if this documentation already exists and covers exactly what the user needs to know:`}function U6(e){return e.trim().split(/\s+/).length>=10}function G6(e,n=8){return e.toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g," ").trim().split(" ").slice(0,n).join(" ")}function q6(e,n){const a=new Set,s=[];let i=0;for(let l=0;l<e.length;l++){const d=e[l];if(n.has(l)){s.push(d);continue}const p=G6(d);if(p.length<10){s.push(d);continue}if(a.has(p)){i++;continue}a.add(p),s.push(d)}return{result:s,removed:i}}const K6=[/^(as mentioned|as noted|as described|as stated|as shown|as seen)\b/i,/^(it is worth noting|it should be noted|it is important to note|note that)\b/i,/^(in this section|in the following|the following section|this section)\b/i,/^(let's|let us|we will|we'll|we can|we should)\s+(look at|examine|explore|consider|discuss|review|take a look)/i,/^(basically|essentially|fundamentally|generally speaking|in general)\b/i,/^(it goes without saying|needless to say|obviously|of course|clearly)\b/i,/^(furthermore|moreover|additionally|in addition|also|besides|what's more)\s*,?\s*$/i,/^(in conclusion|to summarize|to sum up|in summary|overall)\s*,?\s*$/i];function Y6(e){const n=e.trim();if(!n)return 1;let a=0;for(const p of K6)if(p.test(n)){a+=.6;break}const s=n.split(/\s+/).length;s<4&&(a+=.3);const i=new Set(["the","a","an","is","are","was","were","be","been","being","have","has","had","do","does","did","will","would","could","should","may","might","shall","can","this","that","these","those","it","its","to","of","in","for","on","with","at","by","from","as","into","about"]),l=n.toLowerCase().split(/\s+/);return l.filter(p=>i.has(p)).length/l.length>.7&&s>5&&(a+=.2),Math.min(1,a)}function V6(e,n=.5,a){let s=0;const i=[];for(let l=0;l<e.length;l++){const d=e[l];if(a.has(l)){i.push(d);continue}const f=d.split(new RegExp("(?<=[.!?])\\s+")).filter(h=>Y6(h)>=n?(s++,!1):!0);f.length>0&&i.push(f.join(" "))}return{result:i,removed:s}}function W6(e){let n=0;return{result:e.replace(/```[\s\S]*?```/g,s=>{const i=s.split(`
|
|
556
|
+
`),l=i[0],d=i[i.length-1],f=i.slice(1,-1).filter(h=>{const g=h.trim();return g.startsWith("//")&&!g.startsWith("///")&&!g.startsWith("//!")||g.startsWith("#")&&!g.startsWith("#!")&&!g.startsWith("# ")?(n++,!1):!!g});return[l,...f,d].join(`
|
|
557
|
+
`)}),removedComments:n}}function X6(e,n={}){const{dedup:a=!0,removeFiller:s=!0,compressCode:i=!0,aggressiveness:l=.5,tokenBudget:d,preservePatterns:p=[]}=n,f=Ye(e);let h=e,g=0,x=0,b=0;if(i){const T=W6(h);h=T.result,b=T.removedComments}let v=h.split(/\n\s*\n/).filter(T=>T.trim());const k=p.map(T=>new RegExp(T,"i")),w=T=>{const E=new Set;if(k.length===0)return E;for(let S=0;S<T.length;S++)k.some(M=>M.test(T[S]))&&E.add(S);return E};if(a){const T=q6(v,w(v));v=T.result,g=T.removed}if(s){const T=.3+.4*(1-l),E=V6(v,T,w(v));v=E.result,x=E.removed}if(h=v.join(`
|
|
558
|
+
|
|
559
|
+
`),d){let T=Ye(h);if(T>d){const E=w(v);for(;v.length>1&&T>d;){let S=-1;for(let M=v.length-1;M>=0;M--)if(!E.has(M)){S=M;break}if(S<0)break;v.splice(S,1),h=v.join(`
|
|
560
|
+
|
|
561
|
+
`),T=Ye(h)}}}const j=Ye(h);return{content:h,originalTokens:f,compressedTokens:j,ratio:f>0?j/f:1,removals:{duplicates:g,filler:x,codeComments:b}}}function Z6(e){switch(e.type){case"markdown":return Vs(e.name,e.content||"");case"structured":return q4(e.name,e.fields||[],e.sourceType);case"chronological":return K4(e.name,e.entries||[],e.sourceType);case"flat":return Nx(e.name,e.content||"",e.sourceType);default:return Nx(e.name,e.content||"")}}function Q6(e){const n=Date.now(),a=e.sources.map(Z6),s=Date.now()-n,i=a.map(xm),l=bm(i,{task:e.task,tokenBudget:e.tokenBudget});return{indexes:a,headlines:i,navigationPrompt:l,indexMs:s}}function Xx(e,n,a,s){const i=Date.now(),l=a.manualSelections||qc(n),d=Date.now()-i,p={source:a.sources.map(w=>w.name).join(", "),selections:l,taskRelevance:a.task},f=L6(e,p),h=Date.now();let g,x={originalTokens:0,compressedTokens:0,ratio:1,removals:{duplicates:0,filler:0,codeComments:0}};if(a.compression?.enabled!==!1&&f.content)if(f.breakdown.map(j=>({content:f.content,priority:l.find(T=>T.nodeId===j.nodeId)?.priority??2})).length>0){const j=X6(f.content,{tokenBudget:a.tokenBudget,aggressiveness:a.compression?.aggressiveness??.5});g=j.content,x={originalTokens:j.originalTokens,compressedTokens:j.compressedTokens,ratio:j.ratio,removals:j.removals}}else g=f.content;else g=f.content,x.originalTokens=Ye(f.content),x.compressedTokens=x.originalTokens;const b=Date.now()-h,v=s+d+b,k=Ye(g);return{context:g,tokens:k,utilization:a.tokenBudget>0?k/a.tokenBudget:0,sources:e.map(w=>({name:w.source,type:w.sourceType,totalTokens:w.totalTokens,indexedNodes:w.nodeCount})),navigation:{selections:l,prompt:void 0},compression:x,indexes:e,timing:{indexMs:s,navigationMs:d,compressionMs:b,totalMs:v}}}const J6=[/\bnot\b/i,/\bhowever\b/i,/\bcontrary to\b/i,/\bunlike\b/i,/\bfails to\b/i,/\bbut\b/i,/\balthough\b/i,/\bwhile\b/i,/\bwhereas\b/i,/\binstead\b/i,/\brather than\b/i,/\bon the other hand\b/i,/\bin contrast\b/i,/\bnevertheless\b/i,/\bnonetheless\b/i,/\bdespite\b/i,/\bin spite of\b/i],eD=[/\blimitations?\b/i,/\brestrictions?\b/i,/\bchallenges?\b/i,/\bproblems?\b/i,/\bissues?\b/i,/\brisks?\b/i,/\bdisadvantages?\b/i,/\bcons\b/i,/\bweaknesses?\b/i,/\bfailures?\b/i,/\berrors?\b/i,/\bmistakes?\b/i,/\balternatives?\b/i,/\bother approaches?\b/i,/\bdifferent view\b/i,/\bopposing\b/i,/\bcounter\b/i],tD=[/\bresults?\b/i,/\bbenefits?\b/i,/\badvantages?\b/i,/\bpros\b/i,/\bstrengths?\b/i,/\bsuccesses?\b/i,/\bachievements?\b/i,/\bimprovements?\b/i,/\bgains?\b/i,/\bpositive\b/i,/\brecommendations?\b/i,/\bbest practices?\b/i];function Zx(e){const n=new Set;return(e.match(/\b[A-Z][a-z]+(?:\s+[A-Z][a-z]*)*\b/g)||[]).forEach(p=>n.add(p.toLowerCase())),(e.match(/"([^"]+)"/g)||[]).forEach(p=>n.add(p.replace(/"/g,"").toLowerCase())),(e.match(/`([^`]+)`/g)||[]).forEach(p=>n.add(p.replace(/`/g,"").toLowerCase())),(e.match(/\*\*([^*]+)\*\*/g)||[]).forEach(p=>n.add(p.replace(/\*\*/g,"").toLowerCase())),(e.match(/\*([^*]+)\*/g)||[]).forEach(p=>n.add(p.replace(/\*/g,"").toLowerCase())),n}function nD(e,n){const a=Zx(e.content),s=Zx(n.content);if(a.size===0&&s.size===0)return 0;const i=new Set(Array.from(a).filter(d=>s.has(d))),l=new Set([...Array.from(a),...Array.from(s)]);return i.size/l.size}function oD(e){return J6.some(n=>n.test(e))}function Qx(e){const n=e.toLowerCase();return eD.some(a=>a.test(n))?"contrasting":tD.some(a=>a.test(n))?"supporting":"neutral"}function aD(e,n,a=.2){const s=[],i=[],l=new Set(e.map(d=>`${d.source}:${d.section}`));for(const d of e){let p=null,f="",h=0;for(const g of n){const x=`${g.source}:${g.section}`;if(x===`${d.source}:${d.section}`||l.has(x))continue;const b=nD(d,g);if(b<a)continue;let v=0,k="";const w=Qx(d.section),j=Qx(g.section);w==="supporting"&&j==="contrasting"?(v+=.6,k=`contrasting section types: "${d.section}" vs "${g.section}"`):w==="contrasting"&&j==="supporting"&&(v+=.6,k=`contrasting section types: "${d.section}" vs "${g.section}"`),oD(g.content)&&(v+=.4,k?k+=" + negation patterns":k="negation patterns detected"),v+=b*.3,v>h&&(h=v,p=g,f=k)}if(p&&h>.3){const g=`${p.source}:${p.section}`;s.some(x=>`${x.source}:${x.section}`===g)||s.push(p),i.push({supporting:d,contrasting:p,reason:f})}}return{supporting:e,contrasting:s,pairs:i}}function sD(e){return[/\bshould we\b/i,/\bcompare\b/i,/\bwhich is better\b/i,/\bpros and cons\b/i,/\bevaluate\b/i,/\banalyz(e|ation)/i,/\bassess\b/i,/\balternatives?\b/i,/\bdecid[ei](on)?\b/i,/\btrade-?offs?\b/i,/\badvantages?\b/i,/\bdisadvantages?\b/i,/\bvs\.?\s/i,/\bversus\b/i,/\bweigh\b/i].some(a=>a.test(e))}function Jx(e){const n=e.toLowerCase();return/\b(compare|vs|versus|evaluate|pros and cons|advantages|disadvantages|should we|tradeoffs?|better|worse|choose|decide|recommend)\b/.test(n)?"analytical":n.length<50||/\b(what is|how does|who is|when did|where is|define|definition)\b/.test(n)||/\b(version|spec|api|format|syntax|command)\b/.test(n)?"factual":"exploratory"}function rD(e){switch(e){case"factual":return .9;case"analytical":return .5;case"exploratory":return .7}}function iD(e,n=500){if(e.tokens<=n)return[{content:e.text,nodeId:e.nodeId,source:"",section:e.title,parentNodeId:void 0,depth:e.depth,knowledgeType:"signal"}];const a=e.text.split(/\n\s*\n/),s=[];let i="",l=0;for(const d of a){const p=i?`${i}
|
|
562
|
+
|
|
563
|
+
${d}`:d;Ye(p)>n&&i?(s.push({content:i.trim(),nodeId:`${e.nodeId}-${l++}`,source:"",section:`${e.title} (part ${l})`,parentNodeId:e.nodeId,depth:e.depth+1,knowledgeType:"signal"}),i=d):i=p}return i.trim()&&s.push({content:i.trim(),nodeId:`${e.nodeId}-${l}`,source:"",section:`${e.title} (part ${l+1})`,parentNodeId:e.nodeId,depth:e.depth+1,knowledgeType:"signal"}),s}function lD(e){const n=[];for(const{treeIndex:a,knowledgeType:s}of e){const i=[{node:a.root}];for(;i.length>0;){const{node:l,parentId:d}=i.pop();if((l.children.length===0||l.text&&l.text.trim().length>0)&&l.text&&l.text.trim().length>0){const p=iD(l);for(const f of p)f.source=a.source,f.knowledgeType=s,f.parentNodeId=d,n.push(f)}for(const p of l.children)i.push({node:p,parentId:l.nodeId})}}return n}async function cD(e){if(e.length===0)return[];const n=await fetch(`${Ae}/embeddings/embed`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({texts:e})});if(!n.ok)throw new Error(`Embedding service error: ${n.status} ${n.statusText}`);return(await n.json()).embeddings}function li(e,n){if(e.length!==n.length||e.length===0)return 0;let a=0,s=0,i=0;for(let d=0;d<e.length;d++)a+=e[d]*n[d],s+=e[d]*e[d],i+=n[d]*n[d];const l=Math.sqrt(s)*Math.sqrt(i);return l===0?0:a/l}function uD(e){if(e.length<=1)return 1;const n=e.map(i=>i.embedding).filter(i=>i);if(n.length<=1)return 1;let a=0,s=0;for(let i=0;i<n.length;i++)for(let l=i+1;l<n.length;l++)a+=li(n[i],n[l]),s++;return s===0?1:1-a/s}function dD(e,n,a){if(e.length===0)return[];const s=[],i=[...e];let l=0;for(;i.length>0&&l<a;){let d=-1/0,p=-1;for(let g=0;g<i.length;g++){const x=i[g];if(!x.embedding)continue;const b=Ye(x.content);if(l+b>a)continue;const v=x.relevanceScore;let k=0;for(const j of s)if(j.embedding){const T=li(x.embedding,j.embedding);k=Math.max(k,T)}const w=n*v-(1-n)*k;w>d&&(d=w,p=g)}if(p===-1)break;const f=i.splice(p,1)[0],h=Ye(f.content);s.push(f),l+=h}return s}async function pD(e,n,a){const s=Date.now(),i=lD(n);if(i.length===0)return{chunks:[],diversityScore:1,collapseWarning:!1,totalChunks:0,queryType:Jx(e),retrievalMs:Date.now()-s,embeddingMs:0,budgetUsed:0,budgetTotal:a};const l=Date.now(),d=[e,...i.map(B=>B.content)],p=await cD(d),f=Date.now()-l,h=p[0],g=p.slice(1);i.forEach((B,G)=>{B.embedding=g[G]});const x=.3,b=i.map(B=>({...B,relevanceScore:B.embedding?li(h,B.embedding):0,inclusionReason:"direct"})).filter(B=>B.relevanceScore>x),v=new Map(i.map(B=>[B.nodeId,B])),k=new Map;for(const B of b)if(k.set(B.nodeId,B),B.parentNodeId){const G=v.get(B.parentNodeId);if(G&&G.embedding&&!k.has(G.nodeId)){const O=B.relevanceScore*.6;O>x&&k.set(G.nodeId,{...G,relevanceScore:O,inclusionReason:"parent-expansion"})}}const w=.5,j=.4;for(const B of b)if(B.relevanceScore>w&&B.parentNodeId&&B.embedding){const G=i.filter(O=>O.parentNodeId===B.parentNodeId&&O.nodeId!==B.nodeId&&!k.has(O.nodeId));for(const O of G)if(O.embedding&&li(B.embedding,O.embedding)>j){const V=li(h,O.embedding);k.set(O.nodeId,{...O,relevanceScore:V,inclusionReason:"sibling-coherence"})}}const T=Jx(e),E=rD(T),S=Array.from(k.values()),M=dD(S,E,a),$=uD(M),A=$<.3,_=M.reduce((B,G)=>B+Ye(G.content),0),F=Date.now()-s;return{chunks:M,diversityScore:$,collapseWarning:A,totalChunks:i.length,queryType:T,retrievalMs:F,embeddingMs:f,budgetUsed:_,budgetTotal:a}}const Kv={"ground-truth":1,evidence:.8,signal:.6,hypothesis:.4},Yv={full:1,summary:.7,headline:.4};function Df(e,n){const a=[],s=[],i=new Map;n.forEach(d=>{i.set(d.name,d),d.path&&i.set(d.path,d)});for(const d of e.sources){const p=i.get(d.name);if(!p)continue;const f=Vv(p.knowledgeType),h=gD(p.depth);a.push({path:p.path||p.name,type:f,sections:d.indexedNodes,depth:h,method:"tree-index",chunkCount:Math.floor(d.totalTokens/100)}),s.push({from:p.path||p.name,method:"tree-index",to:`index-${d.name}`}),e.compression.ratio<1&&s.push({from:`index-${d.name}`,method:"rtk-compression",to:`compressed-${d.name}`})}const l={weights:Kv,depthWeights:Yv,instructions:xD()};return{sources:a,derivations:s,conflictResolution:l}}function fD(e){return e.map(n=>{const a=Vv(n.type),s=yD(n.depth),i=hD(a,s);return{content:n.content,provenance:{source:n.source,section:n.section,type:a,depth:s,method:n.method,confidence:i}}})}function mD(e){const n=[],a=new Set,s=bD(e);for(const[i,l]of Object.entries(s)){if(l.length<2)continue;const d=vD(l);for(const p of d){const f=p.map(g=>`${g.provenance.source}:${g.provenance.section}`).sort().join("|");if(a.has(f))continue;a.add(f);const h=kD(p);h&&n.push({conflictingChunks:p,resolution:h})}}return n}function hD(e,n){const a=Kv[e]||.5,s=Yv[n]||.5;return a*s}function Vv(e){switch(e){case"ground-truth":return"ground-truth";case"evidence":return"evidence";case"signal":return"signal";case"hypothesis":return"hypothesis";default:return"signal"}}function gD(e){switch(e){case 0:return"full";case 1:return"summary";case 2:return"headline";default:return"summary"}}function yD(e){switch(e){case"full":return"full";case"summary":return"summary";case"headline":return"headline";default:return"summary"}}function xD(){return`When sources conflict, apply this priority order:
|
|
564
|
+
1. Source reliability: ground-truth > evidence > signal > hypothesis
|
|
565
|
+
2. Content depth: full > summary > headline
|
|
566
|
+
3. Recency: prefer more recent information when timestamps are available
|
|
567
|
+
4. Specificity: prefer specific details over general statements
|
|
568
|
+
|
|
569
|
+
When presenting conflicting information, acknowledge the conflict and explain your reasoning based on source reliability.`}function bD(e){const n={};for(const a of e){const s=a.provenance.section||"general";n[s]||(n[s]=[]),n[s].push(a)}return n}function vD(e){const n=[];for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){const i=e[a],l=e[s];i.provenance.source!==l.provenance.source&&i.provenance.section===l.provenance.section&&wD(i.content,l.content)<.7&&n.push([i,l])}return n}function kD(e){let n=e[0],a=n.provenance.confidence;for(const i of e)i.provenance.confidence>a&&(n=i,a=i.provenance.confidence);const s=`Preferred ${n.provenance.type} source (confidence: ${a.toFixed(2)}) over other sources`;return{preferredChunk:n,reason:s,confidence:a}}function wD(e,n){const a=new Set(e.toLowerCase().split(/\s+/)),s=new Set(n.toLowerCase().split(/\s+/)),i=new Set([...a].filter(d=>s.has(d))),l=new Set([...a,...s]);return i.size/l.size}function zf(e,n,a,s,i,l){return`<chunk source="${n}" section="${a}" type="${s}" depth="${i}" method="${l}">
|
|
570
|
+
${e}
|
|
571
|
+
</chunk>`}function SD(e,n){const a=[];if(!e.context)return a;const s=new Map;for(const l of n)s.set(l.name,l),l.path&&s.set(l.path,l);const i=MD(e.context);for(const l of i){let d;for(const f of e.sources)if(l.content.length>0&&s.has(f.name)){d=s.get(f.name);break}const p=d?Fs[d.depth]?.label??"full":"full";a.push({content:l.content,source:d?.path||d?.name||"unknown",section:l.heading||"main",type:d?.knowledgeType||"signal",depth:p,method:"tree-index-pipeline",node:{}})}return a}function MD(e){const n=e.split(`
|
|
572
|
+
`),a=[];let s="",i=[];for(const l of n){const d=l.match(/^#{1,4}\s+(.+)/);if(d){if(i.length>0){const p=i.join(`
|
|
573
|
+
`).trim();p&&a.push({heading:s,content:p})}s=d[1],i=[]}else i.push(l)}if(i.length>0){const l=i.join(`
|
|
574
|
+
`).trim();l&&a.push({heading:s,content:l})}return a}function CD(e,n,a){const s=Df(e,n);if(!sD(a))return{knowledgeBlock:`<knowledge sources="${e.sources.map(w=>`${w.name} (${w.type}, ${w.totalTokens} tokens, ${w.indexedNodes} nodes)`).join(", ")}">
|
|
575
|
+
${e.context}
|
|
576
|
+
</knowledge>`,provenance:s};const i=SD(e,n);if(i.length===0)return{knowledgeBlock:`<knowledge sources="${e.sources.map(w=>`${w.name} (${w.type}, ${w.totalTokens} tokens, ${w.indexedNodes} nodes)`).join(", ")}">
|
|
577
|
+
${e.context}
|
|
578
|
+
</knowledge>`,provenance:s};const l=fD(i),d=mD(l),p=aD(i,i),f=p.supporting.map(v=>zf(v.content,v.source,v.section,v.type,v.depth,v.method)),h=p.contrasting.map(v=>zf(v.content,v.source,v.section,v.type,v.depth,v.method));let g="";if(f.length>0&&(g+=`<supporting>
|
|
579
|
+
${f.join(`
|
|
580
|
+
|
|
581
|
+
`)}
|
|
582
|
+
</supporting>`),h.length>0&&(g&&(g+=`
|
|
583
|
+
|
|
584
|
+
`),g+=`<contrasting>
|
|
585
|
+
${h.join(`
|
|
586
|
+
|
|
587
|
+
`)}
|
|
588
|
+
</contrasting>`),d.length>0){g&&(g+=`
|
|
589
|
+
|
|
590
|
+
`),g+=`<conflicts_resolved>
|
|
591
|
+
`;for(const v of d)g+=`Conflict: ${v.conflictingChunks.map(k=>k.provenance.source).join(" vs ")}
|
|
592
|
+
`,g+=`Resolution: ${v.resolution.reason}
|
|
593
|
+
|
|
594
|
+
`;g+="</conflicts_resolved>"}return g||(g=e.context),{knowledgeBlock:`<knowledge sources="${e.sources.map(v=>`${v.name} (${v.type}, ${v.totalTokens} tokens, ${v.indexedNodes} nodes)`).join(", ")}">
|
|
595
|
+
${g}
|
|
596
|
+
</knowledge>`,provenance:s}}function ED(e){const n=e.filter(l=>l.enabled);if(n.length===0)return"";const a={},s=["ground-truth","signal","evidence","framework","hypothesis","guideline"];for(const l of n)a[l.knowledgeType]||(a[l.knowledgeType]=[]),a[l.knowledgeType].push(l);const i=[];for(const l of s){const d=a[l];if(!d?.length)continue;const p=Qo[l],f=d.map(h=>{const g=Fs[h.depth];return`- ${h.name} (${g.label}, ~${Math.round(h.baseTokens*g.pct).toLocaleString()} tokens) [${h.path}]`});i.push(`[${p.label.toUpperCase()}] ${p.instruction}
|
|
597
|
+
${f.join(`
|
|
598
|
+
`)}`)}return`<knowledge>
|
|
599
|
+
${i.join(`
|
|
600
|
+
|
|
601
|
+
`)}
|
|
602
|
+
</knowledge>`}async function Nc(e,n,a){const s=await fetch(`${Ae}/llm/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:a,messages:[{role:"system",content:"You are a context navigation agent. Respond with ONLY a JSON array, no markdown, no explanation."},{role:"user",content:e}]}),signal:AbortSignal.timeout(3e4)});if(!s.ok)throw new Error(`Navigation LLM call failed: ${s.status}`);const l=(await s.text()).split(`
|
|
603
|
+
`).filter(p=>p.startsWith("data: ")).map(p=>p.slice(6)).filter(p=>p!=="[DONE]");let d="";for(const p of l)try{const h=JSON.parse(p).choices?.[0]?.delta?.content;h&&(d+=h)}catch{}return d}async function jD(e,n,a,s,i){const l=fn.getState(),d=Date.now();try{const p=e.join(". "),f=Math.floor(s.totalBudget*.2),h=new Set(a.map(w=>w.nodeId)),g=n.map(xm),x=bm(g,{task:p,tokenBudget:f}),b=await Nc(x,s.providerId,s.model),k=qc(b).filter(w=>!h.has(w.nodeId));return l.addEvent(i,{kind:"llm_call",model:s.model,durationMs:Date.now()-d,toolResult:`Gap navigation selected ${k.length} new branches for ${e.length} gaps`}),k}catch(p){return l.addEvent(i,{kind:"error",errorMessage:`Gap navigation failed: ${p instanceof Error?p.message:"Unknown"}`,durationMs:Date.now()-d}),[]}}async function Wv(e,n,a,s,i){const l=wn.getState(),d=fn.getState(),{userMessage:p,navigationMode:f="tree-aware",providerId:h,model:g}=s,x=e.filter(T=>T.enabled);let b=a,v=null,k=null,w;const j=[];for(const T of n)if(T.content){const E=`content://${T.contentSourceId||T.sourceId}`,S=Vs(E,T.content),M=wi(ki(S,0).filtered);M.trim()&&j.push({name:T.name,type:"markdown",content:M,sourceType:T.knowledgeType})}else if(T.path){const E=l.getIndex(T.path);if(E){const S=wi(ki(E,0).filtered);S.trim()&&j.push({name:T.name,type:"markdown",content:S,sourceType:T.knowledgeType})}}if(f==="tree-aware"&&n.length>0){const T=x.reduce((S,M)=>S+M.baseTokens,0),E=[];for(const S of n)if(S.content){const M=`content://${S.contentSourceId||S.sourceId}`,$=Vs(M,S.content);E.push({treeIndex:$,knowledgeType:S.knowledgeType})}else if(S.path){const M=l.getIndex(S.path);M&&E.push({treeIndex:M,knowledgeType:S.knowledgeType})}if(E.length>0)try{if(d.addEvent(i,{kind:"retrieval",sourceName:"tree-aware-retrieval",query:p,resultCount:E.length,durationMs:0}),w=await pD(p,E,T),d.addEvent(i,{kind:"retrieval",sourceName:"tree-aware-retrieval",query:p,resultCount:w.chunks.length,durationMs:w.retrievalMs}),w.chunks.length>0){const S=w.chunks.map(F=>zf(F.content,F.source,F.section,F.knowledgeType,F.depth.toString(),"tree-aware")),M=E.map(F=>`${F.treeIndex.source} (${F.knowledgeType}, ${F.treeIndex.totalTokens} tokens, ${F.treeIndex.nodeCount} nodes)`).join(", "),$=`Query type: ${w.queryType}, Diversity: ${w.diversityScore.toFixed(2)}, Total chunks: ${w.totalChunks}`;b=`<knowledge sources="${M}" method="tree-aware" metadata="${$}">
|
|
604
|
+
${S.join(`
|
|
605
|
+
|
|
606
|
+
`)}
|
|
607
|
+
</knowledge>`;const A=S.join(`
|
|
608
|
+
|
|
609
|
+
`),_=Ye(A);v={context:A,tokens:_,utilization:T>0?_/T:0,sources:E.map(F=>({name:F.treeIndex.source,type:F.treeIndex.sourceType,totalTokens:F.treeIndex.totalTokens,indexedNodes:F.treeIndex.nodeCount})),navigation:{selections:[]},compression:{originalTokens:w.totalChunks>0?E.reduce((F,B)=>F+B.treeIndex.totalTokens,0):0,compressedTokens:_,ratio:T>0?_/Math.max(1,E.reduce((F,B)=>F+B.treeIndex.totalTokens,0)):1,removals:{duplicates:0,filler:0,codeComments:0}},indexes:E.map(F=>F.treeIndex),timing:{indexMs:0,navigationMs:0,compressionMs:w.retrievalMs,totalMs:w.retrievalMs}},v&&(k=Df(v,n)),w.collapseWarning&&d.addEvent(i,{kind:"error",errorMessage:`Low diversity score (${w.diversityScore.toFixed(2)}) - chunks may be too similar`,durationMs:0})}}catch(S){const M=S instanceof Error?S.message:"Unknown error";d.addEvent(i,{kind:"error",errorMessage:`Tree-aware retrieval failed: ${M} — falling back to pipeline`,durationMs:0})}}if(j.length>0&&(f!=="tree-aware"||!b)){const T=x.reduce((O,K)=>O+K.baseTokens,0),E=new Map;for(const O of n)E.set(O.name,O.depth);const S=j.map(O=>({name:O.name,knowledgeType:O.sourceType,rawTokens:Ye(O.content||""),depthMultiplier:j_[E.get(O.name)??2]??1})),M=T_(S,T),$=new Map;for(const O of M)$.set(O.name,O.allocatedTokens);for(const O of j){const V=($.get(O.name)??T)*4;O.content&&O.content.length>V&&(O.content=O.content.slice(0,V))}const A=f==="agent-driven",_=Q6({task:p,sources:j,tokenBudget:T});d.addEvent(i,{kind:"retrieval",sourceName:"pipeline:index",query:p,resultCount:_.indexes.length,durationMs:_.indexMs});let F="",B=x.filter(O=>O.path&&l.getIndex(O.path)!=null||O.content).map(O=>({nodeId:O.name,depth:O.depth,priority:O.knowledgeType==="ground-truth"?0:O.knowledgeType==="signal"?1:2}));if(A&&_.indexes.length>0){const O=Date.now();try{let K=p;if(U6(p))try{const D=H6(p),U=await Nc(D,h,g);U.length>20&&(K=U,d.addEvent(i,{kind:"llm_call",model:g,durationMs:Date.now()-O,toolResult:`HyDE generated ${U.length} chars for navigation`}))}catch(D){d.addEvent(i,{kind:"error",errorMessage:`HyDE failed: ${D instanceof Error?D.message:"Unknown"} — using original query`,durationMs:0})}const V=_.indexes.map(xm),P=bm(V,{task:K,tokenBudget:T});F=await Nc(P,h,g);const N=qc(F);N.length>0&&(B=N),d.addEvent(i,{kind:"llm_call",model:g,durationMs:Date.now()-O,toolResult:`Agent selected ${N.length} branches`})}catch(K){d.addEvent(i,{kind:"error",errorMessage:`Navigation failed: ${K instanceof Error?K.message:"Unknown"} — using manual depths`,durationMs:Date.now()-O})}}v=Xx(_.indexes,F,{task:p,sources:j,tokenBudget:T,manualSelections:F?void 0:B,compression:{enabled:!0,aggressiveness:.5}},_.indexMs),d.addEvent(i,{kind:"retrieval",sourceName:"pipeline:compress",resultCount:v.sources.length,durationMs:v.timing.compressionMs});const G=qc(F);if(A&&G.length>0&&v.context.trim())try{const O=B6(p,v.context),K=await Nc(O,h,g),V=P6(K);if(V.length>0){const P=await jD(V,_.indexes,G,{providerId:h,model:g,totalBudget:T},i);if(P.length>0){const N=[...G,...P],D=JSON.stringify(N);v=Xx(_.indexes,D,{task:p,sources:j,tokenBudget:T,manualSelections:void 0,compression:{enabled:!0,aggressiveness:.5}},_.indexMs),d.addEvent(i,{kind:"retrieval",sourceName:"pipeline:re-navigation",resultCount:P.length,durationMs:0})}}}catch(O){d.addEvent(i,{kind:"error",errorMessage:`Corrective re-navigation failed: ${O instanceof Error?O.message:"Unknown"}`,durationMs:0})}if(v.context.trim()){const O=CD(v,n,p);b=O.knowledgeBlock,k=O.provenance}else v&&(k=Df(v,n))}return b||(b=ED(e)),k&&d.addEvent(i,{kind:"provenance",provenanceSources:k.sources.map(T=>({path:T.path,type:T.type,sections:T.sections,depth:T.depth,chunkCount:T.chunkCount||0})),provenanceDerivations:k.derivations,resultCount:k.sources.length}),{knowledgeBlock:b,pipelineResult:v,provenance:k,retrievalResult:w}}function Xv(){const e=[],n=Xe.getState();for(const s of n.servers)if(s.status==="connected")for(const i of s.tools)e.push({name:i.name,description:i.description||"No description",inputSchema:i.inputSchema||{type:"object",properties:{}},origin:{kind:"mcp",serverId:s.id,serverName:s.name}});const a=new Map;for(const s of e)a.set(s.name,(a.get(s.name)??0)+1);return e.map(s=>(a.get(s.name)??0)>1&&s.origin.kind==="mcp"?{...s,name:`${s.origin.serverId}__${s.name}`}:s)}function Zv(e){return e==="anthropic"||e==="openai"||e==="openrouter"}function TD(e){return e.map(n=>({name:n.name,description:n.description,input_schema:n.inputSchema}))}function ND(e){return e.map(n=>({type:"function",function:{name:n.name,description:n.description,parameters:n.inputSchema}}))}function AD(e,n){const a=e.find(i=>i.name===n);if(a)return a.origin;const s=n.includes("__")?n.split("__").slice(1).join("__"):null;return s?e.find(i=>i.name===s)?.origin??null:null}async function _D(e,n,a){const s=AD(a,e);if(!s)return{result:"",serverId:"",error:`Tool "${e}" not found in registry`};const i=Xe.getState();try{const l=await i.callTool(s.serverId,e,n);if(l==null)return e==="get_file_contents"?{result:"No content returned. This path may be a directory - use list_directory first, or check the file tree in your context.",serverId:s.serverId}:{result:"Tool returned no result. Check arguments.",serverId:s.serverId};let d;return l&&typeof l=="object"&&"content"in l?(d=l.content.filter(f=>f.type==="text"&&f.text).map(f=>f.text).join(`
|
|
610
|
+
`),d||(d=JSON.stringify(l))):d=typeof l=="string"?l:JSON.stringify(l),{result:d,serverId:s.serverId}}catch(l){const d=l instanceof Error?l.message:String(l);return{result:"",serverId:s.serverId,error:d}}}async function DD(e,n,a,s){const d=Je.getState().providers.find(g=>g.id===e)?.type??"openai",p=d==="anthropic"?TD(s):ND(s),f=await fetch(`${Ae}/llm/chat-tools`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,model:n,messages:a,tools:p})});if(!f.ok){const g=await f.text().catch(()=>"");throw new Error(`LLM tool call failed (${f.status}): ${g||f.statusText}`)}const h=await f.json();return d==="anthropic"?zD(h):RD(h)}function zD(e){const n=e.content??[],a=e.usage,s=e.stop_reason??"end_turn",i=n.filter(d=>d.type==="text").map(d=>d.text??""),l=n.filter(d=>d.type==="tool_use");return{content:i.join(""),toolCalls:l.map(d=>({id:d.id??`tc-${Date.now()}`,name:d.name??"",args:d.input??{}})),inputTokens:a?.input_tokens??0,outputTokens:a?.output_tokens??0,rawAssistantMessage:{role:"assistant",content:n},stopReason:s}}function RD(e){const n=e.choices??[],a=e.usage,s=n[0]?.message,i=n[0]?.finish_reason??"stop";return{content:s?.content??"",toolCalls:(s?.tool_calls??[]).map(l=>{let d={};try{d=JSON.parse(l.function.arguments)}catch{d={_raw:l.function.arguments,_parseError:!0}}return{id:l.id,name:l.function.name,args:d}}),inputTokens:a?.prompt_tokens??0,outputTokens:a?.completion_tokens??0,rawAssistantMessage:{role:"assistant",...s},stopReason:i}}function OD(e,n){return e==="anthropic"?[{role:"user",content:n.map(a=>({type:"tool_result",tool_use_id:a.id,content:a.error?`Error: ${a.error}`:a.result,...a.error?{is_error:!0}:{}}))}]:n.map(a=>({role:"tool",tool_call_id:a.id,content:a.error?`Error: ${a.error}`:a.result}))}async function $D(e){const{providerId:n,model:a,messages:s,traceId:i,maxTurns:l=10,callbacks:d}=e,p=fn.getState(),g=Je.getState().providers.find(j=>j.id===n)?.type??"openai",x=Xv(),b=[];let v=0,k=0;const w=[...s];if(x.length===0||!Zv(g)){d.onError(new Error("No tools available or provider does not support tool calling"));return}try{for(let j=0;j<l;j++){const T=Date.now(),E=await DD(n,a,w,x);if(v+=E.inputTokens,k+=E.outputTokens,p.addEvent(i,{kind:"llm_call",model:a,inputTokens:E.inputTokens,outputTokens:E.outputTokens,durationMs:Date.now()-T}),E.content&&d.onChunk(E.content),E.toolCalls.length===0){d.onDone({turns:j+1,toolCalls:b,totalInputTokens:v,totalOutputTokens:k});return}w.push(E.rawAssistantMessage);const S=[];for(const $ of E.toolCalls){d.onToolCallStart($.name,$.args);const A=Date.now(),_=await _D($.name,$.args,x),F=Date.now()-A,B={id:$.id,name:$.name,args:$.args,result:_.result,error:_.error,durationMs:F,serverId:_.serverId};S.push(B),b.push(B),p.addEvent(i,{kind:"tool_call",toolName:$.name,toolArgs:$.args,toolResult:(_.error||_.result).slice(0,500),toolError:_.error,mcpServerId:_.serverId,durationMs:F}),d.onToolCallEnd(B)}const M=OD(g,S);w.push(...M)}d.onDone({turns:l,toolCalls:b,totalInputTokens:v,totalOutputTokens:k})}catch(j){d.onError(j instanceof Error?j:new Error(String(j)))}}async function FD(e){const{providerId:n,model:a,messages:s,userMessage:i,systemPrompt:l,traceId:d,onChunk:p}=e,f=fn.getState(),h=Xv(),b=Je.getState().providers.find(T=>T.id===n)?.type??"openai",v=h.length>0&&Zv(b)&&n!=="claude-agent-sdk";let k=[],w=0,j="";if(v){const T=Date.now();f.addEvent(d,{kind:"llm_call",model:a,inputTokens:s.reduce((E,S)=>E+Ye(typeof S.content=="string"?S.content:JSON.stringify(S.content)),0)}),await new Promise((E,S)=>{$D({providerId:n,model:a,messages:s,traceId:d,maxTurns:10,callbacks:{onChunk:M=>{j+=M,p(M)},onToolCallStart:(M,$)=>{p(`
|
|
611
|
+
|
|
612
|
+
🔧 Calling **${M}**...
|
|
613
|
+
`)},onToolCallEnd:M=>{M.error?p(`❌ ${M.name} failed: ${M.error}
|
|
614
|
+
`):p(`✅ ${M.name} (${M.durationMs}ms)
|
|
615
|
+
`)},onDone:M=>{k=M.toolCalls,w=M.turns,f.addEvent(d,{kind:"llm_call",model:a,outputTokens:M.totalOutputTokens,durationMs:Date.now()-T}),E()},onError:M=>S(M)}})})}else{const T=Date.now();f.addEvent(d,{kind:"llm_call",model:a,inputTokens:s.reduce((S,M)=>S+Ye(typeof M.content=="string"?M.content:JSON.stringify(M.content)),0)});let E="";await new Promise((S,M)=>{const $={onChunk:A=>{E+=A,j+=A,p(A)},onDone:()=>{f.addEvent(d,{kind:"llm_call",model:a,outputTokens:Ye(E),durationMs:Date.now()-T}),S()},onError:A=>M(A)};n==="claude-agent-sdk"?ib({prompt:i,model:a,systemPrompt:l,...$}):lb({providerId:n,model:a,messages:s,...$})})}return{fullResponse:j,toolCallResults:k,toolTurns:w}}async function ID(e){const{fullResponse:n,userMessage:a,agentId:s,sandboxRunId:i,traceId:l,activeChannels:d,memoryStats:p}=e,f=fn.getState(),h=We.getState();let g=p;if(h.longTerm.enabled&&n){const v=b6({userMessage:a,assistantResponse:n,agentId:s,traceId:l,sandboxRunId:i});g&&(g={...g,writtenFacts:v.stored.length,writeMs:v.durationMs,domains:v.stored.length>0?[...new Set([...g.domains,...v.stored.map(k=>k.domain)])]:g.domains})}f.endTrace(l);const x=[],b=wn.getState();for(const v of d){let k=function(E){E.depth>0&&E.depth<=2&&j.push({nodeId:E.nodeId,title:E.title,depth:E.depth,tokens:E.totalTokens});for(const S of E.children)k(S)},w=v.path?b.getIndex(v.path):null;if(!w&&v.content){const E=`content://${v.contentSourceId||v.sourceId}`;w=Vs(E,v.content)}if(!w)continue;const j=[];k(w.root);const T=ki(w,v.depth);x.push({name:v.name,path:v.path||`content://${v.contentSourceId||v.sourceId}`,nodeCount:w.nodeCount,totalTokens:w.totalTokens,filteredTokens:T.totalTokens,depth:v.depth,knowledgeType:v.knowledgeType,headings:j})}return{heatmap:x,memoryStats:g}}function Rf(){const{agentConfig:e}=re.getState(),{selectedProviderId:n,providers:a}=Je.getState(),s=a.find(d=>d.id===n),i=Array.isArray(s?.models)?s.models:[];if(!s||s.status!=="connected"&&s.status!=="configured"||i.length===0)return{providerId:"",model:"",error:"No provider/model configured. Open Settings → Providers, connect one provider, refresh models, then retry."};const l=i.some(d=>d.id===e.model);return{providerId:s.id,model:l?e.model:i[0].id}}async function LD(e){const{userMessage:n,channels:a,history:s,providerId:i,model:l,onChunk:d,onDone:p,onError:f}=e,h=fn.getState(),x=Ra.getState().currentVersion||"0.0.0",b=h.startTrace(`chat-${Date.now()}`,x);try{let v=ii();const k=a.filter(Z=>Z.enabled),{frameworkBlock:w,frameworkSummary:j,regularChannels:T,residualKnowledgeBlock:E}=k.length>0?await Uv(k,b):{frameworkBlock:"",frameworkSummary:void 0,regularChannels:[],residualKnowledgeBlock:""};let{knowledgeBlock:S,pipelineResult:M,provenance:$,retrievalResult:A}=k.length>0?await Wv(a,T,E,{userMessage:n,navigationMode:e.navigationMode,providerId:i,model:l},b):{knowledgeBlock:"",pipelineResult:null,provenance:null,retrievalResult:void 0};const _=(e.connectors||[]).filter(Z=>Z.enabled&&Z.direction!=="write");if(_.length>0){const ae=`<connectors>
|
|
616
|
+
Available data connectors (use via MCP tools):
|
|
617
|
+
${_.map(pe=>{const me=pe.hint?` (scope: ${pe.hint})`:"";return`- ${pe.name} [${pe.service}] — ${pe.direction}${me}`}).join(`
|
|
618
|
+
`)}
|
|
619
|
+
</connectors>`;S=S?`${S}
|
|
620
|
+
|
|
621
|
+
${ae}`:ae}const F=We.getState();let B="",G;if(F.longTerm.enabled){F.sandbox.isolation==="reset_each_run"&&v6();const Z=await Pv({userMessage:n,agentId:e.agentId,traceId:b,sandboxRunId:e.sandboxRunId});Z.contextBlock&&(B=Z.contextBlock),G={recalledFacts:Z.facts.length,writtenFacts:0,recallMs:Z.durationMs,writeMs:0,recallTokens:Z.tokenEstimate,domains:[...new Set(Z.facts.map(ae=>ae.domain))]}}$&&(v=ii($));const O=wv(a,wn.getState().getIndex),K=a.some(Z=>Z.enabled&&Z.repoMeta),V=Sv({frame:v,orientationBlock:O,hasRepos:K,knowledgeFormatGuide:Hv(),frameworkBlock:w,memoryBlock:B,knowledgeBlock:S}),P=Ye(V),N=[{role:"system",content:V},...s.map(Z=>({role:Z.role,content:Z.content})),{role:"user",content:n}],{fullResponse:D,toolCallResults:U,toolTurns:q}=await FD({providerId:i,model:l,messages:N,userMessage:n,systemPrompt:V,traceId:b,onChunk:d}),{heatmap:W,memoryStats:oe}=await ID({fullResponse:D,userMessage:n,agentId:e.agentId,sandboxRunId:e.sandboxRunId,traceId:b,activeChannels:k,memoryStats:G}),I=P+s.reduce((Z,ae)=>Z+Ye(ae.content),0)+Ye(n),L=A?{queryType:A.queryType,diversityScore:A.diversityScore,collapseWarning:A.collapseWarning,totalChunks:A.totalChunks,selectedChunks:A.chunks.length,budgetUsed:A.budgetUsed,budgetTotal:A.budgetTotal,retrievalMs:A.retrievalMs,embeddingMs:A.embeddingMs,chunks:A.chunks.map(Z=>({section:Z.section,source:Z.source,relevanceScore:Z.relevanceScore||0,inclusionReason:Z.inclusionReason||"unknown",knowledgeType:Z.knowledgeType,tokens:Ye(Z.content)}))}:void 0;p({pipeline:M,systemTokens:P,totalContextTokens:I,heatmap:W,frameworkSummary:j,toolCalls:U.length>0?U:void 0,toolTurns:q>0?q:void 0,memory:oe,retrieval:L})}catch(v){h.addEvent(b,{kind:"error",errorMessage:v instanceof Error?v.message:"Unknown error"}),h.endTrace(b),f(v instanceof Error?v:new Error("Unknown error"))}}const eb={llm_call:{icon:_i,color:"#9b59b6",label:"LLM Call"},tool_call:{icon:pn,color:"#2ecc71",label:"Tool Call"},retrieval:{icon:Ri,color:"#3498db",label:"Retrieval"},error:{icon:pv,color:"#e74c3c",label:"Error"},token_usage:{icon:zi,color:"#f1c40f",label:"Tokens"},fact_extracted:{icon:Ef,color:"#FE5000",label:"Fact"},handoff:{icon:ZT,color:"#1abc9c",label:"Handoff"}};function BD({event:e}){const n=we(),[a,s]=z.useState(!1),i=eb[e.kind]||eb.error,l=i.icon,d=e.toolArgs||e.toolResult||e.toolError||e.errorStack||e.pageRefs;return c.jsxs("div",{style:{borderBottom:`1px solid ${n.isDark?"#1a1a1e":"#f0f0f5"}`},children:[c.jsxs("button",{type:"button",onClick:()=>d&&s(!a),className:"flex items-center gap-2 w-full px-3 py-2 border-none bg-transparent text-left",style:{cursor:d?"pointer":"default"},children:[c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:e.toolError||e.errorMessage?"#e74c3c":i.color,flexShrink:0}}),c.jsx(l,{size:10,style:{color:i.color,flexShrink:0}}),c.jsxs("span",{className:"text-[12px] flex-1 truncate",style:{fontFamily:"'Geist Sans', sans-serif",color:n.textPrimary},children:[e.kind==="tool_call"&&`${e.mcpServerName||e.mcpServerId}.${e.toolName}`,e.kind==="llm_call"&&`${e.model||"LLM"} — ${e.inputTokens||"?"}→${e.outputTokens||"?"} tokens`,e.kind==="retrieval"&&`${e.sourceName||e.sourceId} (${e.resultCount||0} results)`,e.kind==="error"&&(e.rootCause||e.errorMessage||"Unknown error"),e.kind==="fact_extracted"&&"Fact extracted from conversation",e.kind==="handoff"&&`→ ${e.toAgentId}`,e.kind==="token_usage"&&`${(e.inputTokens||0)+(e.outputTokens||0)} tokens`]}),e.durationMs!=null&&c.jsxs("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:e.durationMs>2e3?"#e74c3c":n.textFaint},children:[e.durationMs,"ms"]}),e.costUsd!=null&&e.costUsd>0&&c.jsxs("span",{className:"text-[12px] shrink-0",style:{fontFamily:"'Geist Mono', monospace",color:n.textFaint},children:["$",e.costUsd.toFixed(4)]}),d&&(a?c.jsx(Ln,{size:9,style:{color:n.textFaint}}):c.jsx(Ba,{size:9,style:{color:n.textFaint}}))]}),a&&c.jsxs("div",{className:"px-3 pb-2 ml-6 text-[13px] flex flex-col gap-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim},children:[e.toolArgs&&c.jsxs("div",{children:[c.jsx("span",{style:{color:n.textFaint},children:"Args:"}),c.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e.toolArgs,null,2).slice(0,500)})]}),e.toolResult&&c.jsxs("div",{children:[c.jsx("span",{style:{color:n.textFaint},children:"Result:"}),c.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e.toolResult.slice(0,500)})]}),e.toolError&&c.jsxs("div",{style:{color:"#e74c3c"},children:[c.jsx("span",{style:{color:"#e74c3c99"},children:"Error:"})," ",e.toolError]}),e.rootCause&&c.jsxs("div",{style:{color:"#e74c3c"},children:[c.jsx("span",{style:{color:"#e74c3c99"},children:"Root cause:"})," ",e.rootCause]}),e.pageRefs&&e.pageRefs.length>0&&c.jsxs("div",{children:[c.jsx("span",{style:{color:n.textFaint},children:"Page refs:"})," ",e.pageRefs.join(", ")]}),e.errorStack&&c.jsxs("details",{children:[c.jsx("summary",{style:{cursor:"pointer",color:n.textFaint},children:"Stack trace"}),c.jsx("pre",{className:"mt-0.5 p-1.5 rounded overflow-x-auto",style:{background:n.isDark?"#0d0d10":"#f5f5fa",margin:0,fontSize:"8px"},children:e.errorStack})]})]})]})}function PD({trace:e}){const n=we(),a=e.summary;return a?c.jsxs("div",{className:"flex gap-3 px-3 py-1.5 text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:n.textDim,borderBottom:`1px solid ${n.isDark?"#1a1a1e":"#f0f0f5"}`},children:[c.jsxs("span",{children:[a.totalTokens.toLocaleString()," tokens"]}),a.totalCostUsd>0&&c.jsxs("span",{children:["$",a.totalCostUsd.toFixed(4)]}),c.jsxs("span",{children:[a.toolCalls," tools"]}),a.toolErrors>0&&c.jsxs("span",{style:{color:"#e74c3c"},children:[a.toolErrors," errors"]}),c.jsxs("span",{children:[a.retrievals," retrievals"]}),c.jsxs("span",{children:[(a.durationMs/1e3).toFixed(1),"s"]})]}):null}function HD(){const e=we(),n=fn(d=>d.traces),a=fn(d=>d.clearTraces),[s,i]=z.useState(null),l=s?n.find(d=>d.id===s):n[n.length-1];return n.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center py-8 gap-2",children:[c.jsx(Ef,{size:20,style:{color:e.textFaint}}),c.jsx("div",{className:"text-[13px]",style:{color:e.textDim},children:"No traces yet"}),c.jsx("div",{className:"text-[13px] text-center px-4",style:{color:e.textFaint},children:"Run a conversation to capture execution traces — tool calls, retrievals, errors, and token usage."})]}):c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:`1px solid ${e.isDark?"#1e1e22":"#e8e8ec"}`},children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ef,{size:11,style:{color:"#FE5000"}}),c.jsx("span",{className:"text-[12px] uppercase tracking-wider font-bold",style:{fontFamily:"'Geist Mono', monospace",color:e.textPrimary},children:"Traces"}),c.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded-full",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:n.length})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[n.length>1&&c.jsx("select",{value:l?.id||"",onChange:d=>i(d.target.value),className:"text-[13px] px-1 py-0.5 rounded border-none outline-none cursor-pointer",style:{background:e.surfaceElevated,color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:n.map((d,p)=>c.jsxs("option",{value:d.id,children:["Run #",p+1," (",d.events.length," events)"]},d.id))}),c.jsx("button",{type:"button","aria-label":"Clear traces",onClick:a,className:"p-2.5 border-none bg-transparent cursor-pointer rounded min-w-[44px] min-h-[44px] flex items-center justify-center",style:{color:e.textFaint},children:c.jsx(Tt,{size:10})})]})]}),l&&c.jsx(PD,{trace:l}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:l?.events.map(d=>c.jsx(BD,{event:d},d.id))})]})}const UD={toolCalling:"Tool Calling",streaming:"Streaming",structuredOutput:"Structured Output",memoryHooks:"Memory Hooks",agentLoop:"Agent Loop",mcpBridge:"MCP Bridge"},yt="supported",dn="degraded",Zr="unsupported",vc={anthropic:{toolCalling:{status:yt},streaming:{status:yt},structuredOutput:{status:yt},memoryHooks:{status:yt},agentLoop:{status:yt},mcpBridge:{status:yt}},"claude-agent-sdk":{toolCalling:{status:yt},streaming:{status:yt},structuredOutput:{status:yt},memoryHooks:{status:yt},agentLoop:{status:yt},mcpBridge:{status:yt}},openai:{toolCalling:{status:yt},streaming:{status:yt},structuredOutput:{status:yt},memoryHooks:{status:dn,note:"Requires external memory layer"},agentLoop:{status:yt},mcpBridge:{status:dn,note:"Via OpenAI-compatible proxy"}},google:{toolCalling:{status:yt},streaming:{status:yt},structuredOutput:{status:dn,note:"JSON mode only, no strict schema"},memoryHooks:{status:Zr,note:"Not natively supported"},agentLoop:{status:dn,note:"Manual orchestration required"},mcpBridge:{status:Zr,note:"No MCP support"}},openrouter:{toolCalling:{status:dn,note:"Depends on underlying model"},streaming:{status:yt},structuredOutput:{status:dn,note:"Depends on underlying model"},memoryHooks:{status:dn,note:"Depends on underlying model"},agentLoop:{status:dn,note:"Depends on underlying model"},mcpBridge:{status:Zr,note:"Not available through proxy"}},custom:{toolCalling:{status:dn,note:"Depends on implementation"},streaming:{status:dn,note:"Depends on implementation"},structuredOutput:{status:dn,note:"Depends on implementation"},memoryHooks:{status:Zr,note:"Unknown provider"},agentLoop:{status:dn,note:"Depends on implementation"},mcpBridge:{status:Zr,note:"Unknown provider"}}};function GD(e){return vc[e]?vc[e]:(e.startsWith("custom"),vc.custom)}function qD(e,n){const a=[];for(const s of n){const i=e[s],l=UD[s];i.status==="unsupported"?a.push({level:"error",capability:s,message:`${l} is not supported by this provider${i.note?`: ${i.note}`:""}`}):i.status==="degraded"?a.push({level:"warning",capability:s,message:`${l} has limited support${i.note?`: ${i.note}`:""}`}):a.push({level:"ok",capability:s,message:`${l} is fully supported`})}return a}function KD({matrix:e,requiredCapabilities:n}){const a=we();if(n.length===0)return null;const s=qD(e,n),i=s.filter(d=>d.level==="error"),l=s.filter(d=>d.level==="warning");return i.length===0&&l.length===0?null:c.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.map(d=>c.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:a.statusErrorBg,color:a.statusError,border:`1px solid ${a.statusError}30`},role:"alert",children:[c.jsx(xi,{size:12,className:"shrink-0 mt-0.5"}),c.jsx("span",{children:d.message})]},d.capability)),l.map(d=>c.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg text-[12px]",style:{background:a.statusWarningBg,color:a.statusWarning,border:`1px solid ${a.statusWarning}30`},role:"status",children:[c.jsx(pv,{size:12,className:"shrink-0 mt-0.5"}),c.jsx("span",{children:d.message})]},d.capability))]})}function YD(){return`run-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const tb={id:"",status:"idle",agents:[],sharedFacts:[],contractFacts:[]},Ut=qt(e=>({...tb,startRun:(n,a,s)=>e({id:YD(),teamId:a,featureSpec:s,status:"running",agents:n.map(i=>({agentId:i.agentId,name:i.name,status:"waiting",turns:0,facts:[],toolCalls:[],isAgentSdk:i.isAgentSdk})),sharedFacts:[],contractFacts:[],startedAt:Date.now(),completedAt:void 0,error:void 0}),updateAgent:(n,a)=>e(s=>({agents:s.agents.map(i=>i.agentId===n?{...i,...a}:i)})),addFact:(n,a)=>e(s=>a==="shared"?{sharedFacts:[...s.sharedFacts,n]}:a==="contract"?{contractFacts:[...s.contractFacts,n]}:{agents:s.agents.map(i=>i.agentId===a.agentId?{...i,facts:[...i.facts,n]}:i)}),setStatus:(n,a)=>e({status:n,error:a,completedAt:n==="completed"||n==="error"?Date.now():void 0}),reset:()=>e({...tb})})),VD={observation:"#3498db",inference:"#f1c40f",decision:"#2ecc71",hypothesis:"#9b59b6",contract:"#FE5000"};function Qv({fact:e}){const n=VD[e.epistemicType]??"#888";return c.jsx("span",{style:{fontSize:12,padding:"2px 6px",borderRadius:4,background:n+"15",color:n,fontFamily:"'Geist Mono', monospace"},children:e.key})}function WD({text:e}){const[n,a]=z.useState(!1);return c.jsx("button",{type:"button",onClick:()=>{navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)},style:{background:"none",border:"none",cursor:"pointer",padding:2,opacity:.6},title:"Copy output",children:n?c.jsx(jt,{size:12,style:{color:"#2ecc71"}}):c.jsx(X1,{size:12})})}function XD({agent:e,expanded:n}){const a=we(),[s,i]=z.useState(n??!1),l={waiting:c.jsx(wN,{size:14,style:{color:a.textDim}}),running:c.jsx(pt,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),completed:c.jsx(Hc,{size:14,style:{color:"#2ecc71"}}),error:c.jsx(xi,{size:14,style:{color:"#dc2626"}})}[e.status],d=e.status==="completed"?e.output:e.currentMessage,p=(d?.length??0)>300;return c.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${e.status==="running"?"#FE500040":a.border}`,background:e.status==="running"?"#FE500008":a.surface},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:d?8:0},children:[l,c.jsx("span",{style:{fontSize:14,fontWeight:600,color:a.textPrimary,fontFamily:"'Geist Mono', monospace"},children:e.name}),e.isAgentSdk&&c.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",fontWeight:600,border:"1px solid #FE500030"},children:"Agent SDK"}),c.jsxs("span",{style:{fontSize:12,color:a.textDim,marginLeft:"auto",display:"flex",alignItems:"center",gap:6},children:[e.status==="running"?`Turn ${e.turns}`:e.status,e.tokens&&(e.tokens.input>0||e.tokens.output>0)&&c.jsxs("span",{style:{fontSize:11,color:a.textFaint},children:[((e.tokens.input+e.tokens.output)/1e3).toFixed(1),"k tok"]})]})]}),d&&c.jsxs("div",{style:{position:"relative"},children:[c.jsx("div",{style:{fontSize:13,padding:10,borderRadius:6,background:a.inputBg,color:a.textPrimary,lineHeight:1.6,whiteSpace:"pre-wrap",overflowY:"auto",maxHeight:s?"none":200},children:d}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:4},children:[p&&c.jsx("button",{type:"button",onClick:()=>i(!s),style:{background:"none",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:12,color:"#FE5000",display:"flex",alignItems:"center",gap:4,fontFamily:"'Geist Mono', monospace"},children:s?c.jsxs(c.Fragment,{children:[c.jsx(Ln,{size:12})," Collapse"]}):c.jsxs(c.Fragment,{children:[c.jsx(Ba,{size:12})," Expand (",Math.ceil((d?.length??0)/1e3),"k chars)"]})}),d&&c.jsx(WD,{text:d})]})]}),e.toolCalls.length>0&&c.jsxs("div",{style:{marginTop:8},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[c.jsx(pn,{size:12,style:{color:"#2ecc71"}}),c.jsxs("span",{style:{fontSize:12,fontWeight:600,color:a.textSecondary,fontFamily:"'Geist Mono', monospace"},children:["Tool Calls (",e.toolCalls.length,")"]})]}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.toolCalls.map((f,h)=>c.jsxs("div",{style:{fontSize:12,padding:6,borderRadius:4,background:"#2ecc7115",border:"1px solid #2ecc7130",color:a.textSecondary,fontFamily:"'Geist Mono', monospace"},children:[c.jsx("div",{style:{fontWeight:600,color:"#2ecc71",marginBottom:2},children:f.tool}),f.args&&c.jsx("div",{style:{color:a.textDim,fontSize:11,lineHeight:1.4},children:f.args.length>100?f.args.slice(0,100)+"…":f.args})]},h))})]}),e.facts.length>0&&c.jsx("div",{style:{marginTop:8,display:"flex",flexWrap:"wrap",gap:4},children:e.facts.map((f,h)=>c.jsx(Qv,{fact:f},h))})]})}function ZD({facts:e}){const n=we();return e.length===0?null:c.jsxs("div",{style:{padding:12,borderRadius:8,border:`1px solid ${n.border}`,background:n.surface},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[c.jsx(Di,{size:14,style:{color:"#FE5000"}}),c.jsxs("span",{style:{fontSize:13,fontWeight:600,color:n.textPrimary,fontFamily:"'Geist Mono', monospace"},children:["Shared Memory (",e.length,")"]})]}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:e.map((a,s)=>c.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[c.jsx(Qv,{fact:a}),c.jsx("span",{style:{fontSize:12,color:n.textDim,flex:1},children:a.value})]},s))})]})}function QD(){const e=we(),n=Ut(x=>x.status),a=Ut(x=>x.agents),s=Ut(x=>x.sharedFacts),i=Ut(x=>x.startedAt),l=Ut(x=>x.completedAt),d=Ut(x=>x.error),[p,f]=z.useState(!1);if(n==="idle")return null;const h=l&&i?((l-i)/1e3).toFixed(1):i?((Date.now()-i)/1e3).toFixed(0):"0",g=c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,height:"100%"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[n==="running"&&c.jsx(pt,{size:14,className:"animate-spin",style:{color:"#FE5000"}}),n==="completed"&&c.jsx(Hc,{size:14,style:{color:"#2ecc71"}}),n==="error"&&c.jsx(xi,{size:14,style:{color:"#dc2626"}}),c.jsx("span",{style:{fontSize:13,fontWeight:600,color:e.textPrimary},children:n==="running"?"Running...":n==="completed"?"Completed":"Error"}),c.jsxs("span",{style:{fontSize:12,color:e.textDim},children:[h,"s"]}),c.jsx("button",{type:"button",onClick:()=>f(!p),style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",padding:4,color:e.textDim},title:p?"Minimize":"Maximize results",children:p?c.jsx(ov,{size:14}):c.jsx(N3,{size:14})})]}),d&&c.jsx("div",{style:{fontSize:13,color:"#dc2626",padding:8,borderRadius:6,background:"#dc262610"},children:d}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,flex:1,overflowY:"auto"},children:a.map(x=>c.jsx(XD,{agent:x,expanded:p},x.agentId))}),c.jsx(ZD,{facts:s})]});return p?c.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:e.bg,padding:24,overflowY:"auto"},children:g}):g}function JD({retrieval:e}){const n=we();if(!e)return null;const a=new Map;for(const p of e.chunks){const f=a.get(p.source)||[];f.push(p),a.set(p.source,f)}const s=p=>({"ground-truth":"#e74c3c",signal:"#f1c40f",evidence:"#3498db",framework:"#2ecc71",guideline:"#FE5000",hypothesis:"#9b59b6"})[p]||n.textDim,i=p=>{const f={direct:{background:"#2ecc71",color:"#fff"},"parent-expansion":{background:"#f1c40f",color:"#333"},"sibling-coherence":{background:"#3498db",color:"#fff"},unknown:{background:n.border,color:n.textDim}};return f[p]||f.unknown},l=p=>({direct:"●","parent-expansion":"↑","sibling-coherence":"↔",unknown:"?"})[p]||"?",d=Array.from(a.keys());return c.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 2fr 1fr",gap:12,padding:12,fontFamily:"'Geist Sans', sans-serif",fontSize:12},children:[c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:10,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",fontWeight:"bold",marginBottom:8,color:"#FE5000"},children:"Sources"}),d.map((p,f)=>{const h=a.get(p)||[],g=h.reduce((b,v)=>b+v.tokens,0),x=h[0]?.knowledgeType||"signal";return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",borderBottom:f<d.length-1?`1px solid ${n.border}20`:"none"},children:[c.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:s(x),flexShrink:0}}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:11,fontWeight:500,color:n.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.split("/").pop()||p}),c.jsxs("div",{style:{fontSize:9,color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:[g.toLocaleString()," tokens"]})]})]},f)})]}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:10,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",fontWeight:"bold",marginBottom:8,color:"#3498db"},children:"Chunks"}),d.map((p,f)=>{const h=a.get(p)||[];return c.jsxs("div",{style:{padding:"4px 0",borderBottom:f<d.length-1?`1px solid ${n.border}20`:"none"},children:[c.jsxs("div",{style:{fontSize:11,fontWeight:500,color:n.textPrimary,marginBottom:2},children:[h.length," chunks"]}),c.jsx("div",{style:{fontSize:9,color:n.textDim,display:"flex",flexWrap:"wrap",gap:4},children:Object.entries(h.reduce((g,x)=>{const b=x.inclusionReason||"unknown";return g[b]=(g[b]||0)+1,g},{})).map(([g,x])=>c.jsxs("span",{style:{fontSize:8,padding:"1px 3px",borderRadius:2,...i(g)},children:[l(g)," ",x]},g))})]},f)})]}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:10,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",fontWeight:"bold",marginBottom:8,color:"#2ecc71"},children:"Retrieved"}),c.jsx("div",{style:{maxHeight:200,overflowY:"auto"},children:e.chunks.sort((p,f)=>f.relevanceScore-p.relevanceScore).map((p,f)=>c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 0",borderBottom:f<e.chunks.length-1?`1px solid ${n.border}10`:"none"},children:[c.jsx("div",{style:{width:24,height:3,borderRadius:1,background:"#333",overflow:"hidden",flexShrink:0},children:c.jsx("div",{style:{width:`${p.relevanceScore*100}%`,height:"100%",background:"#2ecc71"}})}),c.jsxs("span",{style:{fontSize:10,width:24,textAlign:"right",color:n.textDim,fontFamily:"'Geist Mono', monospace",flexShrink:0},children:[(p.relevanceScore*100).toFixed(0),"%"]}),c.jsx("span",{style:{fontSize:11,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:n.textPrimary},children:p.section}),c.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:s(p.knowledgeType),flexShrink:0}}),c.jsx("span",{style:{fontSize:8,padding:"1px 4px",borderRadius:2,flexShrink:0,...i(p.inclusionReason)},children:l(p.inclusionReason)}),c.jsx("span",{style:{fontSize:9,color:n.textFaint,fontFamily:"'Geist Mono', monospace",width:32,textAlign:"right",flexShrink:0},children:p.tokens})]},f))})]}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:10,fontFamily:"'Geist Mono', monospace",textTransform:"uppercase",fontWeight:"bold",marginBottom:8,color:"#f1c40f"},children:"Context"}),c.jsxs("div",{style:{marginBottom:8},children:[c.jsx("div",{style:{fontSize:11,fontWeight:500,color:n.textPrimary,marginBottom:2},children:"Budget"}),c.jsxs("div",{style:{fontSize:10,color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:[e.budgetUsed.toLocaleString()," / ",e.budgetTotal.toLocaleString()]}),c.jsx("div",{style:{width:"100%",height:3,borderRadius:1,background:"#333",overflow:"hidden",marginTop:2},children:c.jsx("div",{style:{width:`${Math.min(100,e.budgetUsed/e.budgetTotal*100)}%`,height:"100%",background:e.budgetUsed>e.budgetTotal?"#e74c3c":"#f1c40f"}})})]}),c.jsxs("div",{style:{marginBottom:8},children:[c.jsx("div",{style:{fontSize:11,fontWeight:500,color:n.textPrimary,marginBottom:2},children:"Diversity"}),c.jsxs("div",{style:{fontSize:10,color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:[(e.diversityScore*100).toFixed(1),"%"]})]}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:11,fontWeight:500,color:n.textPrimary,marginBottom:2},children:"Timing"}),c.jsxs("div",{style:{fontSize:10,color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:["Embedding: ",e.embeddingMs,"ms"]}),c.jsxs("div",{style:{fontSize:10,color:n.textDim,fontFamily:"'Geist Mono', monospace"},children:["Retrieval: ",e.retrievalMs,"ms"]})]})]})]})}async function e8(e,n){const a=new TextDecoder;let s="";for(;;){const{done:i,value:l}=await e.read();if(i)break;s+=a.decode(l,{stream:!0});const d=s.split(`
|
|
622
|
+
`);s=d.pop()??"";for(const p of d){const f=p.trim();if(!f||!f.startsWith("data: "))continue;const h=f.slice(6);if(h==="[DONE]"||n(h))return}}}function nb(e){const n=new AbortController;Ut.getState().startRun(e.agents.map(i=>({agentId:i.agentId,name:i.name,isAgentSdk:e.isAgentSdk})),e.teamId);const s={teamId:e.teamId,systemPrompt:e.systemPrompt,task:e.task,providerId:e.providerId,model:e.model,agents:e.agents.map(i=>({agentId:i.agentId,name:i.name,systemPrompt:i.systemPrompt,rolePrompt:i.rolePrompt,repoUrl:i.repoUrl})),tools:e.tools};return fetch(`${Ae}/runtime/run-team`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s),signal:n.signal}).then(async i=>{if(!i.ok){const p=await i.text().catch(()=>"");throw new Error(`Runtime error ${i.status}: ${p||i.statusText}`)}const l=i.body?.getReader();if(!l)throw new Error("No response body");let d=!1;await e8(l,p=>{try{const f=JSON.parse(p);if(f.type==="error")return d=!0,Ut.getState().setStatus("error",f.error||"Runtime execution failed"),!0;t8(f)}catch{}}),!d&&Ut.getState().status!=="error"&&Ut.getState().setStatus("completed")}).catch(i=>{i instanceof DOMException&&i.name==="AbortError"||Ut.getState().setStatus("error",i instanceof Error?i.message:String(i))}),n}function t8(e){const n=Ut.getState();switch(e.type){case"start":e.isAgentSdk!==void 0&&n.agents.forEach(a=>{n.updateAgent(a.agentId,{isAgentSdk:e.isAgentSdk})});break;case"turn":e.agentId&&n.updateAgent(e.agentId,{status:"running",turns:e.turn??0,currentMessage:e.message,...e.tokens&&{tokens:e.tokens}});break;case"fact":e.fact&&(e.agentId&&n.addFact(e.fact,{agentId:e.agentId}),n.addFact(e.fact,"shared"));break;case"tool_call":if(e.agentId){const a=n.agents.find(s=>s.agentId===e.agentId);a&&n.updateAgent(e.agentId,{toolCalls:[...a.toolCalls,{tool:e.tool??"",args:e.args??""}]})}break;case"done":e.agentId&&n.updateAgent(e.agentId,{status:"completed",output:e.result,...e.tokens&&{tokens:e.tokens}});break}}function n8(){const e=we(),n=po(g=>g.lastPipelineStats),[a,s]=z.useState(!1);if(!n)return null;const i=n.pipeline,l=g=>g>=1e3?`${(g/1e3).toFixed(1)}K`:`${g}`,d=["#2ecc71","#3498db","#f1c40f","#e67e22","#999"],p=["Full","Detail","Summary","Headlines","Mention"],f=g=>g>.5?"#2ecc71":g>.3?"#f1c40f":"#e74c3c",h=g=>{switch(g){case"factual":return"#3498db";case"analytical":return"#e67e22";case"exploratory":return"#9b59b6";default:return e.textDim}};return c.jsxs("div",{style:{borderTop:`1px solid ${e.border}`},children:[n.retrieval&&c.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5",style:{fontFamily:"'Geist Mono', monospace",fontSize:11,borderBottom:`1px solid ${e.border}30`},children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{style:{color:e.textDim},children:"Diversity"}),c.jsx("div",{style:{width:40,height:4,borderRadius:2,background:"#333",overflow:"hidden"},children:c.jsx("div",{style:{width:`${n.retrieval.diversityScore*100}%`,height:"100%",background:f(n.retrieval.diversityScore),borderRadius:2}})}),c.jsxs("span",{style:{fontFamily:"'Geist Mono', monospace",color:f(n.retrieval.diversityScore),fontSize:11},children:[(n.retrieval.diversityScore*100).toFixed(0),"%"]})]}),c.jsxs("span",{style:{color:e.textDim},children:[n.retrieval.selectedChunks,"/",n.retrieval.totalChunks," chunks"]}),c.jsxs("span",{style:{color:e.textDim},children:["Budget ",Math.round(n.retrieval.budgetUsed/n.retrieval.budgetTotal*100),"%"]}),c.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:h(n.retrieval.queryType)+"15",color:h(n.retrieval.queryType)},children:n.retrieval.queryType}),c.jsxs("span",{style:{fontSize:11,color:e.textFaint,marginLeft:"auto"},children:[n.retrieval.embeddingMs+n.retrieval.retrievalMs,"ms"]}),n.retrieval.collapseWarning&&c.jsx("span",{style:{fontSize:11,color:"#e74c3c"},children:"⚠ Low diversity"})]}),c.jsxs("button",{type:"button",onClick:()=>s(!a),className:"flex items-center gap-3 px-4 py-1.5 text-[13px] w-full border-none cursor-pointer",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim,background:"transparent"},"aria-label":"Pipeline statistics","aria-expanded":a,children:[c.jsx(pn,{size:9,style:{color:"#FE5000",flexShrink:0}}),c.jsxs("span",{children:["ctx: ",l(n.totalContextTokens)]}),c.jsxs("span",{children:["sys: ",l(n.systemTokens)]}),i&&c.jsxs(c.Fragment,{children:[c.jsxs("span",{style:{color:i.compression.ratio<.8?"#2ecc71":e.textDim},children:["compress: ",Math.round((1-i.compression.ratio)*100),"%"]}),c.jsxs("span",{children:[i.sources.length," src"]}),c.jsxs("span",{children:[i.timing.totalMs,"ms"]})]}),c.jsx(Ln,{size:8,className:"ml-auto",style:{transform:a?"none":"rotate(-90deg)",transition:"transform 150ms"}})]}),a&&c.jsx("div",{children:n.retrieval?c.jsx(JD,{retrieval:n.retrieval}):n.heatmap.length>0&&c.jsx("div",{className:"px-4 pb-2 flex flex-col gap-2",children:n.heatmap.map(g=>c.jsxs("div",{children:[c.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[c.jsx("span",{className:"text-[12px] font-medium",style:{color:e.textPrimary},children:g.name}),c.jsx("span",{className:"text-[12px] px-1.5 py-0.5 rounded",style:{fontFamily:"'Geist Mono', monospace",background:d[g.depth]+"18",color:d[g.depth]},children:p[g.depth]}),c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:[l(g.filteredTokens),"/",l(g.totalTokens)]})]}),g.headings.length>0&&c.jsxs("div",{className:"flex flex-col gap-0.5 pl-2",children:[g.headings.slice(0,8).map(x=>{const b=Math.max(...g.headings.map(w=>w.tokens),1),v=Math.max(5,x.tokens/b*100),k=d[Math.min(x.depth,4)];return c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"text-[12px] truncate w-24 text-right",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:x.title}),c.jsx("div",{style:{flex:1,height:4,background:`${k}18`,borderRadius:2,overflow:"hidden"},children:c.jsx("div",{style:{width:`${v}%`,height:"100%",background:k,borderRadius:2}})}),c.jsx("span",{className:"text-[7px] w-6 text-right",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:l(x.tokens)})]},x.nodeId)}),g.headings.length>8&&c.jsxs("span",{className:"text-[12px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textFaint},children:["+",g.headings.length-8," more"]})]})]},g.path))})})]})}function o8(){const e=we(),n=po(M=>M.messages),a=po(M=>M.inputText),s=po(M=>M.setInputText),i=po(M=>M.streaming),l=po(M=>M.addMessage),d=po(M=>M.setStreaming),p=po(M=>M.updateLastAssistant),f=po(M=>M.setLastPipelineStats),h=re(M=>M.channels),g=re(M=>M.connectors),x=re(M=>M.mcpServers),b=re(M=>M.agentMeta),v=re(M=>M.navigationMode),k=(()=>{const M=["streaming"];return g.length>0&&M.push("toolCalling"),x.length>0&&M.push("mcpBridge"),M})(),w=Rf(),j=GD(w.providerId||"custom"),T=z.useRef(null);z.useEffect(()=>{const M=window.matchMedia("(prefers-reduced-motion: reduce)").matches;T.current?.scrollIntoView({behavior:M?"auto":"smooth"})},[n]);const E=z.useCallback(async()=>{if(!a.trim()||i)return;const M=a.trim();s(""),l({role:"user",content:M}),l({role:"assistant",content:""}),d(!0);let $="";try{const{providerId:A,model:_,error:F}=Rf();if(F){p(F),d(!1);return}await LD({userMessage:M,channels:h,connectors:g,history:n.map(B=>({role:B.role,content:B.content})),agentMeta:{name:b.name,description:b.description,avatar:b.avatar,tags:b.tags},providerId:A,model:_,navigationMode:v,onChunk:B=>{$+=B,p($)},onDone:B=>{f(B)},onError:B=>{p($+`
|
|
623
|
+
|
|
624
|
+
_Error: ${B.message}_`)}})}catch(A){p($+`
|
|
625
|
+
|
|
626
|
+
_Error: ${A instanceof Error?A.message:"Unknown error"}_`)}finally{d(!1)}},[a,i,n,h,g,b,v,s,l,d,p,f]),S=M=>{(M.metaKey||M.ctrlKey)&&M.key==="Enter"&&(M.preventDefault(),E())};return c.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[c.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 flex flex-col gap-3","aria-live":"polite","aria-relevant":"additions",children:[n.length===0&&c.jsx("div",{className:"flex-1 flex items-center justify-center text-[13px]",style:{color:e.textFaint},children:"Test your agent with a message"}),n.map(M=>c.jsx("div",{className:"max-w-[85%] px-3.5 py-2.5 rounded-xl text-[14px] leading-relaxed",style:{alignSelf:M.role==="user"?"flex-end":"flex-start",background:M.role==="user"?"#FE500015":e.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${M.role==="user"?"#FE500020":e.border}`,color:M.role==="user"?e.textPrimary:e.textSecondary,borderBottomRightRadius:M.role==="user"?4:12,borderBottomLeftRadius:M.role==="assistant"?4:12},children:M.content||(i&&M.role==="assistant"?"...":"")},M.id)),c.jsx("div",{ref:T})]}),k.length>0&&c.jsx("div",{className:"px-4 py-1.5",children:c.jsx(KD,{matrix:j,requiredCapabilities:k})}),c.jsx(n8,{}),c.jsxs("div",{className:"px-4 py-3 flex gap-2",style:{borderTop:`1px solid ${e.border}`},children:[c.jsx("input",{type:"text",value:a,onChange:M=>s(M.target.value),onKeyDown:S,placeholder:"Test your agent...","aria-label":"Test message",className:"flex-1 px-3.5 py-2.5 rounded-lg outline-none text-[14px]",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,fontFamily:"'Geist Sans', sans-serif"}}),c.jsx("button",{type:"button","aria-label":"Send message",onClick:E,disabled:i||!a.trim(),className:"px-4 rounded-lg cursor-pointer border-none text-[12px] font-semibold tracking-wider uppercase min-h-[44px] min-w-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:i||!a.trim()?.5:1},children:c.jsx(i4,{size:12})})]})]})}function a8(){const e=we(),[n,a]=z.useState([{id:"agent-1",name:"Agent 1",rolePrompt:"",repoUrl:"",source:"blank"},{id:"agent-2",name:"Agent 2",rolePrompt:"",repoUrl:"",source:"blank"}]),[s,i]=z.useState(""),[l,d]=z.useState([]),[p,f]=z.useState(null),h=z.useRef(null),g=Ut(_=>_.status),x=Ut(_=>_.reset),b=g==="running";z.useEffect(()=>{fetch(`${Ae}/agents`).then(_=>_.ok?_.json():{data:[]}).then(_=>{const F=_.data??_??[];d(F.map(B=>({id:B.id,name:B.agentMeta?.name||B.id,description:B.agentMeta?.description||""})))}).catch(()=>{})},[]);const v=()=>{const _=n.length+1;a([...n,{id:`agent-${Date.now()}`,name:`Agent ${_}`,rolePrompt:"",repoUrl:"",source:"blank"}])},k=async(_,F)=>{try{const B=await fetch(`${Ae}/agents/${encodeURIComponent(F)}`);if(!B.ok)return;const G=await B.json(),O=G.data??G,K=O.agentMeta??{},V=[],P=O.instructionState??{};K.name&&V.push(`You are ${K.name}. ${K.description||""}`),P.persona&&V.push(`Persona: ${P.persona}`),P.objectives?.primary&&V.push(`Primary Objective: ${P.objectives.primary}`),P.constraints?.customConstraints&&V.push(`Constraints: ${P.constraints.customConstraints}`);const N=V.join(`
|
|
627
|
+
|
|
628
|
+
`);a(D=>D.map(U=>U.id===_?{...U,name:K.name||F,savedSystemPrompt:N,source:F}:U))}catch{}f(null)},w=_=>{n.length<=1||a(n.filter(F=>F.id!==_))},j=(_,F)=>{a(n.map(B=>B.id===_?{...B,...F}:B))},[T,E]=z.useState(null),[S,M]=z.useState(null),$=z.useCallback(async()=>{if(!s.trim()||b)return;E(null),M(null);const{providerId:_,model:F,error:B}=Rf();if(B){E(B),console.error("[TeamRunner] Provider error:",B);return}const K=Je.getState().providers.find(V=>V.id===_)?.authMethod==="claude-agent-sdk";console.log("[TeamRunner] Starting team run with provider:",_,"model:",F,"Agent SDK:",K);try{const V=fn.getState(),N=Ra.getState().currentVersion||"0.0.0",D=V.startTrace(`team-${Date.now()}`,N);let U=ii();const q=re.getState(),W=q.channels,oe=W.filter(H=>H.enabled);let I="",L="",Z=null;if(oe.length>0){console.log("[TeamRunner] Preparing knowledge..."),M("Preparing knowledge...");const H=await Uv(oe,D);L=H.frameworkBlock;const ce=await Wv(W,H.regularChannels,H.residualKnowledgeBlock,{userMessage:s,navigationMode:"manual",providerId:_,model:F},D);I=ce.knowledgeBlock,Z=ce.provenance}const ae=q.connectors.filter(H=>H.enabled&&H.direction!=="write");if(ae.length>0){const ce=`<connectors>
|
|
629
|
+
Available data connectors (use via MCP tools):
|
|
630
|
+
${ae.map(Q=>{const ge=Q.hint?` (scope: ${Q.hint})`:"";return`- ${Q.name} [${Q.service}] — ${Q.direction}${ge}`}).join(`
|
|
631
|
+
`)}
|
|
632
|
+
</connectors>`;I=I?`${I}
|
|
633
|
+
|
|
634
|
+
${ce}`:ce}const pe=We.getState();let me="";if(pe.longTerm.enabled){console.log("[TeamRunner] Recalling memory..."),M("Recalling memory...");const H=await Pv({userMessage:s,agentId:"team",traceId:D});H.contextBlock&&(me=H.contextBlock)}if(Z&&(U=ii(Z)),oe.length>0||I||me){const H=wv(W,wn.getState().getIndex),ce=W.some(ge=>ge.enabled&&ge.repoMeta);U=Sv({frame:U,orientationBlock:H,hasRepos:ce,knowledgeFormatGuide:Hv(),frameworkBlock:L,memoryBlock:me,knowledgeBlock:I})}console.log("[TeamRunner] Running team..."),M("Running team..."),E(null);const he={teamId:`team-${Date.now()}`,systemPrompt:U,task:s.trim(),providerId:_,model:F,isAgentSdk:K,agents:n.map(H=>({agentId:H.id,name:H.name,systemPrompt:H.savedSystemPrompt||void 0,rolePrompt:H.rolePrompt||void 0,repoUrl:H.repoUrl||void 0}))};h.current=nb(he),M(null)}catch(V){console.error("[TeamRunner] Knowledge pipeline error:",V),M(null),E(`Knowledge pipeline error: ${V instanceof Error?V.message:"Unknown error"}`);const P=ii(),N={teamId:`team-${Date.now()}`,systemPrompt:P,task:s.trim(),providerId:_,model:F,isAgentSdk:K,agents:n.map(D=>({agentId:D.id,name:D.name,systemPrompt:D.savedSystemPrompt||void 0,rolePrompt:D.rolePrompt||void 0,repoUrl:D.repoUrl||void 0}))};h.current=nb(N),M(null)}},[s,n,b]),A=()=>{h.current?.abort(),h.current=null};return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"px-4 py-3 flex flex-col gap-2 overflow-y-auto",style:{maxHeight:"45%"},children:[c.jsxs("div",{className:"flex items-center justify-between mb-1",children:[c.jsxs("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:["Team Agents (",n.length,")"]}),c.jsxs("button",{type:"button",onClick:v,disabled:n.length>=5,className:"flex items-center gap-1 text-[12px] px-2 py-1 rounded cursor-pointer border-none",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace",opacity:n.length>=5?.4:1},children:[c.jsx(bt,{size:10})," Add"]})]}),n.map(_=>c.jsxs("div",{style:{padding:10,borderRadius:8,border:`1px solid ${_.source!=="blank"?"#FE500030":e.border}`,background:e.surface},children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[c.jsx(mv,{size:12,style:{color:_.source!=="blank"?"#FE5000":e.textDim}}),c.jsx("input",{type:"text",value:_.name,onChange:F=>j(_.id,{name:F.target.value}),className:"flex-1 text-[13px] font-semibold px-1.5 py-0.5 rounded outline-none border-none",style:{background:"transparent",color:e.textPrimary,fontFamily:"'Geist Mono', monospace"}}),c.jsx("button",{type:"button",onClick:()=>f(p===_.id?null:_.id),className:"text-[11px] px-2 py-0.5 rounded cursor-pointer border-none",style:{background:"#FE500010",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:_.source!=="blank"?"↻ Swap":"↗ Load"}),n.length>1&&c.jsx("button",{type:"button",onClick:()=>w(_.id),className:"border-none cursor-pointer p-0.5 rounded",style:{background:"transparent",color:e.textDim},children:c.jsx(Tt,{size:12})})]}),p===_.id&&l.length>0&&c.jsxs("div",{className:"mb-2 flex flex-col gap-1 p-2 rounded",style:{background:e.inputBg,border:`1px solid ${e.border}`},children:[c.jsx("span",{className:"text-[11px] uppercase font-bold tracking-[0.08em] mb-1",style:{color:e.textDim,fontFamily:"'Geist Mono', monospace"},children:"Load from library"}),l.map(F=>c.jsxs("button",{type:"button",onClick:()=>k(_.id,F.id),className:"text-left text-[12px] px-2 py-1.5 rounded cursor-pointer border-none w-full",style:{background:"transparent",color:e.textPrimary},onMouseEnter:B=>{B.currentTarget.style.background=e.surfaceHover},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[c.jsx("span",{style:{fontWeight:600},children:F.name}),F.description&&c.jsxs("span",{style:{color:e.textDim,marginLeft:6},children:["— ",F.description.slice(0,40)]})]},F.id)),l.length===0&&c.jsx("span",{className:"text-[12px]",style:{color:e.textFaint},children:"No saved agents. Save one from the Agent Builder first."})]}),_.source!=="blank"&&c.jsx("div",{className:"mb-1.5",children:c.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded",style:{background:"#FE500015",color:"#FE5000",fontFamily:"'Geist Mono', monospace"},children:["↗ ",_.source]})}),c.jsx("input",{type:"text",value:_.rolePrompt,onChange:F=>j(_.id,{rolePrompt:F.target.value}),placeholder:"Role override (optional — appended to agent instructions)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none mb-1.5",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textSecondary}}),c.jsx("input",{type:"text",value:_.repoUrl,onChange:F=>j(_.id,{repoUrl:F.target.value}),placeholder:"Repository URL (optional — e.g., https://github.com/user/repo)",className:"w-full text-[12px] px-2 py-1.5 rounded outline-none",style:{background:e.inputBg,border:`1px solid ${e.borderSubtle}`,color:e.textSecondary}})]},_.id))]}),c.jsxs("div",{className:"px-4 py-2",style:{borderTop:`1px solid ${e.border}`},children:[c.jsx("textarea",{value:s,onChange:_=>i(_.target.value),placeholder:"Describe the task for the team...",rows:3,className:"w-full text-[13px] px-3 py-2.5 rounded-lg outline-none resize-none",style:{background:e.inputBg,border:`1px solid ${e.border}`,color:e.textPrimary,lineHeight:1.5}}),S&&c.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#10b98115",color:"#10b981",border:"1px solid #10b98130"},children:S}),T&&c.jsx("div",{className:"text-[12px] px-3 py-2 rounded mb-2",style:{background:"#dc262615",color:"#dc2626",border:"1px solid #dc262630"},children:T}),c.jsxs("div",{className:"flex gap-2 mt-2",children:[b?c.jsxs("button",{type:"button",onClick:A,className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#dc2626",color:"#fff",fontFamily:"'Geist Mono', monospace"},children:[c.jsx(uv,{size:12})," Stop"]}):c.jsxs("button",{type:"button",onClick:$,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg cursor-pointer border-none text-[12px] font-bold tracking-[0.08em] uppercase min-h-[44px]",style:{background:"#FE5000",color:"#fff",fontFamily:"'Geist Mono', monospace",opacity:s.trim()?1:.5},children:[c.jsx(lv,{size:12})," Run Team"]}),g!=="idle"&&!b&&c.jsx("button",{type:"button",onClick:x,className:"text-[12px] px-3 py-2 rounded-lg cursor-pointer border-none",style:{background:e.border,color:e.textDim},children:"Clear"})]})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",style:{borderTop:`1px solid ${e.border}`},children:c.jsx(QD,{})})]})}function s8(){const e=we(),[n,a]=z.useState(null),[s,i]=z.useState(!1),[l,d]=z.useState(null),[p,f]=z.useState(!1),h=z.useRef(null),g=z.useCallback(()=>{const M=re.getState();return{channels:M.channels,selectedModel:M.selectedModel,outputFormat:M.outputFormat,outputFormats:M.outputFormats,prompt:M.prompt,tokenBudget:M.tokenBudget,mcpServers:M.mcpServers,skills:M.skills,agentMeta:M.agentMeta,agentConfig:M.agentConfig,connectors:M.connectors,instructionState:M.instructionState,workflowSteps:M.workflowSteps}},[]),x=z.useCallback(async()=>{try{const{downloadAgentDirectory:M}=await ta(async()=>{const{downloadAgentDirectory:$}=await Promise.resolve().then(()=>f6);return{downloadAgentDirectory:$}},void 0);await M(g()),a("dir"),setTimeout(()=>a(null),2e3)}catch(M){console.error("Directory export failed:",M)}},[g]),b=z.useCallback(async M=>{try{const $=g();let A,_;M==="md"?(A=ri("claude",$),_=".md"):M==="yaml"?(A=ri("openclaw",$),_=".yaml"):(A=ri("generic",$),_=".json");const F=($.agentMeta.name||"modular-agent").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"");gu(A,F,_),await navigator.clipboard.writeText(A),a(M),setTimeout(()=>a(null),2e3)}catch{}},[g]),v=z.useCallback(async M=>{if(!M.name.endsWith(".zip")){d("Please select a ZIP file containing an agent directory");return}i(!0),d(null);try{await Bv(M),a("import"),setTimeout(()=>a(null),2e3)}catch($){const A=$ instanceof Error?$.message:"Unknown import error";d(A),setTimeout(()=>d(null),5e3)}finally{i(!1)}},[]),k=z.useCallback(()=>{h.current?.click()},[]),w=z.useCallback(M=>{const $=M.target.files?.[0];$&&v($),M.target&&(M.target.value="")},[v]),j=z.useCallback(M=>{M.preventDefault(),M.stopPropagation(),f(!0)},[]),T=z.useCallback(M=>{M.preventDefault(),M.stopPropagation(),f(!1)},[]),E=z.useCallback(M=>{M.preventDefault(),M.stopPropagation(),f(!1);const A=Array.from(M.dataTransfer.files).find(_=>_.name.endsWith(".zip"));if(!A){d("Please drop a ZIP file containing an agent directory"),setTimeout(()=>d(null),5e3);return}v(A)},[v]),S=[{id:"dir",icon:om,label:"Agent Directory",fmt:".zip",primary:!0},{id:"md",icon:Ws,label:"Claude Code / .claude",fmt:".md",primary:!1},{id:"yaml",icon:HN,label:"OpenClaw Agent",fmt:".yaml",primary:!1},{id:"json",icon:lu,label:"Vibe Kanban / BloopAI",fmt:".json",primary:!1}];return c.jsxs("div",{className:"px-4 py-3",style:{borderTop:`1px solid ${e.border}`},onDragOver:j,onDragLeave:T,onDrop:E,children:[c.jsxs("div",{className:"mb-4",children:[c.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Import from"}),c.jsxs("button",{type:"button","aria-label":"Import agent from ZIP",onClick:k,disabled:s,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:p?"#FE500020":"#FE500010",border:`1px solid ${p?"#FE500060":"#FE500030"}`,transition:"all 150ms",opacity:s?.6:1},onMouseEnter:M=>{s||(M.currentTarget.style.borderColor="#FE500040")},onMouseLeave:M=>{s||(M.currentTarget.style.borderColor="#FE500030")},onFocus:M=>{s||(M.currentTarget.style.borderColor="#FE500040")},onBlur:M=>{s||(M.currentTarget.style.borderColor="#FE500030")},children:[c.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:e.surfaceElevated},children:n==="import"?c.jsx(jt,{size:12,style:{color:"#00ff88"}}):s?c.jsx("div",{className:"w-3 h-3 border border-t-0 border-l-0",style:{borderColor:"#FE5000",borderRadius:"50%",animation:"spin 1s linear infinite"}}):c.jsx(fv,{size:12,style:{color:e.textDim}})}),c.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary},children:p?"Drop ZIP file here":s?"Importing...":"Import Agent"}),c.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:".zip"})]}),l&&c.jsxs("div",{className:"mt-2 p-2 rounded-lg flex items-start gap-2",style:{background:"#dc262615",border:"1px solid #dc262630"},children:[c.jsx(nm,{size:14,style:{color:"#dc2626",flexShrink:0,marginTop:1}}),c.jsx("span",{className:"text-[12px] leading-relaxed",style:{color:"#dc2626"},children:l})]}),c.jsx("input",{ref:h,type:"file",accept:".zip",style:{display:"none"},onChange:w,"aria-label":"Import agent ZIP file"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"text-[12px] font-bold tracking-[0.08em] uppercase mb-2.5",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Export to"}),c.jsx("div",{className:"flex flex-col gap-1.5",children:S.map(M=>{const $=M.icon,A=M.id==="dir"?x:()=>b(M.id);return c.jsxs("button",{type:"button","aria-label":`Export as ${M.fmt}`,onClick:A,className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg cursor-pointer w-full text-left min-h-[44px] motion-reduce:transition-none",style:{background:M.primary?"#FE500010":e.isDark?"#1c1c20":"#f0f0f5",border:`1px solid ${M.primary?"#FE500030":e.border}`,transition:"border-color 150ms"},onMouseEnter:_=>{_.currentTarget.style.borderColor="#FE500040"},onMouseLeave:_=>{_.currentTarget.style.borderColor=e.border},onFocus:_=>{_.currentTarget.style.borderColor="#FE500040"},onBlur:_=>{_.currentTarget.style.borderColor=e.border},children:[c.jsx("div",{className:"w-6 h-6 rounded flex items-center justify-center",style:{background:e.surfaceElevated},children:n===M.id?c.jsx(jt,{size:12,style:{color:"#00ff88"}}):c.jsx($,{size:12,style:{color:e.textDim}})}),c.jsx("span",{className:"flex-1 text-[13px]",style:{color:e.textPrimary},children:M.label}),c.jsx("span",{className:"text-[13px]",style:{fontFamily:"'Geist Mono', monospace",color:e.textDim},children:M.fmt})]},M.id)})})]})]})}function r8({onCollapse:e}){const n=we(),[a,s]=z.useState("chat");return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3",style:{borderBottom:`1px solid ${n.border}`},children:[c.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#00ff88",boxShadow:"0 0 6px rgba(0,255,136,0.4)"}}),c.jsx("span",{className:"text-[12px] font-bold tracking-[0.08em] uppercase flex-1",style:{fontFamily:"'Geist Mono', monospace",color:n.textSecondary},children:a==="chat"?"Conversation Tester":a==="team"?"Team Runner":a==="traces"?"Execution Traces":"Export"}),c.jsxs("div",{className:"flex gap-0.5 rounded-md overflow-hidden",role:"tablist",style:{border:`1px solid ${n.border}`},children:[c.jsx("button",{type:"button",role:"tab",id:"tab-chat","aria-selected":a==="chat","aria-controls":"tabpanel-chat",onClick:()=>s("chat"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:a==="chat"?"#FE5000":"transparent",color:a==="chat"?"#fff":n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Chat"}),c.jsx("button",{type:"button",role:"tab",id:"tab-team","aria-selected":a==="team","aria-controls":"tabpanel-team",onClick:()=>s("team"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:a==="team"?"#FE5000":"transparent",color:a==="team"?"#fff":n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Team"}),c.jsx("button",{type:"button",role:"tab",id:"tab-traces","aria-selected":a==="traces","aria-controls":"tabpanel-traces",onClick:()=>s("traces"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:a==="traces"?"#FE5000":"transparent",color:a==="traces"?"#fff":n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Traces"}),c.jsx("button",{type:"button",role:"tab",id:"tab-export","aria-selected":a==="export","aria-controls":"tabpanel-export",onClick:()=>s("export"),className:"text-[13px] px-2.5 py-2 cursor-pointer border-none min-h-[44px]",style:{background:a==="export"?"#FE5000":"transparent",color:a==="export"?"#fff":n.textDim,fontFamily:"'Geist Mono', monospace"},children:"Export"})]}),e&&c.jsx("button",{type:"button",onClick:e,"aria-label":"Collapse test panel",className:"w-7 h-7 rounded-md border-none cursor-pointer flex items-center justify-center",style:{background:"transparent",color:n.textDim},children:c.jsx(Ba,{size:14})})]}),a==="chat"&&c.jsx("div",{role:"tabpanel",id:"tabpanel-chat","aria-labelledby":"tab-chat",className:"flex flex-col flex-1 min-h-0",children:c.jsx(o8,{})}),a==="team"&&c.jsx("div",{role:"tabpanel",id:"tabpanel-team","aria-labelledby":"tab-team",className:"flex flex-col flex-1 min-h-0",children:c.jsx(a8,{})}),a==="traces"&&c.jsx("div",{role:"tabpanel",id:"tabpanel-traces","aria-labelledby":"tab-traces",className:"flex-1 overflow-y-auto",children:c.jsx(HD,{})}),a==="export"&&c.jsx("div",{role:"tabpanel",id:"tabpanel-export","aria-labelledby":"tab-export",className:"flex-1 overflow-y-auto",children:c.jsx(s8,{})})]})}function i8(){const e=we(),[n,a]=z.useState(!0);return c.jsxs("div",{role:"main",className:"flex-1 flex overflow-hidden",style:{background:e.bg},children:[c.jsx("nav",{"aria-label":"Agent sources",className:"flex flex-col overflow-y-auto",style:{width:"30%",minWidth:300,maxWidth:480,background:e.isDark?"#161619":"#f8f8fa",borderRight:`1px solid ${e.border}`},children:c.jsx(q_,{})}),c.jsx("section",{"aria-label":"Agent builder",className:"flex-1 overflow-y-auto",style:{padding:"24px 32px"},children:c.jsx(s6,{})}),c.jsx("aside",{"aria-label":"Test and export",className:"flex flex-col overflow-hidden",style:{width:n?48:400,minWidth:n?48:400,background:e.isDark?"#161619":"#f8f8fa",borderLeft:`1px solid ${e.border}`,transition:"width 200ms ease, min-width 200ms ease"},children:n?c.jsx("button",{type:"button",onClick:()=>a(!1),className:"flex flex-col items-center justify-center gap-2 h-full cursor-pointer border-none",style:{background:"transparent",color:e.textDim},"aria-label":"Open test panel",children:c.jsx("span",{style:{writingMode:"vertical-rl",textOrientation:"mixed",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",fontFamily:"'Geist Mono', monospace",color:e.textDim},children:"Test ▶"})}):c.jsx(r8,{onCollapse:()=>a(!0)})})]})}function l8(){const e=we(),n=re(k=>k.showFilePicker),a=re(k=>k.setShowFilePicker),s=re(k=>k.setShowMcpPicker),i=re(k=>k.setShowSkillPicker),l=re(k=>k.setShowConnectorPicker),d=re(k=>k.setShowMarketplace),p=re(k=>k.run),f=re(k=>k.running),h=re(k=>k.showSettings),g=re(k=>k.setShowSettings),x=Xe(k=>k.loadServers),b=z.useRef(null),v=z.useCallback(k=>{const w=k.target.files?.[0];if(!w)return;const j=new FileReader;j.onload=T=>{const E=T.target?.result;if(!E)return;const S=l_(E),M=re.getState();if(S.channels){M.clearChannels();for(const $ of S.channels)M.addChannel($)}S.selectedModel&&M.setModel(S.selectedModel),S.outputFormat&&M.setOutputFormat(S.outputFormat),S.prompt&&M.setPrompt(S.prompt),S.tokenBudget&&M.setTokenBudget(S.tokenBudget),S.agentMeta&&M.setAgentMeta(S.agentMeta),S.instructionState&&M.setInstructionState(S.instructionState),S.workflowSteps&&M.setWorkflowSteps(S.workflowSteps)},j.readAsText(w),k.target.value=""},[]);return z.useEffect(()=>{const k=w=>{(w.metaKey||w.ctrlKey)&&w.key==="k"&&(w.preventDefault(),a(!n)),(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),f||p()),w.key==="Escape"&&(a(!1),s(!1),i(!1),l(!1),d(!1),g(!1),re.getState().setShowSaveModal(!1))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[a,n,s,i,l,d,p,f]),z.useEffect(()=>{x()},[x]),c.jsxs("div",{"data-theme":e.isDark?"dark":"light",style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",background:e.bg},children:[c.jsx("input",{ref:b,type:"file",accept:".md,.yaml,.yml,.json",onChange:v,style:{display:"none"},"aria-hidden":"true"}),c.jsx(sA,{onSettingsClick:()=>g(!0,"providers")}),c.jsx(i8,{}),c.jsx("div",{"aria-live":"polite",id:"canvas-announcements",style:{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}}),c.jsx(rA,{}),c.jsx(lA,{}),c.jsx(mA,{}),c.jsx(bA,{}),c.jsx(AA,{}),c.jsx(vA,{}),c.jsx(FA,{open:h,onClose:()=>g(!1)}),c.jsx(t_,{})]})}pS.createRoot(document.getElementById("root")).render(c.jsx(z.StrictMode,{children:c.jsx(l8,{})}));export{c8 as c,ob as g,Xe as u};
|