@synlexa/studio 0.0.0-stage → 0.4.4

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.
Files changed (46) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +72 -0
  3. package/README.md +73 -2
  4. package/assets/icon-256.png +0 -0
  5. package/assets/icon.icns +0 -0
  6. package/assets/icon.ico +0 -0
  7. package/assets/icon.png +0 -0
  8. package/bin/synlexa-studio.mjs +245 -0
  9. package/package.json +38 -4
  10. package/scripts/desktop-shortcut.mjs +610 -0
  11. package/scripts/postinstall.mjs +13 -0
  12. package/wasm/synlexa_bio_core.wasm +0 -0
  13. package/web-dist/assets/MolStarViewport-BEGb0UZJ.js +8197 -0
  14. package/web-dist/assets/MolStarViewport-BYVdqMR8.css +1 -0
  15. package/web-dist/assets/bioCore.worker-BGMOX1WA.js +1 -0
  16. package/web-dist/assets/index-DR8pRGGj.css +1 -0
  17. package/web-dist/assets/index-OgQ3RYDT.js +845 -0
  18. package/web-dist/assets/node.browser-BFtyutLR.js +1 -0
  19. package/web-dist/assets/node.browser-BoI8HeAS.js +1 -0
  20. package/web-dist/assets/rdkit.worker-BvevbBxc.js +19 -0
  21. package/web-dist/favicon_io/android-chrome-192x192.png +0 -0
  22. package/web-dist/favicon_io/android-chrome-512x512.png +0 -0
  23. package/web-dist/favicon_io/apple-touch-icon.png +0 -0
  24. package/web-dist/favicon_io/favicon-16x16.png +0 -0
  25. package/web-dist/favicon_io/favicon-32x32.png +0 -0
  26. package/web-dist/favicon_io/favicon.ico +0 -0
  27. package/web-dist/favicon_io/site.webmanifest +1 -0
  28. package/web-dist/fixtures/1A3N.cif +8411 -0
  29. package/web-dist/fixtures/1LZ1.cif +2950 -0
  30. package/web-dist/fixtures/1UBQ.cif +2237 -0
  31. package/web-dist/fixtures/3HS4.cif +7817 -0
  32. package/web-dist/fixtures/3HS4.pdb +5385 -0
  33. package/web-dist/fixtures/AF-P00918-F1-model_v6.cif +3372 -0
  34. package/web-dist/fixtures/AF-P00918-F1-model_v6.pdb +2141 -0
  35. package/web-dist/fixtures/AF-P00918-F1-predicted_aligned_error_v6.json +1 -0
  36. package/web-dist/fixtures/AF-P0CG48-F1-model_v6.cif +8128 -0
  37. package/web-dist/fixtures/AF-P61626-F1-model_v6.cif +2075 -0
  38. package/web-dist/fixtures/AF-P68871-F1-model_v6.cif +2029 -0
  39. package/web-dist/fixtures/fixtures-manifest.json +198 -0
  40. package/web-dist/fixtures/pubchem-panel.json +84 -0
  41. package/web-dist/index.html +19 -0
  42. package/web-dist/synlexa-logo.png +0 -0
  43. package/web-dist/synlexa-s-icon.svg +12 -0
  44. package/web-dist/synlexa-wordmark.png +0 -0
  45. package/web-dist/wasm/rdkit/RDKit_minimal.wasm +0 -0
  46. package/web-dist/wasm/synlexa_bio_core.wasm +0 -0
@@ -0,0 +1,845 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MolStarViewport-BEGb0UZJ.js","assets/MolStarViewport-BYVdqMR8.css"])))=>i.map(i=>d[i]);
2
+ (function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&s(d)}).observe(document,{childList:!0,subtree:!0});function n(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function s(i){if(i.ep)return;i.ep=!0;const c=n(i);fetch(i.href,c)}})();function GM(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sb={exports:{}},nd={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var JS;function HM(){if(JS)return nd;JS=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(s,i,c){var d=null;if(c!==void 0&&(d=""+c),i.key!==void 0&&(d=""+i.key),"key"in i){c={};for(var f in i)f!=="key"&&(c[f]=i[f])}else c=i;return i=c.ref,{$$typeof:e,type:s,key:d,ref:i!==void 0?i:null,props:c}}return nd.Fragment=r,nd.jsx=n,nd.jsxs=n,nd}var ZS;function FM(){return ZS||(ZS=1,Sb.exports=HM()),Sb.exports}var o=FM(),kb={exports:{}},Ze={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var ek;function VM(){if(ek)return Ze;ek=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),_=Symbol.for("react.view_transition"),y=Symbol.iterator;function S(D){return D===null||typeof D!="object"?null:(D=y&&D[y]||D["@@iterator"],typeof D=="function"?D:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,T={};function j(D,ae,pe){this.props=D,this.context=ae,this.refs=T,this.updater=pe||k}j.prototype.isReactComponent={},j.prototype.setState=function(D,ae){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,ae,"setState")},j.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function q(){}q.prototype=j.prototype;function z(D,ae,pe){this.props=D,this.context=ae,this.refs=T,this.updater=pe||k}var O=z.prototype=new q;O.constructor=z,E(O,j.prototype),O.isPureReactComponent=!0;var V=Array.isArray;function P(){}var $={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function Z(D,ae,pe){var Ae=pe.ref;return{$$typeof:e,type:D,key:ae,ref:Ae!==void 0?Ae:null,props:pe}}function G(D,ae){return Z(D.type,ae,D.props)}function K(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function we(D){var ae={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(pe){return ae[pe]})}var Se=/\/+/g;function Q(D,ae){return typeof D=="object"&&D!==null&&D.key!=null?we(""+D.key):ae.toString(36)}function F(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(P,P):(D.status="pending",D.then(function(ae){D.status==="pending"&&(D.status="fulfilled",D.value=ae)},function(ae){D.status==="pending"&&(D.status="rejected",D.reason=ae)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function he(D,ae,pe,Ae,Ne){var Re=typeof D;(Re==="undefined"||Re==="boolean")&&(D=null);var $e=!1;if(D===null)$e=!0;else switch(Re){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(D.$$typeof){case e:case r:$e=!0;break;case x:return $e=D._init,he($e(D._payload),ae,pe,Ae,Ne)}}if($e)return Ne=Ne(D),$e=Ae===""?"."+Q(D,0):Ae,V(Ne)?(pe="",$e!=null&&(pe=$e.replace(Se,"$&/")+"/"),he(Ne,ae,pe,"",function(be){return be})):Ne!=null&&(K(Ne)&&(Ne=G(Ne,pe+(Ne.key==null||D&&D.key===Ne.key?"":(""+Ne.key).replace(Se,"$&/")+"/")+$e)),ae.push(Ne)),1;$e=0;var Ce=Ae===""?".":Ae+":";if(V(D))for(var Ue=0;Ue<D.length;Ue++)Ae=D[Ue],Re=Ce+Q(Ae,Ue),$e+=he(Ae,ae,pe,Re,Ne);else if(Ue=S(D),typeof Ue=="function")for(D=Ue.call(D),Ue=0;!(Ae=D.next()).done;)Ae=Ae.value,Re=Ce+Q(Ae,Ue++),$e+=he(Ae,ae,pe,Re,Ne);else if(Re==="object"){if(typeof D.then=="function")return he(F(D),ae,pe,Ae,Ne);throw ae=String(D),Error("Objects are not valid as a React child (found: "+(ae==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":ae)+"). If you meant to render a collection of children, use an array instead.")}return $e}function W(D,ae,pe){if(D==null)return D;var Ae=[],Ne=0;return he(D,Ae,"","",function(Re){return ae.call(pe,Re,Ne++)}),Ae}function me(D){if(D._status===-1){var ae=D._result,pe=ae();pe.then(function(Ae){(D._status===0||D._status===-1)&&(D._status=1,D._result=Ae,pe.status===void 0&&(pe.status="fulfilled",pe.value=Ae))},function(Ae){(D._status===0||D._status===-1)&&(D._status=2,D._result=Ae,pe.status===void 0&&(pe.status="rejected",pe.reason=Ae))}),D._status===-1&&(D._status=0,D._result=pe)}if(D._status===1)return D._result.default;throw D._result}var I=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ae=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(ae))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)};function J(D){var ae=$.T,pe={};pe.types=ae!==null?ae.types:null,$.T=pe;try{var Ae=D(),Ne=$.S;Ne!==null&&Ne(pe,Ae),typeof Ae=="object"&&Ae!==null&&typeof Ae.then=="function"&&Ae.then(P,I)}catch(Re){I(Re)}finally{ae!==null&&pe.types!==null&&(ae.types=pe.types),$.T=ae}}function ge(D){var ae=$.T;if(ae!==null){var pe=ae.types;pe===null?ae.types=[D]:pe.indexOf(D)===-1&&pe.push(D)}else J(ge.bind(null,D))}var le={map:W,forEach:function(D,ae,pe){W(D,function(){ae.apply(this,arguments)},pe)},count:function(D){var ae=0;return W(D,function(){ae++}),ae},toArray:function(D){return W(D,function(ae){return ae})||[]},only:function(D){if(!K(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return Ze.Activity=g,Ze.Children=le,Ze.Component=j,Ze.Fragment=n,Ze.Profiler=i,Ze.PureComponent=z,Ze.StrictMode=s,Ze.Suspense=p,Ze.ViewTransition=_,Ze.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=$,Ze.__COMPILER_RUNTIME={__proto__:null,c:function(D){return $.H.useMemoCache(D)}},Ze.addTransitionType=ge,Ze.cache=function(D){return function(){return D.apply(null,arguments)}},Ze.cacheSignal=function(){return null},Ze.cloneElement=function(D,ae,pe){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var Ae=E({},D.props),Ne=D.key;if(ae!=null)for(Re in ae.key!==void 0&&(Ne=""+ae.key),ae)!H.call(ae,Re)||Re==="key"||Re==="__self"||Re==="__source"||Re==="ref"&&ae.ref===void 0||(Ae[Re]=ae[Re]);var Re=arguments.length-2;if(Re===1)Ae.children=pe;else if(1<Re){for(var $e=Array(Re),Ce=0;Ce<Re;Ce++)$e[Ce]=arguments[Ce+2];Ae.children=$e}return Z(D.type,Ne,Ae)},Ze.createContext=function(D){return D={$$typeof:d,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:c,_context:D},D},Ze.createElement=function(D,ae,pe){var Ae,Ne={},Re=null;if(ae!=null)for(Ae in ae.key!==void 0&&(Re=""+ae.key),ae)H.call(ae,Ae)&&Ae!=="key"&&Ae!=="__self"&&Ae!=="__source"&&(Ne[Ae]=ae[Ae]);var $e=arguments.length-2;if($e===1)Ne.children=pe;else if(1<$e){for(var Ce=Array($e),Ue=0;Ue<$e;Ue++)Ce[Ue]=arguments[Ue+2];Ne.children=Ce}if(D&&D.defaultProps)for(Ae in $e=D.defaultProps,$e)Ne[Ae]===void 0&&(Ne[Ae]=$e[Ae]);return Z(D,Re,Ne)},Ze.createRef=function(){return{current:null}},Ze.forwardRef=function(D){return{$$typeof:f,render:D}},Ze.isValidElement=K,Ze.lazy=function(D){return{$$typeof:x,_payload:{_status:-1,_result:D},_init:me}},Ze.memo=function(D,ae){return{$$typeof:b,type:D,compare:ae===void 0?null:ae}},Ze.startTransition=J,Ze.unstable_useCacheRefresh=function(){return $.H.useCacheRefresh()},Ze.use=function(D){return $.H.use(D)},Ze.useActionState=function(D,ae,pe){return $.H.useActionState(D,ae,pe)},Ze.useCallback=function(D,ae){return $.H.useCallback(D,ae)},Ze.useContext=function(D){return $.H.useContext(D)},Ze.useDebugValue=function(){},Ze.useDeferredValue=function(D,ae){return $.H.useDeferredValue(D,ae)},Ze.useEffect=function(D,ae){return $.H.useEffect(D,ae)},Ze.useEffectEvent=function(D){return $.H.useEffectEvent(D)},Ze.useId=function(){return $.H.useId()},Ze.useImperativeHandle=function(D,ae,pe){return $.H.useImperativeHandle(D,ae,pe)},Ze.useInsertionEffect=function(D,ae){return $.H.useInsertionEffect(D,ae)},Ze.useLayoutEffect=function(D,ae){return $.H.useLayoutEffect(D,ae)},Ze.useMemo=function(D,ae){return $.H.useMemo(D,ae)},Ze.useOptimistic=function(D,ae){return $.H.useOptimistic(D,ae)},Ze.useReducer=function(D,ae,pe){return $.H.useReducer(D,ae,pe)},Ze.useRef=function(D){return $.H.useRef(D)},Ze.useState=function(D){return $.H.useState(D)},Ze.useSyncExternalStore=function(D,ae,pe){return $.H.useSyncExternalStore(D,ae,pe)},Ze.useTransition=function(){return $.H.useTransition()},Ze.version="19.3.1",Ze}var tk;function Ay(){return tk||(tk=1,kb.exports=VM()),kb.exports}var C=Ay();const XL=GM(C);var Cb={exports:{}},sd={},Nb={exports:{}},Ab={};/**
19
+ * @license React
20
+ * scheduler.production.js
21
+ *
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var nk;function KM(){return nk||(nk=1,(function(e){function r(F,he){var W=F.length;F.push(he);e:for(;0<W;){var me=W-1>>>1,I=F[me];if(0<i(I,he))F[me]=he,F[W]=I,W=me;else break e}}function n(F){return F.length===0?null:F[0]}function s(F){if(F.length===0)return null;var he=F[0],W=F.pop();if(W!==he){F[0]=W;e:for(var me=0,I=F.length,J=I>>>1;me<J;){var ge=2*(me+1)-1,le=F[ge],D=ge+1,ae=F[D];if(0>i(le,W))D<I&&0>i(ae,le)?(F[me]=ae,F[D]=W,me=D):(F[me]=le,F[ge]=W,me=ge);else if(D<I&&0>i(ae,W))F[me]=ae,F[D]=W,me=D;else break e}}return he}function i(F,he){var W=F.sortIndex-he.sortIndex;return W!==0?W:F.id-he.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var p=[],b=[],x=1,g=null,_=3,y=!1,S=!1,k=!1,E=!1,T=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,q=typeof setImmediate<"u"?setImmediate:null;function z(F){for(var he=n(b);he!==null;){if(he.callback===null)s(b);else if(he.startTime<=F)s(b),he.sortIndex=he.expirationTime,r(p,he);else break;he=n(b)}}function O(F){if(k=!1,z(F),!S)if(n(p)!==null)S=!0,V||(V=!0,K());else{var he=n(b);he!==null&&Q(O,he.startTime-F)}}var V=!1,P=-1,$=5,H=-1;function Z(){return E?!0:!(e.unstable_now()-H<$)}function G(){if(E=!1,V){var F=e.unstable_now();H=F;var he=!0;try{e:{S=!1,k&&(k=!1,j(P),P=-1),y=!0;var W=_;try{t:{for(z(F),g=n(p);g!==null&&!(g.expirationTime>F&&Z());){var me=g.callback;if(typeof me=="function"){g.callback=null,_=g.priorityLevel;var I=me(g.expirationTime<=F);if(F=e.unstable_now(),typeof I=="function"){g.callback=I,z(F),he=!0;break t}g===n(p)&&s(p),z(F)}else s(p);g=n(p)}if(g!==null)he=!0;else{var J=n(b);J!==null&&Q(O,J.startTime-F),he=!1}}break e}finally{g=null,_=W,y=!1}he=void 0}}finally{he?K():V=!1}}}var K;if(typeof q=="function")K=function(){q(G)};else if(typeof MessageChannel<"u"){var we=new MessageChannel,Se=we.port2;we.port1.onmessage=G,K=function(){Se.postMessage(null)}}else K=function(){T(G,0)};function Q(F,he){P=T(function(){F(e.unstable_now())},he)}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(F){F.callback=null},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_next=function(F){switch(_){case 1:case 2:case 3:var he=3;break;default:he=_}var W=_;_=he;try{return F()}finally{_=W}},e.unstable_requestPaint=function(){E=!0},e.unstable_runWithPriority=function(F,he){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var W=_;_=F;try{return he()}finally{_=W}},e.unstable_scheduleCallback=function(F,he,W){var me=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?me+W:me):W=me,F){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=W+I,F={id:x++,callback:he,priorityLevel:F,startTime:W,expirationTime:I,sortIndex:-1},W>me?(F.sortIndex=W,r(b,F),n(p)===null&&F===n(b)&&(k?(j(P),P=-1):k=!0,Q(O,W-me))):(F.sortIndex=I,r(p,F),S||y||(S=!0,V||(V=!0,K()))),F},e.unstable_shouldYield=Z,e.unstable_wrapCallback=function(F){var he=_;return function(){var W=_;_=he;try{return F.apply(this,arguments)}finally{_=W}}}})(Ab)),Ab}var sk;function YM(){return sk||(sk=1,Nb.exports=KM()),Nb.exports}var jb={exports:{}},On={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var ak;function WM(){if(ak)return On;ak=1;var e=Ay();function r(x){var g="https://react.dev/errors/"+x;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)g+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+x+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var s={d:{f:n,r:function(){throw Error(r(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal"),c=Symbol.for("react.recoverable"),d=Symbol.for("react.optimistic_key");function f(x,g,_){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:y==null?null:y===d?d:""+y,children:x,containerInfo:g,implementation:_}}var p=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function b(x,g){if(x==="font")return"";if(typeof g=="string")return g==="use-credentials"?g:""}return On.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,On.browser=function(x){return{$$typeof:c,_reason:x}},On.createPortal=function(x,g){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!g||g.nodeType!==1&&g.nodeType!==9&&g.nodeType!==11)throw Error(r(299));return f(x,g,null,_)},On.flushSync=function(x){var g=p.T,_=s.p;try{if(p.T=null,s.p=2,x)return x()}finally{p.T=g,s.p=_,s.d.f()}},On.preconnect=function(x,g){typeof x=="string"&&(g?(g=g.crossOrigin,g=typeof g=="string"?g==="use-credentials"?g:"":void 0):g=null,s.d.C(x,g))},On.prefetchDNS=function(x){typeof x=="string"&&s.d.D(x)},On.preinit=function(x,g){if(typeof x=="string"&&g&&typeof g.as=="string"){var _=g.as,y=b(_,g.crossOrigin),S=typeof g.integrity=="string"?g.integrity:void 0,k=typeof g.fetchPriority=="string"?g.fetchPriority:void 0;_==="style"?s.d.S(x,typeof g.precedence=="string"?g.precedence:void 0,{crossOrigin:y,integrity:S,fetchPriority:k}):_==="script"&&s.d.X(x,{crossOrigin:y,integrity:S,fetchPriority:k,nonce:typeof g.nonce=="string"?g.nonce:void 0})}},On.preinitModule=function(x,g){if(typeof x=="string")if(typeof g=="object"&&g!==null){if(g.as==null||g.as==="script"){var _=b(g.as,g.crossOrigin);s.d.M(x,{crossOrigin:_,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0})}}else g==null&&s.d.M(x)},On.preload=function(x,g){if(typeof x=="string"&&typeof g=="object"&&g!==null&&typeof g.as=="string"){var _=g.as,y=b(_,g.crossOrigin);s.d.L(x,_,{crossOrigin:y,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,type:typeof g.type=="string"?g.type:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0,referrerPolicy:typeof g.referrerPolicy=="string"?g.referrerPolicy:void 0,imageSrcSet:typeof g.imageSrcSet=="string"?g.imageSrcSet:void 0,imageSizes:typeof g.imageSizes=="string"?g.imageSizes:void 0,media:typeof g.media=="string"?g.media:void 0})}},On.preloadModule=function(x,g){if(typeof x=="string")if(g){var _=b(g.as,g.crossOrigin);s.d.m(x,{as:typeof g.as=="string"&&g.as!=="script"?g.as:void 0,crossOrigin:_,integrity:typeof g.integrity=="string"?g.integrity:void 0,nonce:typeof g.nonce=="string"?g.nonce:void 0,fetchPriority:typeof g.fetchPriority=="string"?g.fetchPriority:void 0})}else s.d.m(x)},On.requestFormReset=function(x){s.d.r(x)},On.unstable_batchedUpdates=function(x,g){return x(g)},On.useFormState=function(x,g,_){return p.H.useFormState(x,g,_)},On.useFormStatus=function(){return p.H.useHostTransitionStatus()},On.version="19.3.1",On}var rk;function $A(){if(rk)return jb.exports;rk=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(r){console.error(r)}}return e(),jb.exports=WM(),jb.exports}/**
35
+ * @license React
36
+ * react-dom-client.production.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var ik;function XM(){if(ik)return sd;ik=1;var e=YM(),r=Ay(),n=$A();function s(t){var a="https://react.dev/errors/"+t;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+t+"; visit "+a+" 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 c(t){for(var a=t,l=a;l&&!l.alternate;)a=l,(a.flags&4098)!==0&&(t=a.return),l=a.return;for(;a.return;)a=a.return;return a.tag===3?t:null}function d(t){if(t.tag===13){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function f(t){if(t.tag===31){var a=t.memoizedState;if(a===null&&(t=t.alternate,t!==null&&(a=t.memoizedState)),a!==null)return a.dehydrated}return null}function p(t){if(c(t)!==t)throw Error(s(188))}function b(t){var a=t.alternate;if(!a){if(a=c(t),a===null)throw Error(s(188));return a!==t?null:t}for(var l=t,u=a;;){var h=l.return;if(h===null)break;var m=h.alternate;if(m===null){if(u=h.return,u!==null){l=u;continue}break}if(h.child===m.child){for(m=h.child;m;){if(m===l)return p(h),t;if(m===u)return p(h),a;m=m.sibling}throw Error(s(188))}if(l.return!==u.return)l=h,u=m;else{for(var w=!1,A=h.child;A;){if(A===l){w=!0,l=h,u=m;break}if(A===u){w=!0,u=h,l=m;break}A=A.sibling}if(!w){for(A=m.child;A;){if(A===l){w=!0,l=m,u=h;break}if(A===u){w=!0,u=m,l=h;break}A=A.sibling}if(!w)throw Error(s(189))}}if(l.alternate!==u)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?t:a}function x(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t;for(t=t.child;t!==null;){if(a=x(t),a!==null)return a;t=t.sibling}return null}function g(t,a,l,u,h,m){for(;t!==null;){if((t.tag===5||t.tag===27||t.tag===6)&&l(t,u,h,m)||(t.tag!==22||t.memoizedState===null)&&(a||t.tag!==5&&t.tag!==27)&&g(t.child,a,l,u,h,m))return!0;t=t.sibling}return!1}function _(t){for(t=t.return;t!==null;){if(t.tag===3||t.tag===5||t.tag===27)return t;t=t.return}return null}function y(t){var a=!1;for(t=t.return;t!==null&&(t.tag===4&&(a=!0),!(t.tag===3||t.tag===5||t.tag===27));)t=t.return;return a}function S(t){var a=[null,null],l=_(t);return l===null||k(a,t,l.child,{foundSelf:!1}),a}function k(t,a,l,u){for(;l!==null;){if(l===a)u.foundSelf=!0;else if(l.tag===5||l.tag===27||l.tag===6){if(u.foundSelf)return t[1]=l,!0;t[0]=l}else if((l.tag!==22||l.memoizedState===null)&&k(t,a,l.child,u))return!0;l=l.sibling}return!1}function E(t){switch(t.tag){case 5:case 27:case 6:return t.stateNode;case 3:return t.stateNode.containerInfo;default:throw Error(s(559))}}var T=null,j=null;function q(t,a,l){return t===l?!0:t===a?(T=t,!0):!1}function z(t,a,l){return t===l?(j=t,!1):t===a?(j!==null&&(T=t),!0):!1}function O(t){if(t===null)return null;do t=t===null?null:t.return;while(t&&t.tag!==5&&t.tag!==27&&t.tag!==3);return t||null}function V(t,a,l){for(var u=0,h=t;h;h=l(h))u++;h=0;for(var m=a;m;m=l(m))h++;for(;0<u-h;)t=l(t),u--;for(;0<h-u;)a=l(a),h--;for(;u--;){if(t===a||a!==null&&t===a.alternate)return t;t=l(t),a=l(a)}return null}var P=Object.assign,$=Symbol.for("react.element"),H=Symbol.for("react.transitional.element"),Z=Symbol.for("react.portal"),G=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),we=Symbol.for("react.profiler"),Se=Symbol.for("react.consumer"),Q=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),he=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),me=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ge=Symbol.for("react.legacy_hidden"),le=Symbol.for("react.memo_cache_sentinel"),D=Symbol.for("react.view_transition"),ae=Symbol.for("react.recoverable"),pe=Symbol.iterator;function Ae(t){return t===null||typeof t!="object"?null:(t=pe&&t[pe]||t["@@iterator"],typeof t=="function"?t:null)}var Ne=Symbol.for("react.client.reference");function Re(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===Ne?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case G:return"Fragment";case we:return"Profiler";case K:return"StrictMode";case he:return"Suspense";case W:return"SuspenseList";case J:return"Activity";case D:return"ViewTransition"}if(typeof t=="object")switch(t.$$typeof){case Z:return"Portal";case Q:return t.displayName||"Context";case Se:return(t._context.displayName||"Context")+".Consumer";case F:var a=t.render;return t=t.displayName,t||(t=a.displayName||a.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case me:return a=t.displayName||null,a!==null?a:Re(t.type)||"Memo";case I:a=t._payload,t=t._init;try{return Re(t(a))}catch{}}return null}var $e=Array.isArray,Ce=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ue=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,be={pending:!1,data:null,method:null,action:null},bt=[],Ot=-1;function St(t){return{current:t}}function Ke(t){0>Ot||(t.current=bt[Ot],bt[Ot]=null,Ot--)}function et(t,a){Ot++,bt[Ot]=t.current,t.current=a}var ue=St(null),He=St(null),Pe=St(null),ut=St(null);function Je(t,a){switch(et(Pe,a),et(He,t),et(ue,null),a.nodeType){case 9:case 11:t=(t=a.documentElement)&&(t=t.namespaceURI)?oS(t):0;break;default:if(t=a.tagName,a=a.namespaceURI)a=oS(a),t=lS(a,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}Ke(ue),et(ue,t)}function re(){Ke(ue),Ke(He),Ke(Pe)}function ve(t){var a=t.memoizedState;a!==null&&(sc._currentValue=a.memoizedState,et(ut,t)),a=ue.current;var l=lS(a,t.type);a!==l&&(et(He,t),et(ue,l))}function Qe(t){He.current===t&&(Ke(ue),Ke(He)),ut.current===t&&(Ke(ut),sc._currentValue=be)}var Fe,Fn;function We(t){if(Fe===void 0)try{throw Error()}catch(l){var a=l.stack.trim().match(/\n( *(at )?)/);Fe=a&&a[1]||"",Fn=-1<l.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+Fe+t+Fn}var Yr=!1;function ss(t,a){if(!t||Yr)return"";Yr=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(a){var _e=function(){throw Error()};if(Object.defineProperty(_e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_e,[])}catch(ze){var ee=ze}Reflect.construct(t,[],_e)}else{try{_e.call()}catch(ze){ee=ze}_e=!1;try{var ce=Object.getOwnPropertyDescriptor(t.prototype,"props");Object.defineProperty(t.prototype,"props",{configurable:!0,set:function(){throw Error()}}),_e=!0,new t}finally{_e&&(ce!==void 0?Object.defineProperty(t.prototype,"props",ce):delete t.prototype.props)}}}else{try{throw Error()}catch(ze){ee=ze}(_e=t())&&typeof _e.catch=="function"&&_e.catch(function(){})}}catch(ze){if(ze&&ee&&typeof ze.stack=="string")return[ze.stack,ee.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var h=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");h&&h.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=u.DetermineComponentFrameRoot(),w=m[0],A=m[1];if(w&&A){var B=w.split(`
45
+ `),ne=A.split(`
46
+ `);for(h=u=0;u<B.length&&!B[u].includes("DetermineComponentFrameRoot");)u++;for(;h<ne.length&&!ne[h].includes("DetermineComponentFrameRoot");)h++;if(u===B.length||h===ne.length)for(u=B.length-1,h=ne.length-1;1<=u&&0<=h&&B[u]!==ne[h];)h--;for(;1<=u&&0<=h;u--,h--)if(B[u]!==ne[h]){if(u!==1||h!==1)do if(u--,h--,0>h||B[u]!==ne[h]){var de=`
47
+ `+B[u].replace(" at new "," at ");return t.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",t.displayName)),de}while(1<=u&&0<=h);break}}}finally{Yr=!1,Error.prepareStackTrace=l}return(l=t?t.displayName||t.name:"")?We(l):""}function su(t,a){switch(t.tag){case 26:case 27:case 5:return We(t.type);case 16:return We("Lazy");case 13:return t.child!==a&&a!==null?We("Suspense Fallback"):We("Suspense");case 19:return We("SuspenseList");case 0:case 15:return ss(t.type,!1);case 11:return ss(t.type.render,!1);case 1:return ss(t.type,!0);case 31:return We("Activity");case 30:return We("ViewTransition");default:return""}}function qn(t){try{var a="",l=null;do a+=su(t,l),l=t,t=t.return;while(t);return a}catch(u){return`
48
+ Error generating stack: `+u.message+`
49
+ `+u.stack}}var Wr=Object.prototype.hasOwnProperty,_t=e.unstable_scheduleCallback,ja=e.unstable_cancelCallback,Nn=e.unstable_shouldYield,Ji=e.unstable_requestPaint,tt=e.unstable_now,Mh=e.unstable_getCurrentPriorityLevel,Ln=e.unstable_ImmediatePriority,dl=e.unstable_UserBlockingPriority,Zi=e.unstable_NormalPriority,Rh=e.unstable_LowPriority,oa=e.unstable_IdlePriority,hl=e.log,zh=e.unstable_setDisableYieldValue,eo=null,st=null;function Lt(t){if(typeof hl=="function"&&zh(t),st&&typeof st.setStrictMode=="function")try{st.setStrictMode(eo,t)}catch{}}var Ct=Math.clz32?Math.clz32:Ph,Oh=Math.log,i0=Math.LN2;function Ph(t){return t>>>=0,t===0?32:31-(Oh(t)/i0|0)|0}var Nt=256,An=262144,as=4194304;function Ta(t){var a=t&42;if(a!==0)return a;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&-t;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 ml(t,a,l){var u=t.pendingLanes;if(u===0)return 0;var h=0,m=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var A=u&134217727;return A!==0?(u=A&~m,u!==0?h=Ta(u):(w&=A,w!==0?h=Ta(w):l||(l=A&~t,l!==0&&(h=Ta(l))))):(A=u&~m,A!==0?h=Ta(A):w!==0?h=Ta(w):l||(l=u&~t,l!==0&&(h=Ta(l)))),h===0?0:a!==0&&a!==h&&(a&m)===0&&(m=h&-h,l=a&-a,m>=l||m===32&&(l&4194048)!==0)?a:h}function Xr(t,a){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&a)===0}function Mt(t,a){(a&8)!==0&&(a|=a&32);var l=t.entangledLanes;if(l!==0)for(t=t.entanglements,l&=a;0<l;){var u=31-Ct(l),h=1<<u;a|=t[u],l&=~h}return a}function Un(t,a){switch(t){case 1:case 2:case 4:case 8:case 64:return a+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 a+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 Vs(){var t=as;return as<<=1,(as&62914560)===0&&(as=4194304),t}function to(t){for(var a=[],l=0;31>l;l++)a.push(t);return a}function no(t,a){t.pendingLanes|=a,a!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function $h(t,a,l,u,h,m){var w=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var A=t.entanglements,B=t.expirationTimes,ne=t.hiddenUpdates;for(l=w&~l;0<l;){var de=31-Ct(l),_e=1<<de;A[de]=0,B[de]=-1;var ee=ne[de];if(ee!==null)for(ne[de]=null,de=0;de<ee.length;de++){var ce=ee[de];ce!==null&&(ce.lane&=-536870913)}l&=~_e}u!==0&&so(t,u,0),m!==0&&h===0&&t.tag!==0&&(t.suspendedLanes|=m&~(w&~a))}function so(t,a,l){t.pendingLanes|=a,t.suspendedLanes&=~a;var u=31-Ct(a);t.entangledLanes|=a,t.entanglements[u]=t.entanglements[u]|1073741824|l&261930}function au(t,a){var l=t.entangledLanes|=a;for(t=t.entanglements;l;){var u=31-Ct(l),h=1<<u;h&a|t[u]&a&&(t[u]|=a),l&=~h}}function Qr(t,a){var l=a&-a;return l=(l&42)!==0?1:fl(l),(l&(t.suspendedLanes|a))!==0?0:l}function fl(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 ru(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function iu(){var t=Ue.p;return t!==0?t:(t=window.event,t===void 0?32:FS(t.type))}function ou(t,a){var l=Ue.p;try{return Ue.p=t,a()}finally{Ue.p=l}}var rs=Math.random().toString(36).slice(2),Ut="__reactFiber$"+rs,on="__reactProps$"+rs,la="__reactContainer$"+rs,lu="__reactEvents$"+rs,cu="__reactListeners$"+rs,uu="__reactHandles$"+rs,Ih="__reactResources$"+rs,or="__reactMarker$"+rs,pl="__reactLoad$"+rs;function Jr(t){delete t[Ut],delete t[on],delete t[cu],delete t[uu]}function Ea(t){var a;if(a=t[Ut])return a;for(var l=t.parentNode;l;){if(a=l[la]||l[Ut]){if(l=a.alternate,a.child!==null||l!==null&&l.child!==null)for(t=CS(t);t!==null;){if(l=t[Ut])return l;t=CS(t)}return a}t=l,l=t.parentNode}return null}function Zr(t){if(t=t[Ut]||t[la]){var a=t.tag;if(a===5||a===6||a===13||a===31||a===26||a===27||a===3)return t}return null}function Ma(t){var a=t.tag;if(a===5||a===26||a===27||a===6)return t.stateNode;throw Error(s(33))}function ei(t){var a=t[Ih];return a||(a=t[Ih]={hoistableStyles:new Map,hoistableScripts:new Map}),a}function At(t){t[or]=!0}function Dh(t){t[pl]=void 0}var qh=new Set,lr={};function je(t,a){Jt(t,a),Jt(t+"Capture",a)}function Jt(t,a){for(lr[t]=a,t=0;t<a.length;t++)qh.add(a[t])}var Lh=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]*$"),Uh={},ti={};function o0(t){return Wr.call(ti,t)?!0:Wr.call(Uh,t)?!1:Lh.test(t)?ti[t]=!0:(Uh[t]=!0,!1)}var ct=!1;function ao(){var t=ct;return ct=!1,t}function ca(t,a,l){if(o0(a))if(l===null)t.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":t.removeAttribute(a);return;case"boolean":var u=a.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){t.removeAttribute(a);return}}t.setAttribute(a,l)}}function ws(t,a,l){if(l===null)t.removeAttribute(a);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(a);return}t.setAttribute(a,l)}}function Pt(t,a,l,u){if(u===null)t.removeAttribute(l);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(l);return}t.setAttributeNS(a,l,u)}}function fn(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function ua(t){var a=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function gl(t,a,l){var u=Object.getOwnPropertyDescriptor(t.constructor.prototype,a);if(!t.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var h=u.get,m=u.set;return Object.defineProperty(t,a,{configurable:!0,get:function(){return h.call(this)},set:function(w){l=""+w,m.call(this,w)}}),Object.defineProperty(t,a,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(w){l=""+w},stopTracking:function(){t._valueTracker=null,delete t[a]}}}}function du(t){if(!t._valueTracker){var a=ua(t)?"checked":"value";t._valueTracker=gl(t,a,""+t[a])}}function bl(t){if(!t)return!1;var a=t._valueTracker;if(!a)return!0;var l=a.getValue(),u="";return t&&(u=ua(t)?t.checked?"true":"false":t.value),t=u,t!==l?(a.setValue(t),!0):!1}var cr=/[\n"\\]/g;function Bn(t){return t.replace(cr,function(a){return"\\"+a.charCodeAt(0).toString(16)+" "})}function hu(t,a,l,u,h,m,w,A){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),a!=null?w==="number"?(a===0&&t.value===""||t.value!=a)&&(t.value=""+fn(a)):t.value!==""+fn(a)&&(t.value=""+fn(a)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),a!=null?w==="number"&&t.value==a?mu(t,fn(t.value)):mu(t,fn(a)):l!=null?mu(t,fn(l)):u!=null&&t.removeAttribute("value"),h==null&&m!=null&&(t.defaultChecked=!!m),h!=null&&(t.checked=h&&typeof h!="function"&&typeof h!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?t.name=""+fn(A):t.removeAttribute("name")}function Yt(t,a,l,u,h,m,w,A){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(t.type=m),a!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||a!=null)){du(t);return}l=l!=null?""+fn(l):"",a=a!=null?""+fn(a):l,A||a===t.value||(t.value=a),t.defaultValue=a}u=u??h,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=A?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),du(t)}function mu(t,a){t.defaultValue!==""+a&&(t.defaultValue=""+a)}function Ra(t,a,l,u){if(t=t.options,a){a={};for(var h=0;h<l.length;h++)a["$"+l[h]]=!0;for(l=0;l<t.length;l++)h=a.hasOwnProperty("$"+t[l].value),t[l].selected!==h&&(t[l].selected=h),h&&u&&(t[l].defaultSelected=!0)}else{for(l=""+fn(l),a=null,h=0;h<t.length;h++){if(t[h].value===l){t[h].selected=!0,u&&(t[h].defaultSelected=!0);return}a!==null||t[h].disabled||(a=t[h])}a!==null&&(a.selected=!0)}}function xl(t,a,l){if(a!=null&&(a=""+fn(a),a!==t.value&&(t.value=a),l==null)){t.defaultValue!==a&&(t.defaultValue=a);return}t.defaultValue=l!=null?""+fn(l):""}function fu(t,a,l,u){if(a==null){if(u!=null){if(l!=null)throw Error(s(92));if($e(u)){if(1<u.length)throw Error(s(93));u=u[0]}l=u}l==null&&(l=""),a=l}l=fn(a),t.defaultValue=l,u=t.textContent,u===l&&u!==""&&u!==null&&(t.value=u),du(t)}function za(t,a){if(a){var l=t.firstChild;if(l&&l===t.lastChild&&l.nodeType===3){l.nodeValue=a;return}}t.textContent=a}var l0=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 ni(t,a,l){var u=a.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?u?t.setProperty(a,""):a==="float"?t.cssFloat="":t[a]="":u?t.setProperty(a,l):typeof l!="number"||l===0||l0.has(a)?a==="float"?t.cssFloat=l:t[a]=(""+l).trim():t[a]=l+"px"}function da(t,a,l){if(a!=null&&typeof a!="object")throw Error(s(62));if(t=t.style,l!=null){for(var u in l)!l.hasOwnProperty(u)||a!=null&&a.hasOwnProperty(u)||(u.indexOf("--")===0?t.setProperty(u,""):u==="float"?t.cssFloat="":t[u]="",ct=!0);for(var h in a)u=a[h],a.hasOwnProperty(h)&&l[h]!==u&&(ni(t,h,u),ct=!0)}else for(var m in a)a.hasOwnProperty(m)&&ni(t,m,a[m])}function is(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 si=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"],["maskType","mask-type"],["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"]]),Bh=/^[\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 ro(t){return Bh.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}function jn(){}var yl=null;function Ks(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ur=null,ha=null;function _l(t){var a=Zr(t);if(a&&(t=a.stateNode)){var l=t[on]||null;e:switch(t=a.stateNode,a.type){case"input":if(hu(t,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),a=l.name,l.type==="radio"&&a!=null){for(l=t;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Bn(""+a)+'"][type="radio"]'),a=0;a<l.length;a++){var u=l[a];if(u!==t&&u.form===t.form){var h=u[on]||null;if(!h)throw Error(s(90));hu(u,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name)}}for(a=0;a<l.length;a++)u=l[a],u.form===t.form&&bl(u)}break e;case"textarea":xl(t,l.value,l.defaultValue);break e;case"select":a=l.value,a!=null&&Ra(t,!!l.multiple,a,!1)}}}var pu=!1;function vl(t,a,l){if(pu)return t(a,l);pu=!0;try{var u=t(a);return u}finally{if(pu=!1,(ur!==null||ha!==null)&&(Im(),ur&&(a=ur,t=ha,ha=ur=null,_l(a),t)))for(a=0;a<t.length;a++)_l(t[a])}}function io(t,a){var l=t.stateNode;if(l===null)return null;var u=l[on]||null;if(u===null)return null;l=u[a];e:switch(a){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(l&&typeof l!="function")throw Error(s(231,a,typeof l));return l}var Ss=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gu=!1;if(Ss)try{var oo={};Object.defineProperty(oo,"passive",{get:function(){gu=!0}}),window.addEventListener("test",oo,oo),window.removeEventListener("test",oo,oo)}catch{gu=!1}var ma=null,bn=null,wl=null;function ai(){if(wl)return wl;var t,a=bn,l=a.length,u,h="value"in ma?ma.value:ma.textContent,m=h.length;for(t=0;t<l&&a[t]===h[t];t++);var w=l-t;for(u=1;u<=w&&a[l-u]===h[m-u];u++);return wl=h.slice(t,1<u?1-u:void 0)}function Oa(t){var a=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&a===13&&(t=13)):t=a,t===10&&(t=13),32<=t||t===13?t:0}function Sl(){return!0}function lo(){return!1}function ln(t){function a(l,u,h,m,w){this._reactName=l,this._targetInst=h,this.type=u,this.nativeEvent=m,this.target=w,this.currentTarget=null;for(var A in t)t.hasOwnProperty(A)&&(l=t[A],this[A]=l?l(m):m[A]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?Sl:lo,this.isPropagationStopped=lo,this}return P(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Sl)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Sl)},persist:function(){},isPersistent:Sl}),a}var Pa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kl=ln(Pa),co=P({},Pa,{view:0,detail:0}),c0=ln(co),bu,M,R,X=P({},co,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:d0,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!==R&&(R&&t.type==="mousemove"?(bu=t.screenX-R.screenX,M=t.screenY-R.screenY):M=bu=0,R=t),bu)},movementY:function(t){return"movementY"in t?t.movementY:M}}),oe=ln(X),fe=P({},X,{dataTransfer:0}),ke=ln(fe),Le=P({},co,{relatedTarget:0}),Be=ln(Le),ft=P({},Pa,{animationName:0,elapsedTime:0,pseudoElement:0}),vt=ln(ft),Zt=P({},Pa,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),ks=ln(Zt),ri=P({},Pa,{data:0}),$a=ln(ri),u0={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kE={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"},CE={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function NE(t){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(t):(t=CE[t])?!!a[t]:!1}function d0(){return NE}var AE=P({},co,{key:function(t){if(t.key){var a=u0[t.key]||t.key;if(a!=="Unidentified")return a}return t.type==="keypress"?(t=Oa(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?kE[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:d0,charCode:function(t){return t.type==="keypress"?Oa(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Oa(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),jE=ln(AE),TE=P({},X,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),o1=ln(TE),EE=P({},Pa,{submitter:0}),ME=ln(EE),RE=P({},co,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:d0}),zE=ln(RE),OE=P({},Pa,{propertyName:0,elapsedTime:0,pseudoElement:0}),PE=ln(OE),$E=P({},X,{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}),IE=ln($E),DE=P({},Pa,{newState:0,oldState:0,source:0}),qE=ln(DE),LE=[9,13,27,32],h0=Ss&&"CompositionEvent"in window,xu=null;Ss&&"documentMode"in document&&(xu=document.documentMode);var UE=Ss&&"TextEvent"in window&&!xu,l1=Ss&&(!h0||xu&&8<xu&&11>=xu),c1=" ",u1=!1;function d1(t,a){switch(t){case"keyup":return LE.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function h1(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Cl=!1;function BE(t,a){switch(t){case"compositionend":return h1(a);case"keypress":return a.which!==32?null:(u1=!0,c1);case"textInput":return t=a.data,t===c1&&u1?null:t;default:return null}}function GE(t,a){if(Cl)return t==="compositionend"||!h0&&d1(t,a)?(t=ai(),wl=bn=ma=null,Cl=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return l1&&a.locale!=="ko"?null:a.data;default:return null}}var HE={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 m1(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a==="input"?!!HE[t.type]:a==="textarea"}function f1(t,a,l,u){ur?ha?ha.push(u):ha=[u]:ur=u,a=Gm(a,"onChange"),0<a.length&&(l=new kl("onChange","change",null,l,u),t.push({event:l,listeners:a}))}var yu=null,_u=null;function FE(t){tS(t,0)}function Gh(t){var a=Ma(t);if(bl(a))return t}function p1(t,a){if(t==="change")return a}var g1=!1;if(Ss){var m0;if(Ss){var f0="oninput"in document;if(!f0){var b1=document.createElement("div");b1.setAttribute("oninput","return;"),f0=typeof b1.oninput=="function"}m0=f0}else m0=!1;g1=m0&&(!document.documentMode||9<document.documentMode)}function x1(){yu&&(yu.detachEvent("onpropertychange",y1),_u=yu=null)}function y1(t){if(t.propertyName==="value"&&Gh(_u)){var a=[];f1(a,_u,t,Ks(t)),vl(FE,a)}}function VE(t,a,l){t==="focusin"?(x1(),yu=a,_u=l,yu.attachEvent("onpropertychange",y1)):t==="focusout"&&x1()}function KE(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return Gh(_u)}function YE(t,a){if(t==="click")return Gh(a)}function WE(t,a){if(t==="input"||t==="change")return Gh(a)}function XE(t,a){return t===a&&(t!==0||1/t===1/a)||t!==t&&a!==a}var Cs=typeof Object.is=="function"?Object.is:XE;function vu(t,a){if(Cs(t,a))return!0;if(typeof t!="object"||t===null||typeof a!="object"||a===null)return!1;var l=Object.keys(t),u=Object.keys(a);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var h=l[u];if(!Wr.call(a,h)||!Cs(t[h],a[h]))return!1}return!0}function p0(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function _1(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function v1(t,a){var l=_1(t);t=0;for(var u;l;){if(l.nodeType===3){if(u=t+l.textContent.length,t<=a&&u>=a)return{node:l,offset:a-t};t=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=_1(l)}}function w1(t,a){return t&&a?t===a?!0:t&&t.nodeType===3?!1:a&&a.nodeType===3?w1(t,a.parentNode):"contains"in t?t.contains(a):t.compareDocumentPosition?!!(t.compareDocumentPosition(a)&16):!1:!1}function S1(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var a=p0(t.document);a instanceof t.HTMLIFrameElement;){try{var l=typeof a.contentWindow.location.href=="string"}catch{l=!1}if(l)t=a.contentWindow;else break;a=p0(t.document)}return a}function g0(t){var a=t&&t.nodeName&&t.nodeName.toLowerCase();return a&&(a==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||a==="textarea"||t.contentEditable==="true")}var QE=Ss&&"documentMode"in document&&11>=document.documentMode,Nl=null,b0=null,wu=null,x0=!1;function k1(t,a,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;x0||Nl==null||Nl!==p0(u)||(u=Nl,"selectionStart"in u&&g0(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}),wu&&vu(wu,u)||(wu=u,u=Gm(b0,"onSelect"),0<u.length&&(a=new kl("onSelect","select",null,a,l),t.push({event:a,listeners:u}),a.target=Nl)))}function uo(t,a){var l={};return l[t.toLowerCase()]=a.toLowerCase(),l["Webkit"+t]="webkit"+a,l["Moz"+t]="moz"+a,l}var Al={animationend:uo("Animation","AnimationEnd"),animationiteration:uo("Animation","AnimationIteration"),animationstart:uo("Animation","AnimationStart"),transitionrun:uo("Transition","TransitionRun"),transitionstart:uo("Transition","TransitionStart"),transitioncancel:uo("Transition","TransitionCancel"),transitionend:uo("Transition","TransitionEnd")},y0={},C1={};Ss&&(C1=document.createElement("div").style,"AnimationEvent"in window||(delete Al.animationend.animation,delete Al.animationiteration.animation,delete Al.animationstart.animation),"TransitionEvent"in window||delete Al.transitionend.transition);function ho(t){if(y0[t])return y0[t];if(!Al[t])return t;var a=Al[t],l;for(l in a)if(a.hasOwnProperty(l)&&l in C1)return y0[t]=a[l];return t}var N1=ho("animationend"),A1=ho("animationiteration"),j1=ho("animationstart"),JE=ho("transitionrun"),ZE=ho("transitionstart"),e4=ho("transitioncancel"),T1=ho("transitionend"),E1=new Map,_0="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError 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(" ");_0.push("scrollEnd");function fa(t,a){E1.set(t,a),je(a,[t])}var t4=0;function dr(t,a){if(t.name!=null&&t.name!=="auto")return t.name;if(a.autoName!==null)return a.autoName;t=xa.identifierPrefix;var l=t4++;return t="_"+t+"t_"+l.toString(32)+"_",a.autoName=t}function M1(t){if(t==null||typeof t=="string")return t;var a=null,l=Kl;if(l!==null)for(var u=0;u<l.length;u++){var h=t[l[u]];if(h!=null){if(h==="none")return"none";a=a==null?h:a+(" "+h)}}return a??t.default}function hr(t,a){return t=M1(t),a=M1(a),a==null?t==="auto"?null:t:a==="auto"?null:a}var Hh=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var a=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(a))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},Ys=[],jl=0,v0=0;function Fh(){for(var t=jl,a=v0=jl=0;a<t;){var l=Ys[a];Ys[a++]=null;var u=Ys[a];Ys[a++]=null;var h=Ys[a];Ys[a++]=null;var m=Ys[a];if(Ys[a++]=null,u!==null&&h!==null){var w=u.pending;w===null?h.next=h:(h.next=w.next,w.next=h),u.pending=h}m!==0&&R1(l,h,m)}}function Vh(t,a,l,u){Ys[jl++]=t,Ys[jl++]=a,Ys[jl++]=l,Ys[jl++]=u,v0|=u,t.lanes|=u,t=t.alternate,t!==null&&(t.lanes|=u)}function w0(t,a,l,u){return Vh(t,a,l,u),Kh(t)}function mo(t,a){return Vh(t,null,null,a),Kh(t)}function R1(t,a,l){t.lanes|=l;var u=t.alternate;u!==null&&(u.lanes|=l);for(var h=!1,m=t.return;m!==null;)m.childLanes|=l,u=m.alternate,u!==null&&(u.childLanes|=l),m.tag===22&&(t=m.stateNode,t===null||t._visibility&1||(h=!0)),t=m,m=m.return;return t.tag===3?(m=t.stateNode,h&&a!==null&&(h=31-Ct(l),t=m.hiddenUpdates,u=t[h],u===null?t[h]=[a]:u.push(a),a.lane=l|536870912),m):null}function Kh(t){if(50<Hu)throw Hu=0,$m=null,Error(s(185));for(var a=t.return;a!==null;)t=a,a=t.return;return t.tag===3?t.stateNode:null}var Tl={};function n4(t,a,l,u){this.tag=t,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=a,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 os(t,a,l,u){return new n4(t,a,l,u)}function S0(t){return t=t.prototype,!(!t||!t.isReactComponent)}function mr(t,a){var l=t.alternate;return l===null?(l=os(t.tag,a,t.key,t.mode),l.elementType=t.elementType,l.type=t.type,l.stateNode=t.stateNode,l.alternate=t,t.alternate=l):(l.pendingProps=a,l.type=t.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=t.flags&1206910976,l.childLanes=t.childLanes,l.lanes=t.lanes,l.child=t.child,l.memoizedProps=t.memoizedProps,l.memoizedState=t.memoizedState,l.updateQueue=t.updateQueue,a=t.dependencies,l.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},l.sibling=t.sibling,l.index=t.index,l.ref=t.ref,l.refCleanup=t.refCleanup,l}function z1(t,a){t.flags&=1206910978;var l=t.alternate;return l===null?(t.childLanes=0,t.lanes=a,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=l.childLanes,t.lanes=l.lanes,t.child=l.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=l.memoizedProps,t.memoizedState=l.memoizedState,t.updateQueue=l.updateQueue,t.type=l.type,a=l.dependencies,t.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),t}function Yh(t,a,l,u,h,m){var w=0;if(u=t,typeof u=="function")S0(u)&&(w=1);else if(typeof u=="string")w=EM(t,l,ue.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(u){case J:return t=os(31,l,a,h),t.elementType=J,t.lanes=m,t;case G:return fo(l.children,h,m,a);case K:w=8,h|=24;break;case we:return t=os(12,l,a,h|2),t.elementType=we,t.lanes=m,t;case he:return t=os(13,l,a,h),t.elementType=he,t.lanes=m,t;case W:return t=os(19,l,a,h),t.elementType=W,t.lanes=m,t;case ge:case D:return t=h|32,t=os(30,l,a,t),t.elementType=D,t.lanes=m,t.stateNode={autoName:null,paired:null,clones:null,ref:null},t;default:if(typeof u=="object"&&u!==null)switch(u.$$typeof){case Q:w=10;break e;case Se:w=9;break e;case F:w=11;break e;case me:w=14;break e;case I:w=16,u=null;break e}w=29,l=Error(s(130,t===null?"null":typeof t,"")),u=null}return a=os(w,l,a,h),a.elementType=t,a.type=u,a.lanes=m,a}function fo(t,a,l,u){return t=os(7,t,u,a),t.lanes=l,t}function k0(t,a,l){return t=os(6,t,null,a),t.lanes=l,t}function O1(t){var a=os(18,null,null,0);return a.stateNode=t,a}function C0(t,a,l){return a=os(4,t.children!==null?t.children:[],t.key,a),a.lanes=l,a.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},a}var P1=new WeakMap;function Ws(t,a){if(typeof t=="object"&&t!==null){var l=P1.get(t);return l!==void 0?l:(a={value:t,source:a,stack:qn(a)},P1.set(t,a),a)}return{value:t,source:a,stack:qn(a)}}var El=[],Ml=0,Wh=null,Su=0,Xs=[],Qs=0,ii=null,Ia=1,Da="";function fr(t,a){El[Ml++]=Su,El[Ml++]=Wh,Wh=t,Su=a}function $1(t,a,l){Xs[Qs++]=Ia,Xs[Qs++]=Da,Xs[Qs++]=ii,ii=t;var u=Ia;t=Da;var h=32-Ct(u)-1;u&=~(1<<h),l+=1;var m=32-Ct(a)+h;if(30<m){var w=h-h%5;m=(u&(1<<w)-1).toString(32),u>>=w,h-=w,Ia=1<<32-Ct(a)+h|l<<h|u,Da=m+t}else Ia=1<<m|l<<h|u,Da=t}function Xh(t){t.return!==null&&(fr(t,1),$1(t,1,0))}function N0(t){for(;t===Wh;)Wh=El[--Ml],El[Ml]=null,Su=El[--Ml],El[Ml]=null;for(;t===ii;)ii=Xs[--Qs],Xs[Qs]=null,Da=Xs[--Qs],Xs[Qs]=null,Ia=Xs[--Qs],Xs[Qs]=null}function I1(t,a){Xs[Qs++]=Ia,Xs[Qs++]=Da,Xs[Qs++]=ii,Ia=a.id,Da=a.overflow,ii=t}var xn=null,Dt=null,lt=!1,oi=null,Js=!1,A0=Error(s(519));function li(t){var a=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ku(Ws(a,t)),A0}function D1(t){var a=t.stateNode,l=t.type,u=t.memoizedProps;switch(a[Ut]=t,a[on]=u,l){case"dialog":ht("cancel",a),ht("close",a);break;case"iframe":case"object":case"embed":ht("load",a);break;case"video":case"audio":for(l=0;l<Vu.length;l++)ht(Vu[l],a);break;case"source":ht("error",a);break;case"img":case"image":case"link":ht("error",a),ht("load",a);break;case"details":ht("toggle",a);break;case"input":ht("invalid",a),Yt(a,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":ht("invalid",a);break;case"textarea":ht("invalid",a),fu(a,u.value,u.defaultValue,u.children)}l=u.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||a.textContent===""+l||u.suppressHydrationWarning===!0||rS(a.textContent,l)?(u.popover!=null&&(ht("beforetoggle",a),ht("toggle",a)),u.onScroll!=null&&ht("scroll",a),u.onScrollEnd!=null&&ht("scrollend",a),u.onClick!=null&&(a.onclick=jn),a=!0):a=!1,a||li(t,!0)}function Qh(t){for(xn=t.return;xn;)switch(xn.tag){case 5:case 31:case 13:Js=!1;return;case 27:case 3:Js=!0;return;default:xn=xn.return}}function Rl(t){if(t!==xn)return!1;if(!lt)return Qh(t),lt=!0,!1;var a=t.tag,l;if((l=a!==3&&a!==27)&&((l=a===5)&&(l=t.type,l=!(l!=="form"&&l!=="button")||sb(t.type,t.memoizedProps)),l=!l),l&&Dt&&li(t),Qh(t),a===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Dt=kS(t)}else if(a===31){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(317));Dt=kS(t)}else a===27?(a=Dt,ki(t.type)?(t=hb,hb=null,Dt=t):Dt=a):Dt=xn?ea(t.stateNode.nextSibling):null;return!0}function po(){Dt=xn=null,lt=!1}function j0(){var t=oi;return t!==null&&(us===null?us=t:us.push.apply(us,t),oi=null),t}function ku(t){oi===null?oi=[t]:oi.push(t)}var T0=St(null),go=null,pr=null;function ci(t,a,l){et(T0,a._currentValue),a._currentValue=l}function gr(t){t._currentValue=T0.current,Ke(T0)}function Jh(t,a,l){for(;t!==null;){var u=t.alternate;if((t.childLanes&a)!==a?(t.childLanes|=a,u!==null&&(u.childLanes|=a)):u!==null&&(u.childLanes&a)!==a&&(u.childLanes|=a),t===l)break;t=t.return}}function E0(t,a,l,u){var h=t.child;for(h!==null&&(h.return=t);h!==null;){var m=h.dependencies;if(m!==null){var w=h.child;m=m.firstContext;e:for(;m!==null;){var A=m;m=h;for(var B=0;B<a.length;B++)if(A.context===a[B]){m.lanes|=l,A=m.alternate,A!==null&&(A.lanes|=l),Jh(m.return,l,t),u||(w=null);break e}m=A.next}}else if(h.tag===18){if(w=h.return,w===null)throw Error(s(341));w.lanes|=l,m=w.alternate,m!==null&&(m.lanes|=l),Jh(w,l,t),w=null}else h.tag===13&&h.memoizedState!==null&&h.memoizedState.dehydrated===null?(h.lanes|=l,w=h.alternate,w!==null&&(w.lanes|=l),Jh(h.return,l,t),w=h.child,w=w!==null?w.sibling:null):w=h.child;if(w!==null)w.return=h;else for(w=h;w!==null;){if(w===t){w=null;break}if(h=w.sibling,h!==null){h.return=w.return,w=h;break}w=w.return}h=w}}function bo(t,a,l,u){t=null;for(var h=a,m=!1;h!==null;){if(!m){if((h.flags&524288)!==0)m=!0;else if((h.flags&262144)!==0)break}if(h.tag===10){var w=h.alternate;if(w===null)throw Error(s(387));if(w=w.memoizedProps,w!==null){var A=h.type;Cs(h.pendingProps.value,w.value)||(t!==null?t.push(A):t=[A])}}else if(h===ut.current){if(w=h.alternate,w===null)throw Error(s(387));w.memoizedState.memoizedState!==h.memoizedState.memoizedState&&(t!==null?t.push(sc):t=[sc])}h=h.return}return t!==null&&E0(a,t,l,u),a.flags|=262144,t!==null}function Zh(t){for(t=t.firstContext;t!==null;){if(!Cs(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function xo(t){go=t,pr=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Tn(t){return q1(go,t)}function em(t,a){return go===null&&xo(t),q1(t,a)}function q1(t,a){var l=a._currentValue;if(a={context:a,memoizedValue:l,next:null},pr===null){if(t===null)throw Error(s(308));pr=a,t.dependencies={lanes:0,firstContext:a},t.flags|=524288}else pr=pr.next=a;return l}var s4=typeof AbortController<"u"?AbortController:function(){var t=[],a=this.signal={aborted:!1,addEventListener:function(l,u){t.push(u)}};this.abort=function(){a.aborted=!0,t.forEach(function(l){return l()})}},a4=e.unstable_scheduleCallback,r4=e.unstable_NormalPriority,cn={$$typeof:Q,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function M0(){return{controller:new s4,data:new Map,refCount:0}}function Cu(t){t.refCount--,t.refCount===0&&a4(r4,function(){t.controller.abort()})}function L1(t,a){if((t.pendingLanes&4194048)!==0){var l=t.transitionTypes;for(l===null&&(l=t.transitionTypes=[]),t=0;t<a.length;t++){var u=a[t];l.indexOf(u)===-1&&l.push(u)}}}var Nu=null;function i4(t){var a=t.transitionTypes;return t.transitionTypes=null,a}var Au=null,R0=0,yo=0,zl=null;function o4(t,a){if(Au===null){var l=Au=[];R0=0,yo=Yg(),zl={status:"pending",value:void 0,then:function(u){l.push(u)}}}return R0++,a.then(U1,U1),a}function U1(){if(--R0===0&&(Nu=null,Au!==null)){zl!==null&&(zl.status="fulfilled");var t=Au;Au=null,yo=0,zl=null;for(var a=0;a<t.length;a++)(0,t[a])()}}function l4(t,a){var l=[],u={status:"pending",value:null,reason:null,then:function(h){l.push(h)}};return t.then(function(){u.status="fulfilled",u.value=a;for(var h=0;h<l.length;h++)(0,l[h])(a)},function(h){for(u.status="rejected",u.reason=h,h=0;h<l.length;h++)(0,l[h])(void 0)}),u}var B1=Ce.S;Ce.S=function(t,a){if(O2=tt(),typeof a=="object"&&a!==null&&typeof a.then=="function"&&o4(t,a),Nu!==null)for(var l=Ql;l!==null;)L1(l,Nu),l=l.next;if(l=t.types,l!==null){for(var u=Ql;u!==null;)L1(u,l),u=u.next;if(yo!==0){u=Nu,u===null&&(u=Nu=[]);for(var h=0;h<l.length;h++){var m=l[h];u.indexOf(m)===-1&&u.push(m)}}}B1!==null&&B1(t,a)};var _o=St(null);function z0(){var t=_o.current;return t!==null?t:$t.pooledCache}function tm(t,a){a===null?et(_o,_o.current):et(_o,a.pool)}function G1(){var t=z0();return t===null?null:{parent:cn._currentValue,pool:t}}var Ol=Error(s(460)),O0=Error(s(474)),nm=Error(s(542)),sm={then:function(){}};function H1(t){return t=t.status,t==="fulfilled"||t==="rejected"}function F1(t,a,l){switch(l=t[l],l===void 0?t.push(a):l!==a&&(a.then(jn,jn),a=l),a.status){case"fulfilled":return a.value;case"rejected":throw t=a.reason,K1(t),t===void 0&&!("reason"in a)?Error(s(600)):t;default:if(typeof a.status=="string")a.then(jn,jn);else{if(t=$t,t!==null&&100<t.shellSuspendCounter)throw Error(s(482));t=a,t.status="pending",t.then(function(u){if(a.status==="pending"){var h=a;h.status="fulfilled",h.value=u}},function(u){if(a.status==="pending"){var h=a;h.status="rejected",h.reason=u}})}switch(a.status){case"fulfilled":return a.value;case"rejected":throw t=a.reason,K1(t),t}throw wo=a,Ol}}function vo(t){try{var a=t._init;return a(t._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(wo=l,Ol):l}}var wo=null;function V1(){if(wo===null)throw Error(s(459));var t=wo;return wo=null,t}function K1(t){if(t===Ol||t===nm)throw Error(s(483))}var Pl=null,ju=0;function am(t){var a=ju;return ju+=1,Pl===null&&(Pl=[]),F1(Pl,t,a)}function ui(t,a){a=a.props.ref,t.ref=a!==void 0?a:null}function rm(t,a){throw a.$$typeof===$?Error(s(525)):(t=Object.prototype.toString.call(a),Error(s(31,t==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":t)))}function Y1(t){function a(te,Y){if(t){var ie=te.deletions;ie===null?(te.deletions=[Y],te.flags|=16):ie.push(Y)}}function l(te,Y){if(!t)return null;for(;Y!==null;)a(te,Y),Y=Y.sibling;return null}function u(te){for(var Y=new Map;te!==null;)te.key===null?Y.set(te.index,te):Y.set(te.key,te),te=te.sibling;return Y}function h(te,Y){return te=mr(te,Y),te.index=0,te.sibling=null,te}function m(te,Y,ie){return te.index=ie,t?(ie=te.alternate,ie!==null?(ie=ie.index,ie<Y?(te.flags|=2,Y):ie):(te.flags|=134217730,Y)):(te.flags|=1048576,Y)}function w(te){return t&&te.alternate===null&&(te.flags|=134217730),te}function A(te,Y,ie,xe){return Y===null||Y.tag!==6?(Y=k0(ie,te.mode,xe),Y.return=te,Y):(Y=h(Y,ie),Y.return=te,Y)}function B(te,Y,ie,xe){var qe=ie.type;return qe===G?(te=de(te,Y,ie.props.children,xe,ie.key),ui(te,ie),te):Y!==null&&(Y.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===I&&vo(qe)===Y.type)?(Y=h(Y,ie.props),ui(Y,ie),Y.return=te,Y):(Y=Yh(ie.type,ie.key,ie.props,null,te.mode,xe),ui(Y,ie),Y.return=te,Y)}function ne(te,Y,ie,xe){return Y===null||Y.tag!==4||Y.stateNode.containerInfo!==ie.containerInfo||Y.stateNode.implementation!==ie.implementation?(Y=C0(ie,te.mode,xe),Y.return=te,Y):(Y=h(Y,ie.children||[]),Y.return=te,Y)}function de(te,Y,ie,xe,qe){return Y===null||Y.tag!==7?(Y=fo(ie,te.mode,xe,qe),Y.return=te,Y):(Y=h(Y,ie),Y.return=te,Y)}function _e(te,Y,ie){if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Y=k0(""+Y,te.mode,ie),Y.return=te,Y;if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case H:return ie=Yh(Y.type,Y.key,Y.props,null,te.mode,ie),ui(ie,Y),ie.return=te,ie;case Z:return Y=C0(Y,te.mode,ie),Y.return=te,Y;case I:return Y=vo(Y),_e(te,Y,ie)}if($e(Y)||Ae(Y))return Y=fo(Y,te.mode,ie,null),Y.return=te,Y;if(typeof Y.then=="function")return _e(te,am(Y),ie);if(Y.$$typeof===Q)return _e(te,em(te,Y),ie);rm(te,Y)}return null}function ee(te,Y,ie,xe){var qe=Y!==null?Y.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return qe!==null?null:A(te,Y,""+ie,xe);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case H:return ie.key===qe?B(te,Y,ie,xe):null;case Z:return ie.key===qe?ne(te,Y,ie,xe):null;case I:return ie=vo(ie),ee(te,Y,ie,xe)}if($e(ie)||Ae(ie))return qe!==null?null:de(te,Y,ie,xe,null);if(typeof ie.then=="function")return ee(te,Y,am(ie),xe);if(ie.$$typeof===Q)return ee(te,Y,em(te,ie),xe);rm(te,ie)}return null}function ce(te,Y,ie,xe,qe){if(typeof xe=="string"&&xe!==""||typeof xe=="number"||typeof xe=="bigint")return te=te.get(ie)||null,A(Y,te,""+xe,qe);if(typeof xe=="object"&&xe!==null){switch(xe.$$typeof){case H:return te=te.get(xe.key===null?ie:xe.key)||null,B(Y,te,xe,qe);case Z:return te=te.get(xe.key===null?ie:xe.key)||null,ne(Y,te,xe,qe);case I:return xe=vo(xe),ce(te,Y,ie,xe,qe)}if($e(xe)||Ae(xe))return te=te.get(ie)||null,de(Y,te,xe,qe,null);if(typeof xe.then=="function")return ce(te,Y,ie,am(xe),qe);if(xe.$$typeof===Q)return ce(te,Y,ie,em(Y,xe),qe);rm(Y,xe)}return null}function ze(te,Y,ie,xe){for(var qe=null,gt=null,Ve=Y,Xe=Y=0,hn=null;Ve!==null&&Xe<ie.length;Xe++){Ve.index>Xe?(hn=Ve,Ve=null):hn=Ve.sibling;var xt=ee(te,Ve,ie[Xe],xe);if(xt===null){Ve===null&&(Ve=hn);break}t&&Ve&&xt.alternate===null&&a(te,Ve),Y=m(xt,Y,Xe),gt===null?qe=xt:gt.sibling=xt,gt=xt,Ve=hn}if(Xe===ie.length)return l(te,Ve),lt&&fr(te,Xe),qe;if(Ve===null){for(;Xe<ie.length;Xe++)Ve=_e(te,ie[Xe],xe),Ve!==null&&(Y=m(Ve,Y,Xe),gt===null?qe=Ve:gt.sibling=Ve,gt=Ve);return lt&&fr(te,Xe),qe}for(Ve=u(Ve);Xe<ie.length;Xe++)hn=ce(Ve,te,Xe,ie[Xe],xe),hn!==null&&(t&&(xt=hn.alternate,xt!==null&&Ve.delete(xt.key===null?Xe:xt.key)),Y=m(hn,Y,Xe),gt===null?qe=hn:gt.sibling=hn,gt=hn);return t&&Ve.forEach(function(Ti){return a(te,Ti)}),lt&&fr(te,Xe),qe}function Ge(te,Y,ie,xe){if(ie==null)throw Error(s(151));for(var qe=null,gt=null,Ve=Y,Xe=Y=0,hn=null,xt=ie.next();Ve!==null&&!xt.done;Xe++,xt=ie.next()){Ve.index>Xe?(hn=Ve,Ve=null):hn=Ve.sibling;var Ti=ee(te,Ve,xt.value,xe);if(Ti===null){Ve===null&&(Ve=hn);break}t&&Ve&&Ti.alternate===null&&a(te,Ve),Y=m(Ti,Y,Xe),gt===null?qe=Ti:gt.sibling=Ti,gt=Ti,Ve=hn}if(xt.done)return l(te,Ve),lt&&fr(te,Xe),qe;if(Ve===null){for(;!xt.done;Xe++,xt=ie.next())xt=_e(te,xt.value,xe),xt!==null&&(Y=m(xt,Y,Xe),gt===null?qe=xt:gt.sibling=xt,gt=xt);return lt&&fr(te,Xe),qe}for(Ve=u(Ve);!xt.done;Xe++,xt=ie.next())xt=ce(Ve,te,Xe,xt.value,xe),xt!==null&&(t&&(hn=xt.alternate,hn!==null&&Ve.delete(hn.key===null?Xe:hn.key)),Y=m(xt,Y,Xe),gt===null?qe=xt:gt.sibling=xt,gt=xt);return t&&Ve.forEach(function(BM){return a(te,BM)}),lt&&fr(te,Xe),qe}function rt(te,Y,ie,xe){if(typeof ie=="object"&&ie!==null&&ie.type===G&&ie.key===null&&ie.props.ref===void 0&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case H:e:{for(var qe=ie.key;Y!==null;){if(Y.key===qe){if(qe=ie.type,qe===G){if(Y.tag===7){l(te,Y.sibling),xe=h(Y,ie.props.children),ui(xe,ie),xe.return=te,te=xe;break e}}else if(Y.elementType===qe||typeof qe=="object"&&qe!==null&&qe.$$typeof===I&&vo(qe)===Y.type){l(te,Y.sibling),xe=h(Y,ie.props),ui(xe,ie),xe.return=te,te=xe;break e}l(te,Y);break}else a(te,Y);Y=Y.sibling}ie.type===G?(xe=fo(ie.props.children,te.mode,xe,ie.key),ui(xe,ie),xe.return=te,te=xe):(xe=Yh(ie.type,ie.key,ie.props,null,te.mode,xe),ui(xe,ie),xe.return=te,te=xe)}return w(te);case Z:e:{for(qe=ie.key;Y!==null;){if(Y.key===qe)if(Y.tag===4&&Y.stateNode.containerInfo===ie.containerInfo&&Y.stateNode.implementation===ie.implementation){l(te,Y.sibling),xe=h(Y,ie.children||[]),xe.return=te,te=xe;break e}else{l(te,Y);break}else a(te,Y);Y=Y.sibling}xe=C0(ie,te.mode,xe),xe.return=te,te=xe}return w(te);case I:return ie=vo(ie),rt(te,Y,ie,xe)}if($e(ie))return ze(te,Y,ie,xe);if(Ae(ie)){if(qe=Ae(ie),typeof qe!="function")throw Error(s(150));return ie=qe.call(ie),Ge(te,Y,ie,xe)}if(typeof ie.then=="function")return rt(te,Y,am(ie),xe);if(ie.$$typeof===Q)return rt(te,Y,em(te,ie),xe);rm(te,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,Y!==null&&Y.tag===6?(l(te,Y.sibling),xe=h(Y,ie),xe.return=te,te=xe):(l(te,Y),xe=k0(ie,te.mode,xe),xe.return=te,te=xe),w(te)):l(te,Y)}return function(te,Y,ie,xe){try{ju=0;var qe=rt(te,Y,ie,xe);return Pl=null,qe}catch(Ve){if(Ve===Ol||Ve===nm)throw Ve;var gt=os(29,Ve,null,te.mode);return gt.lanes=xe,gt.return=te,gt}finally{}}}var So=Y1(!0),W1=Y1(!1),di=!1;function P0(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $0(t,a){t=t.updateQueue,a.updateQueue===t&&(a.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function hi(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function mi(t,a,l){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(wt&2)!==0){var h=u.pending;return h===null?a.next=a:(a.next=h.next,h.next=a),u.pending=a,a=Kh(t),R1(t,null,l),a}return Vh(t,u,a,l),Kh(t)}function Tu(t,a,l){if(a=a.updateQueue,a!==null&&(a=a.shared,(l&4194048)!==0)){var u=a.lanes;u&=t.pendingLanes,l|=u,a.lanes=l,au(t,l)}}function I0(t,a){var l=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var h=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var w={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?h=m=w:m=m.next=w,l=l.next}while(l!==null);m===null?h=m=a:m=m.next=a}else h=m=a;l={baseState:u.baseState,firstBaseUpdate:h,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=a:t.next=a,l.lastBaseUpdate=a}var D0=!1;function Eu(){if(D0){var t=zl;if(t!==null)throw t}}function Mu(t,a,l,u){D0=!1;var h=t.updateQueue;di=!1;var m=h.firstBaseUpdate,w=h.lastBaseUpdate,A=h.shared.pending;if(A!==null){h.shared.pending=null;var B=A,ne=B.next;B.next=null,w===null?m=ne:w.next=ne,w=B;var de=t.alternate;de!==null&&(de=de.updateQueue,A=de.lastBaseUpdate,A!==w&&(A===null?de.firstBaseUpdate=ne:A.next=ne,de.lastBaseUpdate=B))}if(m!==null){var _e=h.baseState;w=0,de=ne=B=null,A=m;do{var ee=A.lane&-536870913,ce=ee!==A.lane;if(ce?(pt&ee)===ee:(u&ee)===ee){ee!==0&&ee===yo&&(D0=!0),de!==null&&(de=de.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var ze=t,Ge=A;ee=a;var rt=l;switch(Ge.tag){case 1:if(ze=Ge.payload,typeof ze=="function"){_e=ze.call(rt,_e,ee);break e}_e=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=Ge.payload,ee=typeof ze=="function"?ze.call(rt,_e,ee):ze,ee==null)break e;_e=P({},_e,ee);break e;case 2:di=!0}}ee=A.callback,ee!==null&&(t.flags|=64,ce&&(t.flags|=8192),ce=h.callbacks,ce===null?h.callbacks=[ee]:ce.push(ee))}else ce={lane:ee,tag:A.tag,payload:A.payload,callback:A.callback,next:null},de===null?(ne=de=ce,B=_e):de=de.next=ce,w|=ee;if(A=A.next,A===null){if(A=h.shared.pending,A===null)break;ce=A,A=ce.next,ce.next=null,h.lastBaseUpdate=ce,h.shared.pending=null}}while(!0);de===null&&(B=_e),h.baseState=B,h.firstBaseUpdate=ne,h.lastBaseUpdate=de,m===null&&(h.shared.lanes=0),_i|=w,t.lanes=w,t.memoizedState=_e}}function X1(t,a){if(typeof t!="function")throw Error(s(191,t));t.call(a)}function Q1(t,a){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;t<l.length;t++)X1(l[t],a)}var fi=St(null),im=St(0);function J1(t,a){t=vr,et(im,t),et(fi,a),vr=t|a.baseLanes}function q0(){et(im,vr),et(fi,fi.current)}function L0(){vr=im.current,Ke(fi),Ke(im)}var En=St(null),Gn=null;function pi(t){var a=t.alternate;et(Mn,Mn.current&1),et(En,t),Gn===null&&(a===null||fi.current!==null||a.memoizedState!==null)&&(Gn=t)}function U0(t){et(Mn,Mn.current),et(En,t),Gn===null&&(Gn=t)}function Z1(t){t.tag===22?(et(Mn,Mn.current),et(En,t),Gn===null&&(Gn=t)):gi()}function gi(){et(Mn,Mn.current),et(En,En.current)}function Ns(t){Ke(En),Gn===t&&(Gn=null),Ke(Mn)}var Mn=St(0);function Ru(t,a){et(En,En.current),et(Mn,a)}function B0(t){Ke(Mn),Ke(En),Gn===t&&(Gn=null)}function om(t){for(var a=t;a!==null;){if(a.tag===13){var l=a.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||ub(l)||db(l)))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!=="independent"){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var br=0,at=null,Rt=null,un=null,lm=!1,$l=!1,ko=!1,cm=0,zu=0,Il=null,c4=0;function en(){throw Error(s(321))}function G0(t,a){if(a===null)return!1;for(var l=0;l<a.length&&l<t.length;l++)if(!Cs(t[l],a[l]))return!1;return!0}function H0(t,a,l,u,h,m){return br=m,at=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ce.H=t===null||t.memoizedState===null?$w:Iw,ko=!1,m=l(u,h),ko=!1,$l&&(m=tw(a,l,u,h)),ew(t),m}function ew(t){Ce.H=gm;var a=Rt!==null&&Rt.next!==null;if(br=0,un=Rt=at=null,lm=!1,zu=0,Il=null,a)throw Error(s(300));t===null||dn||(t=t.dependencies,t!==null&&Zh(t)&&(dn=!0))}function tw(t,a,l,u){at=t;var h=0;do{if($l&&(Il=null),zu=0,$l=!1,25<=h)throw Error(s(301));if(h+=1,un=Rt=null,t.updateQueue!=null){var m=t.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}Ce.H=b4,m=a(l,u)}while($l);return m}function u4(){var t=Ce.H,a=t.useState()[0];return a=typeof a.then=="function"?Ou(a):a,t=t.useState()[0],(Rt!==null?Rt.memoizedState:null)!==t&&(at.flags|=1024),a}function F0(){var t=cm!==0;return cm=0,t}function V0(t,a,l){a.updateQueue=t.updateQueue,a.flags&=-2053,t.lanes&=~l}function K0(t){if(lm){for(t=t.memoizedState;t!==null;){var a=t.queue;a!==null&&(a.pending=null),t=t.next}lm=!1}br=0,un=Rt=at=null,$l=!1,zu=cm=0,Il=null}function Vn(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return un===null?at.memoizedState=un=t:un=un.next=t,un}function an(){if(Rt===null){var t=at.alternate;t=t!==null?t.memoizedState:null}else t=Rt.next;var a=un===null?at.memoizedState:un.next;if(a!==null)un=a,Rt=t;else{if(t===null)throw at.alternate===null?Error(s(467)):Error(s(310));Rt=t,t={memoizedState:Rt.memoizedState,baseState:Rt.baseState,baseQueue:Rt.baseQueue,queue:Rt.queue,next:null},un===null?at.memoizedState=un=t:un=un.next=t}return un}function um(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ou(t){var a=zu;return zu+=1,Il===null&&(Il=[]),t=F1(Il,t,a),a=at,(un===null?a.memoizedState:un.next)===null&&(a=a.alternate,Ce.H=a===null||a.memoizedState===null?$w:Iw),t}function dm(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return Ou(t);if(t.$$typeof===ae)return;if(t.$$typeof===Q)return Tn(t)}throw Error(s(438,String(t)))}function Y0(t){var a=null,l=at.updateQueue;if(l!==null&&(a=l.memoCache),a==null){var u=at.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(a={data:u.data.map(function(h){return h.slice()}),index:0})))}if(a==null&&(a={data:[],index:0}),l===null&&(l=um(),at.updateQueue=l),l.memoCache=a,l=a.data[a.index],l===void 0)for(l=a.data[a.index]=Array(t),u=0;u<t;u++)l[u]=le;return a.index++,l}function xr(t,a){return typeof a=="function"?a(t):a}function hm(t){var a=an();return W0(a,Rt,t)}function W0(t,a,l){var u=t.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=l;var h=t.baseQueue,m=u.pending;if(m!==null){if(h!==null){var w=h.next;h.next=m.next,m.next=w}a.baseQueue=h=m,u.pending=null}if(m=t.baseState,h===null)t.memoizedState=m;else{a=h.next;var A=w=null,B=null,ne=a,de=!1;do{var _e=ne.lane&-536870913;if(_e!==ne.lane?(pt&_e)===_e:(br&_e)===_e){var ee=ne.revertLane;if(ee===0)B!==null&&(B=B.next={lane:0,revertLane:0,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null}),_e===yo&&(de=!0);else if((br&ee)===ee){ne=ne.next,ee===yo&&(de=!0);continue}else _e={lane:0,revertLane:ne.revertLane,gesture:null,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},B===null?(A=B=_e,w=m):B=B.next=_e,at.lanes|=ee,_i|=ee;_e=ne.action,ko&&l(m,_e),m=ne.hasEagerState?ne.eagerState:l(m,_e)}else ee={lane:_e,revertLane:ne.revertLane,gesture:ne.gesture,action:ne.action,hasEagerState:ne.hasEagerState,eagerState:ne.eagerState,next:null},B===null?(A=B=ee,w=m):B=B.next=ee,at.lanes|=_e,_i|=_e;ne=ne.next}while(ne!==null&&ne!==a);if(B===null?w=m:B.next=A,!Cs(m,t.memoizedState)&&(dn=!0,de&&(l=zl,l!==null)))throw l;t.memoizedState=m,t.baseState=w,t.baseQueue=B,u.lastRenderedState=m}return h===null&&(u.lanes=0),[t.memoizedState,u.dispatch]}function X0(t){var a=an(),l=a.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=t;var u=l.dispatch,h=l.pending,m=a.memoizedState;if(h!==null){l.pending=null;var w=h=h.next;do m=t(m,w.action),w=w.next;while(w!==h);Cs(m,a.memoizedState)||(dn=!0),a.memoizedState=m,a.baseQueue===null&&(a.baseState=m),l.lastRenderedState=m}return[m,u]}function nw(t,a,l){var u=at,h=an(),m=lt;if(m){if(l===void 0)throw Error(s(407));l=l()}else l=a();var w=!Cs((Rt||h).memoizedState,l);if(w&&(h.memoizedState=l,dn=!0),h=h.queue,Z0(rw.bind(null,u,h,t),[t]),t=h.getSnapshot!==a||w||un!==null&&(un.memoizedState.tag&1)!==0,Dl(t?9:8,{destroy:void 0},aw.bind(null,u,h,l,a),null),t){if(u.flags|=2048,$t===null)throw Error(s(349));m||(br&127)!==0||sw(u,a,l)}return l}function sw(t,a,l){t.flags|=16384,t={getSnapshot:a,value:l},a=at.updateQueue,a===null?(a=um(),at.updateQueue=a,a.stores=[t]):(l=a.stores,l===null?a.stores=[t]:l.push(t))}function aw(t,a,l,u){a.value=l,a.getSnapshot=u,iw(a)&&ow(t)}function rw(t,a,l){return l(function(){iw(a)&&ow(t)})}function iw(t){var a=t.getSnapshot;t=t.value;try{var l=a();return!Cs(t,l)}catch{return!0}}function ow(t){var a=mo(t,2);a!==null&&ds(a,t,2)}function Q0(t){var a=Vn();if(typeof t=="function"){var l=t;if(t=l(),ko){Lt(!0);try{l()}finally{Lt(!1)}}}return a.memoizedState=a.baseState=t,a.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xr,lastRenderedState:t},a}function lw(t,a,l,u){return t.baseState=l,W0(t,Rt,typeof u=="function"?u:xr)}function d4(t,a,l,u,h){if(pm(t))throw Error(s(485));if(t=a.action,t!==null){var m={payload:h,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(w){m.listeners.push(w)}};Ce.T!==null?l(!0):m.isTransition=!1,u(m),l=a.pending,l===null?(m.next=a.pending=m,cw(a,m)):(m.next=l.next,a.pending=l.next=m)}}function cw(t,a){var l=a.action,u=a.payload,h=t.state;if(a.isTransition){var m=Ce.T,w={};w.types=m!==null?m.types:null,Ce.T=w;try{var A=l(h,u),B=Ce.S;B!==null&&B(w,A),uw(t,a,A)}catch(ne){J0(t,a,ne)}finally{m!==null&&w.types!==null&&(m.types=w.types),Ce.T=m}}else try{m=l(h,u),uw(t,a,m)}catch(ne){J0(t,a,ne)}}function uw(t,a,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){dw(t,a,u)},function(u){return J0(t,a,u)}):dw(t,a,l)}function dw(t,a,l){a.status="fulfilled",a.value=l,hw(a),t.state=l,a=t.pending,a!==null&&(l=a.next,l===a?t.pending=null:(l=l.next,a.next=l,cw(t,l)))}function J0(t,a,l){var u=t.pending;if(t.pending=null,u!==null){u=u.next;do a.status="rejected",a.reason=l,hw(a),a=a.next;while(a!==u)}t.action=null}function hw(t){t=t.listeners;for(var a=0;a<t.length;a++)(0,t[a])()}function mw(t,a){return a}function fw(t,a){if(lt){var l=$t.formState;if(l!==null){e:{var u=at;if(lt){if(Dt){t:{for(var h=Dt,m=Js;h.nodeType!==8;){if(!m){h=null;break t}if(h=ea(h.nextSibling),h===null){h=null;break t}}m=h.data,h=m==="F!"||m==="F"?h:null}if(h){Dt=ea(h.nextSibling),u=h.data==="F!";break e}}li(u)}u=!1}u&&(a=l[0])}}return l=Vn(),l.memoizedState=l.baseState=a,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mw,lastRenderedState:a},l.queue=u,l=zw.bind(null,at,u),u.dispatch=l,u=Q0(!1),m=ag.bind(null,at,!1,u.queue),u=Vn(),h={state:a,dispatch:null,action:t,pending:null},u.queue=h,l=d4.bind(null,at,h,m,l),h.dispatch=l,u.memoizedState=t,[a,l,!1]}function pw(t){var a=an();return gw(a,Rt,t)}function gw(t,a,l){if(a=W0(t,a,mw)[0],t=hm(xr)[0],typeof a=="object"&&a!==null&&typeof a.then=="function")try{var u=Ou(a)}catch(w){throw w===Ol?nm:w}else u=a;a=an();var h=a.queue,m=h.dispatch;return l!==a.memoizedState&&(at.flags|=2048,Dl(9,{destroy:void 0},h4.bind(null,h,l),null)),[u,m,t]}function h4(t,a){t.action=a}function bw(t){var a=an(),l=Rt;if(l!==null)return gw(a,l,t);an(),a=a.memoizedState,l=an();var u=l.queue.dispatch;return l.memoizedState=t,[a,u,!1]}function Dl(t,a,l,u){return t={tag:t,create:l,deps:u,inst:a,next:null},a=at.updateQueue,a===null&&(a=um(),at.updateQueue=a),l=a.lastEffect,l===null?a.lastEffect=t.next=t:(u=l.next,l.next=t,t.next=u,a.lastEffect=t),t}function xw(){return an().memoizedState}function mm(t,a,l,u){var h=Vn();at.flags|=t,h.memoizedState=Dl(1|a,{destroy:void 0},l,u===void 0?null:u)}function fm(t,a,l,u){var h=an();u=u===void 0?null:u;var m=h.memoizedState.inst;Rt!==null&&u!==null&&G0(u,Rt.memoizedState.deps)?h.memoizedState=Dl(a,m,l,u):(at.flags|=t,h.memoizedState=Dl(1|a,m,l,u))}function yw(t,a){mm(8390656,8,t,a)}function Z0(t,a){fm(2048,8,t,a)}function m4(t){at.flags|=4;var a=at.updateQueue;if(a===null)a=um(),at.updateQueue=a,a.events=[t];else{var l=a.events;l===null?a.events=[t]:l.push(t)}}function _w(t){var a=an().memoizedState;return m4({ref:a,nextImpl:t}),function(){if((wt&2)!==0)throw Error(s(440));return a.impl.apply(void 0,arguments)}}function vw(t,a){return fm(4,2,t,a)}function ww(t,a){return fm(4,4,t,a)}function Sw(t,a){if(typeof a=="function"){t=t();var l=a(t);return function(){typeof l=="function"?l():a(null)}}if(a!=null)return t=t(),a.current=t,function(){a.current=null}}function kw(t,a,l){l=l!=null?l.concat([t]):null,fm(4,4,Sw.bind(null,a,t),l)}function eg(){}function Cw(t,a){var l=an();a=a===void 0?null:a;var u=l.memoizedState;return a!==null&&G0(a,u[1])?u[0]:(l.memoizedState=[t,a],t)}function Nw(t,a){var l=an();a=a===void 0?null:a;var u=l.memoizedState;if(a!==null&&G0(a,u[1]))return u[0];if(u=t(),ko){Lt(!0);try{t()}finally{Lt(!1)}}return l.memoizedState=[u,a],u}function tg(t,a,l){return l===void 0||(br&1073741824)!==0&&(pt&261930)===0?t.memoizedState=a:(t.memoizedState=l,t=$2(),at.lanes|=t,_i|=t,l)}function Aw(t,a,l,u){return Cs(l,a)?l:fi.current!==null?(t=tg(t,l,u),Cs(t,a)||(dn=!0),t):(br&106)===0||(br&1073741824)!==0&&(pt&261930)===0?(dn=!0,t.memoizedState=l):(t=$2(),at.lanes|=t,_i|=t,a)}function jw(t,a,l,u,h){var m=Ue.p;Ue.p=m!==0&&8>m?m:8;var w=Ce.T,A={};A.types=w!==null?w.types:null,Ce.T=A,ag(t,!1,a,l);try{var B=h(),ne=Ce.S;if(ne!==null&&ne(A,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var de=l4(B,u);Pu(t,a,de,Es(t))}else Pu(t,a,u,Es(t))}catch(_e){Pu(t,a,{then:function(){},status:"rejected",reason:_e},Es())}finally{Ue.p=m,w!==null&&A.types!==null&&(w.types=A.types),Ce.T=w}}function f4(){}function ng(t,a,l,u){if(t.tag!==5)throw Error(s(476));var h=Tw(t).queue;jw(t,h,a,be,l===null?f4:function(){return Ew(t),l(u)})}function Tw(t){var a=t.memoizedState;if(a!==null)return a;a={memoizedState:be,baseState:be,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xr,lastRenderedState:be},next:null};var l={};return a.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xr,lastRenderedState:l},next:null},t.memoizedState=a,t=t.alternate,t!==null&&(t.memoizedState=a),a}function Ew(t){var a=Tw(t);a.next===null&&(a=t.alternate.memoizedState),Pu(t,a.next.queue,{},Es())}function sg(){return Tn(sc)}function Mw(){return an().memoizedState}function Rw(){return an().memoizedState}function p4(t){for(var a=t.return;a!==null;){switch(a.tag){case 24:case 3:var l=Es();t=hi(l);var u=mi(a,t,l);u!==null&&(ds(u,a,l),Tu(u,a,l)),a={cache:M0()},t.payload=a;return}a=a.return}}function g4(t,a,l){var u=Es();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},pm(t)?Ow(a,l):(l=w0(t,a,l,u),l!==null&&(ds(l,t,u),Pw(l,a,u)))}function zw(t,a,l){var u=Es();Pu(t,a,l,u)}function Pu(t,a,l,u){var h={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(pm(t))Ow(a,h);else{var m=t.alternate;if(t.lanes===0&&(m===null||m.lanes===0)&&(m=a.lastRenderedReducer,m!==null))try{var w=a.lastRenderedState,A=m(w,l);if(h.hasEagerState=!0,h.eagerState=A,Cs(A,w))return Vh(t,a,h,0),$t===null&&Fh(),!1}catch{}finally{}if(l=w0(t,a,h,u),l!==null)return ds(l,t,u),Pw(l,a,u),!0}return!1}function ag(t,a,l,u){if(u={lane:2,revertLane:Yg(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},pm(t)){if(a)throw Error(s(479))}else a=w0(t,l,u,2),a!==null&&ds(a,t,2)}function pm(t){var a=t.alternate;return t===at||a!==null&&a===at}function Ow(t,a){$l=lm=!0;var l=t.pending;l===null?a.next=a:(a.next=l.next,l.next=a),t.pending=a}function Pw(t,a,l){if((l&4194048)!==0){var u=a.lanes;u&=t.pendingLanes,l|=u,a.lanes=l,au(t,l)}}var gm={readContext:Tn,use:dm,useCallback:en,useContext:en,useEffect:en,useImperativeHandle:en,useLayoutEffect:en,useInsertionEffect:en,useMemo:en,useReducer:en,useRef:en,useState:en,useDebugValue:en,useDeferredValue:en,useTransition:en,useSyncExternalStore:en,useId:en,useHostTransitionStatus:en,useFormState:en,useActionState:en,useOptimistic:en,useMemoCache:en,useCacheRefresh:en,useEffectEvent:en},$w={readContext:Tn,use:dm,useCallback:function(t,a){return Vn().memoizedState=[t,a===void 0?null:a],t},useContext:Tn,useEffect:yw,useImperativeHandle:function(t,a,l){l=l!=null?l.concat([t]):null,mm(4194308,4,Sw.bind(null,a,t),l)},useLayoutEffect:function(t,a){return mm(4194308,4,t,a)},useInsertionEffect:function(t,a){mm(4,2,t,a)},useMemo:function(t,a){var l=Vn();a=a===void 0?null:a;var u=t();if(ko){Lt(!0);try{t()}finally{Lt(!1)}}return l.memoizedState=[u,a],u},useReducer:function(t,a,l){var u=Vn();if(l!==void 0){var h=l(a);if(ko){Lt(!0);try{l(a)}finally{Lt(!1)}}}else h=a;return u.memoizedState=u.baseState=h,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:h},u.queue=t,t=t.dispatch=g4.bind(null,at,t),[u.memoizedState,t]},useRef:function(t){var a=Vn();return t={current:t},a.memoizedState=t},useState:function(t){t=Q0(t);var a=t.queue,l=zw.bind(null,at,a);return a.dispatch=l,[t.memoizedState,l]},useDebugValue:eg,useDeferredValue:function(t,a){var l=Vn();return tg(l,t,a)},useTransition:function(){var t=Q0(!1);return t=jw.bind(null,at,t.queue,!0,!1),Vn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,a,l){var u=at,h=Vn();if(lt){if(l===void 0)throw Error(s(407));l=l()}else{if(l=a(),$t===null)throw Error(s(349));(pt&127)!==0||sw(u,a,l)}h.memoizedState=l;var m={value:l,getSnapshot:a};return h.queue=m,yw(rw.bind(null,u,m,t),[t]),u.flags|=2048,Dl(9,{destroy:void 0},aw.bind(null,u,m,l,a),null),l},useId:function(){var t=Vn(),a=$t.identifierPrefix;if(lt){var l=Da,u=Ia;l=(u&~(1<<32-Ct(u)-1)).toString(32)+l,a="_"+a+"R_"+l,l=cm++,0<l&&(a+="H"+l.toString(32)),a+="_"}else l=c4++,a="_"+a+"r_"+l.toString(32)+"_";return t.memoizedState=a},useHostTransitionStatus:sg,useFormState:fw,useActionState:fw,useOptimistic:function(t){var a=Vn();a.memoizedState=a.baseState=t;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return a.queue=l,a=ag.bind(null,at,!0,l),l.dispatch=a,[t,a]},useMemoCache:Y0,useCacheRefresh:function(){return Vn().memoizedState=p4.bind(null,at)},useEffectEvent:function(t){var a=Vn(),l={impl:t};return a.memoizedState=l,function(){if((wt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},Iw={readContext:Tn,use:dm,useCallback:Cw,useContext:Tn,useEffect:Z0,useImperativeHandle:kw,useInsertionEffect:vw,useLayoutEffect:ww,useMemo:Nw,useReducer:hm,useRef:xw,useState:function(){return hm(xr)},useDebugValue:eg,useDeferredValue:function(t,a){var l=an();return Aw(l,Rt.memoizedState,t,a)},useTransition:function(){var t=hm(xr)[0],a=an().memoizedState;return[typeof t=="boolean"?t:Ou(t),a]},useSyncExternalStore:nw,useId:Mw,useHostTransitionStatus:sg,useFormState:pw,useActionState:pw,useOptimistic:function(t,a){var l=an();return lw(l,Rt,t,a)},useMemoCache:Y0,useCacheRefresh:Rw,useEffectEvent:_w},b4={readContext:Tn,use:dm,useCallback:Cw,useContext:Tn,useEffect:Z0,useImperativeHandle:kw,useInsertionEffect:vw,useLayoutEffect:ww,useMemo:Nw,useReducer:X0,useRef:xw,useState:function(){return X0(xr)},useDebugValue:eg,useDeferredValue:function(t,a){var l=an();return Rt===null?tg(l,t,a):Aw(l,Rt.memoizedState,t,a)},useTransition:function(){var t=X0(xr)[0],a=an().memoizedState;return[typeof t=="boolean"?t:Ou(t),a]},useSyncExternalStore:nw,useId:Mw,useHostTransitionStatus:sg,useFormState:bw,useActionState:bw,useOptimistic:function(t,a){var l=an();return Rt!==null?lw(l,Rt,t,a):(l.baseState=t,[t,l.queue.dispatch])},useMemoCache:Y0,useCacheRefresh:Rw,useEffectEvent:_w};function rg(t,a,l,u){a=t.memoizedState,l=l(u,a),l=l==null?a:P({},a,l),t.memoizedState=l,t.lanes===0&&(t.updateQueue.baseState=l)}var ig={enqueueSetState:function(t,a,l){t=t._reactInternals;var u=Es(),h=hi(u);h.payload=a,l!=null&&(h.callback=l),a=mi(t,h,u),a!==null&&(ds(a,t,u),Tu(a,t,u))},enqueueReplaceState:function(t,a,l){t=t._reactInternals;var u=Es(),h=hi(u);h.tag=1,h.payload=a,l!=null&&(h.callback=l),a=mi(t,h,u),a!==null&&(ds(a,t,u),Tu(a,t,u))},enqueueForceUpdate:function(t,a){t=t._reactInternals;var l=Es(),u=hi(l);u.tag=2,a!=null&&(u.callback=a),a=mi(t,u,l),a!==null&&(ds(a,t,l),Tu(a,t,l))}};function Dw(t,a,l,u,h,m,w){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(u,m,w):a.prototype&&a.prototype.isPureReactComponent?!vu(l,u)||!vu(h,m):!0}function qw(t,a,l,u){t=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(l,u),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(l,u),a.state!==t&&ig.enqueueReplaceState(a,a.state,null)}function Co(t,a){var l=a;if("ref"in a){l={};for(var u in a)u!=="ref"&&(l[u]=a[u])}if(t=t.defaultProps){l===a&&(l=P({},l));for(var h in t)l[h]===void 0&&(l[h]=t[h])}return l}function Lw(t){Hh(t)}function Uw(t){console.error(t)}function Bw(t){Hh(t)}function bm(t,a){try{var l=t.onUncaughtError;l(a.value,{componentStack:a.stack})}catch(u){setTimeout(function(){throw u})}}function Gw(t,a,l){try{var u=t.onCaughtError;u(l.value,{componentStack:l.stack,errorBoundary:a.tag===1?a.stateNode:null})}catch(h){setTimeout(function(){throw h})}}function og(t,a,l){return l=hi(l),l.tag=3,l.payload={element:null},l.callback=function(){bm(t,a)},l}function Hw(t){return t=hi(t),t.tag=3,t}function Fw(t,a,l,u){var h=l.type.getDerivedStateFromError;if(typeof h=="function"){var m=u.value;t.payload=function(){return h(m)},t.callback=function(){Gw(a,l,u)}}var w=l.stateNode;w!==null&&typeof w.componentDidCatch=="function"&&(t.callback=function(){Gw(a,l,u),typeof h!="function"&&(vi===null?vi=new Set([this]):vi.add(this));var A=u.stack;this.componentDidCatch(u.value,{componentStack:A!==null?A:""})})}function x4(t,a,l,u,h){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(a=l.alternate,a!==null&&bo(a,l,h,!0),l=En.current,l!==null){switch(l.tag){case 31:case 13:case 19:return Gn===null?Dm():l.alternate===null&&tn===0&&(tn=3),l.flags&=-257,l.flags|=65536,l.lanes=h,u===sm?l.flags|=16384:(a=l.updateQueue,a===null?l.updateQueue=new Set([u]):a.add(u),Fg(t,u,h)),!1;case 22:return l.flags|=65536,u===sm?l.flags|=16384:(a=l.updateQueue,a===null?(a={transitions:null,markerInstances:null,retryQueue:new Set([u])},l.updateQueue=a):(l=a.retryQueue,l===null?a.retryQueue=new Set([u]):l.add(u)),Fg(t,u,h)),!1}throw Error(s(435,l.tag))}return Fg(t,u,h),Dm(),!1}if(lt)return a=En.current,a!==null?((a.flags&65536)===0&&(a.flags|=256),a.flags|=65536,a.lanes=h,u!==A0&&(t=Error(s(422),{cause:u}),ku(Ws(t,l)))):(u!==A0&&(a=Error(s(423),{cause:u}),ku(Ws(a,l))),t=t.current.alternate,t.flags|=65536,h&=-h,t.lanes|=h,u=Ws(u,l),h=og(t.stateNode,u,h),I0(t,h),tn!==4&&(tn=2)),!1;var m=Error(s(520),{cause:u});if(m=Ws(m,l),Gu===null?Gu=[m]:Gu.push(m),tn!==4&&(tn=2),a===null)return!0;u=Ws(u,l),l=a;do{switch(l.tag){case 3:return l.flags|=65536,t=h&-h,l.lanes|=t,t=og(l.stateNode,u,t),I0(l,t),!1;case 1:if(a=l.type,m=l.stateNode,(l.flags&128)===0&&(typeof a.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(vi===null||!vi.has(m))))return l.flags|=65536,h&=-h,l.lanes|=h,h=Hw(h),Fw(h,t,l,u),I0(l,h),!1;break;case 22:if(l.memoizedState!==null)return l.flags|=65536,!1}l=l.return}while(l!==null);return!1}var lg=Error(s(461)),dn=!1;function pn(t,a,l,u){a.child=t===null?W1(a,null,l,u):So(a,t.child,l,u)}function Vw(t,a,l,u,h){l=l.render;var m=a.ref;if("ref"in u){var w={};for(var A in u)A!=="ref"&&(w[A]=u[A])}else w=u;return xo(a),u=H0(t,a,l,w,m,h),A=F0(),t!==null&&!dn?(V0(t,a,h),yr(t,a,h)):(lt&&A&&Xh(a),a.flags|=1,pn(t,a,u,h),a.child)}function Kw(t,a,l,u,h){if(t===null){var m=l.type;return typeof m=="function"&&!S0(m)&&m.defaultProps===void 0&&l.compare===null?(a.tag=15,a.type=m,Yw(t,a,m,u,h)):(t=Yh(l.type,null,u,a,a.mode,h),t.ref=a.ref,t.return=a,a.child=t)}if(m=t.child,!gg(t,h)){var w=m.memoizedProps;if(l=l.compare,l=l!==null?l:vu,l(w,u)&&t.ref===a.ref)return yr(t,a,h)}return a.flags|=1,t=mr(m,u),t.ref=a.ref,t.return=a,a.child=t}function Yw(t,a,l,u,h){if(t!==null){var m=t.memoizedProps;if(vu(m,u)&&t.ref===a.ref)if(dn=!1,a.pendingProps=u=m,gg(t,h))(t.flags&131072)!==0&&(dn=!0);else return a.lanes=t.lanes,yr(t,a,h)}return cg(t,a,l,u,h)}function Ww(t,a,l,u){var h=u.children,m=t!==null?t.memoizedState:null;if(t===null&&a.stateNode===null&&(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((a.flags&128)!==0){if(m=m!==null?m.baseLanes|l:l,t!==null){for(u=a.child=t.child,h=0;u!==null;)h=h|u.lanes|u.childLanes,u=u.sibling;u=h&~m}else u=0,a.child=null;return Xw(t,a,m,l,u)}if((l&536870912)!==0)a.memoizedState={baseLanes:0,cachePool:null},t!==null&&tm(a,m!==null?m.cachePool:null),m!==null?J1(a,m):q0(),Z1(a);else return u=a.lanes=536870912,Xw(t,a,m!==null?m.baseLanes|l:l,l,u)}else m!==null?(tm(a,m.cachePool),J1(a,m),gi(),a.memoizedState=null):(t!==null&&tm(a,null),q0(),gi());return pn(t,a,h,l),a.child}function $u(t,a){return t!==null&&t.tag===22||a.stateNode!==null||(a.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),a.sibling}function Xw(t,a,l,u,h){var m=z0();return m=m===null?null:{parent:cn._currentValue,pool:m},a.memoizedState={baseLanes:l,cachePool:m},t!==null&&tm(a,null),q0(),Z1(a),t!==null&&bo(t,a,u,!0),a.childLanes=h,null}function xm(t,a){return a=ym({mode:a.mode,children:a.children},t.mode),a.ref=t.ref,t.child=a,a.return=t,a}function Qw(t,a,l){return So(a,t.child,null,l),t=xm(a,a.pendingProps),t.flags|=2,Ns(a),a.memoizedState=null,t}function y4(t,a,l){var u=a.pendingProps,h=(a.flags&128)!==0;if(a.flags&=-129,t===null){if(lt){if(u.mode==="hidden")return t=xm(a,u),a.lanes=536870912,t.memoizedState={baseLanes:0,cachePool:null},$u(null,t);if(U0(a),(t=Dt)?(t=SS(t,Js),t=t!==null&&t.data==="&"?t:null,t!==null&&(a.memoizedState={dehydrated:t,treeContext:ii!==null?{id:Ia,overflow:Da}:null,retryLane:536870912,hydrationErrors:null},l=O1(t),l.return=a,a.child=l,xn=a,Dt=null)):t=null,t===null)throw li(a);return a.lanes=536870912,null}return xm(a,u)}var m=t.memoizedState;if(m!==null){var w=m.dehydrated;if(U0(a),h)if(a.flags&256)a.flags&=-257,a=Qw(t,a,l);else if(a.memoizedState!==null)a.child=t.child,a.flags|=128,a=null;else throw Error(s(558));else if(dn||bo(t,a,l,!1),h=(l&t.childLanes)!==0,dn||h){if(fi.current===null){if(u=$t,u!==null&&(w=Qr(u,l),w!==0&&w!==m.retryLane))throw m.retryLane=w,mo(t,w),ds(u,t,w),lg;Dm()}a=Qw(t,a,l)}else t=m.treeContext,Dt=ea(w.nextSibling),xn=a,lt=!0,oi=null,Js=!1,t!==null&&I1(a,t),a=xm(a,u),a.flags|=134221824;return a}return t=mr(t.child,{mode:u.mode,children:u.children}),t.ref=a.ref,a.child=t,t.return=a,t}function ql(t,a){var l=a.ref;if(l===null)t!==null&&t.ref!==null&&(a.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(s(284));(t===null||t.ref!==l)&&(a.flags|=4194816)}}function cg(t,a,l,u,h){return xo(a),l=H0(t,a,l,u,void 0,h),u=F0(),t!==null&&!dn?(V0(t,a,h),yr(t,a,h)):(lt&&u&&Xh(a),a.flags|=1,pn(t,a,l,h),a.child)}function Jw(t,a,l,u,h,m){return xo(a),a.updateQueue=null,l=tw(a,u,l,h),ew(t),u=F0(),t!==null&&!dn?(V0(t,a,m),yr(t,a,m)):(lt&&u&&Xh(a),a.flags|=1,pn(t,a,l,m),a.child)}function Zw(t,a,l,u,h){if(xo(a),a.stateNode===null){var m=Tl,w=l.contextType;typeof w=="object"&&w!==null&&(m=Tn(w)),m=new l(u,m),a.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=ig,a.stateNode=m,m._reactInternals=a,m=a.stateNode,m.props=u,m.state=a.memoizedState,m.refs={},P0(a),w=l.contextType,m.context=typeof w=="object"&&w!==null?Tn(w):Tl,m.state=a.memoizedState,w=l.getDerivedStateFromProps,typeof w=="function"&&(rg(a,l,w,u),m.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(w=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),w!==m.state&&ig.enqueueReplaceState(m,m.state,null),Mu(a,u,m,h),Eu(),m.state=a.memoizedState),typeof m.componentDidMount=="function"&&(a.flags|=4194308),u=!0}else if(t===null){m=a.stateNode;var A=a.memoizedProps,B=Co(l,A);m.props=B;var ne=m.context,de=l.contextType;w=Tl,typeof de=="object"&&de!==null&&(w=Tn(de));var _e=l.getDerivedStateFromProps;de=typeof _e=="function"||typeof m.getSnapshotBeforeUpdate=="function",A=a.pendingProps!==A,de||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(A||ne!==w)&&qw(a,m,u,w),di=!1;var ee=a.memoizedState;m.state=ee,Mu(a,u,m,h),Eu(),ne=a.memoizedState,A||ee!==ne||di?(typeof _e=="function"&&(rg(a,l,_e,u),ne=a.memoizedState),(B=di||Dw(a,l,B,u,ee,ne,w))?(de||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(a.flags|=4194308)):(typeof m.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=u,a.memoizedState=ne),m.props=u,m.state=ne,m.context=w,u=B):(typeof m.componentDidMount=="function"&&(a.flags|=4194308),u=!1)}else{m=a.stateNode,$0(t,a),w=a.memoizedProps,de=Co(l,w),m.props=de,_e=a.pendingProps,ee=m.context,ne=l.contextType,B=Tl,typeof ne=="object"&&ne!==null&&(B=Tn(ne)),A=l.getDerivedStateFromProps,(ne=typeof A=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(w!==_e||ee!==B)&&qw(a,m,u,B),di=!1,ee=a.memoizedState,m.state=ee,Mu(a,u,m,h),Eu();var ce=a.memoizedState;w!==_e||ee!==ce||di||t!==null&&t.dependencies!==null&&Zh(t.dependencies)?(typeof A=="function"&&(rg(a,l,A,u),ce=a.memoizedState),(de=di||Dw(a,l,de,u,ee,ce,B)||t!==null&&t.dependencies!==null&&Zh(t.dependencies))?(ne||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(u,ce,B),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(u,ce,B)),typeof m.componentDidUpdate=="function"&&(a.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof m.componentDidUpdate!="function"||w===t.memoizedProps&&ee===t.memoizedState||(a.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&ee===t.memoizedState||(a.flags|=1024),a.memoizedProps=u,a.memoizedState=ce),m.props=u,m.state=ce,m.context=B,u=de):(typeof m.componentDidUpdate!="function"||w===t.memoizedProps&&ee===t.memoizedState||(a.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||w===t.memoizedProps&&ee===t.memoizedState||(a.flags|=1024),u=!1)}return m=u,ql(t,a),u=(a.flags&128)!==0,m||u?(m=a.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:m.render(),a.flags|=1,t!==null&&u?(a.child=So(a,t.child,null,h),a.child=So(a,null,l,h)):pn(t,a,l,h),a.memoizedState=m.state,t=a.child):t=yr(t,a,h),t}function e2(t,a,l,u){return po(),a.flags|=256,pn(t,a,l,u),a.child}var ug={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function dg(t){return{baseLanes:t,cachePool:G1()}}function hg(t,a,l){return t=t!==null?t.childLanes&~l:0,a&&(t|=Ts),t}function t2(t,a,l){var u=a.pendingProps,h=!1,m=(a.flags&128)!==0,w;if((w=m)||(w=t!==null&&t.memoizedState===null?!1:(Mn.current&2)!==0),w&&(h=!0,a.flags&=-129),w=(a.flags&32)!==0,a.flags&=-33,t===null){if(lt){if(h?pi(a):gi(),(t=Dt)?(t=SS(t,Js),t=t!==null&&t.data!=="&"?t:null,t!==null&&(a.memoizedState={dehydrated:t,treeContext:ii!==null?{id:Ia,overflow:Da}:null,retryLane:536870912,hydrationErrors:null},l=O1(t),l.return=a,a.child=l,xn=a,Dt=null)):t=null,t===null)throw li(a);return db(t)?a.lanes=32:a.lanes=536870912,null}return m=u.children,u=u.fallback,h?(gi(),h=a.mode,m=ym({mode:"hidden",children:m},h),u=fo(u,h,l,null),m.return=a,u.return=a,m.sibling=u,a.child=m,u=a.child,u.memoizedState=dg(l),u.childLanes=hg(t,w,l),a.memoizedState=ug,$u(null,u)):(pi(a),mg(a,m))}var A=t.memoizedState;if(A!==null){var B=A.dehydrated;if(B!==null)return _4(t,a,m,w,u,B,A,l)}return h?(gi(),h=u.fallback,m=a.mode,A=t.child,B=A.sibling,u=mr(A,{mode:"hidden",children:u.children}),u.subtreeFlags=A.subtreeFlags&1206910976,B!==null?h=mr(B,h):(h=fo(h,m,l,null),h.flags|=2),h.return=a,u.return=a,u.sibling=h,a.child=u,$u(null,u),u=a.child,h=t.child.memoizedState,h===null?h=dg(l):(m=h.cachePool,m!==null?(A=cn._currentValue,m=m.parent!==A?{parent:A,pool:A}:m):m=G1(),h={baseLanes:h.baseLanes|l,cachePool:m}),u.memoizedState=h,u.childLanes=hg(t,w,l),a.memoizedState=ug,$u(t.child,u)):(pi(a),l=t.child,t=l.sibling,l=mr(l,{mode:"visible",children:u.children}),l.return=a,l.sibling=null,t!==null&&(w=a.deletions,w===null?(a.deletions=[t],a.flags|=16):w.push(t)),a.child=l,a.memoizedState=null,l)}function mg(t,a){return a=ym({mode:"visible",children:a},t.mode),a.return=t,t.child=a}function ym(t,a){return t=os(22,t,null,a),t.lanes=0,t}function _m(t,a,l){return So(a,t.child,null,l),t=mg(a,a.pendingProps.children),t.flags|=2,a.memoizedState=null,t}function _4(t,a,l,u,h,m,w,A){if(l)return a.flags&256?(pi(a),a.flags&=-257,_m(t,a,A)):a.memoizedState!==null?(gi(),a.child=t.child,a.flags|=128,null):(gi(),m=h.fallback,w=a.mode,h=ym({mode:"visible",children:h.children},w),m=fo(m,w,A,null),m.flags|=2,h.return=a,m.return=a,h.sibling=m,a.child=h,So(a,t.child,null,A),h=a.child,h.memoizedState=dg(A),h.childLanes=hg(t,u,A),a.memoizedState=ug,$u(null,h));if(pi(a),db(m)){if(u=m.nextSibling&&m.nextSibling.dataset,u)var B=u.dgst;return u=B,u!==""&&(h=Error(s(419)),h.stack="",h.digest=u,ku({value:h,source:null,stack:null})),_m(t,a,A)}if(dn||bo(t,a,A,!1),u=(A&t.childLanes)!==0,dn||u){if(fi.current!==null)return _m(t,a,A);if(u=$t,u!==null&&(h=Qr(u,A),h!==0&&h!==w.retryLane))throw w.retryLane=h,mo(t,h),ds(u,t,h),lg;return ub(m)||Dm(),_m(t,a,A)}return ub(m)?(a.flags|=192,a.child=t.child,null):(t=w.treeContext,Dt=ea(m.nextSibling),xn=a,lt=!0,oi=null,Js=!1,t!==null&&I1(a,t),a=mg(a,h.children),a.flags|=134221824,a)}function n2(t,a,l){t.lanes|=a;var u=t.alternate;u!==null&&(u.lanes|=a),Jh(t.return,a,l)}function s2(t){for(var a=null;t!==null;){var l=t.alternate;l!==null&&om(l)===null&&(a=t),t=t.sibling}return a}function vm(t,a,l,u,h,m){var w=t.memoizedState;w===null?t.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:h,treeForkCount:m}:(w.isBackwards=a,w.rendering=null,w.renderingStartTime=0,w.last=u,w.tail=l,w.tailMode=h,w.treeForkCount=m)}function fg(t){var a=t.child;for(t.child=null;a!==null;){var l=a.sibling;a.sibling=t.child,t.child=a,a=l}}function pg(t,a,l){var u=a.pendingProps,h=u.revealOrder,m=u.tail;u=u.children;var w=Mn.current;if(a.flags&128)return Ru(a,w),null;var A=(w&2)!==0;if(A?(w=w&1|2,a.flags|=128):w&=1,Ru(a,w),h==="backwards"&&t!==null?(fg(t),pn(t,a,u,l),fg(t)):pn(t,a,u,l),u=lt?Su:0,!A&&t!==null&&(t.flags&128)!==0)e:for(t=a.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&n2(t,l,a);else if(t.tag===19)n2(t,l,a);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===a)break e;for(;t.sibling===null;){if(t.return===null||t.return===a)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}switch(h){case"backwards":l=s2(a.child),l===null?(h=a.child,a.child=null):(h=l.sibling,l.sibling=null,fg(a)),vm(a,!0,h,null,m,u);break;case"unstable_legacy-backwards":for(l=null,h=a.child,a.child=null;h!==null;){if(t=h.alternate,t!==null&&om(t)===null){a.child=h;break}t=h.sibling,h.sibling=l,l=h,h=t}vm(a,!0,l,null,m,u);break;case"together":vm(a,!1,null,null,void 0,u);break;case"independent":a.memoizedState=null;break;default:l=s2(a.child),l===null?(h=a.child,a.child=null):(h=l.sibling,l.sibling=null),vm(a,!1,h,l,m,u)}return a.child}function a2(t,a,l){var u=a.pendingProps;return ci(a,a.type,u.value),pn(t,a,u.children,l),a.child}function yr(t,a,l){if(t!==null&&(a.dependencies=t.dependencies),_i|=a.lanes,(l&a.childLanes)===0)if(t!==null){if(bo(t,a,l,!1),(l&a.childLanes)===0)return null}else return null;if(t!==null&&a.child!==t.child)throw Error(s(153));if(a.child!==null){for(t=a.child,l=mr(t,t.pendingProps),a.child=l,l.return=a;t.sibling!==null;)t=t.sibling,l=l.sibling=mr(t,t.pendingProps),l.return=a;l.sibling=null}return a.child}function gg(t,a){return(t.lanes&a)!==0?!0:(t=t.dependencies,!!(t!==null&&Zh(t)))}function v4(t,a,l){switch(a.tag){case 3:Je(a,a.stateNode.containerInfo),ci(a,cn,t.memoizedState.cache),po();break;case 27:case 5:ve(a);break;case 4:Je(a,a.stateNode.containerInfo);break;case 10:ci(a,a.type,a.memoizedProps.value);break;case 31:if(a.memoizedState!==null)return a.flags|=128,U0(a),null;break;case 13:var u=a.memoizedState;if(u!==null){if(u.dehydrated!==null)return pi(a),a.flags|=128,null;u=bo(t,a,l,!1);var h=a.child.childLanes;return u||(l&h)!==0?t2(t,a,l):(pi(a),t=yr(t,a,l),t!==null?t.sibling:null)}pi(a);break;case 19:if(a.flags&128)return pg(t,a,l);if(h=(t.flags&128)!==0,u=(l&a.childLanes)!==0,u||(bo(t,a,l,!1),u=(l&a.childLanes)!==0),h){if(u)return pg(t,a,l);a.flags|=128}if(h=a.memoizedState,h!==null&&(h.rendering=null,h.tail=null,h.lastEffect=null),Ru(a,Mn.current),u)break;return null;case 22:return a.lanes=0,Ww(t,a,l,a.pendingProps);case 24:ci(a,cn,t.memoizedState.cache)}return yr(t,a,l)}function r2(t,a,l){if(t!==null)if(t.memoizedProps!==a.pendingProps)dn=!0;else{if(!gg(t,l)&&(a.flags&128)===0)return dn=!1,v4(t,a,l);dn=(t.flags&131072)!==0}else dn=!1,lt&&(a.flags&1048576)!==0&&$1(a,Su,a.index);switch(a.lanes=0,a.tag){case 16:e:{var u=a.pendingProps;if(t=vo(a.elementType),a.type=t,typeof t=="function")S0(t)?(u=Co(t,u),a.tag=1,a=Zw(null,a,t,u,l)):(a.tag=0,a=cg(null,a,t,u,l));else{if(t!=null){var h=t.$$typeof;if(h===F){a.tag=11,a=Vw(null,a,t,u,l);break e}else if(h===me){a.tag=14,a=Kw(null,a,t,u,l);break e}else if(h===Q){a.tag=10,a.type=t,a=a2(null,a,l);break e}}throw a=Re(t)||t,Error(s(306,a,""))}}return a;case 0:return cg(t,a,a.type,a.pendingProps,l);case 1:return u=a.type,h=Co(u,a.pendingProps),Zw(t,a,u,h,l);case 3:e:{if(Je(a,a.stateNode.containerInfo),t===null)throw Error(s(387));u=a.pendingProps;var m=a.memoizedState;h=m.element,$0(t,a),Mu(a,u,null,l);var w=a.memoizedState;if(u=w.cache,ci(a,cn,u),u!==m.cache&&E0(a,[cn],l,!0),Eu(),u=w.element,m.isDehydrated)if(m={element:u,isDehydrated:!1,cache:w.cache},a.updateQueue.baseState=m,a.memoizedState=m,a.flags&256){a=e2(t,a,u,l);break e}else if(u!==h){h=Ws(Error(s(424)),a),ku(h),a=e2(t,a,u,l);break e}else{switch(t=a.stateNode.containerInfo,t.nodeType){case 9:t=t.body;break;default:t=t.nodeName==="HTML"?t.ownerDocument.body:t}for(Dt=ea(t.firstChild),xn=a,lt=!0,oi=null,Js=!0,l=W1(a,null,u,l),a.child=l;l;)l.flags=l.flags&-3|134221824,l=l.sibling}else{if(po(),u===h){a=yr(t,a,l);break e}pn(t,a,u,l)}a=a.child}return a;case 26:return ql(t,a),t===null?(l=ES(a.type,null,a.pendingProps,null))?a.memoizedState=l:lt||(a.stateNode=cS(a.type,a.pendingProps,Pe.current,a)):a.memoizedState=ES(a.type,t.memoizedProps,a.pendingProps,t.memoizedState),null;case 27:return ve(a),t===null&&lt&&(u=a.stateNode=NS(a.type,a.pendingProps,Pe.current),xn=a,Js=!0,h=Dt,ki(a.type)?(hb=h,Dt=ea(u.firstChild)):Dt=h),pn(t,a,a.pendingProps.children,l),ql(t,a),t===null&&(a.flags|=4194304),a.child;case 5:return t===null&&lt&&((h=u=Dt)&&(u=pM(u,a.type,a.pendingProps,Js),u!==null?(a.stateNode=u,xn=a,Dt=ea(u.firstChild),Js=!1,h=!0):h=!1),h||li(a)),ve(a),h=a.type,m=a.pendingProps,w=t!==null?t.memoizedProps:null,u=m.children,sb(h,m)?u=null:w!==null&&sb(h,w)&&(a.flags|=32),a.memoizedState!==null&&(h=H0(t,a,u4,null,null,l),sc._currentValue=h),ql(t,a),pn(t,a,u,l),a.child;case 6:return t===null&&lt&&((t=l=Dt)&&(l=gM(l,a.pendingProps,Js),l!==null?(a.stateNode=l,xn=a,Dt=null,t=!0):t=!1),t||li(a)),null;case 13:return t2(t,a,l);case 4:return Je(a,a.stateNode.containerInfo),u=a.pendingProps,t===null?a.child=So(a,null,u,l):pn(t,a,u,l),a.child;case 11:return Vw(t,a,a.type,a.pendingProps,l);case 7:return u=a.pendingProps,ql(t,a),pn(t,a,u,l),a.child;case 8:return pn(t,a,a.pendingProps.children,l),a.child;case 12:return pn(t,a,a.pendingProps.children,l),a.child;case 10:return a2(t,a,l);case 9:return h=a.type._context,u=a.pendingProps.children,xo(a),h=Tn(h),u=u(h),a.flags|=1,pn(t,a,u,l),a.child;case 14:return Kw(t,a,a.type,a.pendingProps,l);case 15:return Yw(t,a,a.type,a.pendingProps,l);case 19:return pg(t,a,l);case 31:return y4(t,a,l);case 22:return Ww(t,a,l,a.pendingProps);case 24:return xo(a),u=Tn(cn),t===null?(h=z0(),h===null&&(h=$t,m=M0(),h.pooledCache=m,m.refCount++,m!==null&&(h.pooledCacheLanes|=l),h=m),a.memoizedState={parent:u,cache:h},P0(a),ci(a,cn,h)):((t.lanes&l)!==0&&($0(t,a),Mu(a,null,null,l),Eu()),h=t.memoizedState,m=a.memoizedState,h.parent!==u?(h={parent:u,cache:u},a.memoizedState=h,a.lanes===0&&(a.memoizedState=a.updateQueue.baseState=h),ci(a,cn,u)):(u=m.cache,ci(a,cn,u),u!==h.cache&&E0(a,[cn],l,!0))),pn(t,a,a.pendingProps.children,l),a.child;case 30:return a.stateNode===null&&(a.stateNode={autoName:null,paired:null,clones:null,ref:null}),u=a.pendingProps,u.name!=null&&u.name!=="auto"?a.flags|=t===null?18882560:18874368:lt&&Xh(a),t!==null&&t.memoizedProps.name!==u.name?a.flags|=4194816:ql(t,a),pn(t,a,u.children,l),a.child;case 29:throw a.pendingProps}throw Error(s(156,a.tag))}function _r(t){t.flags|=4}function bg(t,a,l,u,h){var m;if((m=(t.mode&32)!==0)&&(m=l===null?OS(a,u):OS(a,u)&&(u.src!==l.src||u.srcSet!==l.srcSet)),m){if(t.flags|=16777216,(h&335544128)===h)if(t.stateNode.complete)t.flags|=8192;else if(L2())t.flags|=8192;else throw wo=sm,O0}else t.flags&=-16777217}function i2(t,a){if(a.type!=="stylesheet"||(a.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!PS(a))if(L2())t.flags|=8192;else throw wo=sm,O0}function wm(t,a){a!==null&&(t.flags|=4),t.flags&16384&&(a=t.tag!==22?Vs():536870912,t.lanes|=a,Hl|=a)}function Iu(t,a){if(!lt)switch(t.tailMode){case"visible":break;case"collapsed":for(var l=t.tail,u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?a||t.tail===null?t.tail=null:t.tail.sibling=null:u.sibling=null;break;default:for(a=t.tail,l=null;a!==null;)a.alternate!==null&&(l=a),a=a.sibling;l===null?t.tail=null:l.sibling=null}}function qt(t){var a=t.alternate!==null&&t.alternate.child===t.child,l=0,u=0;if(a)for(var h=t.child;h!==null;)l|=h.lanes|h.childLanes,u|=h.subtreeFlags&1206910976,u|=h.flags&1206910976,h.return=t,h=h.sibling;else for(h=t.child;h!==null;)l|=h.lanes|h.childLanes,u|=h.subtreeFlags,u|=h.flags,h.return=t,h=h.sibling;return t.subtreeFlags|=u,t.childLanes=l,a}function w4(t,a,l){var u=a.pendingProps;switch(N0(a),a.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qt(a),null;case 1:return qt(a),null;case 3:return l=a.stateNode,u=null,t!==null&&(u=t.memoizedState.cache),a.memoizedState.cache!==u&&(a.flags|=2048),gr(cn),re(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(t===null||t.child===null)&&(Rl(a)?_r(a):t===null||t.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,j0())),qt(a),null;case 26:var h=a.type,m=a.memoizedState;return t===null?(_r(a),m!==null?(qt(a),i2(a,m)):(qt(a),bg(a,h,null,u,l))):m?m!==t.memoizedState?(_r(a),qt(a),i2(a,m)):(qt(a),a.flags&=-16777217):(t=t.memoizedProps,t!==u&&_r(a),qt(a),bg(a,h,t,u,l)),null;case 27:if(Qe(a),l=Pe.current,h=a.type,t!==null&&a.stateNode!=null)t.memoizedProps!==u&&_r(a);else{if(!u){if(a.stateNode===null)throw Error(s(166));return qt(a),a.subtreeFlags&=-33554433,null}t=ue.current,Rl(a)?D1(a):(t=NS(h,u,l),a.stateNode=t,_r(a))}return qt(a),a.subtreeFlags&=-33554433,null;case 5:if(Qe(a),h=a.type,t!==null&&a.stateNode!=null)t.memoizedProps!==u&&_r(a);else{if(!u){if(a.stateNode===null)throw Error(s(166));return qt(a),a.subtreeFlags&=-33554433,null}if(m=ue.current,Rl(a))D1(a);else{var w=Yu(Pe.current);switch(m){case 1:m=w.createElementNS("http://www.w3.org/2000/svg",h);break;case 2:m=w.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;default:switch(h){case"svg":m=w.createElementNS("http://www.w3.org/2000/svg",h);break;case"math":m=w.createElementNS("http://www.w3.org/1998/Math/MathML",h);break;case"script":m=w.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?w.createElement("select",{is:u.is}):w.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?w.createElement(h,{is:u.is}):w.createElement(h)}}m[Ut]=a,m[on]=u;e:for(w=a.child;w!==null;){if(w.tag===5||w.tag===6)m.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===a)break e;for(;w.sibling===null;){if(w.return===null||w.return===a)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}a.stateNode=m;e:switch(zn(m,h,u),h){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&_r(a)}}return qt(a),a.subtreeFlags&=-33554433,bg(a,a.type,t===null?null:t.memoizedProps,a.pendingProps,l),null;case 6:if(t&&a.stateNode!=null)t.memoizedProps!==u&&_r(a);else{if(typeof u!="string"&&a.stateNode===null)throw Error(s(166));if(t=Pe.current,Rl(a)){if(t=a.stateNode,l=a.memoizedProps,u=null,h=xn,h!==null)switch(h.tag){case 27:case 5:u=h.memoizedProps}t[Ut]=a,t=!!(t.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||rS(t.nodeValue,l)),t||li(a,!0)}else t=Yu(t).createTextNode(u),t[Ut]=a,a.stateNode=t}return qt(a),null;case 31:if(l=a.memoizedState,t===null||t.memoizedState!==null){if(u=Rl(a),l!==null){if(t===null){if(!u)throw Error(s(318));if(t=a.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(s(557));t[Ut]=a}else po(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;qt(a),t=!1}else l=j0(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return a.flags&256?(Ns(a),a):(Ns(a),null);if((a.flags&128)!==0)throw Error(s(558))}return qt(a),null;case 13:if(u=a.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(h=Rl(a),u!==null&&u.dehydrated!==null){if(t===null){if(!h)throw Error(s(318));if(h=a.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(s(317));h[Ut]=a}else po(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;qt(a),h=!1}else h=j0(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=h),h=!0;if(!h)return a.flags&256?(Ns(a),a):(Ns(a),null)}return Ns(a),(a.flags&128)!==0?(a.lanes=l,a):(l=u!==null,t=t!==null&&t.memoizedState!==null,l&&(u=a.child,h=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(h=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==h&&(u.flags|=2048)),l!==t&&l&&(a.child.flags|=8192),wm(a,a.updateQueue),qt(a),null);case 4:return re(),t===null&&Jg(a.stateNode.containerInfo),a.flags|=67108864,qt(a),null;case 10:return gr(a.type),qt(a),null;case 19:if(B0(a),u=a.memoizedState,u===null)return qt(a),null;if(h=(a.flags&128)!==0,m=u.rendering,m===null)if(h)Iu(u,!1);else{if(tn!==0||t!==null&&(t.flags&128)!==0)for(t=a.child;t!==null;){if(m=om(t),m!==null){for(a.flags|=128,Iu(u,!1),t=m.updateQueue,a.updateQueue=t,wm(a,t),a.subtreeFlags=0,t=l,l=a.child;l!==null;)z1(l,t),l=l.sibling;return Ru(a,Mn.current&1|2),lt&&fr(a,u.treeForkCount),a.child}t=t.sibling}u.tail!==null&&tt()>Om&&(a.flags|=128,h=!0,Iu(u,!1),a.lanes=4194304)}else{if(!h)if(t=om(m),t!==null){if(a.flags|=128,h=!0,t=t.updateQueue,a.updateQueue=t,wm(a,t),Iu(u,!0),u.tail===null&&u.tailMode!=="collapsed"&&u.tailMode!=="visible"&&!m.alternate&&!lt)return qt(a),null}else 2*tt()-u.renderingStartTime>Om&&l!==536870912&&(a.flags|=128,h=!0,Iu(u,!1),a.lanes=4194304);u.isBackwards?(m.sibling=a.child,a.child=m):(t=u.last,t!==null?t.sibling=m:a.child=m,u.last=m)}if(u.tail!==null){t=u.tail;e:{for(l=t;l!==null;){if(l.alternate!==null){l=!1;break e}l=l.sibling}l=!0}return u.rendering=t,u.tail=t.sibling,u.renderingStartTime=tt(),t.sibling=null,m=Mn.current,m=h?m&1|2:m&1,u.tailMode==="visible"||u.tailMode==="collapsed"||!l||lt?Ru(a,m):(l=m,et(En,a),et(Mn,l),Gn===null&&(Gn=a)),lt&&fr(a,u.treeForkCount),t}return qt(a),null;case 22:case 23:return Ns(a),L0(),u=a.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(a.flags|=8192):u&&(a.flags|=8192),u?(l&536870912)!==0&&(a.flags&128)===0&&(qt(a),a.subtreeFlags&6&&(a.flags|=8192)):qt(a),l=a.updateQueue,l!==null&&wm(a,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==l&&(a.flags|=2048),t!==null&&Ke(_o),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),a.memoizedState.cache!==l&&(a.flags|=2048),gr(cn),qt(a),null;case 25:return null;case 30:return a.flags|=33554432,qt(a),null}throw Error(s(156,a.tag))}function S4(t,a){switch(N0(a),a.tag){case 1:return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 3:return gr(cn),re(),t=a.flags,(t&65536)!==0&&(t&128)===0?(a.flags=t&-65537|128,a):null;case 26:case 27:case 5:return Qe(a),null;case 31:if(a.memoizedState!==null){if(Ns(a),a.alternate===null)throw Error(s(340));po()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 13:if(Ns(a),t=a.memoizedState,t!==null&&t.dehydrated!==null){if(a.alternate===null)throw Error(s(340));po()}return t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 19:return B0(a),t=a.flags,t&65536?(a.flags=t&-65537|128,t=a.memoizedState,t!==null&&(t.rendering=null,t.tail=null),a.flags|=4,a):null;case 4:return re(),null;case 10:return gr(a.type),null;case 22:case 23:return Ns(a),L0(),t!==null&&Ke(_o),t=a.flags,t&65536?(a.flags=t&-65537|128,a):null;case 24:return gr(cn),null;case 25:return null;default:return null}}function o2(t,a){switch(N0(a),a.tag){case 3:gr(cn),re();break;case 26:case 27:case 5:Qe(a);break;case 4:re();break;case 31:a.memoizedState!==null&&Ns(a);break;case 13:Ns(a);break;case 19:B0(a);break;case 10:gr(a.type);break;case 22:case 23:Ns(a),L0(),t!==null&&Ke(_o);break;case 24:gr(cn)}}function Du(t,a){try{var l=a.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var h=u.next;l=h;do{if((l.tag&t)===t){u=void 0;var m=l.create,w=l.inst;u=m(),w.destroy=u}l=l.next}while(l!==h)}}catch(A){Tt(a,a.return,A)}}function bi(t,a,l){try{var u=a.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var m=h.next;u=m;do{if((u.tag&t)===t){var w=u.inst,A=w.destroy;if(A!==void 0){w.destroy=void 0,h=a;var B=l,ne=A;try{ne()}catch(de){Tt(h,B,de)}}}u=u.next}while(u!==m)}}catch(de){Tt(a,a.return,de)}}function l2(t){var a=t.updateQueue;if(a!==null){var l=t.stateNode;try{Q1(a,l)}catch(u){Tt(t,t.return,u)}}}function c2(t,a,l){l.props=Co(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(u){Tt(t,a,u)}}function qa(t,a){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:var h=t.stateNode,m=dr(t.memoizedProps,h);(h.ref===null||h.ref.name!==m)&&(h.ref=gS(m)),u=h.ref;break;case 7:if(t.stateNode===null){var w=new Ms(t);g(t.child,!1,mM,w,void 0,void 0),t.stateNode=w}u=t.stateNode;break;default:u=t.stateNode}typeof l=="function"?t.refCleanup=l(u):l.current=u}}catch(A){Tt(t,a,A)}}function Rn(t,a){var l=t.ref,u=t.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(h){Tt(t,a,h)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(h){Tt(t,a,h)}else l.current=null}function Sm(t,a){if((t.tag===5||t.tag===27||t.tag===6)&&t.alternate===null&&a!==null)for(var l=0;l<a.length;l++)wS(t.stateNode,a[l])}function u2(t){for(var a=t.return;a!==null&&(yg(a)&&wS(t.stateNode,a.stateNode),!xg(a));)a=a.return}function qu(t){for(var a=t.return;a!==null&&(yg(a)&&fM(t.stateNode,a.stateNode),!xg(a));)a=a.return}function xg(t){return t.tag===5||t.tag===3||t.tag===27}function yg(t){return t&&t.tag===7&&t.stateNode!==null}function _g(t){var a=t.type,l=t.memoizedProps,u=t.stateNode;try{e:switch(a){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(h){Tt(t,t.return,h)}}function vg(t,a,l){try{var u=t.stateNode;W4(u,t.type,l,a),u[on]=a}catch(h){Tt(t,t.return,h)}}function d2(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&ki(t.type)||t.tag===4}function wg(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||d2(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&&ki(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 Sg(t,a,l,u){var h=t.tag;if(h===5||h===6)h=t.stateNode,a?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(h,a):(a=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,a.appendChild(h),l=l._reactRootContainer,l!=null||a.onclick!==null||(a.onclick=jn)),Sm(t,u),ct=!0;else if(h!==4&&(h===27&&(Sm(t,u),u=null,ki(t.type)&&(l=t.stateNode,a=null)),t=t.child,t!==null))for(Sg(t,a,l,u),t=t.sibling;t!==null;)Sg(t,a,l,u),t=t.sibling}function km(t,a,l,u){var h=t.tag;if(h===5||h===6)h=t.stateNode,a?l.insertBefore(h,a):l.appendChild(h),Sm(t,u),ct=!0;else if(h!==4&&(h===27&&(Sm(t,u),u=null,ki(t.type)&&(l=t.stateNode)),t=t.child,t!==null))for(km(t,a,l,u),t=t.sibling;t!==null;)km(t,a,l,u),t=t.sibling}function h2(t){var a=t.stateNode,l=t.memoizedProps;try{for(var u=t.type,h=a.attributes;h.length;)a.removeAttributeNode(h[0]);zn(a,u,l),a[Ut]=t,a[on]=l}catch(m){Tt(t,t.return,m)}}var Cm=!1,As=null;function m2(t){(t.tag===30||(t.subtreeFlags&33554432)!==0)&&(Cm=!0)}var La=null;function f2(){var t=La;return La=null,t}var ls=0;function Ll(t,a,l,u,h){return ls=0,p2(t.child,a,l,u,h)}function p2(t,a,l,u,h){for(var m=!1;t!==null;){if(t.tag===5){var w=t.stateNode;if(u!==null){var A=ib(w);u.push(A),A.view&&(m=!0)}else m||ib(w).view&&(m=!0);Cm=!0,fS(w,ls===0?a:a+"_"+ls,l),ls++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&h||p2(t.child,a,l,u,h)&&(m=!0));t=t.sibling}return m}function Ua(t,a){for(;t!==null;)t.tag===5?pS(t.stateNode,t.memoizedProps):(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&a||Ua(t.child,a)),t=t.sibling}function Nm(t){if((t.subtreeFlags&18874368)!==0)for(t=t.child;t!==null;){if((t.tag!==22||t.memoizedState===null)&&(Nm(t),t.tag===30&&(t.flags&18874368)!==0&&t.stateNode.paired)){var a=t.memoizedProps;if(a.name==null||a.name==="auto")throw Error(s(544));var l=a.name;a=hr(a.default,a.share),a!=="none"&&(Ll(t,l,a,null,!1)||Ua(t.child,!1))}t=t.sibling}}function kg(t,a){if(t.tag===30){var l=t.stateNode,u=t.memoizedProps,h=dr(u,l),m=hr(u.default,l.paired?u.share:u.enter);m!=="none"?Ll(t,h,m,null,!1)?(Nm(t),l.paired||a||Yl(t,u.onEnter)):Ua(t.child,!1):Nm(t)}else if((t.subtreeFlags&33554432)!==0)for(t=t.child;t!==null;)kg(t,a),t=t.sibling;else Nm(t)}function Cg(t){if(As!==null&&As.size!==0){var a=As;if((t.subtreeFlags&18874368)!==0)for(t=t.child;t!==null;){if(t.tag!==22||t.memoizedState===null){if(t.tag===30&&(t.flags&18874368)!==0){var l=t.memoizedProps,u=l.name;if(u!=null&&u!=="auto"){var h=a.get(u);if(h!==void 0){var m=hr(l.default,l.share);if(m!=="none"&&(Ll(t,u,m,null,!1)?(m=t.stateNode,h.paired=m,m.paired=h,Yl(t,l.onShare)):Ua(t.child,!1)),a.delete(u),a.size===0)break}}}Cg(t)}t=t.sibling}}}function Ng(t){if(t.tag===30){var a=t.memoizedProps,l=dr(a,t.stateNode),u=As!==null?As.get(l):void 0,h=hr(a.default,u!==void 0?a.share:a.exit);h!=="none"&&(Ll(t,l,h,null,!1)?u!==void 0?(h=t.stateNode,u.paired=h,h.paired=u,As.delete(l),Yl(t,a.onShare)):Yl(t,a.onExit):Ua(t.child,!1)),As!==null&&Cg(t)}else if((t.subtreeFlags&33554432)!==0)for(t=t.child;t!==null;)Ng(t),t=t.sibling;else As!==null&&Cg(t)}function g2(t){for(t=t.child;t!==null;){if(t.tag===30){var a=t.memoizedProps,l=dr(a,t.stateNode);a=hr(a.default,a.update),t.flags&=-5,a!=="none"&&Ll(t,l,a,t.memoizedState=[],!1)}else(t.subtreeFlags&33554432)!==0&&g2(t);t=t.sibling}}function Ag(t){if((t.subtreeFlags&18874368)!==0)for(t=t.child;t!==null;){if(t.tag!==22||t.memoizedState===null){if(t.tag===30&&(t.flags&18874368)!==0){var a=t.stateNode;a.paired!==null&&(a.paired=null,Ua(t.child,!1))}Ag(t)}t=t.sibling}}function Am(t){if(t.tag===30)t.stateNode.paired=null,Ua(t.child,!1),Ag(t);else if((t.subtreeFlags&33554432)!==0)for(t=t.child;t!==null;)Am(t),t=t.sibling;else Ag(t)}function b2(t){for(t=t.child;t!==null;)t.tag===30?Ua(t.child,!1):(t.subtreeFlags&33554432)!==0&&b2(t),t=t.sibling}function jg(t,a,l,u,h,m,w){for(var A=!1;a!==null;){if(a.tag===5){var B=a.stateNode;if(m!==null&&ls<m.length){var ne=m[ls],de=ib(B);(ne.view||de.view)&&(A=!0);var _e;if(_e=(t.flags&4)===0)if(de.clip)_e=!0;else{_e=ne.rect;var ee=de.rect;_e=_e.y!==ee.y||_e.x!==ee.x||_e.height!==ee.height||_e.width!==ee.width}_e&&(t.flags|=4),de.abs?de=!ne.abs:(ne=ne.rect,de=de.rect,de=ne.height!==de.height||ne.width!==de.width),de&&(t.flags|=32)}else t.flags|=32;(t.flags&4)!==0&&fS(B,ls===0?l:l+"_"+ls,h),A&&(t.flags&4)!==0||(La===null&&(La=[]),La.push(B,ls===0?u:u+"_"+ls,a.memoizedProps)),ls++}else(a.tag!==22||a.memoizedState===null)&&(a.tag===30&&w?t.flags|=a.flags&32:jg(t,a.child,l,u,h,m,w)&&(A=!0));a=a.sibling}return A}function x2(t,a){for(t=t.child;t!==null;){if(t.tag===30){var l=t.memoizedProps,u=t.stateNode,h=dr(l,u),m=hr(l.default,l.update),w;w=t.memoizedState,t.memoizedState=null,u=t;var A=t.child;ls=0,h=jg(u,A,h,h,m,w,!1),(t.flags&4)!==0&&h&&Yl(t,l.onUpdate)}else(t.subtreeFlags&33554432)!==0&&x2(t);t=t.sibling}}var yn=!1,kt=!1,Ba=!1,Tg=!1,y2=typeof WeakSet=="function"?WeakSet:Set,_n=null,Ga=!1,Lu=!1,jm=!1,Eg=!1;function k4(t,a,l){if(t=t.containerInfo,tb=ac,t=S1(t),g0(t)){if("selectionStart"in t)var u={start:t.selectionStart,end:t.selectionEnd};else e:{u=(u=t.ownerDocument)&&u.defaultView||window;var h=u.getSelection&&u.getSelection();if(h&&h.rangeCount!==0){u=h.anchorNode;var m=h.anchorOffset,w=h.focusNode;h=h.focusOffset;try{u.nodeType,w.nodeType}catch{u=null;break e}var A=0,B=-1,ne=-1,de=0,_e=0,ee=t,ce=null;t:for(;;){for(var ze;ee!==u||m!==0&&ee.nodeType!==3||(B=A+m),ee!==w||h!==0&&ee.nodeType!==3||(ne=A+h),ee.nodeType===3&&(A+=ee.nodeValue.length),(ze=ee.firstChild)!==null;)ce=ee,ee=ze;for(;;){if(ee===t)break t;if(ce===u&&++de===m&&(B=A),ce===w&&++_e===h&&(ne=A),(ze=ee.nextSibling)!==null)break;ee=ce,ce=ee.parentNode}ee=ze}u=B===-1||ne===-1?null:{start:B,end:ne}}else u=null}u=u||{start:0,end:0}}else u=null;for(nb={focusedElem:t,selectionRange:u},ac=!1,l=(l&335544064)===l,_n=a,a=l?9270:1024;_n!==null;){if(t=_n,l&&(u=t.deletions,u!==null))for(m=0;m<u.length;m++)l&&Ng(u[m]);if(t.alternate===null&&(t.flags&2)!==0)l&&m2(t),Tm(l);else{if(t.tag===22){if(u=t.alternate,t.memoizedState!==null){u!==null&&u.memoizedState===null&&l&&Ng(u),Tm(l);continue}else if(u!==null&&u.memoizedState!==null){l&&m2(t),Tm(l);continue}}u=t.child,(t.subtreeFlags&a)!==0&&u!==null?(u.return=t,_n=u):(l&&g2(t),Tm(l))}}As=null}function Tm(t){for(;_n!==null;){var a=_n,l=t,u=a.alternate,h=a.flags;switch(a.tag){case 0:case 11:case 15:break;case 1:if((h&1024)!==0&&u!==null){l=void 0,h=u.memoizedProps,u=u.memoizedState;var m=a.stateNode;try{var w=Co(a.type,h);l=m.getSnapshotBeforeUpdate(w,u),m.__reactInternalSnapshotBeforeUpdate=l}catch(A){Tt(a,a.return,A)}}break;case 3:if((h&1024)!==0){if(u=a.stateNode.containerInfo,l=u.nodeType,l===9)cb(u);else if(l===1)switch(u.nodeName){case"HEAD":case"HTML":case"BODY":cb(u);break;default:u.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:l&&u!==null&&(l=dr(u.memoizedProps,u.stateNode),h=a.memoizedProps,h=hr(h.default,h.update),h!=="none"&&Ll(u,l,h,u.memoizedState=[],!0));break;default:if((h&1024)!==0)throw Error(s(163))}if(u=a.sibling,u!==null){u.return=a.return,_n=u;break}_n=a.return}}function _2(t,a,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:Ha(t,l),u&4&&Du(5,l);break;case 1:if(Ha(t,l),u&4)if(t=l.stateNode,a===null)try{t.componentDidMount()}catch(w){Tt(l,l.return,w)}else{var h=Co(l.type,a.memoizedProps);a=a.memoizedState;try{t.componentDidUpdate(h,a,t.__reactInternalSnapshotBeforeUpdate)}catch(w){Tt(l,l.return,w)}}u&64&&l2(l),u&512&&qa(l,l.return);break;case 3:if(Ha(t,l),u&64&&(t=l.updateQueue,t!==null)){if(a=null,l.child!==null)switch(l.child.tag){case 27:case 5:a=l.child.stateNode;break;case 1:a=l.child.stateNode}try{Q1(t,a)}catch(w){Tt(l,l.return,w)}}break;case 27:a===null&&u&4&&h2(l);case 26:case 5:Ha(t,l),a===null&&u&4&&_g(l),u&512&&qa(l,l.return);break;case 12:Ha(t,l);break;case 31:Ha(t,l),u&4&&k2(t,l);break;case 13:Ha(t,l),u&4&&C2(t,l),u&64&&(t=l.memoizedState,t!==null&&(t=t.dehydrated,t!==null&&(l=$4.bind(null,l),bM(t,l))));break;case 22:if(u=l.memoizedState!==null||yn,!u){var m=a!==null&&a.memoizedState!==null||kt;a=yn,h=kt,yn=u,(kt=m)&&!h?(u=2,(l.subtreeFlags&8772)!==0&&(u|=1),ba(t,l,u)):Ha(t,l),yn=a,kt=h}break;case 30:Ha(t,l),u&512&&qa(l,l.return);break;case 7:u&512&&qa(l,l.return);default:Ha(t,l)}}function Mg(t,a){for(t=t.child;t!==null;)v2(t,a),t=t.sibling}function v2(t,a){switch(t.tag){case 5:case 26:try{var l=t.stateNode;if(a){var u=l.style;typeof u.setProperty=="function"?u.setProperty("display","none","important"):u.display="none"}else{var h=t.stateNode,m=t.memoizedProps.style,w=m!=null&&m.hasOwnProperty("display")?m.display:null;h.style.display=w==null||typeof w=="boolean"?"":(""+w).trim()}}catch(B){Tt(t,t.return,B)}Rg(t,a);break;case 6:try{t.stateNode.nodeValue=a?"":t.memoizedProps,ct=!0}catch(B){Tt(t,t.return,B)}break;case 18:try{var A=t.stateNode;a?mS(A,!0):mS(t.stateNode,!1)}catch(B){Tt(t,t.return,B)}break;case 22:case 23:t.memoizedState===null&&Mg(t,a);break;default:Mg(t,a)}}function Rg(t,a){if(t.subtreeFlags&67108864)for(t=t.child;t!==null;){e:{var l=t,u=a;switch(l.tag){case 4:v2(l,u);break e;case 22:l.memoizedState===null&&Rg(l,u);break e;default:Rg(l,u)}}t=t.sibling}}function w2(t){var a=t.alternate;a!==null&&(t.alternate=null,w2(a)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(a=t.stateNode,a!==null&&Jr(a)),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 Ht=null,cs=!1;function pa(t,a,l){for(l=l.child;l!==null;)S2(t,a,l),l=l.sibling}function S2(t,a,l){if(st&&typeof st.onCommitFiberUnmount=="function")try{st.onCommitFiberUnmount(eo,l)}catch{}switch(l.tag){case 26:kt||Rn(l,a),pa(t,a,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&!kt&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:kt||Rn(l,a),qu(l);var u=Ht,h=cs;ki(l.type)&&(Ht=l.stateNode,cs=!1),pa(t,a,l),AS(l.stateNode,l.type,l.memoizedProps),Ht=u,cs=h;break;case 5:kt||Rn(l,a),qu(l);case 6:if(l.tag===6&&qu(l),u=Ht,h=cs,Ht=null,pa(t,a,l),Ht=u,cs=h,Ht!==null)if(cs)try{(Ht.nodeType===9?Ht.body:Ht.nodeName==="HTML"?Ht.ownerDocument.body:Ht).removeChild(l.stateNode),ct=!0}catch(m){Tt(l,a,m)}else try{Ht.removeChild(l.stateNode),ct=!0}catch(m){Tt(l,a,m)}break;case 18:Ht!==null&&(cs?(t=Ht,hS(t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,l.stateNode),rc(t)):hS(Ht,l.stateNode));break;case 4:u=Ht,h=cs,Ht=l.stateNode.containerInfo,cs=!0,pa(t,a,l),Ht=u,cs=h;break;case 0:case 11:case 14:case 15:bi(2,l,a),kt||bi(4,l,a),pa(t,a,l);break;case 1:kt||(Rn(l,a),u=l.stateNode,typeof u.componentWillUnmount=="function"&&c2(l,a,u)),pa(t,a,l);break;case 21:pa(t,a,l);break;case 22:kt=(u=kt)||l.memoizedState!==null,pa(t,a,l),kt=u;break;case 30:Rn(l,a),pa(t,a,l);break;case 7:kt||Rn(l,a),pa(t,a,l);break;default:pa(t,a,l)}}function k2(t,a){if(a.memoizedState===null&&(t=a.alternate,t!==null&&(t=t.memoizedState,t!==null))){t=t.dehydrated;try{rc(t)}catch(l){Tt(a,a.return,l)}}}function C2(t,a){if(a.memoizedState===null&&(t=a.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{rc(t)}catch(l){Tt(a,a.return,l)}}function C4(t){switch(t.tag){case 31:case 13:case 19:var a=t.stateNode;return a===null&&(a=t.stateNode=new y2),a;case 22:return t=t.stateNode,a=t._retryCache,a===null&&(a=t._retryCache=new y2),a;default:throw Error(s(435,t.tag))}}function Em(t,a){var l=C4(t);a.forEach(function(u){if(!l.has(u)){l.add(u);var h=I4.bind(null,t,u);u.then(h,h)}})}function Kn(t,a,l){var u=a.deletions;if(u!==null)for(var h=0;h<u.length;h++){var m=u[h],w=t,A=a,B=A;e:for(;B!==null;){switch(B.tag){case 27:if(ki(B.type)){Ht=B.stateNode,cs=!1;break e}break;case 5:Ht=B.stateNode,cs=!1;break e;case 3:case 4:Ht=B.stateNode.containerInfo,cs=!0;break e}B=B.return}if(Ht===null)throw Error(s(160));S2(w,A,m),Ht=null,cs=!1,w=m.alternate,w!==null&&(w.return=null),m.return=null}if(a.subtreeFlags&13886)for(a=a.child;a!==null;)N2(a,t,l),a=a.sibling}var ga=null;function N2(t,a,l){var u=t.alternate,h=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(h&4&&(u=t.updateQueue,u=u!==null?u.events:null,u!==null))for(var m=0;m<u.length;m++){var w=u[m];w.ref.impl=w.nextImpl}Kn(a,t,l),Yn(t),h&4&&(bi(3,t,t.return),Du(3,t),bi(5,t,t.return));break;case 1:Kn(a,t,l),Yn(t),h&512&&(kt||u===null||Rn(u,u.return)),h&64&&yn&&(t=t.updateQueue,t!==null&&(a=t.callbacks,a!==null&&(l=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=l===null?a:l.concat(a))));break;case 26:if(m=ga,Kn(a,t,l),Yn(t),h&512&&(kt||u===null||Rn(u,u.return)),h&4)if(h=u!==null?u.memoizedState:null,l=t.memoizedState,u===null)if(l===null)if(t.stateNode===null)if(yn)t.stateNode=cS(t.type,t.memoizedProps,a.containerInfo,t);else{e:{a=t.type,l=t.memoizedProps,h=m.ownerDocument||m;t:switch(a){case"title":u=h.getElementsByTagName("title")[0],(!u||u[or]||u[Ut]||u.namespaceURI==="http://www.w3.org/2000/svg"||u.hasAttribute("itemprop"))&&(u=h.createElement(a),h.head.insertBefore(u,h.querySelector("head > title"))),zn(u,a,l),u[Ut]=t,At(u),a=u;break e;case"link":if(m=zS("link","href",h).get(a+(l.href||""))){for(w=0;w<m.length;w++)if(u=m[w],u.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&u.getAttribute("rel")===(l.rel==null?null:l.rel)&&u.getAttribute("title")===(l.title==null?null:l.title)&&u.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){m.splice(w,1);break t}}u=h.createElement(a),zn(u,a,l),h.head.appendChild(u);break;case"meta":if(m=zS("meta","content",h).get(a+(l.content||""))){for(w=0;w<m.length;w++)if(u=m[w],u.getAttribute("content")===(l.content==null?null:""+l.content)&&u.getAttribute("name")===(l.name==null?null:l.name)&&u.getAttribute("property")===(l.property==null?null:l.property)&&u.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&u.getAttribute("charset")===(l.charSet==null?null:l.charSet)){m.splice(w,1);break t}}u=h.createElement(a),zn(u,a,l),h.head.appendChild(u);break;default:throw Error(s(468,a))}u[Ut]=t,At(u),a=u}t.stateNode=a}else yn||gb(m,t.type,t.stateNode);else t.stateNode=RS(m,l,t.memoizedProps);else h!==l?(h===null?(a=u.stateNode,a===null||kt||a.parentNode.removeChild(a)):h.count--,l===null?yn||gb(m,t.type,t.stateNode):RS(m,l,t.memoizedProps)):l===null&&t.stateNode!==null&&vg(t,t.memoizedProps,u.memoizedProps);break;case 27:Kn(a,t,l),Yn(t),h&512&&(kt||u===null||Rn(u,u.return)),u!==null&&h&4&&vg(t,t.memoizedProps,u.memoizedProps);break;case 5:if(m=Ba,Ba=!1,Kn(a,t,l),Ba=m,Yn(t),h&512&&(kt||u===null||Rn(u,u.return)),t.flags&32){a=t.stateNode;try{za(a,""),ct=!0}catch(de){Tt(t,t.return,de)}}h&4&&t.stateNode!=null&&(a=t.memoizedProps,vg(t,a,u!==null?u.memoizedProps:a)),h&1024&&(Tg=!0);break;case 6:if(Kn(a,t,l),Yn(t),h&4){if(t.stateNode===null)throw Error(s(162));a=t.memoizedProps,l=t.stateNode;try{l.nodeValue=a,ct=!0}catch(de){Tt(t,t.return,de)}}break;case 3:if(ct=!1,Fm=null,m=ga,ga=Wu(a.containerInfo),Kn(a,t,l),ga=m,Yn(t),h&4&&u!==null&&u.memoizedState.isDehydrated)try{rc(a.containerInfo)}catch(de){Tt(t,t.return,de)}Tg&&(Tg=!1,A2(t)),ct=!1;break;case 4:h=Ba,Ba=yn,u=ao(),m=ga,ga=Wu(t.stateNode.containerInfo),Kn(a,t,l),Yn(t),ga=m,ct&&Lu&&(jm=!0),ct=u,Ba=h;break;case 12:Kn(a,t,l),Yn(t);break;case 31:Kn(a,t,l),Yn(t),h&4&&(a=t.updateQueue,a!==null&&(t.updateQueue=null,Em(t,a)));break;case 13:Kn(a,t,l),Yn(t),t.child.flags&8192&&t.memoizedState!==null!=(u!==null&&u.memoizedState!==null)&&(zm=tt()),h&4&&(a=t.updateQueue,a!==null&&(t.updateQueue=null,Em(t,a)));break;case 22:m=t.memoizedState!==null,w=u!==null&&u.memoizedState!==null;var A=yn,B=kt,ne=Ba;yn=A||m,Ba=ne||m,kt=B||w,Kn(a,t,l),kt=B,Ba=ne,yn=A,Yn(t),h&8192&&(a=t.stateNode,a._visibility=m?a._visibility&-2:a._visibility|1,!m||u===null||w||yn||kt||(a=w||kt,l=yn,u=kt,yn=m||yn,kt=a,xi(t,2),yn=l,kt=u),!m&&Ba||Mg(t,m)),h&4&&(a=t.updateQueue,a!==null&&(l=a.retryQueue,l!==null&&(a.retryQueue=null,Em(t,l))));break;case 19:Kn(a,t,l),Yn(t),h&4&&(a=t.updateQueue,a!==null&&(t.updateQueue=null,Em(t,a)));break;case 30:h&512&&(kt||u===null||Rn(u,u.return)),h=ao(),m=Lu,w=(l&335544064)===l,A=t.memoizedProps,Lu=w&&hr(A.default,A.update)!=="none",Kn(a,t,l),Yn(t),w&&u!==null&&ct&&(t.flags|=4),Lu=m,ct=h;break;case 21:break;case 7:h&512&&(kt||u===null||Rn(u,u.return)),u&&u.stateNode!==null&&(u.stateNode._fragmentFiber=t);default:Kn(a,t,l),Yn(t)}}function Yn(t){var a=t.flags;if(a&2){try{for(var l,u=t.return;u!==null;){if(d2(u)){l=u;break}u=u.return}u=null;for(var h=t.return;h!==null;){if(yg(h)){var m=h.stateNode;u===null?u=[m]:u.push(m)}if(xg(h))break;h=h.return}var w=u;if(l==null)throw Error(s(160));switch(l.tag){case 27:var A=l.stateNode,B=wg(t);km(t,B,A,w);break;case 5:var ne=l.stateNode;l.flags&32&&(za(ne,""),l.flags&=-33);var de=wg(t);km(t,de,ne,w);break;case 3:case 4:var _e=l.stateNode.containerInfo,ee=wg(t);Sg(t,ee,_e,w);break;default:throw Error(s(161))}}catch(ce){Tt(t,t.return,ce)}t.flags&=-3}a&4096&&(t.flags&=-4097)}function A2(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var a=t;A2(a),a.tag===5&&a.flags&1024&&(a=a.stateNode,ac=!0,a.reset(),ac=!1),t=t.sibling}}function Ul(t,a){if(a.subtreeFlags&9270)for(a=a.child;a!==null;)j2(a,t),a=a.sibling;else x2(a)}function j2(t,a){var l=t.alternate;if(l===null)kg(t,!1);else switch(t.tag){case 3:if(Eg=Ga=!1,f2(),Ul(a,t),!Ga&&!jm){if(t=La,t!==null)for(var u=0;u<t.length;u+=3){l=t[u];var h=t[u+1];pS(l,t[u+2]),l=l.ownerDocument.documentElement,l!==null&&l.animate({opacity:[0,0],pointerEvents:["none","none"]},{duration:0,fill:"forwards",pseudoElement:"::view-transition-group("+h+")"})}t=a.containerInfo,t=t.nodeType===9?t.documentElement:t.ownerDocument.documentElement,t!==null&&t.style.viewTransitionName===""&&(t.style.viewTransitionName="none",t.animate({opacity:[0,0],pointerEvents:["none","none"]},{duration:0,fill:"forwards",pseudoElement:"::view-transition-group(root)"}),t.animate({width:[0,0],height:[0,0]},{duration:0,fill:"forwards",pseudoElement:"::view-transition"})),Eg=!0}La=null;break;case 5:Ul(a,t);break;case 4:u=Ga,Ga=!1,Ul(a,t),Ga&&(jm=!0),Ga=u;break;case 22:t.memoizedState===null&&(l.memoizedState!==null?kg(t,!1):Ul(a,t));break;case 30:u=Ga,h=f2(),Ga=!1,Ul(a,t),Ga&&(t.flags|=4);var m=t.memoizedProps,w=t.stateNode;a=dr(m,w),w=dr(l.memoizedProps,w);var A=hr(m.default,m.update);A==="none"?a=!1:(m=l.memoizedState,l.memoizedState=null,l=t.child,ls=0,a=jg(t,l,a,w,A,m,!0),ls!==(m===null?0:m.length)&&(t.flags|=32)),(t.flags&4)!==0&&a?(Yl(t,t.memoizedProps.onUpdate),La=h):h!==null&&(h.push.apply(h,La),La=h),Ga=(t.flags&32)!==0?!0:u;break;default:Ul(a,t)}}function Ha(t,a){if(a.subtreeFlags&8772)for(a=a.child;a!==null;)_2(t,a.alternate,a),a=a.sibling}function xi(t,a){for(t=t.child;t!==null;){var l=t,u=a;switch(l.tag){case 0:case 11:case 14:case 15:bi(4,l,l.return),xi(l,u);break;case 1:Rn(l,l.return);var h=l.stateNode;typeof h.componentWillUnmount=="function"&&c2(l,l.return,h),xi(l,u);break;case 27:(u&2)!==0&&AS(l.stateNode,l.type,l.memoizedProps);case 5:Rn(l,l.return),l.tag!==5&&l.tag!==27||qu(l),xi(l,u);break;case 6:qu(l);break;case 26:Rn(l,l.return),h=l.stateNode,l.memoizedState!==null||h===null||kt||h.parentNode.removeChild(h),xi(l,u);break;case 22:l.memoizedState===null&&xi(l,u);break;case 30:Rn(l,l.return),xi(l,u);break;case 7:Rn(l,l.return);default:xi(l,u)}t=t.sibling}}function ba(t,a,l){for(l=(a.subtreeFlags&8772)!==0?l:l&-2,a=a.child;a!==null;){var u=a.alternate,h=t,m=a,w=m.flags,A=(l&1)!==0;switch(m.tag){case 0:case 11:case 15:ba(h,m,l),Du(4,m);break;case 1:if(ba(h,m,l),u=m,h=u.stateNode,typeof h.componentDidMount=="function")try{h.componentDidMount()}catch(de){Tt(u,u.return,de)}if(u=m,h=u.updateQueue,h!==null){var B=u.stateNode;try{var ne=h.shared.hiddenCallbacks;if(ne!==null)for(h.shared.hiddenCallbacks=null,h=0;h<ne.length;h++)X1(ne[h],B)}catch(de){Tt(u,u.return,de)}}A&&w&64&&l2(m),qa(m,m.return);break;case 27:(l&2)!==0&&h2(m);case 5:m.tag!==5&&m.tag!==27||u2(m),ba(h,m,l),A&&u===null&&w&4&&_g(m),qa(m,m.return);break;case 6:u2(m);break;case 26:B=m.stateNode,m.memoizedState!==null||B===null||yn||gb(Wu(B.ownerDocument),m.type,B),ba(h,m,l),A&&u===null&&w&4&&_g(m),qa(m,m.return);break;case 12:ba(h,m,l);break;case 31:ba(h,m,l),A&&w&4&&k2(h,m);break;case 13:ba(h,m,l),A&&w&4&&C2(h,m);break;case 22:m.memoizedState===null&&ba(h,m,l),qa(m,m.return);break;case 30:ba(h,m,l),qa(m,m.return);break;case 7:qa(m,m.return);default:ba(h,m,l)}a=a.sibling}}function zg(t,a){var l=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),t=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(t=a.memoizedState.cachePool.pool),t!==l&&(t!=null&&t.refCount++,l!=null&&Cu(l))}function Og(t,a){t=null,a.alternate!==null&&(t=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==t&&(a.refCount++,t!=null&&Cu(t))}function Zs(t,a,l,u){var h=(l&335544064)===l;if(a.subtreeFlags&(h?10262:10256))for(a=a.child;a!==null;)T2(t,a,l,u),a=a.sibling;else h&&b2(a)}function T2(t,a,l,u){var h=(l&335544064)===l;h&&a.alternate===null&&a.return!==null&&a.return.alternate!==null&&Am(a);var m=a.flags;switch(a.tag){case 0:case 11:case 15:Zs(t,a,l,u),m&2048&&Du(9,a);break;case 1:Zs(t,a,l,u);break;case 3:Zs(t,a,l,u),h&&Eg&&(t=t.containerInfo,t=t.nodeType===9?t.body:t.nodeName==="HTML"?t.ownerDocument.body:t,t.style.viewTransitionName==="root"&&(t.style.viewTransitionName=""),t=t.ownerDocument.documentElement,t!==null&&t.style.viewTransitionName==="none"&&(t.style.viewTransitionName="")),m&2048&&(m=null,a.alternate!==null&&(m=a.alternate.memoizedState.cache),a=a.memoizedState.cache,a!==m&&(a.refCount++,m!=null&&Cu(m)));break;case 12:if(m&2048){Zs(t,a,l,u),m=a.stateNode;try{var w=a.memoizedProps,A=w.id,B=w.onPostCommit;typeof B=="function"&&B(A,a.alternate===null?"mount":"update",m.passiveEffectDuration,-0)}catch(ne){Tt(a,a.return,ne)}}else Zs(t,a,l,u);break;case 31:Zs(t,a,l,u);break;case 13:Zs(t,a,l,u);break;case 23:break;case 22:w=a.stateNode,A=a.alternate,a.memoizedState!==null?(h&&A!==null&&A.memoizedState===null&&Am(A),w._visibility&2?Zs(t,a,l,u):Uu(t,a)):(h&&A!==null&&A.memoizedState!==null&&Am(a),w._visibility&2?Zs(t,a,l,u):(w._visibility|=2,Bl(t,a,l,u,(a.subtreeFlags&10256)!==0||!1))),m&2048&&zg(A,a);break;case 24:Zs(t,a,l,u),m&2048&&Og(a.alternate,a);break;case 30:h&&(m=a.alternate,m!==null&&(Ua(m.child,!0),Ua(a.child,!0))),Zs(t,a,l,u);break;default:Zs(t,a,l,u)}}function Bl(t,a,l,u,h){for(h=h&&((a.subtreeFlags&10256)!==0||!1),a=a.child;a!==null;){var m=t,w=a,A=l,B=u,ne=w.flags;switch(w.tag){case 0:case 11:case 15:Bl(m,w,A,B,h),Du(8,w);break;case 23:break;case 22:var de=w.stateNode;w.memoizedState!==null?de._visibility&2?Bl(m,w,A,B,h):Uu(m,w):(de._visibility|=2,Bl(m,w,A,B,h)),h&&ne&2048&&zg(w.alternate,w);break;case 24:Bl(m,w,A,B,h),h&&ne&2048&&Og(w.alternate,w);break;default:Bl(m,w,A,B,h)}a=a.sibling}}function Uu(t,a){if(a.subtreeFlags&10256)for(a=a.child;a!==null;){var l=t,u=a,h=u.flags;switch(u.tag){case 22:Uu(l,u),h&2048&&zg(u.alternate,u);break;case 24:Uu(l,u),h&2048&&Og(u.alternate,u);break;default:Uu(l,u)}a=a.sibling}}var No=8192;function Ao(t,a,l){if(t.subtreeFlags&No)for(t=t.child;t!==null;)E2(t,a,l),t=t.sibling}function E2(t,a,l){switch(t.tag){case 26:Ao(t,a,l),t.flags&No&&(t.memoizedState!==null?MM(l,ga,t.memoizedState,t.memoizedProps):(t=t.stateNode,(a&335544128)===a&&IS(l,t)));break;case 5:Ao(t,a,l),t.flags&No&&(t=t.stateNode,(a&335544128)===a&&IS(l,t));break;case 3:case 4:var u=ga;ga=Wu(t.stateNode.containerInfo),Ao(t,a,l),ga=u;break;case 22:t.memoizedState===null&&(u=t.alternate,u!==null&&u.memoizedState!==null?(u=No,No=16777216,Ao(t,a,l),No=u):Ao(t,a,l));break;case 30:if((t.flags&No)!==0&&(u=t.memoizedProps.name,u!=null&&u!=="auto")){var h=t.stateNode;h.paired=null,As===null&&(As=new Map),As.set(u,h)}Ao(t,a,l);break;default:Ao(t,a,l)}}function M2(t){var a=t.alternate;if(a!==null&&(t=a.child,t!==null)){a.child=null;do a=t.sibling,t.sibling=null,t=a;while(t!==null)}}function Bu(t){var a=t.deletions;if((t.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];_n=u,z2(u,t)}M2(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)R2(t),t=t.sibling}function R2(t){switch(t.tag){case 0:case 11:case 15:Bu(t),t.flags&2048&&bi(9,t,t.return);break;case 3:Bu(t);break;case 12:Bu(t);break;case 22:var a=t.stateNode;t.memoizedState!==null&&a._visibility&2&&(t.return===null||t.return.tag!==13)?(a._visibility&=-3,Mm(t)):Bu(t);break;default:Bu(t)}}function Mm(t){var a=t.deletions;if((t.flags&16)!==0){if(a!==null)for(var l=0;l<a.length;l++){var u=a[l];_n=u,z2(u,t)}M2(t)}for(t=t.child;t!==null;){switch(a=t,a.tag){case 0:case 11:case 15:bi(8,a,a.return),Mm(a);break;case 22:l=a.stateNode,l._visibility&2&&(l._visibility&=-3,Mm(a));break;default:Mm(a)}t=t.sibling}}function z2(t,a){for(;_n!==null;){var l=_n;switch(l.tag){case 0:case 11:case 15:bi(8,l,a);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var u=l.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:Cu(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,_n=u;else e:for(l=t;_n!==null;){u=_n;var h=u.sibling,m=u.return;if(w2(u),u===l){_n=null;break e}if(h!==null){h.return=m,_n=h;break e}_n=m}}}var N4={getCacheForType:function(t){var a=Tn(cn),l=a.data.get(t);return l===void 0&&(l=t(),a.data.set(t,l)),l},cacheSignal:function(){return Tn(cn).controller.signal}},A4=typeof WeakMap=="function"?WeakMap:Map,wt=0,$t=null,dt=null,pt=0,jt=0,js=null,yi=!1,Gl=!1,Pg=!1,vr=0,tn=0,_i=0,jo=0,Rm=0,Ts=0,Hl=0,Gu=null,us=null,$g=!1,zm=0,O2=0,Om=1/0,Pm=null,vi=null,Wt=0,xa=null,To=null,Fa=0,Ig=0,Dg=null,P2=null,Fl=null,Vl=null,Kl=null,Hu=0,$m=null;function Es(){return(wt&2)!==0&&pt!==0?pt&-pt:Ce.T!==null?Yg():iu()}function $2(){if(Ts===0)if((pt&536870912)===0||lt){var t=An;An<<=1,(An&3932160)===0&&(An=262144),Ts=t}else Ts=536870912;return t=En.current,t!==null&&(t.flags|=32),Ts}function Yl(t,a){if(a!=null){var l=t.stateNode,u=l.ref;u===null&&(u=l.ref=gS(dr(t.memoizedProps,l))),Vl===null&&(Vl=[]),Vl.push(a.bind(null,u))}}function ds(t,a,l){(t===$t&&(jt===2||jt===9)||t.cancelPendingCommit!==null)&&(Wl(t,0),wi(t,pt,Ts,!1)),no(t,l),((wt&2)===0||t!==$t)&&(t===$t&&((wt&2)===0&&(jo|=l),tn===4&&wi(t,pt,Ts,!1)),Va(t))}function I2(t,a,l){if((wt&6)!==0)throw Error(s(327));var u=!l&&(a&127)===0&&(a&t.expiredLanes)===0||Xr(t,a),h=u?E4(t,a):Lg(t,a,!0),m=u;do{if(h===0){Gl&&!u&&wi(t,a,0,!1);break}else{if(l=t.current.alternate,m&&!j4(l)){h=Lg(t,a,!1),m=!1;continue}if(h===2){if(m=a,t.errorRecoveryDisabledLanes&m)var w=0;else w=t.pendingLanes&-536870913,w=w!==0?w:w&536870912?536870912:0;if(w!==0){a=w;e:{var A=t;h=Gu;var B=A.current.memoizedState.isDehydrated;if(B&&(Wl(A,w).flags|=256),w=Lg(A,w,!1),w!==2&&w!==6){if(Pg&&!B){A.errorRecoveryDisabledLanes|=m,jo|=m,h=4;break e}m=us,us=h,m!==null&&(us===null?us=m:us.push.apply(us,m))}h=w}if(m=!1,h!==2)continue}}if(h===1){Wl(t,0),wi(t,a,0,!0);break}e:{switch(u=t,m=h,m){case 0:case 1:throw Error(s(345));case 4:if((a&4194048)!==a&&(a&62914560)!==a)break;case 6:wi(u,a,Ts,!yi);break e;case 2:us=null;break;case 3:case 5:break;default:throw Error(s(329))}if((a&62914560)===a&&(h=zm+300-tt(),10<h)){if(wi(u,a,Ts,!yi),ml(u,0,!0)!==0)break e;Fa=a,u.timeoutHandle=rb(D2.bind(null,u,l,us,Pm,$g,a,Ts,jo,Hl,yi,m,"Throttled",-0,0),h);break e}D2(u,l,us,Pm,$g,a,Ts,jo,Hl,yi,m,null,-0,0)}}break}while(!0);Va(t)}function D2(t,a,l,u,h,m,w,A,B,ne,de,_e,ee,ce){t.timeoutHandle=-1;var ze=a.subtreeFlags,Ge=(m&335544064)===m;if(_e=null,(Ge||ze&8192||(ze&16785408)===16785408)&&(_e={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:jn},As=null,E2(a,m,_e),Ge&&(ze=_e,Ge=t.containerInfo,Ge=(Ge.nodeType===9?Ge:Ge.ownerDocument).__reactViewTransition,Ge!=null&&(ze.count++,ze.waitingForViewTransition=!0,ze=Ju.bind(ze),Ge.finished.then(ze,ze))),ze=(m&62914560)===m?zm-tt():(m&4194048)===m?O2-tt():0,ze=RM(_e,ze),ze!==null)){Fa=m,t.cancelPendingCommit=ze(V2.bind(null,t,a,m,l,u,h,w,A,B,ne,de,_e,null,ee,ce)),wi(t,m,w,!ne);return}V2(t,a,m,l,u,h,w,A,B,ne,de,_e)}function j4(t){for(var a=t;;){var l=a.tag;if((l===0||l===11||l===15)&&a.flags&16384&&(l=a.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var u=0;u<l.length;u++){var h=l[u],m=h.getSnapshot;h=h.value;try{if(!Cs(m(),h))return!1}catch{return!1}}if(l=a.child,a.subtreeFlags&16384&&l!==null)l.return=a,a=l;else{if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function wi(t,a,l,u){a=Mt(t,a),a&=~Rm,a&=~jo,t.suspendedLanes|=a,t.pingedLanes&=~a,u&&(t.warmLanes|=a),u=t.expirationTimes;for(var h=a;0<h;){var m=31-Ct(h),w=1<<m;u[m]=-1,h&=~w}l!==0&&so(t,l,a)}function Im(){return(wt&6)===0?(Fu(0),!1):!0}function qg(){if(dt!==null){if(jt===0)var t=dt.return;else t=dt,pr=go=null,K0(t),Pl=null,ju=0,t=dt;for(;t!==null;)o2(t.alternate,t),t=t.return;dt=null}}function Wl(t,a){var l=t.timeoutHandle;return l!==-1&&(t.timeoutHandle=-1,J4(l)),l=t.cancelPendingCommit,l!==null&&(t.cancelPendingCommit=null,l()),Fa=0,qg(),$t=t,dt=l=mr(t.current,null),pt=a,jt=0,js=null,yi=!1,Gl=Xr(t,a),Pg=!1,Hl=Ts=Rm=jo=_i=tn=0,us=Gu=null,$g=!1,vr=Mt(t,a),Fh(),l}function q2(t,a){at=null,Ce.H=gm,a===Ol||a===nm?(a=V1(),jt=3):a===O0?(a=V1(),jt=4):jt=a===lg?8:a!==null&&typeof a=="object"&&typeof a.then=="function"?6:1,js=a,dt===null&&(tn=1,bm(t,Ws(a,t.current)))}function L2(){var t=En.current;return t===null?!0:(pt&4194048)===pt?Gn===null:(pt&62914560)===pt||(pt&536870912)!==0?t===Gn:!1}function U2(){var t=Ce.H;return Ce.H=gm,t===null?gm:t}function B2(){var t=Ce.A;return Ce.A=N4,t}function Dm(){tn=4,yi||(pt&4194048)!==pt&&En.current!==null||(Gl=!0),(_i&134217727)===0&&(jo&134217727)===0||$t===null||wi($t,pt,Ts,!1)}function Lg(t,a,l){var u=wt;wt|=2;var h=U2(),m=B2();($t!==t||pt!==a)&&(Pm=null,Wl(t,a)),a=!1;var w=tn;e:do try{if(jt!==0&&dt!==null){var A=dt,B=js;switch(jt){case 8:qg(),w=6;break e;case 3:case 2:case 9:case 6:En.current===null&&(a=!0);var ne=jt;if(jt=0,js=null,Xl(t,A,B,ne),l&&Gl){w=0;break e}break;default:ne=jt,jt=0,js=null,Xl(t,A,B,ne)}}T4(),w=tn;break}catch(de){q2(t,de)}while(!0);return a&&t.shellSuspendCounter++,pr=go=null,wt=u,Ce.H=h,Ce.A=m,dt===null&&($t=null,pt=0,Fh()),w}function T4(){for(;dt!==null;)G2(dt)}function E4(t,a){var l=wt;wt|=2;var u=U2(),h=B2();$t!==t||pt!==a?(Pm=null,Om=tt()+500,Wl(t,a)):Gl=Xr(t,a);e:do try{if(jt!==0&&dt!==null){a=dt;var m=js;t:switch(jt){case 1:jt=0,js=null,Xl(t,a,m,1);break;case 2:case 9:if(H1(m)){jt=0,js=null,H2(a);break}a=function(){jt!==2&&jt!==9||$t!==t||(jt=7),Va(t)},m.then(a,a);break e;case 3:jt=7;break e;case 4:jt=5;break e;case 7:H1(m)?(jt=0,js=null,H2(a)):(jt=0,js=null,Xl(t,a,m,7));break;case 5:var w=null;switch(dt.tag){case 26:w=dt.memoizedState;case 5:case 27:var A=dt;if(w?PS(w):A.stateNode.complete){jt=0,js=null;var B=A.sibling;if(B!==null)dt=B;else{var ne=A.return;ne!==null?(dt=ne,qm(ne)):dt=null}break t}}jt=0,js=null,Xl(t,a,m,5);break;case 6:jt=0,js=null,Xl(t,a,m,6);break;case 8:qg(),tn=6;break e;default:throw Error(s(462))}}M4();break}catch(de){q2(t,de)}while(!0);return pr=go=null,Ce.H=u,Ce.A=h,wt=l,dt!==null?0:($t=null,pt=0,Fh(),tn)}function M4(){for(;dt!==null&&!Nn();)G2(dt)}function G2(t){var a=r2(t.alternate,t,vr);t.memoizedProps=t.pendingProps,a===null?qm(t):dt=a}function H2(t){var a=t,l=a.alternate;switch(a.tag){case 15:case 0:a=Jw(l,a,a.pendingProps,a.type,void 0,pt);break;case 11:a=Jw(l,a,a.pendingProps,a.type.render,a.ref,pt);break;case 5:K0(a);var u=a;u===xn&&(lt?(Qh(u),u.tag===5&&u.stateNode!=null&&(Dt=u.stateNode)):(Qh(u),lt=!0));default:o2(l,a),a=dt=z1(a,vr),a=r2(l,a,vr)}t.memoizedProps=t.pendingProps,a===null?qm(t):dt=a}function Xl(t,a,l,u){pr=go=null,K0(a),Pl=null,ju=0;var h=a.return;try{if(x4(t,h,a,l,pt)){tn=1,bm(t,Ws(l,t.current)),dt=null;return}}catch(m){if(h!==null)throw dt=h,m;tn=1,bm(t,Ws(l,t.current)),dt=null;return}a.flags&32768?(lt||u===1?t=!0:Gl||(pt&536870912)!==0?t=!1:(yi=t=!0,(u===2||u===9||u===3||u===6)&&(u=En.current,u!==null&&u.tag===13&&(u.flags|=16384))),F2(a,t)):qm(a)}function qm(t){var a=t;do{if((a.flags&32768)!==0){F2(a,yi);return}t=a.return;var l=w4(a.alternate,a,vr);if(l!==null){dt=l;return}if(a=a.sibling,a!==null){dt=a;return}dt=a=t}while(a!==null);tn===0&&(tn=5)}function F2(t,a){do{var l=S4(t.alternate,t);if(l!==null){l.flags&=32767,dt=l;return}if(l=t.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!a&&(t=t.sibling,t!==null)){dt=t;return}dt=t=l}while(t!==null);tn=6,dt=null}function V2(t,a,l,u,h,m,w,A,B,ne,de,_e){t.cancelPendingCommit=null;do Lm();while(Wt!==0);if((wt&6)!==0)throw Error(s(327));if(a!==null){if(a===t.current)throw Error(s(177));t===$t&&(dt=$t=null,pt=0),To=a,xa=t,Fa=l,Dg=h,P2=u,R4(t,a,l,w,A,B,_e)}}function R4(t,a,l,u,h,m,w){var A=a.lanes|a.childLanes;if(Ig=A,A|=v0,$h(t,l,A,u,h,m),Vl=null,(l&335544064)===l?(Kl=i4(t),u=10262):(Kl=null,u=10256),(a.subtreeFlags&u)!==0||(a.flags&u)!==0?(t.callbackNode=null,t.callbackPriority=0,D4(Zi,function(){return Hg(),null})):(t.callbackNode=null,t.callbackPriority=0),Cm=!1,u=(a.flags&13878)!==0,(a.subtreeFlags&13878)!==0||u){u=Ce.T,Ce.T=null,h=Ue.p,Ue.p=2,m=wt,wt|=4;try{k4(t,a,l)}finally{wt=m,Ue.p=h,Ce.T=u}}Wt=1,Cm?Fl=aM(w,t.containerInfo,Kl,Ug,Bg,O4,Gg,Hg,z4):(Ug(),Bg(),Gg())}function z4(t){if(Wt!==0){var a=xa.onRecoverableError;a(t,{componentStack:null})}}function O4(){Wt===3&&(Wt=0,j2(To,xa),Wt=4)}function Ug(){if(Wt===1){Wt=0;var t=xa,a=To,l=Fa,u=(a.flags&13878)!==0;if((a.subtreeFlags&13878)!==0||u){u=Ce.T,Ce.T=null;var h=Ue.p;Ue.p=2;var m=wt;wt|=4;try{Lu=jm=!1,N2(a,t,l),l=nb;var w=S1(t.containerInfo),A=l.focusedElem,B=l.selectionRange;if(w!==A&&A&&A.ownerDocument&&w1(A.ownerDocument.documentElement,A)){if(B!==null&&g0(A)){var ne=B.start,de=B.end;if(de===void 0&&(de=ne),"selectionStart"in A)A.selectionStart=ne,A.selectionEnd=Math.min(de,A.value.length);else{var _e=A.ownerDocument||document,ee=_e&&_e.defaultView||window;if(ee.getSelection){var ce=ee.getSelection(),ze=A.textContent.length,Ge=Math.min(B.start,ze),rt=B.end===void 0?Ge:Math.min(B.end,ze);!ce.extend&&Ge>rt&&(w=rt,rt=Ge,Ge=w);var te=v1(A,Ge),Y=v1(A,rt);if(te&&Y&&(ce.rangeCount!==1||ce.anchorNode!==te.node||ce.anchorOffset!==te.offset||ce.focusNode!==Y.node||ce.focusOffset!==Y.offset)){var ie=_e.createRange();ie.setStart(te.node,te.offset),ce.removeAllRanges(),Ge>rt?(ce.addRange(ie),ce.extend(Y.node,Y.offset)):(ie.setEnd(Y.node,Y.offset),ce.addRange(ie))}}}}for(_e=[],ce=A;ce=ce.parentNode;)ce.nodeType===1&&_e.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<_e.length;A++){var xe=_e[A];xe.element.scrollLeft=xe.left,xe.element.scrollTop=xe.top}}ac=!!tb,nb=tb=null}finally{wt=m,Ue.p=h,Ce.T=u}}t.current=a,Wt=2}}function Bg(){if(Wt===2){Wt=0;var t=xa,a=To,l=(a.flags&8772)!==0;if((a.subtreeFlags&8772)!==0||l){l=Ce.T,Ce.T=null;var u=Ue.p;Ue.p=2;var h=wt;wt|=4;try{_2(t,a.alternate,a)}finally{wt=h,Ue.p=u,Ce.T=l}}Wt=3}}function Gg(){if(Wt===4||Wt===3){Wt=0;var t=Fl;Fl=null,Ji();var a=xa,l=To,u=Fa,h=P2,m=(u&335544064)===u?10262:10256;if((l.subtreeFlags&m)!==0||(l.flags&m)!==0?Wt=5:(Wt=0,To=xa=null,K2(a,a.pendingLanes)),m=a.pendingLanes,m===0&&(vi=null),ru(u),l=l.stateNode,st&&typeof st.onCommitFiberRoot=="function")try{st.onCommitFiberRoot(eo,l,void 0,(l.current.flags&128)===128)}catch{}if(h!==null){l=Ce.T,m=Ue.p,Ue.p=2,Ce.T=null;try{for(var w=a.onRecoverableError,A=0;A<h.length;A++){var B=h[A];w(B.value,{componentStack:B.stack})}}finally{Ce.T=l,Ue.p=m}}if(h=Vl,w=Kl,Kl=null,h!==null&&(Vl=null,w===null&&(w=[]),t!==null))for(B=0;B<h.length;B++)l=(0,h[B])(w),l!==void 0&&t.finished.finally(l);(Fa&3)!==0&&Lm(),Va(a),m=a.pendingLanes,(u&261930)!==0&&(m&42)!==0?a===$m?Hu++:(Hu=0,$m=a):(Hu=0,$m=null),Fu(0)}}function K2(t,a){(t.pooledCacheLanes&=a)===0&&(a=t.pooledCache,a!=null&&(t.pooledCache=null,Cu(a)))}function Lm(){return Fl!==null&&(Fl.skipTransition(),Fl=null),Ug(),Bg(),Gg(),Hg()}function Hg(){if(Wt!==5)return!1;var t=xa,a=Ig;Ig=0;var l=ru(Fa),u=Ce.T,h=Ue.p;try{Ue.p=32>l?32:l,Ce.T=null,l=Dg,Dg=null;var m=xa,w=Fa;if(Wt=0,To=xa=null,Fa=0,(wt&6)!==0)throw Error(s(331));var A=wt;if(wt|=4,R2(m.current),T2(m,m.current,w,l),wt=A,Fu(0,!1),st&&typeof st.onPostCommitFiberRoot=="function")try{st.onPostCommitFiberRoot(eo,m)}catch{}return!0}finally{Ue.p=h,Ce.T=u,K2(t,a)}}function Y2(t,a,l){a=Ws(l,a),a=og(t.stateNode,a,2),t=mi(t,a,2),t!==null&&(no(t,2),Va(t))}function Tt(t,a,l){if(t.tag===3)Y2(t,t,l);else for(;a!==null;){if(a.tag===3){Y2(a,t,l);break}else if(a.tag===1){var u=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(vi===null||!vi.has(u))){t=Ws(l,t),l=Hw(2),u=mi(a,l,2),u!==null&&(Fw(l,u,a,t),no(u,2),Va(u));break}}a=a.return}}function Fg(t,a,l){var u=t.pingCache;if(u===null){u=t.pingCache=new A4;var h=new Set;u.set(a,h)}else h=u.get(a),h===void 0&&(h=new Set,u.set(a,h));h.has(l)||(Pg=!0,h.add(l),t=P4.bind(null,t,a,l),a.then(t,t))}function P4(t,a,l){var u=t.pingCache;u!==null&&u.delete(a),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,$t===t&&(pt&l)===l&&((tn===4||tn===3&&(pt&62914560)===pt&&300>tt()-zm)&&(wt&2)===0?Wl(t,0):Rm|=l,Hl===pt&&(Hl=0)),Va(t)}function W2(t,a){a===0&&(a=Vs()),t=mo(t,a),t!==null&&(no(t,a),Va(t))}function $4(t){var a=t.memoizedState,l=0;a!==null&&(l=a.retryLane),W2(t,l)}function I4(t,a){var l=0;switch(t.tag){case 31:case 13:var u=t.stateNode,h=t.memoizedState;h!==null&&(l=h.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(a),W2(t,l)}function D4(t,a){return _t(t,a)}var Ql=null,Jl=null,Vg=!1,Um=!1,Kg=!1,Si=0;function Va(t){t!==Jl&&t.next===null&&(Jl===null?Ql=Jl=t:Jl=Jl.next=t),Um=!0,Vg||(Vg=!0,L4())}function Fu(t,a){if(!Kg&&Um){Kg=!0;do for(var l=!1,u=Ql;u!==null;){if(t!==0){var h=u.pendingLanes;if(h===0)var m=0;else{var w=u.suspendedLanes,A=u.pingedLanes;m=(1<<31-Ct(42|t)+1)-1,m&=h&~(w&~A),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,Z2(u,m))}else m=pt,m=ml(u,u===$t?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||Xr(u,m)||(l=!0,Z2(u,m));u=u.next}while(l);Kg=!1}}function q4(){X2()}function X2(){Um=Vg=!1;var t=0;Si!==0&&Q4()&&(t=Si);for(var a=tt(),l=null,u=Ql;u!==null;){var h=u.next,m=Q2(u,a);m===0?(u.next=null,l===null?Ql=h:l.next=h,h===null&&(Jl=l)):(l=u,(t!==0||(m&3)!==0)&&(Um=!0)),u=h}Wt!==0&&Wt!==5||Fu(t),Si!==0&&(Si=0)}function Q2(t,a){for(var l=t.suspendedLanes,u=t.pingedLanes,h=t.expirationTimes,m=t.pendingLanes&-62914561;0<m;){var w=31-Ct(m),A=1<<w,B=h[w];B===-1?((A&l)===0||(A&u)!==0)&&(h[w]=Un(A,a)):B<=a&&(t.expiredLanes|=A),m&=~A}if(a=$t,l=pt,l=ml(t,t===a?l:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u=t.callbackNode,l===0||t===a&&(jt===2||jt===9)||t.cancelPendingCommit!==null)return u!==null&&u!==null&&ja(u),t.callbackNode=null,t.callbackPriority=0;if((l&3)===0||Xr(t,l)){if(a=l&-l,a===t.callbackPriority)return a;switch(u!==null&&ja(u),ru(l)){case 2:case 8:l=dl;break;case 32:l=Zi;break;case 268435456:l=oa;break;default:l=Zi}return u=J2.bind(null,t),l=_t(l,u),t.callbackPriority=a,t.callbackNode=l,a}return u!==null&&u!==null&&ja(u),t.callbackPriority=2,t.callbackNode=null,2}function J2(t,a){if(Wt!==0&&Wt!==5)return t.callbackNode=null,t.callbackPriority=0,null;var l=t.callbackNode;if(Lm()&&t.callbackNode!==l)return null;var u=pt;return u=ml(t,t===$t?u:0,t.cancelPendingCommit!==null||t.timeoutHandle!==-1),u===0?null:(I2(t,u,a),Q2(t,tt()),t.callbackNode!=null&&t.callbackNode===l?J2.bind(null,t):null)}function Z2(t,a){if(Lm())return null;I2(t,a,!0)}function L4(){Z4(function(){(wt&6)!==0?_t(Ln,q4):X2()})}function Yg(){if(Si===0){var t=yo;t===0&&(t=Nt,Nt<<=1,(Nt&261888)===0&&(Nt=256)),Si=t}return Si}function eS(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:ro(t)}function U4(t,a,l,u,h){if(a==="submit"&&l&&l.stateNode===h){var m=eS((h[on]||null).action),w=u.submitter;w&&(a=(a=w[on]||null)?eS(a.formAction):w.getAttribute("formAction"),a!==null&&(m=a,w=null));var A=new kl("action","action",null,u,h);t.push({event:A,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Si!==0){var B=new FormData(h,w);ng(l,{pending:!0,data:B,method:h.method,action:m},null,B)}}else typeof m=="function"&&(A.preventDefault(),B=new FormData(h,w),ng(l,{pending:!0,data:B,method:h.method,action:m},m,B))},currentTarget:h}]})}}for(var Wg=0;Wg<_0.length;Wg++){var Xg=_0[Wg],B4=Xg.toLowerCase(),G4=Xg[0].toUpperCase()+Xg.slice(1);fa(B4,"on"+G4)}fa(N1,"onAnimationEnd"),fa(A1,"onAnimationIteration"),fa(j1,"onAnimationStart"),fa("dblclick","onDoubleClick"),fa("focusin","onFocus"),fa("focusout","onBlur"),fa(JE,"onTransitionRun"),fa(ZE,"onTransitionStart"),fa(e4,"onTransitionCancel"),fa(T1,"onTransitionEnd"),Jt("onMouseEnter",["mouseout","mouseover"]),Jt("onMouseLeave",["mouseout","mouseover"]),Jt("onPointerEnter",["pointerout","pointerover"]),Jt("onPointerLeave",["pointerout","pointerover"]),je("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),je("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),je("onBeforeInput",["compositionend","keypress","textInput","paste"]),je("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),je("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),je("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vu="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(" "),H4=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Vu));function tS(t,a){a=(a&4)!==0;for(var l=0;l<t.length;l++){var u=t[l],h=u.event;u=u.listeners;e:{var m=void 0;if(a)for(var w=u.length-1;0<=w;w--){var A=u[w],B=A.instance,ne=A.currentTarget;if(A=A.listener,B!==m&&h.isPropagationStopped())break e;m=A,h.currentTarget=ne;try{m(h)}catch(de){Hh(de)}h.currentTarget=null,m=B}else for(w=0;w<u.length;w++){if(A=u[w],B=A.instance,ne=A.currentTarget,A=A.listener,B!==m&&h.isPropagationStopped())break e;m=A,h.currentTarget=ne;try{m(h)}catch(de){Hh(de)}h.currentTarget=null,m=B}}}}function ht(t,a){var l=a[lu];l===void 0&&(l=a[lu]=new Set);var u=t+"__bubble";l.has(u)||(nS(a,t,2,!1),l.add(u))}function Qg(t,a,l){var u=0;a&&(u|=4),nS(l,t,u,a)}var Bm="_reactListening"+Math.random().toString(36).slice(2);function Jg(t){if(!t[Bm]){t[Bm]=!0,qh.forEach(function(l){l!=="selectionchange"&&(H4.has(l)||Qg(l,!1,t),Qg(l,!0,t))});var a=t.nodeType===9?t:t.ownerDocument;a===null||a[Bm]||(a[Bm]=!0,Qg("selectionchange",!1,a))}}function nS(t,a,l,u){switch(FS(a)){case 2:var h=$M;break;case 8:h=IM;break;default:h=xb}l=h.bind(null,a,l,t),h=void 0,!gu||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(h=!0),u?h!==void 0?t.addEventListener(a,l,{capture:!0,passive:h}):t.addEventListener(a,l,!0):h!==void 0?t.addEventListener(a,l,{passive:h}):t.addEventListener(a,l,!1)}function Zg(t,a,l,u,h){var m=u;if((a&1)===0&&(a&2)===0&&u!==null)e:for(;;){if(u===null)return;var w=u.tag;if(w===3||w===4){var A=u.stateNode.containerInfo;if(A===h)break;if(w===4)for(w=u.return;w!==null;){var B=w.tag;if((B===3||B===4)&&w.stateNode.containerInfo===h)return;w=w.return}for(;A!==null;){if(w=Ea(A),w===null)return;if(B=w.tag,B===5||B===6||B===26||B===27){u=m=w;continue e}A=A.parentNode}}u=u.return}vl(function(){var ne=m,de=Ks(l),_e=[];e:{var ee=E1.get(t);if(ee!==void 0){var ce=kl,ze=t;switch(t){case"keypress":if(Oa(l)===0)break e;case"keydown":case"keyup":ce=jE;break;case"focusin":ze="focus",ce=Be;break;case"focusout":ze="blur",ce=Be;break;case"beforeblur":case"afterblur":ce=Be;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ce=oe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=ke;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=zE;break;case N1:case A1:case j1:ce=vt;break;case T1:ce=PE;break;case"scroll":case"scrollend":ce=c0;break;case"wheel":ce=IE;break;case"copy":case"cut":case"paste":ce=ks;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=o1;break;case"submit":ce=ME;break;case"toggle":case"beforetoggle":ce=qE}var Ge=(a&4)!==0,rt=!Ge&&(t==="scroll"||t==="scrollend"),te=Ge?ee!==null?ee+"Capture":null:ee;Ge=[];for(var Y=ne,ie;Y!==null;){var xe=Y;if(ie=xe.stateNode,xe=xe.tag,xe!==5&&xe!==26&&xe!==27||ie===null||te===null||(xe=io(Y,te),xe!=null&&Ge.push(Ku(Y,xe,ie))),rt)break;Y=Y.return}0<Ge.length&&(ee=new ce(ee,ze,null,l,de),_e.push({event:ee,listeners:Ge}))}}if((a&7)===0){e:{if(ce=t==="mouseover"||t==="pointerover",ee=t==="mouseout"||t==="pointerout",ce&&l!==yl&&(ze=l.relatedTarget||l.fromElement)&&(Ea(ze)||ze[la]))break e;(ee||ce)&&(ze=de.window===de?de:(ce=de.ownerDocument)?ce.defaultView||ce.parentWindow:window,ee?(ce=l.relatedTarget||l.toElement,ee=ne,ce=ce?Ea(ce):null,ce!==null&&(rt=c(ce),Ge=ce.tag,ce!==rt||Ge!==5&&Ge!==27&&Ge!==6)&&(ce=null)):(ee=null,ce=ne),ee!==ce&&(Ge=oe,xe="onMouseLeave",te="onMouseEnter",Y="mouse",(t==="pointerout"||t==="pointerover")&&(Ge=o1,xe="onPointerLeave",te="onPointerEnter",Y="pointer"),rt=ee==null?ze:Ma(ee),ie=ce==null?ze:Ma(ce),ze=new Ge(xe,Y+"leave",ee,l,de),ze.target=rt,ze.relatedTarget=ie,xe=null,Ea(de)===ne&&(Ge=new Ge(te,Y+"enter",ce,l,de),Ge.target=ie,Ge.relatedTarget=rt,xe=Ge),rt=xe,Ge=ee&&ce?V(ee,ce,F4):null,ee!==null&&sS(_e,ze,ee,Ge,!1),ce!==null&&rt!==null&&sS(_e,rt,ce,Ge,!0)))}e:{if(ee=ne?Ma(ne):window,ce=ee.nodeName&&ee.nodeName.toLowerCase(),ce==="select"||ce==="input"&&ee.type==="file")var qe=p1;else if(m1(ee))if(g1)qe=WE;else{qe=KE;var gt=VE}else ce=ee.nodeName,!ce||ce.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?ne&&is(ne.elementType)&&(qe=p1):qe=YE;if(qe&&(qe=qe(t,ne))){f1(_e,qe,l,de);break e}gt&&gt(t,ee,ne)}switch(gt=ne?Ma(ne):window,t){case"focusin":(m1(gt)||gt.contentEditable==="true")&&(Nl=gt,b0=ne,wu=null);break;case"focusout":wu=b0=Nl=null;break;case"mousedown":x0=!0;break;case"contextmenu":case"mouseup":case"dragend":x0=!1,k1(_e,l,de);break;case"selectionchange":if(QE)break;case"keydown":case"keyup":k1(_e,l,de)}var Ve;if(h0)e:{switch(t){case"compositionstart":var Xe="onCompositionStart";break e;case"compositionend":Xe="onCompositionEnd";break e;case"compositionupdate":Xe="onCompositionUpdate";break e}Xe=void 0}else Cl?d1(t,l)&&(Xe="onCompositionEnd"):t==="keydown"&&l.keyCode===229&&(Xe="onCompositionStart");Xe&&(l1&&l.locale!=="ko"&&(Cl||Xe!=="onCompositionStart"?Xe==="onCompositionEnd"&&Cl&&(Ve=ai()):(ma=de,bn="value"in ma?ma.value:ma.textContent,Cl=!0)),gt=Gm(ne,Xe),0<gt.length&&(Xe=new $a(Xe,t,null,l,de),_e.push({event:Xe,listeners:gt}),Ve?Xe.data=Ve:(Ve=h1(l),Ve!==null&&(Xe.data=Ve)))),(Ve=UE?BE(t,l):GE(t,l))&&(Xe=Gm(ne,"onBeforeInput"),0<Xe.length&&(gt=new $a("onBeforeInput","beforeinput",null,l,de),_e.push({event:gt,listeners:Xe}),gt.data=Ve)),U4(_e,t,ne,l,de)}tS(_e,a)})}function Ku(t,a,l){return{instance:t,listener:a,currentTarget:l}}function Gm(t,a){for(var l=a+"Capture",u=[];t!==null;){var h=t,m=h.stateNode;if(h=h.tag,h!==5&&h!==26&&h!==27||m===null||(h=io(t,l),h!=null&&u.unshift(Ku(t,h,m)),h=io(t,a),h!=null&&u.push(Ku(t,h,m))),t.tag===3)return u;t=t.return}return[]}function F4(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function sS(t,a,l,u,h){for(var m=a._reactName,w=[];l!==null&&l!==u;){var A=l,B=A.alternate,ne=A.stateNode;if(A=A.tag,B!==null&&B===u)break;A!==5&&A!==26&&A!==27||ne===null||(B=ne,h?(ne=io(l,m),ne!=null&&w.unshift(Ku(l,ne,B))):h||(ne=io(l,m),ne!=null&&w.push(Ku(l,ne,B)))),l=l.return}w.length!==0&&t.push({event:a,listeners:w})}var V4=/\r\n?/g,K4=/\u0000|\uFFFD/g;function aS(t){return(typeof t=="string"?t:""+t).replace(V4,`
50
+ `).replace(K4,"")}function rS(t,a){return a=aS(a),aS(t)===a}function Et(t,a,l,u,h,m){switch(l){case"children":if(typeof u=="string")a==="body"||a==="textarea"&&u===""||za(t,u);else if(typeof u=="number"||typeof u=="bigint")a!=="body"&&za(t,""+u);else return;break;case"className":ws(t,"class",u);break;case"tabIndex":ws(t,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":ws(t,l,u);break;case"style":da(t,u,m);return;case"data":if(a!=="object"){ws(t,"data",u);break}case"src":case"href":if(u===""&&(a!=="a"||l!=="href")){t.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(l);break}u=ro(u),t.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){t.setAttribute(l,"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 m=="function"&&(l==="formAction"?(a!=="input"&&Et(t,a,"name",h.name,h,null),Et(t,a,"formEncType",h.formEncType,h,null),Et(t,a,"formMethod",h.formMethod,h,null),Et(t,a,"formTarget",h.formTarget,h,null)):(Et(t,a,"encType",h.encType,h,null),Et(t,a,"method",h.method,h,null),Et(t,a,"target",h.target,h,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){t.removeAttribute(l);break}u=ro(u),t.setAttribute(l,u);break;case"onClick":u!=null&&(t.onclick=jn);return;case"onScroll":u!=null&&ht("scroll",t);return;case"onScrollEnd":u!=null&&ht("scrollend",t);return;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(h.children!=null)throw Error(s(60));m?.__html!==l&&(t.innerHTML=l)}}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}l=ro(u),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);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(l,u):t.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"credentialless":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(l,""):t.removeAttribute(l);break;case"capture":case"download":u===!0?t.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?t.setAttribute(l,u):t.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?t.setAttribute(l,u):t.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?t.removeAttribute(l):t.setAttribute(l,u);break;case"popover":ht("beforetoggle",t),ht("toggle",t),ca(t,"popover",u);break;case"xlinkActuate":Pt(t,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":Pt(t,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":Pt(t,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":Pt(t,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":Pt(t,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":Pt(t,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":Pt(t,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":Pt(t,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":Pt(t,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":ca(t,"is",u);break;case"innerText":case"textContent":return;default:if(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")l=si.get(l)||l,ca(t,l,u);else return}ct=!0}function eb(t,a,l,u,h,m){switch(l){case"style":da(t,u,m);return;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(h.children!=null)throw Error(s(60));m?.__html!==l&&(t.innerHTML=l)}}break;case"children":if(typeof u=="string")za(t,u);else if(typeof u=="number"||typeof u=="bigint")za(t,""+u);else return;break;case"onScroll":u!=null&&ht("scroll",t);return;case"onScrollEnd":u!=null&&ht("scrollend",t);return;case"onClick":u!=null&&(t.onclick=jn);return;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":return;case"innerText":case"textContent":return;default:if(!lr.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(h=l.endsWith("Capture"),m=l.slice(2,h?l.length-7:void 0),a=t[on]||null,a=a!=null?a[l]:null,typeof a=="function"&&t.removeEventListener(m,a,h),typeof u=="function")){typeof a!="function"&&a!==null&&(l in t?t[l]=null:t.hasAttribute(l)&&t.removeAttribute(l)),t.addEventListener(m,u,h);break e}ct=!0,l in t?t[l]=u:u===!0?t.setAttribute(l,""):ca(t,l,u)}return}ct=!0}function zn(t,a,l){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ht("error",t),ht("load",t);var u=!1,h=!1,m;for(m in l)if(l.hasOwnProperty(m)){var w=l[m];if(w!=null)switch(m){case"src":u=!0;break;case"srcSet":h=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,a));default:Et(t,a,m,w,l,null)}}h&&Et(t,a,"srcSet",l.srcSet,l,null),u&&Et(t,a,"src",l.src,l,null);return;case"input":ht("invalid",t);var A=m=w=h=null,B=null,ne=null;for(u in l)if(l.hasOwnProperty(u)){var de=l[u];if(de!=null)switch(u){case"name":h=de;break;case"type":w=de;break;case"checked":B=de;break;case"defaultChecked":ne=de;break;case"value":m=de;break;case"defaultValue":A=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(s(137,a));break;default:Et(t,a,u,de,l,null)}}Yt(t,m,A,B,ne,w,h,!1);return;case"select":ht("invalid",t),u=w=m=null;for(h in l)if(l.hasOwnProperty(h)&&(A=l[h],A!=null))switch(h){case"value":m=A;break;case"defaultValue":w=A;break;case"multiple":u=A;default:Et(t,a,h,A,l,null)}a=m,l=w,t.multiple=!!u,a!=null?Ra(t,!!u,a,!1):l!=null&&Ra(t,!!u,l,!0);return;case"textarea":ht("invalid",t),m=h=u=null;for(w in l)if(l.hasOwnProperty(w)&&(A=l[w],A!=null))switch(w){case"value":u=A;break;case"defaultValue":h=A;break;case"children":m=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(s(91));break;default:Et(t,a,w,A,l,null)}fu(t,u,h,m);return;case"option":for(B in l)if(l.hasOwnProperty(B)&&(u=l[B],u!=null))switch(B){case"selected":t.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:Et(t,a,B,u,l,null)}return;case"dialog":ht("beforetoggle",t),ht("toggle",t),ht("cancel",t),ht("close",t);break;case"iframe":case"object":ht("load",t);break;case"video":case"audio":for(u=0;u<Vu.length;u++)ht(Vu[u],t);break;case"image":ht("error",t),ht("load",t);break;case"details":ht("toggle",t);break;case"embed":case"source":case"link":ht("error",t),ht("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 l)if(l.hasOwnProperty(ne)&&(u=l[ne],u!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,a));default:Et(t,a,ne,u,l,null)}return;default:if(is(a)){for(de in l)l.hasOwnProperty(de)&&(u=l[de],u!==void 0&&eb(t,a,de,u,l,void 0));return}}for(A in l)l.hasOwnProperty(A)&&(u=l[A],u!=null&&Et(t,a,A,u,l,null))}var Y4={};function W4(t,a,l,u){switch(a){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var h=null,m=null,w=null,A=null,B=null,ne=null,de=null;for(ce in l){var _e=l[ce];if(l.hasOwnProperty(ce)&&_e!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":B=_e;default:u.hasOwnProperty(ce)||Et(t,a,ce,null,u,_e)}}for(var ee in u){var ce=u[ee];if(_e=l[ee],u.hasOwnProperty(ee)&&(ce!=null||_e!=null))switch(ee){case"type":ce!==_e&&(ct=!0),m=ce;break;case"name":ce!==_e&&(ct=!0),h=ce;break;case"checked":ce!==_e&&(ct=!0),ne=ce;break;case"defaultChecked":ce!==_e&&(ct=!0),de=ce;break;case"value":ce!==_e&&(ct=!0),w=ce;break;case"defaultValue":ce!==_e&&(ct=!0),A=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,a));break;default:ce!==_e&&Et(t,a,ee,ce,u,_e)}}hu(t,w,A,B,ne,de,m,h);return;case"select":ce=w=A=ee=null;for(m in l)if(B=l[m],l.hasOwnProperty(m)&&B!=null)switch(m){case"value":break;case"multiple":ce=B;default:u.hasOwnProperty(m)||Et(t,a,m,null,u,B)}for(h in u)if(m=u[h],B=l[h],u.hasOwnProperty(h)&&(m!=null||B!=null))switch(h){case"value":m!==B&&(ct=!0),ee=m;break;case"defaultValue":m!==B&&(ct=!0),A=m;break;case"multiple":m!==B&&(ct=!0),w=m;default:m!==B&&Et(t,a,h,m,u,B)}a=A,l=w,u=ce,ee!=null?Ra(t,!!l,ee,!1):!!u!=!!l&&(a!=null?Ra(t,!!l,a,!0):Ra(t,!!l,l?[]:"",!1));return;case"textarea":ce=ee=null;for(A in l)if(h=l[A],l.hasOwnProperty(A)&&h!=null&&!u.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:Et(t,a,A,null,u,h)}for(w in u)if(h=u[w],m=l[w],u.hasOwnProperty(w)&&(h!=null||m!=null))switch(w){case"value":h!==m&&(ct=!0),ee=h;break;case"defaultValue":h!==m&&(ct=!0),ce=h;break;case"children":break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(s(91));break;default:h!==m&&Et(t,a,w,h,u,m)}xl(t,ee,ce);return;case"option":for(var ze in l)if(ee=l[ze],l.hasOwnProperty(ze)&&ee!=null&&!u.hasOwnProperty(ze))switch(ze){case"selected":t.selected=!1;break;default:Et(t,a,ze,null,u,ee)}for(B in u)if(ee=u[B],ce=l[B],u.hasOwnProperty(B)&&ee!==ce&&(ee!=null||ce!=null))switch(B){case"selected":ee!==ce&&(ct=!0),t.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:Et(t,a,B,ee,u,ce)}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 Ge in l)ee=l[Ge],l.hasOwnProperty(Ge)&&ee!=null&&!u.hasOwnProperty(Ge)&&Et(t,a,Ge,null,u,ee);for(ne in u)if(ee=u[ne],ce=l[ne],u.hasOwnProperty(ne)&&ee!==ce&&(ee!=null||ce!=null))switch(ne){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(s(137,a));break;default:Et(t,a,ne,ee,u,ce)}return;default:if(is(a)){for(var rt in l)ee=l[rt],l.hasOwnProperty(rt)&&ee!==void 0&&!u.hasOwnProperty(rt)&&eb(t,a,rt,void 0,u,ee);for(de in u)ee=u[de],ce=l[de],!u.hasOwnProperty(de)||ee===ce||ee===void 0&&ce===void 0||eb(t,a,de,ee,u,ce);return}}for(var te in l)ee=l[te],l.hasOwnProperty(te)&&ee!=null&&!u.hasOwnProperty(te)&&Et(t,a,te,null,u,ee);for(_e in u)ee=u[_e],ce=l[_e],!u.hasOwnProperty(_e)||ee===ce||ee==null&&ce==null||Et(t,a,_e,ee,u,ce)}function iS(t){switch(t){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function X4(){if(typeof performance.getEntriesByType=="function"){for(var t=0,a=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var h=l[u],m=h.transferSize,w=h.initiatorType,A=h.duration;if(m&&A&&iS(w)){for(w=0,A=h.responseEnd,u+=1;u<l.length;u++){var B=l[u],ne=B.startTime;if(ne>A)break;var de=B.transferSize,_e=B.initiatorType;de&&iS(_e)&&(B=B.responseEnd,w+=de*(B<A?1:(A-ne)/(B-ne)))}if(--u,a+=8*(m+w)/(h.duration/1e3),t++,10<t)break}}if(0<t)return a/t/1e6}return navigator.connection&&(t=navigator.connection.downlink,typeof t=="number")?t:5}var tb=null,nb=null;function Yu(t){return t.nodeType===9?t:t.ownerDocument}function oS(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 lS(t,a){if(t===0)switch(a){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&a==="foreignObject"?0:t}function cS(t,a,l,u){return l=Yu(l).createElement(t),l[Ut]=u,l[on]=a,zn(l,t,a),At(l),l}function sb(t,a){return t==="textarea"||t==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.children=="bigint"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var ab=null;function Q4(){var t=window.event;return t&&t.type==="popstate"?t===ab?!1:(ab=t,!0):(ab=null,!1)}var rb=typeof setTimeout=="function"?setTimeout:void 0,J4=typeof clearTimeout=="function"?clearTimeout:void 0,uS=typeof Promise=="function"?Promise:void 0,dS=typeof requestAnimationFrame=="function"?requestAnimationFrame:rb,Z4=typeof queueMicrotask=="function"?queueMicrotask:typeof uS<"u"?function(t){return uS.resolve(null).then(t).catch(eM)}:rb;function eM(t){setTimeout(function(){throw t})}function ki(t){return t==="head"}function hS(t,a){var l=a,u=0;do{var h=l.nextSibling;if(t.removeChild(l),h&&h.nodeType===8)if(l=h.data,l==="/$"||l==="/&"){if(u===0){t.removeChild(h),rc(a);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")mb(t.ownerDocument.documentElement);else if(l==="head"){l=t.ownerDocument.head,mb(l);for(var m=l.firstChild;m;){var w=m.nextSibling,A=m.nodeName;m[or]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&m.rel.toLowerCase()==="stylesheet"||l.removeChild(m),m=w}}else l==="body"&&mb(t.ownerDocument.body);l=h}while(l);rc(a)}function mS(t,a){var l=t;t=0;do{var u=l.nextSibling;if(l.nodeType===1?a?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(a?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),u&&u.nodeType===8)if(l=u.data,l==="/$"){if(t===0)break;t--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||t++;l=u}while(l)}function fS(t,a,l){if(a=CSS.escape(a)!==a?"r-"+btoa(a).replace(/=/g,""):a,t.style.viewTransitionName=a,l!=null&&(t.style.viewTransitionClass=l),l=getComputedStyle(t),l.display==="inline"){if(a=t.getClientRects(),a.length===1)var u=1;else for(var h=u=0;h<a.length;h++){var m=a[h];0<m.width&&0<m.height&&u++}u===1&&(t=t.style,t.display=a.length===1?"inline-block":"block",t.marginTop="-"+l.paddingTop,t.marginBottom="-"+l.paddingBottom)}}function pS(t,a){t=t.style,a=a.style;var l=a!=null?a.hasOwnProperty("viewTransitionName")?a.viewTransitionName:a.hasOwnProperty("view-transition-name")?a["view-transition-name"]:null:null;t.viewTransitionName=l==null||typeof l=="boolean"?"":(""+l).trim(),l=a!=null?a.hasOwnProperty("viewTransitionClass")?a.viewTransitionClass:a.hasOwnProperty("view-transition-class")?a["view-transition-class"]:null:null,t.viewTransitionClass=l==null||typeof l=="boolean"?"":(""+l).trim(),t.display==="inline-block"&&(a==null?t.display=t.margin="":(l=a.display,t.display=l==null||typeof l=="boolean"?"":l,l=a.margin,l!=null?t.margin=l:(l=a.hasOwnProperty("marginTop")?a.marginTop:a["margin-top"],t.marginTop=l==null||typeof l=="boolean"?"":l,a=a.hasOwnProperty("marginBottom")?a.marginBottom:a["margin-bottom"],t.marginBottom=a==null||typeof a=="boolean"?"":a)))}function tM(t,a,l){return l=l.ownerDocument.defaultView,{rect:t,abs:a.position==="absolute"||a.position==="fixed",clip:a.clipPath!=="none"||a.overflow!=="visible"||a.filter!=="none"||a.mask!=="none"||a.mask!=="none"||a.borderRadius!=="0px",view:0<=t.bottom&&0<=t.right&&t.top<=l.innerHeight&&t.left<=l.innerWidth}}function ib(t){var a=t.getBoundingClientRect(),l=getComputedStyle(t);return tM(a,l,t)}function nM(t){return t.documentElement.clientHeight}function sM(t){this.addEventListener("load",t),this.addEventListener("error",t)}function aM(t,a,l,u,h,m,w,A,B){var ne=a.nodeType===9?a:a.ownerDocument;try{var de=ne.startViewTransition({update:function(){var ee=ne.defaultView,ce=ee.navigation&&ee.navigation.transition,ze=ne.fonts.status;u();var Ge=[];if(ze==="loaded"&&(nM(ne),ne.fonts.status==="loading"&&Ge.push(ne.fonts.ready)),ze=Ge.length,t!==null)for(var rt=t.suspenseyImages,te=0,Y=0;Y<rt.length;Y++){var ie=rt[Y];if(!ie.complete){var xe=ie.getBoundingClientRect();if(0<xe.bottom&&0<xe.right&&xe.top<ee.innerHeight&&xe.left<ee.innerWidth){if(te+=$S(ie),te>Vm){Ge.length=ze;break}ie=new Promise(sM.bind(ie)),Ge.push(ie)}}}if(0<Ge.length)return ee=Promise.race([Promise.all(Ge),new Promise(function(qe){return setTimeout(qe,500)})]).then(h,h),(ce?Promise.allSettled([ce.finished,ee]):ee).then(m,m);if(h(),ce)return ce.finished.then(m,m);m()},types:l});ne.__reactViewTransition=de;var _e=[];return de.ready.then(function(){for(var ee=ne.documentElement.getAnimations({subtree:!0}),ce=0;ce<ee.length;ce++){var ze=ee[ce],Ge=ze.effect,rt=Ge.pseudoElement;if(rt!=null&&rt.startsWith("::view-transition")){_e.push(ze),ze=Ge.getKeyframes();for(var te=rt=void 0,Y=!0,ie=0;ie<ze.length;ie++){var xe=ze[ie],qe=xe.width;if(rt===void 0)rt=qe;else if(rt!==qe){Y=!1;break}if(qe=xe.height,te===void 0)te=qe;else if(te!==qe){Y=!1;break}delete xe.width,delete xe.height,xe.transform==="none"&&delete xe.transform}Y&&rt!==void 0&&te!==void 0&&(Ge.setKeyframes(ze),Y=getComputedStyle(Ge.target,Ge.pseudoElement),Y.width!==rt||Y.height!==te)&&(Y=ze[0],Y.width=rt,Y.height=te,Y=ze[ze.length-1],Y.width=rt,Y.height=te,Ge.setKeyframes(ze))}}w()},function(ee){ne.__reactViewTransition===de&&(ne.__reactViewTransition=null);try{if(typeof ee=="object"&&ee!==null)switch(ee.name){case"InvalidStateError":(ee.message==="View transition was skipped because document visibility state is hidden."||ee.message==="Skipping view transition because document visibility state has become hidden."||ee.message==="Skipping view transition because viewport size changed."||ee.message==="Transition was aborted because of invalid state")&&(ee=null)}ee!==null&&B(ee)}finally{u(),h(),w()}}),de.finished.finally(function(){for(var ee=0;ee<_e.length;ee++)_e[ee].cancel();ne.__reactViewTransition===de&&(ne.__reactViewTransition=null),A()}),de}catch{return u(),h(),w(),null}}function Eo(t,a){this._scope=document.documentElement,this._selector="::view-transition-"+t+"("+a+")"}Eo.prototype.animate=function(t,a){return a=typeof a=="number"?{duration:a}:P({},a),a.pseudoElement=this._selector,this._scope.animate(t,a)},Eo.prototype.getAnimations=function(){for(var t=this._scope,a=this._selector,l=t.getAnimations({subtree:!0}),u=[],h=0;h<l.length;h++){var m=l[h].effect;m!==null&&m.target===t&&m.pseudoElement===a&&u.push(l[h])}return u},Eo.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function gS(t){return{name:t,group:new Eo("group",t),imagePair:new Eo("image-pair",t),old:new Eo("old",t),new:new Eo("new",t)}}function Ms(t){this._fragmentFiber=t,this._observers=this._eventListeners=null}Ms.prototype.addEventListener=function(t,a,l){var u=null,h=null;if(!(l!=null&&typeof l!="boolean"&&(u=l.signal||null,u!==null&&u.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var m=this._eventListeners;if(xS(m,t,a,l)===-1){var w=this,A=a;l!=null&&typeof l!="boolean"&&l.once===!0&&(A=function(B){w.removeEventListener(t,a,l),typeof a=="function"?a.call(this,B):a.handleEvent(B)}),u!==null&&(h=w.removeEventListener.bind(w,t,a,l),u.addEventListener("abort",h,{once:!0}),h=u.removeEventListener.bind(u,"abort",h)),u=Zl(l),m.push({type:t,listener:a,optionsOrUseCapture:l,attachedListener:A,cleanup:h}),g(this._fragmentFiber.child,!1,rM,t,A,u)}this._eventListeners=m}};function rM(t,a,l,u){return E(t).addEventListener(a,l,u),!1}Ms.prototype.removeEventListener=function(t,a,l){var u=this._eventListeners;if(u!==null&&(a=xS(u,t,a,l),a!==-1)){var h=u[a];l=h.attachedListener;var m=h.cleanup;h=Zl(h.optionsOrUseCapture),g(this._fragmentFiber.child,!1,iM,t,l,h),u.splice(a,1),m!==null&&m()}};function iM(t,a,l,u){return E(t).removeEventListener(a,l,u),!1}function Zl(t){return t!=null&&typeof t!="boolean"&&(t.once===!0||t.signal instanceof AbortSignal)?{capture:t.capture,passive:t.passive}:t}function bS(t){return t==null?"c=0":typeof t=="boolean"?"c="+(t?"1":"0"):"c="+(t.capture?"1":"0")}function xS(t,a,l,u){if(t.length===0)return-1;u=bS(u);for(var h=0;h<t.length;h++){var m=t[h];if(m.type===a&&m.listener===l&&bS(m.optionsOrUseCapture)===u)return h}return-1}Ms.prototype.dispatchEvent=function(t){var a=_(this._fragmentFiber);if(a===null)return!0;a=E(a);var l=this._eventListeners;if(l!==null&&0<l.length||!t.bubbles){var u=a.nodeType===9?a.createComment(""):document.createTextNode("");if(l)for(var h=0;h<l.length;h++){var m=l[h];u.addEventListener(m.type,m.attachedListener,Zl(m.optionsOrUseCapture))}if(a.appendChild(u),t=u.dispatchEvent(t),l)for(h=0;h<l.length;h++)m=l[h],u.removeEventListener(m.type,m.attachedListener,Zl(m.optionsOrUseCapture));return a.removeChild(u),t}return a.dispatchEvent(t)},Ms.prototype.focus=function(t){g(this._fragmentFiber.child,!0,yS,t,void 0,void 0)};function yS(t,a){return t.tag===6?!1:(t=E(t),xM(t,a))}Ms.prototype.focusLast=function(t){var a=[];g(this._fragmentFiber.child,!0,ob,a,void 0,void 0);for(var l=a.length-1;0<=l&&!yS(a[l],t);l--);};function ob(t,a){return a.push(t),!1}Ms.prototype.blur=function(){var t=_(this._fragmentFiber);t!==null&&(t=E(t),t=Yu(t).activeElement,t!==null&&g(this._fragmentFiber.child,!1,oM,t,void 0,void 0))};function oM(t,a){return t.tag===6?!1:(t=E(t),t===a||t.contains(a)?(a.blur(),!0):!1)}Ms.prototype.observeUsing=function(t){this._observers===null&&(this._observers=new Set),this._observers.add(t),g(this._fragmentFiber.child,!1,lM,t,void 0,void 0)};function lM(t,a){return t.tag===6||(t=E(t),a.observe(t)),!1}Ms.prototype.unobserveUsing=function(t){var a=this._observers;if(a!==null&&a.has(t)){a.delete(t),g(this._fragmentFiber.child,!1,cM,t,void 0,void 0);for(var l=a=0;l<ya.length;l++){var u=ya[l];u.fragmentInstance===this&&u.observer===t?t.unobserve(u.instance):ya[a++]=u}ya.length=a}};function cM(t,a){return t.tag===6||(t=E(t),a.unobserve(t)),!1}var ya=[],lb=!1;function uM(t,a,l){ya.push({fragmentInstance:t,observer:a,instance:l}),lb||(lb=!0,yM(function(){lb=!1;var u=ya;ya=[];for(var h=0;h<u.length;h++){var m=u[h];m.observer.unobserve(m.instance)}}))}Ms.prototype.getClientRects=function(){var t=[];return g(this._fragmentFiber.child,!1,dM,t,void 0,void 0),t};function dM(t,a){if(t.tag===6){t=t.stateNode;var l=t.ownerDocument.createRange();l.selectNodeContents(t),a.push.apply(a,l.getClientRects())}else t=E(t),a.push.apply(a,t.getClientRects());return!1}Ms.prototype.getRootNode=function(t){var a=_(this._fragmentFiber);return a===null?this:E(a).getRootNode(t)},Ms.prototype.compareDocumentPosition=function(t){var a=_(this._fragmentFiber);if(a===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var l=[];g(this._fragmentFiber.child,!1,ob,l,void 0,void 0);var u=E(a);if(l.length===0){if(l=u,y(this._fragmentFiber)){e:{for(a=this._fragmentFiber.return;a!==null;){if(a.tag===4){a=a.stateNode.containerInfo;break e}if(a.tag===3||a.tag===5||a.tag===27)break;a=a.return}a=null}a!=null&&(l=a)}a=this._fragmentFiber;var h=u=l.compareDocumentPosition(t);return l===t?h=Node.DOCUMENT_POSITION_CONTAINS:u&Node.DOCUMENT_POSITION_CONTAINED_BY&&(l=S(a)[1],l===null?h=Node.DOCUMENT_POSITION_PRECEDING:(t=E(l).compareDocumentPosition(t),h=t===0||t&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),h|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}a=E(l[0]),h=E(l[l.length-1]);var m=y(this._fragmentFiber)?a.parentElement:u;if(m==null)return Node.DOCUMENT_POSITION_DISCONNECTED;u=m.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_CONTAINED_BY,m=m.compareDocumentPosition(h)&Node.DOCUMENT_POSITION_CONTAINED_BY;var w=a.compareDocumentPosition(t),A=h.compareDocumentPosition(t),B=w&Node.DOCUMENT_POSITION_CONTAINED_BY||A&Node.DOCUMENT_POSITION_CONTAINED_BY;return A=u&&m&&w&Node.DOCUMENT_POSITION_FOLLOWING&&A&Node.DOCUMENT_POSITION_PRECEDING,a=u&&a===t||m&&h===t||B||A?Node.DOCUMENT_POSITION_CONTAINED_BY:!u&&a===t||!m&&h===t?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:w,a&Node.DOCUMENT_POSITION_DISCONNECTED||a&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||hM(a,this._fragmentFiber,l[0],l[l.length-1],t)?a:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function hM(t,a,l,u,h){var m=Ea(h);if(t&Node.DOCUMENT_POSITION_CONTAINED_BY){if(l=!!m)e:{for(;m!==null;){if(m.tag===7&&(m===a||m.alternate===a)){l=!0;break e}m=m.return}l=!1}return l}if(t&Node.DOCUMENT_POSITION_CONTAINS){if(m===null)return m=h.ownerDocument,h===m||h===m.documentElement||h===m.body;e:{for(m=a,a=_(a);m!==null;){if(!(m.tag!==5&&m.tag!==3&&m.tag!==27||m!==a&&m.alternate!==a)){m=!0;break e}m=m.return}m=!1}return m}return t&Node.DOCUMENT_POSITION_PRECEDING?((a=!!m)&&!(a=m===l)&&(a=V(l,m,O),a===null?a=!1:(g(a,!0,q,m,l),m=T,T=null,a=m!==null)),a):t&Node.DOCUMENT_POSITION_FOLLOWING?((a=!!m)&&!(a=m===u)&&(a=V(u,m,O),a===null?a=!1:(g(a,!0,z,m,u),m=T,j=T=null,a=m!==null)),a):!1}function _S(t,a){var l=t.ownerDocument.createRange();l.selectNodeContents(t),t=l.getBoundingClientRect(),window.scrollTo(window.scrollX+t.left,a?window.scrollY+t.top:window.scrollY+t.bottom-window.innerHeight)}Ms.prototype.scrollIntoView=function(t){if(typeof t=="object")throw Error(s(566));var a=[];g(this._fragmentFiber.child,!1,ob,a,void 0,void 0);var l=t!==!1;if(a.length===0){var u=S(this._fragmentFiber);if(u=l?u[1]||u[0]||_(this._fragmentFiber):u[0]||u[1],u===null)return;if(u.tag===6){t=E(u),_S(t,l);return}if(u=E(u),u.nodeType!==9){if(u.nodeType===11){l="host"in u?u.host:null,l!==null&&l.scrollIntoView(t);return}u.scrollIntoView(t)}}for(u=l?a.length-1:0;u!==(l?-1:a.length);){var h=a[u];h.tag===6?(h=E(h),_S(h,l)):E(h).scrollIntoView(t),u+=l?-1:1}};function mM(t,a){return t=E(t),vS(t,a),!1}function vS(t,a){t.reactFragments==null&&(t.reactFragments=new Set),t.reactFragments.add(a)}function wS(t,a){var l=a._eventListeners;if(l!==null)for(var u=0;u<l.length;u++){var h=l[u];t.addEventListener(h.type,h.attachedListener,Zl(h.optionsOrUseCapture))}t.nodeType!==3&&(l=a._observers,l!==null&&l.forEach(function(m){for(var w=0,A=0;A<ya.length;A++){var B=ya[A];(B.fragmentInstance!==a||B.observer!==m||B.instance!==t)&&(ya[w++]=B)}ya.length=w,m.observe(t)}),vS(t,a))}function fM(t,a){var l=a._eventListeners;if(l!==null)for(var u=0;u<l.length;u++){var h=l[u];t.removeEventListener(h.type,h.attachedListener,Zl(h.optionsOrUseCapture))}t.nodeType!==3&&(l=a._observers,l!==null&&l.forEach(function(m){typeof m.rootMargin=="string"?uM(a,m,t):m.unobserve(t)}),t.reactFragments!=null&&t.reactFragments.delete(a))}function cb(t){var a=t.firstChild;for(a&&a.nodeType===10&&(a=a.nextSibling);a;){var l=a;switch(a=a.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":cb(l),Jr(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}t.removeChild(l)}}function pM(t,a,l,u){for(;t.nodeType===1;){var h=l;if(t.nodeName.toLowerCase()!==a.toLowerCase()){if(!u&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(u){if(!t[or])switch(a){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(m=t.getAttribute("rel"),m==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(m!==h.rel||t.getAttribute("href")!==(h.href==null||h.href===""?null:h.href)||t.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin)||t.getAttribute("title")!==(h.title==null?null:h.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(m=t.getAttribute("src"),(m!==(h.src==null?null:h.src)||t.getAttribute("type")!==(h.type==null?null:h.type)||t.getAttribute("crossorigin")!==(h.crossOrigin==null?null:h.crossOrigin))&&m&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(a==="input"&&t.type==="hidden"){var m=h.name==null?null:""+h.name;if(h.type==="hidden"&&t.getAttribute("name")===m)return t}else return t;if(t=ea(t.nextSibling),t===null)break}return null}function gM(t,a,l){if(a==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!l||(t=ea(t.nextSibling),t===null))return null;return t}function SS(t,a){for(;t.nodeType!==8;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!a||(t=ea(t.nextSibling),t===null))return null;return t}function ub(t){return t.data==="$?"||t.data==="$~"}function db(t){return t.data==="$!"||t.data==="$?"&&t.ownerDocument.readyState!=="loading"}function bM(t,a){var l=t.ownerDocument;if(t.data==="$~")t._reactRetry=a;else if(t.data!=="$?"||l.readyState!=="loading")a();else{var u=function(){a(),l.removeEventListener("DOMContentLoaded",u)};l.addEventListener("DOMContentLoaded",u),t._reactRetry=u}}function ea(t){for(;t!=null;t=t.nextSibling){var a=t.nodeType;if(a===1||a===3)break;if(a===8){if(a=t.data,a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"||a==="F!"||a==="F")break;if(a==="/$"||a==="/&")return null}}return t}var hb=null;function kS(t){t=t.nextSibling;for(var a=0;t;){if(t.nodeType===8){var l=t.data;if(l==="/$"||l==="/&"){if(a===0)return ea(t.nextSibling);a--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||a++}t=t.nextSibling}return null}function CS(t){t=t.previousSibling;for(var a=0;t;){if(t.nodeType===8){var l=t.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(a===0)return t;a--}else l!=="/$"&&l!=="/&"||a++}t=t.previousSibling}return null}function xM(t,a){function l(){u=!0}if(t.ownerDocument.activeElement===t)return!0;var u=!1;try{t.ownerDocument.addEventListener("focus",l,!0),(t.focus||HTMLElement.prototype.focus).call(t,a)}finally{t.ownerDocument.removeEventListener("focus",l,!0)}return u}function yM(t){dS(function(){dS(function(a){return t(a)})})}function NS(t,a,l){switch(a=Yu(l),t){case"html":if(t=a.documentElement,!t)throw Error(s(452));return t;case"head":if(t=a.head,!t)throw Error(s(453));return t;case"body":if(t=a.body,!t)throw Error(s(454));return t;default:throw Error(s(451))}}function AS(t,a,l){for(var u in l){var h=l[u];l.hasOwnProperty(u)&&h!=null&&Et(t,a,u,null,Y4,h)}l.dangerouslySetInnerHTML!=null&&(t.textContent=""),t.onclick===jn&&(t.onclick=null),Jr(t)}function mb(t){for(var a=t.attributes;a.length;)t.removeAttributeNode(a[0]);Jr(t)}var ta=new Map,jS=new Set;function Wu(t){if(typeof t.getRootNode=="function"){var a=t.getRootNode();if(a.nodeType===9||a.nodeType===11)return a}return t.nodeType===9?t:t.ownerDocument}var wr=Ue.d;Ue.d={f:_M,r:vM,D:wM,C:SM,L:kM,m:CM,X:AM,S:NM,M:jM};function _M(){var t=wr.f(),a=Im();return t||a}function vM(t){var a=Zr(t);a!==null&&a.tag===5&&a.type==="form"?Ew(a):wr.r(t)}var ec=typeof document>"u"?null:document;function TS(t,a,l){var u=ec;if(u&&typeof a=="string"&&a){var h=Bn(a);h='link[rel="'+t+'"][href="'+h+'"]',typeof l=="string"&&(h+='[crossorigin="'+l+'"]'),jS.has(h)||(jS.add(h),t={rel:t,crossOrigin:l,href:a},u.querySelector(h)===null&&(a=u.createElement("link"),zn(a,"link",t),At(a),u.head.appendChild(a)))}}function wM(t){wr.D(t),TS("dns-prefetch",t,null)}function SM(t,a){wr.C(t,a),TS("preconnect",t,a)}function kM(t,a,l){wr.L(t,a,l);var u=ec;if(u&&t&&a){var h='link[rel="preload"][as="'+Bn(a)+'"]';a==="image"&&l&&l.imageSrcSet?(h+='[imagesrcset="'+Bn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(h+='[imagesizes="'+Bn(l.imageSizes)+'"]')):h+='[href="'+Bn(t)+'"]';var m=h;switch(a){case"style":m=tc(t);break;case"script":m=nc(t)}if(!(ta.has(m)||(t=P({rel:"preload",href:a==="image"&&l&&l.imageSrcSet?void 0:t,as:a},l),ta.set(m,t),u.querySelector(h)!==null||a==="style"&&u.querySelector(Xu(m))||a==="script"&&u.querySelector(Qu(m))))){var w=u.createElement("link");zn(w,"link",t),a==="style"&&(w[pl]=!0,w.onload=w.onerror=function(){Dh(w)}),At(w),u.head.appendChild(w)}}}function CM(t,a){wr.m(t,a);var l=ec;if(l&&t){var u=a&&typeof a.as=="string"?a.as:"script",h='link[rel="modulepreload"][as="'+Bn(u)+'"][href="'+Bn(t)+'"]',m=h;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=nc(t)}if(!ta.has(m)&&(t=P({rel:"modulepreload",href:t},a),ta.set(m,t),l.querySelector(h)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Qu(m)))return}u=l.createElement("link"),zn(u,"link",t),At(u),l.head.appendChild(u)}}}function NM(t,a,l){wr.S(t,a,l);var u=ec;if(u&&t){var h=ei(u).hoistableStyles,m=tc(t);a=a||"default";var w=h.get(m);if(!w){var A={loading:0,preload:null};if(w=u.querySelector(Xu(m)))A.loading=5;else{t=P({rel:"stylesheet",href:t,"data-precedence":a},l),(l=ta.get(m))&&fb(t,l);var B=w=u.createElement("link");At(B),zn(B,"link",t),B._p=new Promise(function(ne,de){B.onload=ne,B.onerror=de}),B.addEventListener("load",function(){A.loading|=1}),B.addEventListener("error",function(){A.loading|=2}),A.loading|=4,Hm(w,a,u)}w={type:"stylesheet",instance:w,count:1,state:A},h.set(m,w)}}}function AM(t,a){wr.X(t,a);var l=ec;if(l&&t){var u=ei(l).hoistableScripts,h=nc(t),m=u.get(h);m||(m=l.querySelector(Qu(h)),m||(t=P({src:t,async:!0},a),(a=ta.get(h))&&pb(t,a),m=l.createElement("script"),At(m),zn(m,"link",t),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(h,m))}}function jM(t,a){wr.M(t,a);var l=ec;if(l&&t){var u=ei(l).hoistableScripts,h=nc(t),m=u.get(h);m||(m=l.querySelector(Qu(h)),m||(t=P({src:t,async:!0,type:"module"},a),(a=ta.get(h))&&pb(t,a),m=l.createElement("script"),At(m),zn(m,"link",t),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(h,m))}}function ES(t,a,l,u){var h=(h=Pe.current)?Wu(h):null;if(!h)throw Error(s(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(l=tc(l.href),a=ei(h).hoistableStyles,u=a.get(l),u||(u={type:"style",instance:null,count:0,state:null},a.set(l,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=tc(l.href);var m=ei(h).hoistableStyles,w=m.get(t);if(w||(h=h.ownerDocument||h,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(t,w),(m=h.querySelector(Xu(t)))?m._p||(w.instance=m,w.state.loading=5):(m=ta.get(t),m||(m={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},ta.set(t,m)),TM(h,t,m,w.state))),a&&u===null)throw Error(s(528,""));return w}if(a&&u!==null)throw Error(s(529,""));return null;case"script":return a=l.async,l=l.src,typeof l=="string"&&a&&typeof a!="function"&&typeof a!="symbol"?(l=nc(l),a=ei(h).hoistableScripts,u=a.get(l),u||(u={type:"script",instance:null,count:0,state:null},a.set(l,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,t))}}function tc(t){return'href="'+Bn(t)+'"'}function Xu(t){return'link[rel="stylesheet"]['+t+"]"}function MS(t){return P({},t,{"data-precedence":t.precedence,precedence:null})}function TM(t,a,l,u){if(a=t.querySelector('link[rel="preload"][as="style"]['+a+"]")){if(a[pl]!==!0){u.loading=1;return}}else a=t.createElement("link"),a[pl]=!0,a.onload=a.onerror=Dh.bind(null,a),zn(a,"link",l),At(a),t.head.appendChild(a);u.preload=a,a.addEventListener("load",function(){return u.loading|=1}),a.addEventListener("error",function(){return u.loading|=2})}function nc(t){return'[src="'+Bn(t)+'"]'}function Qu(t){return"script[async]"+t}function RS(t,a,l){if(a.count++,a.instance===null)switch(a.type){case"style":var u=t.querySelector('style[data-href~="'+Bn(l.href)+'"]');if(u)return a.instance=u,At(u),u;var h=P({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),At(u),zn(u,"style",h),Hm(u,l.precedence,t),a.instance=u;case"stylesheet":h=tc(l.href);var m=t.querySelector(Xu(h));if(m)return a.state.loading|=4,a.instance=m,At(m),m;u=MS(l),(h=ta.get(h))&&fb(u,h),m=(t.ownerDocument||t).createElement("link"),At(m);var w=m;return w._p=new Promise(function(A,B){w.onload=A,w.onerror=B}),zn(m,"link",u),a.state.loading|=4,Hm(m,l.precedence,t),a.instance=m;case"script":return m=nc(l.src),(h=t.querySelector(Qu(m)))?(a.instance=h,At(h),h):(u=l,(h=ta.get(m))&&(u=P({},l),pb(u,h)),t=t.ownerDocument||t,h=t.createElement("script"),At(h),zn(h,"link",u),t.head.appendChild(h),a.instance=h);case"void":return null;default:throw Error(s(443,a.type))}else a.type==="stylesheet"&&(a.state.loading&4)===0&&(u=a.instance,a.state.loading|=4,Hm(u,l.precedence,t));return a.instance}function Hm(t,a,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),h=u.length?u[u.length-1]:null,m=h,w=0;w<u.length;w++){var A=u[w];if(A.dataset.precedence===a)m=A;else if(m!==h)break}m?m.parentNode.insertBefore(t,m.nextSibling):(a=l.nodeType===9?l.head:l,a.insertBefore(t,a.firstChild))}function fb(t,a){t.crossOrigin==null&&(t.crossOrigin=a.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=a.referrerPolicy),t.title==null&&(t.title=a.title)}function pb(t,a){t.crossOrigin==null&&(t.crossOrigin=a.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=a.referrerPolicy),t.integrity==null&&(t.integrity=a.integrity)}var Fm=null;function zS(t,a,l){if(Fm===null){var u=new Map,h=Fm=new Map;h.set(l,u)}else h=Fm,u=h.get(l),u||(u=new Map,h.set(l,u));if(u.has(t))return u;for(u.set(t,null),l=l.getElementsByTagName(t),h=0;h<l.length;h++){var m=l[h];if(!(m[or]||m[Ut]||t==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var w=m.getAttribute(a)||"";w=t+w;var A=u.get(w);A?A.push(m):u.set(w,[m])}}return u}function gb(t,a,l){t=t.ownerDocument||t,t.head.insertBefore(l,a==="title"?t.querySelector("head > title"):null)}function EM(t,a,l){if(l===1||a.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof a.precedence!="string"||typeof a.href!="string"||a.href==="")break;return!0;case"link":if(typeof a.rel!="string"||typeof a.href!="string"||a.href===""||a.onLoad||a.onError)break;switch(a.rel){case"stylesheet":return t=a.disabled,typeof a.precedence=="string"&&t==null;default:return!0}case"script":if(a.async&&typeof a.async!="function"&&typeof a.async!="symbol"&&!a.onLoad&&!a.onError&&a.src&&typeof a.src=="string")return!0}return!1}function OS(t,a){return t==="img"&&a.src!=null&&a.src!==""&&a.onLoad==null&&a.loading!=="lazy"}function PS(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function $S(t){return(t.width||100)*(t.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function IS(t,a){typeof a.decode=="function"&&(t.imgCount++,a.complete||(t.imgBytes+=$S(a),t.suspenseyImages.push(a)),t=zM.bind(t),a.decode().then(t,t))}function MM(t,a,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var h=tc(u.href),m=a.querySelector(Xu(h));if(m){a=m._p,a!==null&&typeof a=="object"&&typeof a.then=="function"&&(t.count++,t=Ju.bind(t),a.then(t,t)),l.state.loading|=4,l.instance=m,At(m);return}m=a.ownerDocument||a,u=MS(u),(h=ta.get(h))&&fb(u,h),m=m.createElement("link"),At(m);var w=m;w._p=new Promise(function(A,B){w.onload=A,w.onerror=B}),zn(m,"link",u),l.instance=m}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,a),(a=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=Ju.bind(t),a.addEventListener("load",l),a.addEventListener("error",l))}}var Vm=0;function RM(t,a){return t.stylesheets&&t.count===0&&Ym(t,t.stylesheets),0<t.count||0<t.imgCount?function(l){var u=setTimeout(function(){if(t.stylesheets&&Ym(t,t.stylesheets),t.unsuspend){var m=t.unsuspend;t.unsuspend=null,m()}},6e4+a);0<t.imgBytes&&Vm===0&&(Vm=62500*X4());var h=setTimeout(function(){if(t.waitingForImages=!1,t.count===0&&(t.stylesheets&&Ym(t,t.stylesheets),t.unsuspend)){var m=t.unsuspend;t.unsuspend=null,m()}},(t.imgBytes>Vm?50:800)+a);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(h)}}:null}function DS(t){if(t.count===0&&(t.imgCount===0||!t.waitingForImages)){if(t.stylesheets)Ym(t,t.stylesheets);else if(t.unsuspend){var a=t.unsuspend;t.unsuspend=null,a()}}}function Ju(){this.count--,DS(this)}function zM(){this.imgCount--,DS(this)}var Km=null;function Ym(t,a){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Km=new Map,a.forEach(OM,t),Km=null,Ju.call(t))}function OM(t,a){if(!(a.state.loading&4)){var l=Km.get(t);if(l)var u=l.get(null);else{l=new Map,Km.set(t,l);for(var h=t.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<h.length;m++){var w=h[m];(w.nodeName==="LINK"||w.getAttribute("media")!=="not all")&&(l.set(w.dataset.precedence,w),u=w)}u&&l.set(null,u)}h=a.instance,w=h.getAttribute("data-precedence"),m=l.get(w)||u,m===u&&l.set(null,h),l.set(w,h),this.count++,u=Ju.bind(this),h.addEventListener("load",u),h.addEventListener("error",u),m?m.parentNode.insertBefore(h,m.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(h,t.firstChild)),a.state.loading|=4}}var sc={$$typeof:Q,Provider:null,Consumer:null,_currentValue:be,_currentValue2:be,_threadCount:0};function PM(t,a,l,u,h,m,w,A,B){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=to(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=to(0),this.hiddenUpdates=to(null),this.identifierPrefix=u,this.onUncaughtError=h,this.onCaughtError=m,this.onRecoverableError=w,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=B,this.transitionTypes=null,this.incompleteTransitions=new Map}function qS(t,a,l,u,h,m,w,A,B,ne,de,_e){return t=new PM(t,a,l,w,B,ne,de,_e,A),a=1,m===!0&&(a|=24),m=os(3,null,null,a),t.current=m,m.stateNode=t,a=M0(),a.refCount++,t.pooledCache=a,a.refCount++,m.memoizedState={element:u,isDehydrated:l,cache:a},P0(m),t}function LS(t){return t?(t=Tl,t):Tl}function US(t,a,l,u,h,m){h=LS(h),u.context===null?u.context=h:u.pendingContext=h,u=hi(a),u.payload={element:l},m=m===void 0?null:m,m!==null&&(u.callback=m),l=mi(t,u,a),l!==null&&(ds(l,t,a),Tu(l,t,a))}function BS(t,a){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var l=t.retryLane;t.retryLane=l!==0&&l<a?l:a}}function bb(t,a){BS(t,a),(t=t.alternate)&&BS(t,a)}function GS(t){if(t.tag===13||t.tag===31){var a=mo(t,67108864);a!==null&&ds(a,t,67108864),bb(t,67108864)}}function HS(t){if(t.tag===13||t.tag===31){var a=Es();a=fl(a);var l=mo(t,a);l!==null&&ds(l,t,a),bb(t,a)}}var ac=!0;function $M(t,a,l,u){var h=Ce.T;Ce.T=null;var m=Ue.p;try{Ue.p=2,xb(t,a,l,u)}finally{Ue.p=m,Ce.T=h}}function IM(t,a,l,u){var h=Ce.T;Ce.T=null;var m=Ue.p;try{Ue.p=8,xb(t,a,l,u)}finally{Ue.p=m,Ce.T=h}}function xb(t,a,l,u){if(ac){var h=yb(u);if(h===null)Zg(t,a,u,Wm,l),VS(t,u);else if(qM(h,t,a,l,u))u.stopPropagation();else if(VS(t,u),a&4&&-1<DM.indexOf(t)){for(;h!==null;){var m=Zr(h);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var w=Ta(m.pendingLanes);if(w!==0){var A=m;for(A.pendingLanes|=2,A.entangledLanes|=2;w;){var B=1<<31-Ct(w);A.entanglements[1]|=B,w&=~B}Va(m),(wt&6)===0&&(Om=tt()+500,Fu(0))}}break;case 31:case 13:A=mo(m,2),A!==null&&ds(A,m,2),Im(),bb(m,2)}if(m=yb(u),m===null&&Zg(t,a,u,Wm,l),m===h)break;h=m}h!==null&&u.stopPropagation()}else Zg(t,a,u,null,l)}}function yb(t){return t=Ks(t),_b(t)}var Wm=null;function _b(t){if(Wm=null,t=Ea(t),t!==null){var a=c(t);if(a===null)t=null;else{var l=a.tag;if(l===13){if(t=d(a),t!==null)return t;t=null}else if(l===31){if(t=f(a),t!==null)return t;t=null}else if(l===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;t=null}else a!==t&&(t=null)}}return Wm=t,null}function FS(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"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"fullscreenerror":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"resize":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Mh()){case Ln:return 2;case dl:return 8;case Zi:case Rh:return 32;case oa:return 268435456;default:return 32}default:return 32}}var vb=!1,Ci=null,Ni=null,Ai=null,Zu=new Map,ed=new Map,ji=[],DM="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 VS(t,a){switch(t){case"focusin":case"focusout":Ci=null;break;case"dragenter":case"dragleave":Ni=null;break;case"mouseover":case"mouseout":Ai=null;break;case"pointerover":case"pointerout":Zu.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":ed.delete(a.pointerId)}}function td(t,a,l,u,h,m){return t===null||t.nativeEvent!==m?(t={blockedOn:a,domEventName:l,eventSystemFlags:u,nativeEvent:m,targetContainers:[h]},a!==null&&(a=Zr(a),a!==null&&GS(a)),t):(t.eventSystemFlags|=u,a=t.targetContainers,h!==null&&a.indexOf(h)===-1&&a.push(h),t)}function qM(t,a,l,u,h){switch(a){case"focusin":return Ci=td(Ci,t,a,l,u,h),!0;case"dragenter":return Ni=td(Ni,t,a,l,u,h),!0;case"mouseover":return Ai=td(Ai,t,a,l,u,h),!0;case"pointerover":var m=h.pointerId;return Zu.set(m,td(Zu.get(m)||null,t,a,l,u,h)),!0;case"gotpointercapture":return m=h.pointerId,ed.set(m,td(ed.get(m)||null,t,a,l,u,h)),!0}return!1}function KS(t){var a=Ea(t.target);if(a!==null){var l=c(a);if(l!==null){if(a=l.tag,a===13){if(a=d(l),a!==null){t.blockedOn=a,ou(t.priority,function(){HS(l)});return}}else if(a===31){if(a=f(l),a!==null){t.blockedOn=a,ou(t.priority,function(){HS(l)});return}}else if(a===3&&l.stateNode.current.memoizedState.isDehydrated){t.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Xm(t){if(t.blockedOn!==null)return!1;for(var a=t.targetContainers;0<a.length;){var l=yb(t.nativeEvent);if(l===null){l=t.nativeEvent;var u=new l.constructor(l.type,l);yl=u,l.target.dispatchEvent(u),yl=null}else return a=Zr(l),a!==null&&GS(a),t.blockedOn=l,!1;a.shift()}return!0}function YS(t,a,l){Xm(t)&&l.delete(a)}function LM(){vb=!1,Ci!==null&&Xm(Ci)&&(Ci=null),Ni!==null&&Xm(Ni)&&(Ni=null),Ai!==null&&Xm(Ai)&&(Ai=null),Zu.forEach(YS),ed.forEach(YS)}function Qm(t,a){t.blockedOn===a&&(t.blockedOn=null,vb||(vb=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,LM)))}var Jm=null;function WS(t){Jm!==t&&(Jm=t,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Jm===t&&(Jm=null);for(var a=0;a<t.length;a+=3){var l=t[a],u=t[a+1],h=t[a+2];if(typeof u!="function"){if(_b(u||l)===null)continue;break}var m=Zr(l);m!==null&&(t.splice(a,3),a-=3,ng(m,{pending:!0,data:h,method:l.method,action:u},u,h))}}))}function rc(t){function a(B){return Qm(B,t)}Ci!==null&&Qm(Ci,t),Ni!==null&&Qm(Ni,t),Ai!==null&&Qm(Ai,t),Zu.forEach(a),ed.forEach(a);for(var l=0;l<ji.length;l++){var u=ji[l];u.blockedOn===t&&(u.blockedOn=null)}for(;0<ji.length&&(l=ji[0],l.blockedOn===null);)KS(l),l.blockedOn===null&&ji.shift();if(l=(t.ownerDocument||t).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var h=l[u],m=l[u+1],w=h[on]||null;if(typeof m=="function")w||WS(l);else if(w){var A=null;if(m&&m.hasAttribute("formAction")){if(h=m,w=m[on]||null)A=w.formAction;else if(_b(h)!==null)continue}else A=w.action;typeof A=="function"?l[u+1]=A:(l.splice(u,3),u-=3),WS(l)}}}function XS(){function t(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(w){return h=w})},focusReset:"manual",scroll:"manual"})}function a(){h!==null&&(h(),h=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,h=null;return navigation.addEventListener("navigate",t),navigation.addEventListener("navigatesuccess",a),navigation.addEventListener("navigateerror",a),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",t),navigation.removeEventListener("navigatesuccess",a),navigation.removeEventListener("navigateerror",a),h!==null&&(h(),h=null)}}}function wb(t){this._internalRoot=t}Zm.prototype.render=wb.prototype.render=function(t){var a=this._internalRoot;if(a===null)throw Error(s(409));var l=a.current,u=Es();US(l,u,t,a,null,null)},Zm.prototype.unmount=wb.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var a=t.containerInfo;US(t.current,2,null,t,null,null),Im(),a[la]=null}};function Zm(t){this._internalRoot=t}Zm.prototype.unstable_scheduleHydration=function(t){if(t){var a=iu();t={blockedOn:null,target:t,priority:a};for(var l=0;l<ji.length&&a!==0&&a<ji[l].priority;l++);ji.splice(l,0,t),l===0&&KS(t)}};var QS=r.version;if(QS!=="19.3.1")throw Error(s(527,QS,"19.3.1"));Ue.findDOMNode=function(t){var a=t._reactInternals;if(a===void 0)throw typeof t.render=="function"?Error(s(188)):(t=Object.keys(t).join(","),Error(s(268,t)));return t=b(a),t=t!==null?x(t):null,t=t===null?null:t.stateNode,t};var UM={bundleType:0,version:"19.3.1",rendererPackageName:"react-dom",currentDispatcherRef:Ce,reconcilerVersion:"19.3.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ef=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ef.isDisabled&&ef.supportsFiber)try{eo=ef.inject(UM),st=ef}catch{}}return sd.createRoot=function(t,a){if(!i(t))throw Error(s(299));var l=!1,u="",h=Lw,m=Uw,w=Bw;return a!=null&&(a.unstable_strictMode===!0&&(l=!0),a.identifierPrefix!==void 0&&(u=a.identifierPrefix),a.onUncaughtError!==void 0&&(h=a.onUncaughtError),a.onCaughtError!==void 0&&(m=a.onCaughtError),a.onRecoverableError!==void 0&&(w=a.onRecoverableError)),a=qS(t,1,!1,null,null,l,u,null,h,m,w,XS),t[la]=a.current,Jg(t),new wb(a)},sd.hydrateRoot=function(t,a,l){if(!i(t))throw Error(s(299));var u=!1,h="",m=Lw,w=Uw,A=Bw,B=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(h=l.identifierPrefix),l.onUncaughtError!==void 0&&(m=l.onUncaughtError),l.onCaughtError!==void 0&&(w=l.onCaughtError),l.onRecoverableError!==void 0&&(A=l.onRecoverableError),l.formState!==void 0&&(B=l.formState)),a=qS(t,1,!0,a,l??null,u,h,B,m,w,A,XS),a.context=LS(null),l=a.current,u=Es(),u=fl(u),h=hi(u),h.callback=null,mi(l,h,u),l=u,a.current.lanes=l,no(a,l),Va(a),t[la]=a.current,Jg(t),new Zm(a)},sd.version="19.3.1",sd}var ok;function QM(){if(ok)return Cb.exports;ok=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(r){console.error(r)}}return e(),Cb.exports=XM(),Cb.exports}var JM=QM();const ZM="modulepreload",eR=function(e){return"/"+e},lk={},Aa=function(r,n,s){let i=Promise.resolve();if(n&&n.length>0){let d=function(b){return Promise.all(b.map(x=>Promise.resolve(x).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),p=f?.nonce||f?.getAttribute("nonce");i=d(n.map(b=>{if(b=eR(b),b in lk)return;lk[b]=!0;const x=b.endsWith(".css"),g=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${b}"]${g}`))return;const _=document.createElement("link");if(_.rel=x?"stylesheet":ZM,x||(_.as="script"),_.crossOrigin="",_.href=b,p&&_.setAttribute("nonce",p),document.head.appendChild(_),x)return new Promise((y,S)=>{_.addEventListener("load",y),_.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${b}`)))})}))}function c(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return i.then(d=>{for(const f of d||[])f.status==="rejected"&&c(f.reason);return r().catch(c)})};/**
51
+ * @license lucide-react v0.475.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */const tR=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),IA=(...e)=>e.filter((r,n,s)=>!!r&&r.trim()!==""&&s.indexOf(r)===n).join(" ").trim();/**
56
+ * @license lucide-react v0.475.0 - ISC
57
+ *
58
+ * This source code is licensed under the ISC license.
59
+ * See the LICENSE file in the root directory of this source tree.
60
+ */var nR={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"};/**
61
+ * @license lucide-react v0.475.0 - ISC
62
+ *
63
+ * This source code is licensed under the ISC license.
64
+ * See the LICENSE file in the root directory of this source tree.
65
+ */const sR=C.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:i="",children:c,iconNode:d,...f},p)=>C.createElement("svg",{ref:p,...nR,width:r,height:r,stroke:e,strokeWidth:s?Number(n)*24/Number(r):n,className:IA("lucide",i),...f},[...d.map(([b,x])=>C.createElement(b,x)),...Array.isArray(c)?c:[c]]));/**
66
+ * @license lucide-react v0.475.0 - ISC
67
+ *
68
+ * This source code is licensed under the ISC license.
69
+ * See the LICENSE file in the root directory of this source tree.
70
+ */const Te=(e,r)=>{const n=C.forwardRef(({className:s,...i},c)=>C.createElement(sR,{ref:c,iconNode:r,className:IA(`lucide-${tR(e)}`,s),...i}));return n.displayName=`${e}`,n};/**
71
+ * @license lucide-react v0.475.0 - ISC
72
+ *
73
+ * This source code is licensed under the ISC license.
74
+ * See the LICENSE file in the root directory of this source tree.
75
+ */const aR=[["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"}]],Qo=Te("Activity",aR);/**
76
+ * @license lucide-react v0.475.0 - ISC
77
+ *
78
+ * This source code is licensed under the ISC license.
79
+ * See the LICENSE file in the root directory of this source tree.
80
+ */const rR=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],iR=Te("ArrowLeft",rR);/**
81
+ * @license lucide-react v0.475.0 - ISC
82
+ *
83
+ * This source code is licensed under the ISC license.
84
+ * See the LICENSE file in the root directory of this source tree.
85
+ */const oR=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],DA=Te("ArrowRight",oR);/**
86
+ * @license lucide-react v0.475.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */const lR=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],cR=Te("ArrowUp",lR);/**
91
+ * @license lucide-react v0.475.0 - ISC
92
+ *
93
+ * This source code is licensed under the ISC license.
94
+ * See the LICENSE file in the root directory of this source tree.
95
+ */const uR=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]],ia=Te("Atom",uR);/**
96
+ * @license lucide-react v0.475.0 - ISC
97
+ *
98
+ * This source code is licensed under the ISC license.
99
+ * See the LICENSE file in the root directory of this source tree.
100
+ */const dR=[["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"}]],jy=Te("BookOpen",dR);/**
101
+ * @license lucide-react v0.475.0 - ISC
102
+ *
103
+ * This source code is licensed under the ISC license.
104
+ * See the LICENSE file in the root directory of this source tree.
105
+ */const hR=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}],["line",{x1:"12",x2:"12",y1:"7",y2:"13",key:"1cppfj"}],["line",{x1:"15",x2:"9",y1:"10",y2:"10",key:"1gty7f"}]],qA=Te("BookmarkPlus",hR);/**
106
+ * @license lucide-react v0.475.0 - ISC
107
+ *
108
+ * This source code is licensed under the ISC license.
109
+ * See the LICENSE file in the root directory of this source tree.
110
+ */const mR=[["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"}]],qr=Te("Bot",mR);/**
111
+ * @license lucide-react v0.475.0 - ISC
112
+ *
113
+ * This source code is licensed under the ISC license.
114
+ * See the LICENSE file in the root directory of this source tree.
115
+ */const fR=[["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"}]],_s=Te("Box",fR);/**
116
+ * @license lucide-react v0.475.0 - ISC
117
+ *
118
+ * This source code is licensed under the ISC license.
119
+ * See the LICENSE file in the root directory of this source tree.
120
+ */const pR=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],Tb=Te("Brain",pR);/**
121
+ * @license lucide-react v0.475.0 - ISC
122
+ *
123
+ * This source code is licensed under the ISC license.
124
+ * See the LICENSE file in the root directory of this source tree.
125
+ */const gR=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],bR=Te("Camera",gR);/**
126
+ * @license lucide-react v0.475.0 - ISC
127
+ *
128
+ * This source code is licensed under the ISC license.
129
+ * See the LICENSE file in the root directory of this source tree.
130
+ */const xR=[["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"}]],yR=Te("ChartColumn",xR);/**
131
+ * @license lucide-react v0.475.0 - ISC
132
+ *
133
+ * This source code is licensed under the ISC license.
134
+ * See the LICENSE file in the root directory of this source tree.
135
+ */const _R=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Fi=Te("Check",_R);/**
136
+ * @license lucide-react v0.475.0 - ISC
137
+ *
138
+ * This source code is licensed under the ISC license.
139
+ * See the LICENSE file in the root directory of this source tree.
140
+ */const vR=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ph=Te("ChevronDown",vR);/**
141
+ * @license lucide-react v0.475.0 - ISC
142
+ *
143
+ * This source code is licensed under the ISC license.
144
+ * See the LICENSE file in the root directory of this source tree.
145
+ */const wR=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ty=Te("ChevronRight",wR);/**
146
+ * @license lucide-react v0.475.0 - ISC
147
+ *
148
+ * This source code is licensed under the ISC license.
149
+ * See the LICENSE file in the root directory of this source tree.
150
+ */const SR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Gs=Te("CircleCheck",SR);/**
151
+ * @license lucide-react v0.475.0 - ISC
152
+ *
153
+ * This source code is licensed under the ISC license.
154
+ * See the LICENSE file in the root directory of this source tree.
155
+ */const kR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],CR=Te("CircleHelp",kR);/**
156
+ * @license lucide-react v0.475.0 - ISC
157
+ *
158
+ * This source code is licensed under the ISC license.
159
+ * See the LICENSE file in the root directory of this source tree.
160
+ */const NR=[["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"}]],Bc=Te("CircleX",NR);/**
161
+ * @license lucide-react v0.475.0 - ISC
162
+ *
163
+ * This source code is licensed under the ISC license.
164
+ * See the LICENSE file in the root directory of this source tree.
165
+ */const AR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],zx=Te("Clock",AR);/**
166
+ * @license lucide-react v0.475.0 - ISC
167
+ *
168
+ * This source code is licensed under the ISC license.
169
+ * See the LICENSE file in the root directory of this source tree.
170
+ */const jR=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],TR=Te("Cloud",jR);/**
171
+ * @license lucide-react v0.475.0 - ISC
172
+ *
173
+ * This source code is licensed under the ISC license.
174
+ * See the LICENSE file in the root directory of this source tree.
175
+ */const ER=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Ey=Te("Columns2",ER);/**
176
+ * @license lucide-react v0.475.0 - ISC
177
+ *
178
+ * This source code is licensed under the ISC license.
179
+ * See the LICENSE file in the root directory of this source tree.
180
+ */const MR=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],RR=Te("Command",MR);/**
181
+ * @license lucide-react v0.475.0 - ISC
182
+ *
183
+ * This source code is licensed under the ISC license.
184
+ * See the LICENSE file in the root directory of this source tree.
185
+ */const zR=[["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"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],OR=Te("Compass",zR);/**
186
+ * @license lucide-react v0.475.0 - ISC
187
+ *
188
+ * This source code is licensed under the ISC license.
189
+ * See the LICENSE file in the root directory of this source tree.
190
+ */const PR=[["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"}]],Lr=Te("Copy",PR);/**
191
+ * @license lucide-react v0.475.0 - ISC
192
+ *
193
+ * This source code is licensed under the ISC license.
194
+ * See the LICENSE file in the root directory of this source tree.
195
+ */const $R=[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]],IR=Te("CornerDownLeft",$R);/**
196
+ * @license lucide-react v0.475.0 - ISC
197
+ *
198
+ * This source code is licensed under the ISC license.
199
+ * See the LICENSE file in the root directory of this source tree.
200
+ */const DR=[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]],al=Te("Cpu",DR);/**
201
+ * @license lucide-react v0.475.0 - ISC
202
+ *
203
+ * This source code is licensed under the ISC license.
204
+ * See the LICENSE file in the root directory of this source tree.
205
+ */const qR=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Ur=Te("Crosshair",qR);/**
206
+ * @license lucide-react v0.475.0 - ISC
207
+ *
208
+ * This source code is licensed under the ISC license.
209
+ * See the LICENSE file in the root directory of this source tree.
210
+ */const LR=[["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"}]],Vi=Te("Database",LR);/**
211
+ * @license lucide-react v0.475.0 - ISC
212
+ *
213
+ * This source code is licensed under the ISC license.
214
+ * See the LICENSE file in the root directory of this source tree.
215
+ */const UR=[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]],Fs=Te("Dna",UR);/**
216
+ * @license lucide-react v0.475.0 - ISC
217
+ *
218
+ * This source code is licensed under the ISC license.
219
+ * See the LICENSE file in the root directory of this source tree.
220
+ */const BR=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],sr=Te("Download",BR);/**
221
+ * @license lucide-react v0.475.0 - ISC
222
+ *
223
+ * This source code is licensed under the ISC license.
224
+ * See the LICENSE file in the root directory of this source tree.
225
+ */const GR=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],HR=Te("Ellipsis",GR);/**
226
+ * @license lucide-react v0.475.0 - ISC
227
+ *
228
+ * This source code is licensed under the ISC license.
229
+ * See the LICENSE file in the root directory of this source tree.
230
+ */const FR=[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]],VR=Te("Eraser",FR);/**
231
+ * @license lucide-react v0.475.0 - ISC
232
+ *
233
+ * This source code is licensed under the ISC license.
234
+ * See the LICENSE file in the root directory of this source tree.
235
+ */const KR=[["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"}]],Kd=Te("ExternalLink",KR);/**
236
+ * @license lucide-react v0.475.0 - ISC
237
+ *
238
+ * This source code is licensed under the ISC license.
239
+ * See the LICENSE file in the root directory of this source tree.
240
+ */const YR=[["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"}]],WR=Te("EyeOff",YR);/**
241
+ * @license lucide-react v0.475.0 - ISC
242
+ *
243
+ * This source code is licensed under the ISC license.
244
+ * See the LICENSE file in the root directory of this source tree.
245
+ */const XR=[["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"}]],LA=Te("Eye",XR);/**
246
+ * @license lucide-react v0.475.0 - ISC
247
+ *
248
+ * This source code is licensed under the ISC license.
249
+ * See the LICENSE file in the root directory of this source tree.
250
+ */const QR=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],UA=Te("FileCode2",QR);/**
251
+ * @license lucide-react v0.475.0 - ISC
252
+ *
253
+ * This source code is licensed under the ISC license.
254
+ * See the LICENSE file in the root directory of this source tree.
255
+ */const JR=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],BA=Te("FileJson",JR);/**
256
+ * @license lucide-react v0.475.0 - ISC
257
+ *
258
+ * This source code is licensed under the ISC license.
259
+ * See the LICENSE file in the root directory of this source tree.
260
+ */const ZR=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],Oc=Te("FileUp",ZR);/**
261
+ * @license lucide-react v0.475.0 - ISC
262
+ *
263
+ * This source code is licensed under the ISC license.
264
+ * See the LICENSE file in the root directory of this source tree.
265
+ */const e6=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],ck=Te("Fingerprint",e6);/**
266
+ * @license lucide-react v0.475.0 - ISC
267
+ *
268
+ * This source code is licensed under the ISC license.
269
+ * See the LICENSE file in the root directory of this source tree.
270
+ */const t6=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Br=Te("FlaskConical",t6);/**
271
+ * @license lucide-react v0.475.0 - ISC
272
+ *
273
+ * This source code is licensed under the ISC license.
274
+ * See the LICENSE file in the root directory of this source tree.
275
+ */const n6=[["path",{d:"M2 9V5a2 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 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Eb=Te("FolderInput",n6);/**
276
+ * @license lucide-react v0.475.0 - ISC
277
+ *
278
+ * This source code is licensed under the ISC license.
279
+ * See the LICENSE file in the root directory of this source tree.
280
+ */const s6=[["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"}]],My=Te("FolderOpen",s6);/**
281
+ * @license lucide-react v0.475.0 - ISC
282
+ *
283
+ * This source code is licensed under the ISC license.
284
+ * See the LICENSE file in the root directory of this source tree.
285
+ */const a6=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],Qc=Te("FolderPlus",a6);/**
286
+ * @license lucide-react v0.475.0 - ISC
287
+ *
288
+ * This source code is licensed under the ISC license.
289
+ * See the LICENSE file in the root directory of this source tree.
290
+ */const r6=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Dp=Te("GitBranch",r6);/**
291
+ * @license lucide-react v0.475.0 - ISC
292
+ *
293
+ * This source code is licensed under the ISC license.
294
+ * See the LICENSE file in the root directory of this source tree.
295
+ */const i6=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],Vo=Te("GitCompareArrows",i6);/**
296
+ * @license lucide-react v0.475.0 - ISC
297
+ *
298
+ * This source code is licensed under the ISC license.
299
+ * See the LICENSE file in the root directory of this source tree.
300
+ */const o6=[["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"}]],Ry=Te("Globe",o6);/**
301
+ * @license lucide-react v0.475.0 - ISC
302
+ *
303
+ * This source code is licensed under the ISC license.
304
+ * See the LICENSE file in the root directory of this source tree.
305
+ */const l6=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],GA=Te("HardDrive",l6);/**
306
+ * @license lucide-react v0.475.0 - ISC
307
+ *
308
+ * This source code is licensed under the ISC license.
309
+ * See the LICENSE file in the root directory of this source tree.
310
+ */const c6=[["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"}]],u6=Te("Hexagon",c6);/**
311
+ * @license lucide-react v0.475.0 - ISC
312
+ *
313
+ * This source code is licensed under the ISC license.
314
+ * See the LICENSE file in the root directory of this source tree.
315
+ */const d6=[["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"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],HA=Te("History",d6);/**
316
+ * @license lucide-react v0.475.0 - ISC
317
+ *
318
+ * This source code is licensed under the ISC license.
319
+ * See the LICENSE file in the root directory of this source tree.
320
+ */const h6=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],FA=Te("House",h6);/**
321
+ * @license lucide-react v0.475.0 - ISC
322
+ *
323
+ * This source code is licensed under the ISC license.
324
+ * See the LICENSE file in the root directory of this source tree.
325
+ */const m6=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],zy=Te("Info",m6);/**
326
+ * @license lucide-react v0.475.0 - ISC
327
+ *
328
+ * This source code is licensed under the ISC license.
329
+ * See the LICENSE file in the root directory of this source tree.
330
+ */const f6=[["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"}]],tp=Te("KeyRound",f6);/**
331
+ * @license lucide-react v0.475.0 - ISC
332
+ *
333
+ * This source code is licensed under the ISC license.
334
+ * See the LICENSE file in the root directory of this source tree.
335
+ */const p6=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],g6=Te("Keyboard",p6);/**
336
+ * @license lucide-react v0.475.0 - ISC
337
+ *
338
+ * This source code is licensed under the ISC license.
339
+ * See the LICENSE file in the root directory of this source tree.
340
+ */const b6=[["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"}]],qi=Te("Layers",b6);/**
341
+ * @license lucide-react v0.475.0 - ISC
342
+ *
343
+ * This source code is licensed under the ISC license.
344
+ * See the LICENSE file in the root directory of this source tree.
345
+ */const x6=[["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"}]],VA=Te("LayoutGrid",x6);/**
346
+ * @license lucide-react v0.475.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */const y6=[["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"}]],sh=Te("Library",y6);/**
351
+ * @license lucide-react v0.475.0 - ISC
352
+ *
353
+ * This source code is licensed under the ISC license.
354
+ * See the LICENSE file in the root directory of this source tree.
355
+ */const _6=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],qs=Te("LoaderCircle",_6);/**
356
+ * @license lucide-react v0.475.0 - ISC
357
+ *
358
+ * This source code is licensed under the ISC license.
359
+ * See the LICENSE file in the root directory of this source tree.
360
+ */const v6=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],w6=Te("Lock",v6);/**
361
+ * @license lucide-react v0.475.0 - ISC
362
+ *
363
+ * This source code is licensed under the ISC license.
364
+ * See the LICENSE file in the root directory of this source tree.
365
+ */const S6=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],k6=Te("LogOut",S6);/**
366
+ * @license lucide-react v0.475.0 - ISC
367
+ *
368
+ * This source code is licensed under the ISC license.
369
+ * See the LICENSE file in the root directory of this source tree.
370
+ */const C6=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],Oy=Te("Maximize2",C6);/**
371
+ * @license lucide-react v0.475.0 - ISC
372
+ *
373
+ * This source code is licensed under the ISC license.
374
+ * See the LICENSE file in the root directory of this source tree.
375
+ */const N6=[["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"}]],A6=Te("Monitor",N6);/**
376
+ * @license lucide-react v0.475.0 - ISC
377
+ *
378
+ * This source code is licensed under the ISC license.
379
+ * See the LICENSE file in the root directory of this source tree.
380
+ */const j6=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],T6=Te("PenLine",j6);/**
381
+ * @license lucide-react v0.475.0 - ISC
382
+ *
383
+ * This source code is licensed under the ISC license.
384
+ * See the LICENSE file in the root directory of this source tree.
385
+ */const E6=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Ox=Te("Pencil",E6);/**
386
+ * @license lucide-react v0.475.0 - ISC
387
+ *
388
+ * This source code is licensed under the ISC license.
389
+ * See the LICENSE file in the root directory of this source tree.
390
+ */const M6=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],qp=Te("Play",M6);/**
391
+ * @license lucide-react v0.475.0 - ISC
392
+ *
393
+ * This source code is licensed under the ISC license.
394
+ * See the LICENSE file in the root directory of this source tree.
395
+ */const R6=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],gh=Te("Plus",R6);/**
396
+ * @license lucide-react v0.475.0 - ISC
397
+ *
398
+ * This source code is licensed under the ISC license.
399
+ * See the LICENSE file in the root directory of this source tree.
400
+ */const z6=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],Lp=Te("Puzzle",z6);/**
401
+ * @license lucide-react v0.475.0 - ISC
402
+ *
403
+ * This source code is licensed under the ISC license.
404
+ * See the LICENSE file in the root directory of this source tree.
405
+ */const O6=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],P6=Te("Redo2",O6);/**
406
+ * @license lucide-react v0.475.0 - ISC
407
+ *
408
+ * This source code is licensed under the ISC license.
409
+ * See the LICENSE file in the root directory of this source tree.
410
+ */const $6=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],gp=Te("RefreshCw",$6);/**
411
+ * @license lucide-react v0.475.0 - ISC
412
+ *
413
+ * This source code is licensed under the ISC license.
414
+ * See the LICENSE file in the root directory of this source tree.
415
+ */const I6=[["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"}]],KA=Te("RotateCcw",I6);/**
416
+ * @license lucide-react v0.475.0 - ISC
417
+ *
418
+ * This source code is licensed under the ISC license.
419
+ * See the LICENSE file in the root directory of this source tree.
420
+ */const D6=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],q6=Te("Ruler",D6);/**
421
+ * @license lucide-react v0.475.0 - ISC
422
+ *
423
+ * This source code is licensed under the ISC license.
424
+ * See the LICENSE file in the root directory of this source tree.
425
+ */const L6=[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]],ar=Te("Scissors",L6);/**
426
+ * @license lucide-react v0.475.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */const U6=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Gr=Te("Search",U6);/**
431
+ * @license lucide-react v0.475.0 - ISC
432
+ *
433
+ * This source code is licensed under the ISC license.
434
+ * See the LICENSE file in the root directory of this source tree.
435
+ */const B6=[["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"}]],rl=Te("Server",B6);/**
436
+ * @license lucide-react v0.475.0 - ISC
437
+ *
438
+ * This source code is licensed under the ISC license.
439
+ * See the LICENSE file in the root directory of this source tree.
440
+ */const G6=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],H6=Te("Settings",G6);/**
441
+ * @license lucide-react v0.475.0 - ISC
442
+ *
443
+ * This source code is licensed under the ISC license.
444
+ * See the LICENSE file in the root directory of this source tree.
445
+ */const F6=[["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"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],YA=Te("ShieldAlert",F6);/**
446
+ * @license lucide-react v0.475.0 - ISC
447
+ *
448
+ * This source code is licensed under the ISC license.
449
+ * See the LICENSE file in the root directory of this source tree.
450
+ */const V6=[["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"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ki=Te("ShieldCheck",V6);/**
451
+ * @license lucide-react v0.475.0 - ISC
452
+ *
453
+ * This source code is licensed under the ISC license.
454
+ * See the LICENSE file in the root directory of this source tree.
455
+ */const K6=[["path",{d:"M16 3h5v5",key:"1806ms"}],["path",{d:"M8 3H3v5",key:"15dfkv"}],["path",{d:"M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3",key:"1qrqzj"}],["path",{d:"m15 9 6-6",key:"ko1vev"}]],Px=Te("Split",K6);/**
456
+ * @license lucide-react v0.475.0 - ISC
457
+ *
458
+ * This source code is licensed under the ISC license.
459
+ * See the LICENSE file in the root directory of this source tree.
460
+ */const Y6=[["path",{d:"M8 19H5c-1 0-2-1-2-2V7c0-1 1-2 2-2h3",key:"lubmu8"}],["path",{d:"M16 5h3c1 0 2 1 2 2v10c0 1-1 2-2 2h-3",key:"1ag34g"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],W6=Te("SquareSplitHorizontal",Y6);/**
461
+ * @license lucide-react v0.475.0 - ISC
462
+ *
463
+ * This source code is licensed under the ISC license.
464
+ * See the LICENSE file in the root directory of this source tree.
465
+ */const X6=[["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"}]],Mb=Te("Star",X6);/**
466
+ * @license lucide-react v0.475.0 - ISC
467
+ *
468
+ * This source code is licensed under the ISC license.
469
+ * See the LICENSE file in the root directory of this source tree.
470
+ */const Q6=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],WA=Te("Terminal",Q6);/**
471
+ * @license lucide-react v0.475.0 - ISC
472
+ *
473
+ * This source code is licensed under the ISC license.
474
+ * See the LICENSE file in the root directory of this source tree.
475
+ */const J6=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Wi=Te("Trash2",J6);/**
476
+ * @license lucide-react v0.475.0 - ISC
477
+ *
478
+ * This source code is licensed under the ISC license.
479
+ * See the LICENSE file in the root directory of this source tree.
480
+ */const Z6=[["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"}]],Gc=Te("TriangleAlert",Z6);/**
481
+ * @license lucide-react v0.475.0 - ISC
482
+ *
483
+ * This source code is licensed under the ISC license.
484
+ * See the LICENSE file in the root directory of this source tree.
485
+ */const ez=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],tz=Te("Undo2",ez);/**
486
+ * @license lucide-react v0.475.0 - ISC
487
+ *
488
+ * This source code is licensed under the ISC license.
489
+ * See the LICENSE file in the root directory of this source tree.
490
+ */const nz=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],sz=Te("Unlink",nz);/**
491
+ * @license lucide-react v0.475.0 - ISC
492
+ *
493
+ * This source code is licensed under the ISC license.
494
+ * See the LICENSE file in the root directory of this source tree.
495
+ */const az=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]],rz=Te("Upload",az);/**
496
+ * @license lucide-react v0.475.0 - ISC
497
+ *
498
+ * This source code is licensed under the ISC license.
499
+ * See the LICENSE file in the root directory of this source tree.
500
+ */const iz=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ah=Te("User",iz);/**
501
+ * @license lucide-react v0.475.0 - ISC
502
+ *
503
+ * This source code is licensed under the ISC license.
504
+ * See the LICENSE file in the root directory of this source tree.
505
+ */const oz=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]],Py=Te("Wrench",oz);/**
506
+ * @license lucide-react v0.475.0 - ISC
507
+ *
508
+ * This source code is licensed under the ISC license.
509
+ * See the LICENSE file in the root directory of this source tree.
510
+ */const lz=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Xi=Te("X",lz);class Tr extends Error{constructor(r,n){super(`Cancelled stale bio-core run on channel "${r}" (#${n}).`),this.name="CancelledRunError"}}class XA extends Error{code;details;constructor(r){super(r.message),this.name="BioEngineOperationError",this.code=r.code,this.details=r.details}}class $y{worker=null;customInvoker=null;nextId=1;latestIdByChannel=new Map;pending=new Map;constructor(r){r&&(this.customInvoker=r)}static fromWasmSession(r){return new $y(async(n,s)=>({cancelled:!1,response:r.invokeJson(n,s)}))}ensureWorker(){if(this.worker)return this.worker;if(typeof Worker>"u")throw new Error("Web Worker is unavailable in this runtime; provide a custom invoker.");const r=new Worker(new URL("/assets/bioCore.worker-BGMOX1WA.js",import.meta.url),{type:"module"});return r.onmessage=n=>{const{id:s,cancelled:i,response:c,fatalError:d}=n.data,f=this.pending.get(s);f&&(this.pending.delete(s),d?f.reject(new Error(d)):f.resolve({cancelled:i,response:c}))},r.onerror=n=>{for(const[,s]of this.pending)s.reject(new Error(n.message||"BioCore Web Worker error"));this.pending.clear()},this.worker=r,r}cancelChannel(r){const n=this.nextId++;this.latestIdByChannel.set(r,n),this.worker&&this.worker.postMessage({type:"cancel",channel:r,minId:n})}async invoke(r,n,s){const i=this.nextId++;this.latestIdByChannel.set(r,i);let c;if(this.customInvoker)c=await this.customInvoker(n,s,{id:i,channel:r});else{const f=this.ensureWorker();c=await new Promise((p,b)=>{this.pending.set(i,{resolve:p,reject:b}),f.postMessage({type:"run",id:i,channel:r,op:n,payload:s})})}if(c.cancelled||this.latestIdByChannel.get(r)!==i)throw new Tr(r,i);const d=c.response;if(!d)throw new Error(`Empty response from bio-core for ${n}`);if(!d.ok)throw new XA(d.error);return d.data}inspectStructure(r,n){return this.invoke(r,"inspect_structure",n)}compareStructures(r,n="compare"){return this.invoke(n,"compare_structures",r)}analyzePeptide(r,n="peptide"){return this.invoke(n,"analyze_peptide",r)}analyzeGeneCrispr(r,n="crispr"){return this.invoke(n,"analyze_gene_crispr",r)}analyzeMoleculeSmiles(r,n="smiles"){return this.invoke(n,"analyze_molecule_smiles",r)}analyzeRamachandran(r,n="ramachandran"){return this.invoke(n,"analyze_ramachandran",r)}dispose(){this.worker&&(this.worker.terminate(),this.worker=null);for(const[,r]of this.pending)r.reject(new Error("BioEngineClient disposed"));this.pending.clear()}}async function cz(){const e=await fetch("/fixtures/fixtures-manifest.json");if(!e.ok)throw new Error("Failed to load pinned fixtures manifest from /fixtures/.");return await e.json()}async function Rb(e){if(!/^[A-Za-z0-9._-]+$/.test(e))throw new Error(`Invalid fixture file name: ${e}`);const r=await fetch(`/fixtures/${e}`);if(!r.ok)throw new Error(`Failed to load pinned fixture ${e} from /fixtures/.`);return r.text()}async function uz(){const[e,r,n,s]=await Promise.all([fetch("/fixtures/fixtures-manifest.json"),fetch("/fixtures/3HS4.cif"),fetch("/fixtures/AF-P00918-F1-model_v6.cif"),fetch("/fixtures/AF-P00918-F1-predicted_aligned_error_v6.json")]);if(!e.ok||!r.ok||!n.ok||!s.ok)throw new Error("Failed to load pinned local fixtures from /fixtures/.");const[i,c,d,f]=await Promise.all([e.json(),r.text(),n.text(),s.text()]);return{manifest:i,refCif:c,mobCif:d,paeJson:f}}const dz=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function hz(e){const r=e.length,n=Math.floor(r/536870912),s=r<<3>>>0,i=new Uint8Array(Math.ceil((r+9)/64)*64);i.set(e),i[r]=128;const c=new DataView(i.buffer);c.setUint32(i.length-8,n,!1),c.setUint32(i.length-4,s,!1);let d=1779033703,f=3144134277,p=1013904242,b=2773480762,x=1359893119,g=2600822924,_=528734635,y=1541459225;const S=new Uint32Array(64);for(let T=0;T<i.length;T+=64){for(let Z=0;Z<16;Z++)S[Z]=c.getUint32(T+Z*4,!1);for(let Z=16;Z<64;Z++){const G=S[Z-15],K=S[Z-2],we=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,Se=(K>>>17|K<<15)^(K>>>19|K<<13)^K>>>10;S[Z]=S[Z-16]+we+S[Z-7]+Se|0}let j=d,q=f,z=p,O=b,V=x,P=g,$=_,H=y;for(let Z=0;Z<64;Z++){const G=(V>>>6|V<<26)^(V>>>11|V<<21)^(V>>>25|V<<7),K=V&P^~V&$,we=H+G+K+dz[Z]+S[Z]|0,Se=(j>>>2|j<<30)^(j>>>13|j<<19)^(j>>>22|j<<10),Q=j&q^j&z^q&z,F=Se+Q|0;H=$,$=P,P=V,V=O+we|0,O=z,z=q,q=j,j=we+F|0}d=d+j|0,f=f+q|0,p=p+z|0,b=b+O|0,x=x+V|0,g=g+P|0,_=_+$|0,y=y+H|0}const k=new Uint8Array(32),E=new DataView(k.buffer);return[d,f,p,b,x,g,_,y].forEach((T,j)=>E.setUint32(j*4,T>>>0,!1)),k}function mz(e){if(typeof e=="string"){const n=new TextEncoder().encode(e),s=new Uint8Array(new ArrayBuffer(n.byteLength));return s.set(n),s}if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));const r=new Uint8Array(new ArrayBuffer(e.byteLength));return r.set(e),r}function fz(e){let r="";for(let n=0;n<e.length;n++)r+=e[n].toString(16).padStart(2,"0");return r}async function QA(e){const r=mz(e),n=globalThis.crypto?.subtle;if(n&&typeof n.digest=="function")try{return new Uint8Array(await n.digest("SHA-256",r))}catch{}return hz(r)}async function Jc(e){return fz(await QA(e))}const $x={rcsb:"RCSB PDB",alphafold:"AlphaFold DB",uniprot:"UniProtKB",pubchem:"PubChem",chembl:"ChEMBL",opentargets:"Open Targets"},ts={rcsb:"CC0-1.0",alphafold:"CC-BY-4.0",uniprot:"CC-BY-4.0",pubchem:"Public domain (NCBI/PubChem data policy)",chembl:"CC-BY-SA-3.0",opentargets:"Apache-2.0 (Open Targets Platform)"},pz=50*1024*1024,uk="/fixtures/",dk=200,Up=10;class ys extends Error{status;url;constructor(r,n){super(`HTTP ${r} from ${n}`),this.name="DatabaseHttpError",this.status=r,this.url=n}}const JA=/^[A-Za-z0-9]{4}$/,ZA=/^(?:[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9](?:[A-Z][A-Z0-9]{2}[0-9]){1,2})$/;function gz(e){return JA.test(e.trim())}function bh(e){const r=e.trim();if(!JA.test(r))throw new Error(`Invalid PDB ID "${e}": expected 4 alphanumeric characters (e.g. 3HS4).`);return r.toUpperCase()}function xh(e){const r=e.trim().toUpperCase();if(!ZA.test(r))throw new Error(`Invalid UniProtKB accession "${e}" (e.g. P00918).`);return r}function yh(e){const r=e.trim().toUpperCase(),n=/^(?:AF-)?([A-Z0-9]{6,10})(?:-F\d+(?:-MODEL_V\d+)?)?$/.exec(r);return n&&ZA.test(n[1])?n[1]:null}function Bp(e){const r=(e??"").trim();if(!r)throw new Error("Search query must not be empty.");if(r.length>dk)throw new Error(`Search query exceeds ${dk} characters.`);return r}const bz="https://search.rcsb.org/rcsbsearch/v2/query",xz="accession,id,protein_name,organism_name,length,gene_names",yz="Title,MolecularFormula,MolecularWeight,CanonicalSMILES,IsomericSMILES,TPSA,XLogP,HBondDonorCount,HBondAcceptorCount,RotatableBondCount";function _z(){return bz}function vz(e){const r=Bp(e);return JSON.stringify({query:{type:"terminal",service:"full_text",parameters:{value:r}},return_type:"entry",request_options:{paginate:{start:0,rows:Up}}})}function wz(e){return`https://data.rcsb.org/rest/v1/core/entry/${bh(e)}`}function np(e){return`https://files.rcsb.org/download/${bh(e)}.cif`}function sp(e){return`https://www.rcsb.org/structure/${bh(e)}`}function ej(e){return`https://alphafold.ebi.ac.uk/api/prediction/${xh(e)}`}function tj(e){return`https://alphafold.ebi.ac.uk/entry/${xh(e)}`}function Sz(e){const r=Bp(e);return`https://rest.uniprot.org/uniprotkb/search?query=${encodeURIComponent(r)}&fields=${xz}&format=json&size=${Up}`}function nj(e){return`https://www.uniprot.org/uniprotkb/${xh(e)}/entry`}function kz(e){const r=Bp(e);return`https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/${encodeURIComponent(r)}/property/${yz}/JSON`}function sj(e){if(!Number.isInteger(e)||e<=0)throw new Error(`Invalid PubChem CID "${e}".`);return`https://pubchem.ncbi.nlm.nih.gov/compound/${e}`}const Mr={manifestGeneratedAtUtc:"2026-11-15T12:19:00Z",structures:[{source:"rcsb",id:"3HS4",uniprotAccession:"P00918",fileName:"3HS4.cif",paeFileName:null,title:"Crystal structure of human carbonic anhydrase II (1.10 A)",sourceUrl:"https://files.rcsb.org/download/3HS4.cif",dataRevision:"PDB 3HS4 (2025-09-25)",retrievedAtUtc:"2026-11-15T09:05:30Z",license:"CC0-1.0",sha256:"84e006ac301979de150f351fdc235a97ba73bffec8514dfe6c96447517da91d6"},{source:"rcsb",id:"1UBQ",uniprotAccession:"P0CG48",fileName:"1UBQ.cif",paeFileName:null,title:"Structure of ubiquitin refined at 1.8 Angstroms resolution",sourceUrl:"https://files.rcsb.org/download/1UBQ.cif",dataRevision:"PDB 1UBQ (2024-02-14)",retrievedAtUtc:"2026-11-15T12:18:14Z",license:"CC0-1.0",sha256:"056f98710cb2b36f633c45e41902a02eb446e82871da21ff2dd44f74a56ca0f6"},{source:"rcsb",id:"1A3N",uniprotAccession:"P68871",fileName:"1A3N.cif",paeFileName:null,title:"Deoxy human hemoglobin (chains A, B, C, D; beta subunit chain B)",sourceUrl:"https://files.rcsb.org/download/1A3N.cif",dataRevision:"PDB 1A3N (2026-08-12)",retrievedAtUtc:"2026-11-15T12:18:15Z",license:"CC0-1.0",sha256:"7cd2eb16d3469a3ef32864f33ee2ca09258b1b1fff2c1c83214b9af3087f93dd"},{source:"rcsb",id:"1LZ1",uniprotAccession:"P61626",fileName:"1LZ1.cif",paeFileName:null,title:"Refinement of human lysozyme at 1.5 Angstroms resolution",sourceUrl:"https://files.rcsb.org/download/1LZ1.cif",dataRevision:"PDB 1LZ1 (2024-10-30)",retrievedAtUtc:"2026-11-15T12:18:15Z",license:"CC0-1.0",sha256:"b7c3da2c7a54184fa768a2f51b56c4d7f4516854a4e77dbaa2528803a673cea0"},{source:"alphafold",id:"AF-P00918-F1",uniprotAccession:"P00918",fileName:"AF-P00918-F1-model_v6.cif",paeFileName:"AF-P00918-F1-predicted_aligned_error_v6.json",title:"AlphaFold DB prediction for Human Carbonic Anhydrase 2 (UniProt P00918, v6)",sourceUrl:"https://alphafold.ebi.ac.uk/files/AF-P00918-F1-model_v6.cif",dataRevision:"AlphaFold DB v6 (modelCreatedDate 2025-08-01)",retrievedAtUtc:"2026-11-15T09:06:04Z",license:"CC-BY-4.0",sha256:"173c4f1fa81ffb1a288c881040217d1473ed2d08cd792671252ee116cac10c7d"},{source:"alphafold",id:"AF-P0CG48-F1",uniprotAccession:"P0CG48",fileName:"AF-P0CG48-F1-model_v6.cif",paeFileName:null,title:"AlphaFold DB prediction for Human Polyubiquitin-C (UniProt P0CG48, v6)",sourceUrl:"https://alphafold.ebi.ac.uk/files/AF-P0CG48-F1-model_v6.cif",dataRevision:"AlphaFold DB v6 (modelCreatedDate 2025-08-01)",retrievedAtUtc:"2026-11-15T12:18:14Z",license:"CC-BY-4.0",sha256:"02b8ea3d522fabee58abed221fad1a2101e9ad633ddecbe30bc96d158fc2c408"},{source:"alphafold",id:"AF-P68871-F1",uniprotAccession:"P68871",fileName:"AF-P68871-F1-model_v6.cif",paeFileName:null,title:"AlphaFold DB prediction for Human Hemoglobin Subunit Beta (UniProt P68871, v6)",sourceUrl:"https://alphafold.ebi.ac.uk/files/AF-P68871-F1-model_v6.cif",dataRevision:"AlphaFold DB v6 (modelCreatedDate 2025-08-01)",retrievedAtUtc:"2026-11-15T12:18:15Z",license:"CC-BY-4.0",sha256:"0c1603478734a034d38f807a57badc41c2e2086daaa98334d218a9c70ace1f4e"},{source:"alphafold",id:"AF-P61626-F1",uniprotAccession:"P61626",fileName:"AF-P61626-F1-model_v6.cif",paeFileName:null,title:"AlphaFold DB prediction for Human Lysozyme C (UniProt P61626, v6)",sourceUrl:"https://alphafold.ebi.ac.uk/files/AF-P61626-F1-model_v6.cif",dataRevision:"AlphaFold DB v6 (modelCreatedDate 2025-08-01)",retrievedAtUtc:"2026-11-15T12:18:15Z",license:"CC-BY-4.0",sha256:"8444ea54dc496d7a8107257040ca7d12476f0508a943b17890b846ecd1e2b99e"}],uniprot:[{id:"P00918",title:"Human Carbonic Anhydrase 2 (UniProt P00918)",relatedPdbId:"3HS4",relatedAfId:"AF-P00918-F1",retrievedAtUtc:"2026-11-15T09:06:04Z"},{id:"P0CG48",title:"Human Polyubiquitin-C (UniProt P0CG48)",relatedPdbId:"1UBQ",relatedAfId:"AF-P0CG48-F1",retrievedAtUtc:"2026-11-15T12:18:14Z"},{id:"P68871",title:"Human Hemoglobin Subunit Beta (UniProt P68871)",relatedPdbId:"1A3N",relatedAfId:"AF-P68871-F1",retrievedAtUtc:"2026-11-15T12:18:15Z"},{id:"P61626",title:"Human Lysozyme C (UniProt P61626)",relatedPdbId:"1LZ1",relatedAfId:"AF-P61626-F1",retrievedAtUtc:"2026-11-15T12:18:15Z"}],pubchemPanel:{fileName:"pubchem-panel.json",sourceUrl:"https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/1986,3154,5291,2244,2519,4091/property/Title,MolecularFormula,MolecularWeight,CanonicalSMILES,IsomericSMILES,TPSA,XLogP,HBondDonorCount,HBondAcceptorCount,RotatableBondCount/JSON",license:"Public domain (NCBI/PubChem data policy)",retrievedAtUtc:"2026-11-15T12:18:16Z",dataRevision:"PubChem PUG REST snapshot (2026-11-15)",sha256:"149fde62389640deced63caec8a749cee1477d160f99c27630fddece00350d8b",compounds:[{cid:1986,name:"Acetazolamide"},{cid:3154,name:"4H-Thieno(2,3-b)thiopyran-2-sulfonamide, 4-(ethylamino)-5,6-dihydro-6-methyl-, 7,7-dioxide"},{cid:5291,name:"Imatinib"},{cid:2244,name:"Aspirin"},{cid:2519,name:"Caffeine"},{cid:4091,name:"Metformin"}]}};function il(e){const r=e?.fetchImpl??globalThis.fetch;if(typeof r!="function")throw new Error("No fetch implementation available.");return r}function Dr(e){return(e?.now?e.now():new Date).toISOString()}function aj(e){return!!(e?.offline||typeof navigator<"u"&&navigator.onLine===!1)}function rj(e){const r=(e??uk).trim();return r?r.endsWith("/")?r:`${r}/`:uk}function Gp(e,r){return r?.aborted?!0:e instanceof Error&&e.name==="AbortError"}function Cz(e){return e instanceof ys?e.status===429||e.status>=500&&e.status<=599:!0}async function ad(e){return Jc(e)}async function rd(e,r,n=pz){const s=e.headers?.get?.("content-length");if(s!=null&&s!==""){const d=Number(s);if(Number.isFinite(d)&&d>n)throw new Error(`Artifact from ${r} exceeds the ${Math.round(n/(1024*1024))} MB size cap (${d} bytes declared).`)}let i;if(e.body&&typeof e.body.getReader=="function"){const d=e.body.getReader(),f=[];let p=0;for(;;){const{done:x,value:g}=await d.read();if(x)break;if(g){if(p+=g.byteLength,p>n)throw await d.cancel().catch(()=>{}),new Error(`Artifact from ${r} exceeds the ${Math.round(n/(1024*1024))} MB size cap.`);f.push(g)}}i=new Uint8Array(p);let b=0;for(const x of f)i.set(x,b),b+=x.byteLength}else{const d=await e.arrayBuffer();if(d.byteLength>n)throw new Error(`Artifact from ${r} exceeds the ${Math.round(n/(1024*1024))} MB size cap (${d.byteLength} bytes).`);i=new Uint8Array(d)}const c=new TextDecoder().decode(i);return{bytes:i,text:c}}function ij(e){if(!e||typeof e!="object")return null;const r=[e.IsomericSMILES,e.SMILES,e.CanonicalSMILES,e.ConnectivitySMILES];for(const n of r)if(typeof n=="string"&&n.trim().length>0)return n.trim();return null}function ka(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){const r=Number(e);if(Number.isFinite(r))return r}return null}function oj(e){const r=e.latestVersion,n=typeof e.modelCreatedDate=="string"?e.modelCreatedDate.slice(0,10):null;return r!=null&&n?`AlphaFold DB v${r} (modelCreatedDate ${n})`:r!=null?`AlphaFold DB v${r}`:n?`AlphaFold DB (modelCreatedDate ${n})`:null}function lj(e,r,n,s){return e.map((i,c)=>{const d=ka(i.CID),f=d!==null&&Number.isInteger(d)&&d>0?d:null,p=typeof i.Title=="string"&&i.Title.trim()?i.Title.trim():f!==null?`PubChem CID ${f}`:`Compound #${c+1}`,b=ka(i.MolecularWeight),x=typeof i.MolecularFormula=="string"?i.MolecularFormula:null,g=ij(i),_=ka(i.TPSA),y=ka(i.XLogP),S=[];return f!==null&&S.push(`CID ${f}`),_!==null&&S.push(`TPSA ${_} Ų`),y!==null&&S.push(`XLogP ${y}`),{source:"pubchem",id:f!==null?String(f):p,title:p,subtitle:S.length>0?S.join(" · "):void 0,organism:null,length:null,formula:x,smiles:g,molecularWeight:b,downloadUrl:null,sourceUrl:f!==null?sj(f):s??"https://pubchem.ncbi.nlm.nih.gov/",license:ts.pubchem,origin:r,retrievedAtUtc:n,raw:i}})}function hk(e,r,n,s){const i=typeof e.uniprotAccession=="string"?e.uniprotAccession:r,c=yh(i)??r,d=typeof e.entryId=="string"&&e.entryId.trim()?e.entryId.trim():`AF-${c}-F1`,f=typeof e.uniprotDescription=="string"&&e.uniprotDescription.trim()?e.uniprotDescription.trim():typeof e.proteinName=="string"&&e.proteinName.trim()?e.proteinName.trim():`AlphaFold DB model ${d}`,p=oj(e),b=typeof e.gene=="string"&&e.gene.trim()?e.gene.trim():null,g=[typeof e.uniprotId=="string"&&e.uniprotId.trim()?e.uniprotId.trim():null,b?`Gene: ${b}`:null,p].filter(Boolean),_=ka(e.uniprotEnd)??ka(e.sequenceEnd)??null;return{source:"alphafold",id:d,title:f,subtitle:g.length>0?g.join(" · "):void 0,organism:typeof e.organismScientificName=="string"?e.organismScientificName:null,length:_,downloadUrl:typeof e.cifUrl=="string"?e.cifUrl:null,sourceUrl:tj(c),license:ts.alphafold,origin:n,retrievedAtUtc:s,uniprotAccession:c,dataRevision:p,raw:e}}function Nz(e){return{source:e.source,id:e.id,title:e.title,subtitle:`${e.dataRevision} · UniProt ${e.uniprotAccession}`,organism:null,length:null,downloadUrl:e.sourceUrl,sourceUrl:e.sourceUrl,license:e.license,origin:"pinned-local-cache",retrievedAtUtc:e.retrievedAtUtc,uniprotAccession:e.uniprotAccession,dataRevision:e.dataRevision,pinnedFileName:e.fileName,pinnedPaeFileName:e.paeFileName,expectedSha256:e.sha256}}function Az(e){return{source:"uniprot",id:e.id,title:e.title,subtitle:`Pinned manifest link · PDB ${e.relatedPdbId} · ${e.relatedAfId}`,organism:null,length:null,downloadUrl:null,sourceUrl:nj(e.id),license:ts.uniprot,origin:"pinned-local-cache",retrievedAtUtc:e.retrievedAtUtc,uniprotAccession:e.id}}function jz(e,r){const n=r.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e;const s=[];for(const i of e){const c=[i.id,i.title,i.subtitle??"",i.uniprotAccession??"",i.formula??"",i.pinnedFileName??""].join(" ").toLowerCase();let d=0;for(const f of n)c.includes(f)&&(d+=1);if(d>0){const f=i.id.toLowerCase()===r.trim().toLowerCase()?10:0;s.push({record:i,score:d+f})}}return s.sort((i,c)=>c.score-i.score),s.map(i=>i.record)}async function Ix(e,r,n,s){let i=[],c="";if(e==="rcsb"||e==="alphafold")i=Mr.structures.filter(x=>x.source===e).map(Nz);else if(e==="uniprot")i=Mr.uniprot.map(Az);else if(e==="opentargets")i=[],c=" Open Targets requires live network access (no offline target-disease dataset bundled).";else{const g=`${rj(s?.fixturesBaseUrl)}${Mr.pubchemPanel.fileName}`;let _=!1;try{const y=s?.fetchImpl??globalThis.fetch;if(typeof y=="function"){const S=await y(g,{signal:s?.signal});if(S.ok){const E=(await S.json())?.PropertyTable?.Properties;Array.isArray(E)&&E.length>0&&(i=lj(E,"pinned-local-cache",Mr.pubchemPanel.retrievedAtUtc,Mr.pubchemPanel.sourceUrl),_=!0)}}}catch{}_||(i=Mr.pubchemPanel.compounds.map(y=>({source:"pubchem",id:String(y.cid),title:y.name,subtitle:`CID ${y.cid} · Pinned name/CID list only (properties unavailable offline)`,organism:null,length:null,formula:null,smiles:null,molecularWeight:null,downloadUrl:null,sourceUrl:sj(y.cid),license:ts.pubchem,origin:"pinned-local-cache",retrievedAtUtc:Mr.pubchemPanel.retrievedAtUtc})),c=" PubChem panel JSON was unreachable; displaying CID and compound name only.")}const d=r.trim(),f=d?jz(i,d):i,p=f.length>0?f:i,b=d&&f.length===0?` No pinned fixture matched "${d}"; showing all ${i.length} curated local entries.`:"";return{records:p,origin:"pinned-local-cache",warning:`${n}${c}${b}`.trim()}}async function Tz(e,r){return Ix(e,"","Showing pinned local fixture cache.",r)}async function Ez(e,r){const n=il(r),s=Dr(r),i=_z(),c=await n(i,{method:"POST",headers:{"Content-Type":"application/json"},body:vz(e),signal:r?.signal});if(c.status===204)return[];if(!c.ok)throw new ys(c.status,i);const d=await c.json(),f=Array.isArray(d?.result_set)?d.result_set:[],p=[];for(const x of f)if(typeof x?.identifier=="string"&&gz(x.identifier)){const g=bh(x.identifier);if(p.includes(g)||p.push(g),p.length>=Up)break}return p.length===0?[]:await Promise.all(p.map(async x=>{const g=wz(x);try{const _=await n(g,{signal:r?.signal});if(!_.ok){if(_.status===429||_.status>=500)throw new ys(_.status,g);return{source:"rcsb",id:x,title:`PDB Entry ${x}`,organism:null,length:null,downloadUrl:np(x),sourceUrl:sp(x),license:ts.rcsb,origin:"live-network",retrievedAtUtc:s,dataRevision:null}}const y=await _.json(),S=y?.struct?.title?.trim()||`PDB Entry ${x}`,k=y?.exptl?.[0]?.method??y?.rcsb_entry_info?.experimental_method,E=y?.rcsb_entry_info?.resolution_combined?.[0],T=[];typeof k=="string"&&k&&T.push(k),typeof E=="number"&&Number.isFinite(E)&&T.push(`${E.toFixed(2)} Å`);const j=y?.rcsb_accession_info?.revision_date,q=typeof j=="string"&&j.length>=10?`PDB ${x} (${j.slice(0,10)})`:null;return{source:"rcsb",id:x,title:S,subtitle:T.length>0?T.join(" · "):void 0,organism:null,length:null,downloadUrl:np(x),sourceUrl:sp(x),license:ts.rcsb,origin:"live-network",retrievedAtUtc:s,dataRevision:q,raw:y}}catch(_){if(_ instanceof ys&&(_.status===429||_.status>=500)||Gp(_,r?.signal))throw _;return{source:"rcsb",id:x,title:`PDB Entry ${x}`,organism:null,length:null,downloadUrl:np(x),sourceUrl:sp(x),license:ts.rcsb,origin:"live-network",retrievedAtUtc:s,dataRevision:null}}}))}async function mk(e,r){const n=il(r),s=ej(e),i=await n(s,{signal:r?.signal});if(i.status===404)return[];if(!i.ok)throw new ys(i.status,s);const c=await i.json();return Array.isArray(c)?c.filter(d=>!!(d&&typeof d=="object")):c&&typeof c=="object"?[c]:[]}async function cj(e,r){const n=il(r),s=Dr(r),i=Sz(e),c=await n(i,{signal:r?.signal});if(!c.ok)throw new ys(c.status,i);const d=await c.json(),f=Array.isArray(d?.results)?d.results:[],p=[];for(const b of f){const x=typeof b.primaryAccession=="string"?b.primaryAccession:"",g=yh(x);if(!g)continue;const _=typeof b.uniProtkbId=="string"?b.uniProtkbId:null,y=b.proteinDescription,S=y?.recommendedName?.fullName?.value??y?.submissionNames?.[0]?.fullName?.value??y?.alternativeNames?.[0]?.fullName?.value??(typeof b.proteinName=="string"?b.proteinName:null)??_??g,E=b.organism?.scientificName??(typeof b.organismName=="string"?b.organismName:null)??null,T=b.sequence,j=ka(T?.length??b.length),z=b.genes?.[0]?.geneName?.value??(typeof b.geneName=="string"?b.geneName:null)??null,O=[_,z?`Gene: ${z}`:null].filter(Boolean);p.push({source:"uniprot",id:g,title:S,subtitle:O.length>0?O.join(" · "):void 0,organism:E,length:j,downloadUrl:null,sourceUrl:nj(g),license:ts.uniprot,origin:"live-network",retrievedAtUtc:s,uniprotAccession:g,raw:b})}return p}async function Mz(e,r){const n=Dr(r),s=yh(e);if(s)return(await mk(s,r)).map(p=>hk(p,s,"live-network",n));const c=(await cj(e,r)).slice(0,5).map(f=>f.id),d=[];for(const f of c)try{const p=await mk(f,r);for(const b of p)d.push(hk(b,f,"live-network",n))}catch(p){if(p instanceof ys&&(p.status===429||p.status>=500)||Gp(p,r?.signal))throw p}return d}async function Rz(e,r){const n=il(r),s=Dr(r),i=kz(e),c=await n(i,{signal:r?.signal});if(c.status===404)return[];if(!c.ok)throw new ys(c.status,i);const d=await c.json(),f=Array.isArray(d?.PropertyTable?.Properties)?d.PropertyTable.Properties:[];return lj(f,"live-network",s,i)}async function zz(e,r){const n=il(r),s=Dr(r),i=`https://www.ebi.ac.uk/chembl/api/data/molecule/search.json?q=${encodeURIComponent(e)}&limit=${Up}`,c=await n(i,{signal:r?.signal});if(c.status===404)return[];if(!c.ok)throw new ys(c.status,i);const d=await c.json();return(Array.isArray(d?.molecules)?d.molecules:[]).map(p=>{const b=String(p.molecule_chembl_id??""),x=typeof p.pref_name=="string"&&p.pref_name.trim()?p.pref_name.trim():b,g=p.molecule_structures??{},_=p.molecule_properties??{},y=typeof g.canonical_smiles=="string"?g.canonical_smiles:null,S=typeof _.full_molformula=="string"?_.full_molformula:null,k=ka(_.full_mwt),E=ka(p.max_phase);return{source:"chembl",id:b,title:x,subtitle:[b,E!==null?`Max Phase ${E}`:null].filter(Boolean).join(" · "),organism:null,length:null,formula:S,smiles:y,molecularWeight:k,downloadUrl:null,sourceUrl:`https://www.ebi.ac.uk/chembl/compound_report_card/${encodeURIComponent(b)}/`,license:ts.chembl,origin:"live-network",retrievedAtUtc:s,raw:p}})}async function Oz(e,r){const n=il(r),s=Dr(r),i="https://api.platform.opentargets.org/api/v4/graphql",d=await n(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`query SearchTargets($q: String!) {
511
+ search(queryString: $q, entityNames: ["target"], page: { index: 0, size: 8 }) {
512
+ hits { id name description }
513
+ }
514
+ }`,variables:{q:e}}),signal:r?.signal});if(!d.ok)throw new ys(d.status,i);return((await d.json())?.data?.search?.hits??[]).map(b=>({source:"opentargets",id:b.id,title:b.name||b.id,subtitle:b.description||`Ensembl target ${b.id}`,organism:"Homo sapiens",length:null,downloadUrl:null,sourceUrl:`https://platform.opentargets.org/target/${encodeURIComponent(b.id)}`,license:ts.opentargets,origin:"live-network",retrievedAtUtc:s,raw:b}))}async function Iy(e,r,n){if(aj(n)){const i=n?.offline?"Offline mode enabled — searching pinned local fixture cache.":"Browser reports offline — searching pinned local fixture cache.";return Ix(e,r,i,n)}const s=Bp(r);try{let i;return e==="rcsb"?i=await Ez(s,n):e==="alphafold"?i=await Mz(s,n):e==="uniprot"?i=await cj(s,n):e==="chembl"?i=await zz(s,n):e==="opentargets"?i=await Oz(s,n):i=await Rz(s,n),{records:i,origin:"live-network"}}catch(i){if(Gp(i,n?.signal)||!Cz(i))throw i;const c=i instanceof Error?i.message:"Network error";return Ix(e,s,`Live ${$x[e]} request fell back to pinned local cache (${c}).`,n)}}async function Pz(e,r){const n=xh(e);return Iy("alphafold",n,r)}function $z(e){if(e.pinnedFileName)return Mr.structures.find(s=>s.fileName===e.pinnedFileName);const r=e.id.trim().toUpperCase(),n=e.uniprotAccession??yh(e.id);return Mr.structures.find(s=>s.id.toUpperCase()===r||e.source==="alphafold"&&n&&s.source==="alphafold"&&s.uniprotAccession===n||e.source==="uniprot"&&n&&s.source==="alphafold"&&s.uniprotAccession===n)}async function uj(e,r){if(e.source==="pubchem"||e.source==="chembl"||e.source==="opentargets")throw new Error(`Cannot import a ${e.source} record directly as a 3D structure.`);const n=il(r),s=[];if(e.origin==="pinned-local-cache"||aj(r)){const T=$z(e),j=e.pinnedFileName??T?.fileName;if(!j)throw new Error(`No pinned local fixture is available for "${e.id}" while offline.`);const q=rj(r?.fixturesBaseUrl),z=`${q}${j}`,O=await n(z,{signal:r?.signal});if(!O.ok)throw new ys(O.status,z);const{bytes:V,text:P}=await rd(O,z),$=await ad(V),H=e.expectedSha256??T?.sha256??null;H&&$!==H&&s.push(`SHA-256 differs from fixtures-manifest.json (expected ${H.slice(0,12)}…, got ${$.slice(0,12)}…).`);let Z=null,G=null;const K=e.pinnedPaeFileName??T?.paeFileName??null;if(K){const Se=`${q}${K}`;try{const Q=await n(Se,{signal:r?.signal});if(Q.ok){const F=await rd(Q,Se);Z=F.text,G=await ad(F.bytes)}else s.push(`Pinned PAE matrix (${K}) returned HTTP ${Q.status}.`)}catch(Q){if(Gp(Q,r?.signal))throw Q;s.push(`Pinned PAE matrix (${K}) could not be loaded.`)}}const we=e.source==="alphafold"||e.source==="uniprot"||T?.source==="alphafold"?"prediction":"experimental";return{label:j,content:P,sha256:$,sourceUrl:e.sourceUrl||T?.sourceUrl||z,downloadUrl:e.downloadUrl??T?.sourceUrl??z,license:e.license||T?.license||(we==="prediction"?ts.alphafold:ts.rcsb),retrievedAtUtc:e.retrievedAtUtc||T?.retrievedAtUtc||Dr(r),dataRevision:e.dataRevision??T?.dataRevision??null,origin:"pinned-local-cache",sourceTypeHint:we,paeJson:Z,paeSha256:G,uniprotAccession:e.uniprotAccession??T?.uniprotAccession??void 0,byteLength:V.byteLength,warnings:s}}if(e.source==="rcsb"){const T=bh(e.id),j=e.downloadUrl||np(T),q=await n(j,{signal:r?.signal});if(!q.ok)throw new ys(q.status,j);const{bytes:z,text:O}=await rd(q,j),V=await ad(z),P=Dr(r);return{label:`${T}.cif`,content:O,sha256:V,sourceUrl:e.sourceUrl||sp(T),downloadUrl:j,license:e.license||ts.rcsb,retrievedAtUtc:P,dataRevision:e.dataRevision??null,origin:"live-network",sourceTypeHint:"experimental",paeJson:null,paeSha256:null,uniprotAccession:e.uniprotAccession??void 0,byteLength:z.byteLength,warnings:s}}const i=e.uniprotAccession??yh(e.id)??xh(e.id);let c=e.raw&&typeof e.raw=="object"&&typeof e.raw.cifUrl=="string"?e.raw:null;if(!c){const T=ej(i),j=await n(T,{signal:r?.signal});if(!j.ok)throw new ys(j.status,T);const q=await j.json(),O=(Array.isArray(q)?q:[q])[0];if(!O||typeof O!="object"||typeof O.cifUrl!="string")throw new Error(`AlphaFold prediction API did not return a cifUrl for ${i}.`);c=O}const d=String(c.cifUrl),f=await n(d,{signal:r?.signal});if(!f.ok)throw new ys(f.status,d);const{bytes:p,text:b}=await rd(f,d),x=await ad(p);let g=null,_=null;const y=typeof c.paeDocUrl=="string"&&c.paeDocUrl?c.paeDocUrl:null;if(y){const T=await n(y,{signal:r?.signal});if(T.ok){const j=await rd(T,y);g=j.text,_=await ad(j.bytes)}else s.push(`AlphaFold PAE fetch returned HTTP ${T.status}; imported structure without PAE matrix.`)}const S=typeof c.entryId=="string"&&c.entryId.trim()?c.entryId.trim():`AF-${i}-F1`,k=oj(c)??e.dataRevision??null,E=Dr(r);return{label:`${S}.cif`,content:b,sha256:x,sourceUrl:e.sourceUrl&&e.source==="alphafold"?e.sourceUrl:tj(i),downloadUrl:d,license:ts.alphafold,retrievedAtUtc:E,dataRevision:k,origin:"live-network",sourceTypeHint:"prediction",paeJson:g,paeSha256:_,uniprotAccession:i,byteLength:p.byteLength,warnings:s}}function dj(e){if(e.source!=="pubchem"&&e.source!=="chembl")throw new Error(`Expected a PubChem or ChEMBL record, got "${e.source}".`);const r=e.raw&&typeof e.raw=="object"?e.raw:null,n=(typeof e.smiles=="string"&&e.smiles.trim()?e.smiles.trim():null)??ij(r);if(!n)throw new Error(`No SMILES string is available for "${e.title}" (live PubChem or /fixtures/pubchem-panel.json required).`);const s=ka(r?.CID??e.id),i=s!==null&&Number.isInteger(s)&&s>0?s:null;return{name:e.title,smiles:n,cid:i,formula:e.formula??(typeof r?.MolecularFormula=="string"?r.MolecularFormula:null),molecularWeight:e.molecularWeight??ka(r?.MolecularWeight)??null,sourceUrl:e.sourceUrl,license:e.license||ts.pubchem,retrievedAtUtc:e.retrievedAtUtc,origin:e.origin}}function se(e,r,n,s,i){if(typeof r=="function"?e!==r||!0:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r.set(e,n),n}function v(e,r,n,s){if(n==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?e!==r||!s:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?s:n==="a"?s.call(e):s?s.value:r.get(e)}function Jo(e){return typeof e=="object"&&e!==null&&("name"in e&&e.name==="AbortError"||"message"in e&&String(e.message).includes("FetchRequestCanceledException"))}const Yd=e=>{if(e instanceof Error)return e;if(typeof e=="object"&&e!==null){try{const r=Object.prototype.toString.call(e);if(r==="[object Error]"||r==="[object DOMException]"){const n=new Error(e.message,e.cause?{cause:e.cause}:{});return e.stack&&(n.stack=e.stack),e.cause&&!n.cause&&(n.cause=e.cause),e.name&&(n.name=e.name),n}}catch{}try{return new Error(JSON.stringify(e))}catch{}}return new Error(e)};var De=(()=>{class e extends Error{constructor(n,s){super(n,s),Object.defineProperty(this,"name",{value:new.target._errorName,writable:!0,configurable:!0})}}return e._errorName="AnthropicError",e})(),Gt=(()=>{class e extends De{constructor(n,s,i,c,d){super(`${e.makeMessage(n,s,i)}`),this.status=n,this.headers=c,this.requestID=c?.get("request-id"),this.workspaceID=c?.get("anthropic-workspace-id"),this.error=s;const f=s??{};this.apiMessage=f.error?.message??null,this.type=d??f.error?.type??null;const p=f.error?.details?.error_code;this.errorCode=typeof p=="string"?p:null,this.details=f.error?.details??null}static makeMessage(n,s,i){const c=s?.message?typeof s.message=="string"?s.message:JSON.stringify(s.message):s?JSON.stringify(s):i;return n&&c?`${n} ${c}`:n?`${n} status code (no body)`:c||"(no status code or body)"}static generate(n,s,i,c){if(!n||!c)return new Hc({message:i,cause:Yd(s)});const d=s,f=Dz.get(n);return f?new f(n,d,i,c):n>=500?new eu(n,d,i,c):new e(n,d,i,c)}}return e._errorName="APIError",e})(),Ls=(()=>{class e extends Gt{constructor({message:n}={}){super(void 0,void 0,n||"Request was aborted.",void 0)}}return e._errorName="APIUserAbortError",e})(),Hc=(()=>{class e extends Gt{constructor({message:n,cause:s}){super(void 0,void 0,n||"Connection error.",void 0),s&&(this.cause=s)}}return e._errorName="APIConnectionError",e})(),Dx=(()=>{class e extends Hc{constructor({message:n}={}){super({message:n??"Request timed out."})}}return e._errorName="APIConnectionTimeoutError",e})(),Iz=(()=>{class e extends De{constructor(n,{cause:s}={}){super(n??"Retryable error."),s!==void 0&&(this.cause=s)}}return e._errorName="RetryableError",e})(),Ye=(()=>{class e extends Gt{}return e._errorName="BadRequestError",e})(),hj=(()=>{class e extends Gt{}return e._errorName="AuthenticationError",e})(),vs=(()=>{class e extends Gt{}return e._errorName="PermissionDeniedError",e})(),Zc=(()=>{class e extends Gt{}return e._errorName="NotFoundError",e})(),mj=(()=>{class e extends Gt{}return e._errorName="RequestTimeoutError",e})(),Vr=(()=>{class e extends Gt{}return e._errorName="ConflictError",e})(),Dy=(()=>{class e extends Gt{}return e._errorName="PreconditionFailedError",e})(),qy=(()=>{class e extends Gt{}return e._errorName="ContentTooLargeError",e})(),fj=(()=>{class e extends Gt{}return e._errorName="UnprocessableEntityError",e})(),Hp=(()=>{class e extends Gt{}return e._errorName="RateLimitError",e})(),pj=(()=>{class e extends Gt{}return e._errorName="RequestHeaderFieldsTooLargeError",e})(),gj=(()=>{class e extends Gt{}return e._errorName="ClientClosedRequestError",e})(),eu=(()=>{class e extends Gt{}return e._errorName="InternalServerError",e})(),bj=(()=>{class e extends eu{}return e._errorName="NotImplementedError",e})(),_h=(()=>{class e extends eu{}return e._errorName="ServiceUnavailableError",e})(),xj=(()=>{class e extends eu{}return e._errorName="GatewayTimeoutError",e})(),Ly=(()=>{class e extends eu{}return e._errorName="OverloadedError",e})();const Dz=new Map([[400,Ye],[401,hj],[403,vs],[404,Zc],[408,mj],[409,Vr],[412,Dy],[413,qy],[422,fj],[429,Hp],[431,pj],[499,gj],[501,bj],[503,_h],[504,xj],[529,Ly]]),qz=/^[a-z][a-z0-9+.-]*:/i,Lz=e=>qz.test(e);let xs=e=>(xs=Array.isArray,xs(e)),qx=xs;function rh(e){return typeof e!="object"?{}:e??{}}function fk(e){if(!e)return!0;for(const r in e)return!1;return!0}function Uz(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function Hn(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}const zb=(e,r)=>{if(typeof r!="number"||!Number.isInteger(r))throw new De(`${e} must be an integer`);if(r<0)throw new De(`${e} must be a positive integer`);return r},ic=["apiKey","authToken","credentials","config","profile"],yj=e=>{try{return JSON.parse(e)}catch{return}};const Ko=(e,r)=>new Promise(n=>{if(r?.aborted)return n();const s=()=>{clearTimeout(i),n()},i=setTimeout(()=>{r?.removeEventListener("abort",s),n()},e);r?.addEventListener("abort",s,{once:!0})}),Pr="1.8.0",Bz=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Gz(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}const Hz=()=>{const e=Gz();if(e==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Pr,"X-Stainless-OS":gk(Deno.build.os),"X-Stainless-Arch":pk(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Pr,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if(e==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Pr,"X-Stainless-OS":gk(globalThis.process.platform??"unknown"),"X-Stainless-Arch":pk(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};const r=Fz();return r?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Pr,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${r.browser}`,"X-Stainless-Runtime-Version":r.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":Pr,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Fz(){if(typeof navigator>"u"||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:r,pattern:n}of e){const s=n.exec(navigator.userAgent);if(s){const i=s[1]||0,c=s[2]||0,d=s[3]||0;return{browser:r,version:`${i}.${c}.${d}`}}}return null}const pk=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarch64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",gk=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Android":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Other:${e}`:"Unknown");let bk;const Uy=()=>bk??(bk=Hz()),bp=new WeakMap,_j=typeof globalThis.FinalizationRegistry=="function"?new globalThis.FinalizationRegistry(e=>Yo(e)):null;function Vz(e,r){return()=>e.removeEventListener("abort",r)}function Kz(e,r,n){bp.set(e,Vz(r,n))}function Yz(e,r){bp.has(r)&&_j?.register(e,r,r)}function Yo(e){const r=bp.get(e);r&&(bp.delete(e),_j?.unregister(e),r())}function Wz(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function vj(...e){const r=globalThis.ReadableStream;if(typeof r>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new r(...e)}function wj(e){let r=Symbol.asyncIterator in e?e[Symbol.asyncIterator]():e[Symbol.iterator]();return vj({start(){},async pull(n){const{done:s,value:i}=await r.next();s?n.close():n.enqueue(i)},async cancel(){await r.return?.()}})}function Xz(e){if(e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();const r=e.getReader();return{async next(){try{const n=await r.read();return n?.done&&r.releaseLock(),n}catch(n){throw r.releaseLock(),n}},async return(){const n=r.cancel();return r.releaseLock(),await n,{done:!0,value:void 0}}}}const xk=typeof FinalizationRegistry>"u"?void 0:new FinalizationRegistry(async e=>{try{await e.return?.()}catch{}});async function*By(e){const r=Xz(e),n={};xk?.register(n,r,n);try{for await(const s of{[Symbol.asyncIterator]:()=>r})yield s}finally{xk?.unregister(n)}}async function Qz(e){if(e===null||typeof e!="object")return;if(e[Symbol.asyncIterator]){await e[Symbol.asyncIterator]().return?.();return}const r=e.getReader(),n=r.cancel();r.releaseLock(),await n}const Jz=({headers:e,body:r})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(r)}),Fc="1.10.0",yk=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Zz(e){const r=new Set([e]),n=new Set,s=e.match(yk);if(!s)return()=>!1;const i={major:+s[1],minor:+s[2],patch:+s[3],prerelease:s[4]};if(i.prerelease!=null)return function(p){return p===e};function c(f){return n.add(f),!1}function d(f){return r.add(f),!0}return function(p){if(r.has(p))return!0;if(n.has(p))return!1;const b=p.match(yk);if(!b)return c(p);const x={major:+b[1],minor:+b[2],patch:+b[3],prerelease:b[4]};return x.prerelease!=null||i.major!==x.major?c(p):i.major===0?i.minor===x.minor&&i.patch<=x.patch?d(p):c(p):i.minor<=x.minor?d(p):c(p)}}const eO=Zz(Fc),tO=Fc.split(".")[0],xp=Symbol.for(`opentelemetry.js.api.${tO}`),yp=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{};function nO(){return Object.defineProperty({},"version",{value:Fc,enumerable:!0,writable:!1,configurable:!1})}function Fp(e,r,n,s=!1){var i;const c=yp[xp]=(i=yp[xp])!==null&&i!==void 0?i:nO();if(!s&&c[e]){const d=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(d.stack||d.message),!1}if(c.version!=="1.10.0"){const d=new Error(`@opentelemetry/api: Registration of version v${c.version} for ${e} does not match previously registered API v${Fc}`);return n.error(d.stack||d.message),!1}return c[e]=r,n.debug(`@opentelemetry/api: Registered a global for ${e} v${Fc}.`),!0}let _k;function Vc(e){const r=yp[xp];if(r!=null){if(r!==_k){if(!r.version||!eO(r.version))return;_k=r}return r[e]}}function Vp(e,r){r.debug(`@opentelemetry/api: Unregistering a global for ${e} v${Fc}.`);const n=yp[xp];n&&delete n[e]}var sO=class{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return id("debug",this._namespace,e)}error(...e){return id("error",this._namespace,e)}info(...e){return id("info",this._namespace,e)}warn(...e){return id("warn",this._namespace,e)}verbose(...e){return id("verbose",this._namespace,e)}};function id(e,r,n){const s=Vc("diag");if(s)return s[e](r,...n)}function aO(e,r){e<0?e=0:e>9999&&(e=9999),r=r||{};function n(s,i){const c=r[s];return typeof c=="function"&&e>=i?c.bind(r):function(){}}return{error:n("error",30),warn:n("warn",50),info:n("info",60),debug:n("debug",70),verbose:n("verbose",80)}}const rO="diag";var Li=class Sj{static instance(){return this._instance||(this._instance=new Sj),this._instance}constructor(){function r(i){return function(...c){const d=Vc("diag");if(d)return d[i](...c)}}const n=this,s=(i,c={logLevel:60})=>{var d;if(i===n){var f;const g=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((f=g.stack)!==null&&f!==void 0?f:g.message),!1}typeof c=="number"&&(c={logLevel:c});const p=Vc("diag"),b=aO((d=c.logLevel)!==null&&d!==void 0?d:60,i);if(p&&!c.suppressOverrideMessage){var x;const g=(x=new Error().stack)!==null&&x!==void 0?x:"<failed to generate stacktrace>";p.warn(`Current logger will be overwritten from ${g}`),b.warn(`Current logger will overwrite one already registered from ${g}`)}return Fp("diag",b,n,!0)};n.setLogger=s,n.disable=()=>{Vp(rO,n)},n.createComponentLogger=i=>new sO(i),n.verbose=r("verbose"),n.debug=r("debug"),n.info=r("info"),n.warn=r("warn"),n.error=r("error")}},iO=class Ld{constructor(r){this._entries=r?new Map(r):new Map}getEntry(r){const n=this._entries.get(r);if(n)return Object.assign({},n)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(r,n){const s=new Ld(this._entries);return s._entries.set(r,n),s}removeEntry(r){const n=new Ld(this._entries);return n._entries.delete(r),n}removeEntries(...r){const n=new Ld(this._entries);for(const s of r)n._entries.delete(s);return n}clear(){return new Ld}};Li.instance();function oO(e={}){return new iO(new Map(Object.entries(e)))}function kj(e){return Symbol.for(e)}const lO=new class Lx{constructor(r){const n=this;n._currentContext=r?new Map(r):new Map,n.getValue=s=>n._currentContext.get(s),n.setValue=(s,i)=>{const c=new Lx(n._currentContext);return c._currentContext.set(s,i),c},n.deleteValue=s=>{const i=new Lx(n._currentContext);return i._currentContext.delete(s),i}}},cO={get(e,r){if(e!=null)return e[r]},keys(e){return e==null?[]:Object.keys(e)}},uO={set(e,r,n){e!=null&&(e[r]=n)}},dO="0000000000000000",hO="00000000000000000000000000000000",mO={traceId:hO,spanId:dO,traceFlags:0};var Wd=class{constructor(e=mO){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,r){return this}setAttributes(e){return this}addEvent(e,r){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,r){}};const tf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function Cj(e,r){if(typeof e!="string"||e.length!==r)return!1;let n=0;for(let s=0;s<e.length;s+=4)n+=(tf[e.charCodeAt(s)]|0)+(tf[e.charCodeAt(s+1)]|0)+(tf[e.charCodeAt(s+2)]|0)+(tf[e.charCodeAt(s+3)]|0);return n===r}function fO(e){return Cj(e,32)&&e!=="00000000000000000000000000000000"}function pO(e){return Cj(e,16)&&e!=="0000000000000000"}function Nj(e){return fO(e.traceId)&&pO(e.spanId)}function gO(e){return new Wd(e)}var bO=class{active(){return lO}with(e,r,n,...s){return r.call(n,...s)}bind(e,r){return r}enable(){return this}disable(){return this}attach(e){return{dispose(){}}}};const Ob="context",xO=new bO,yO=Object.freeze({dispose:()=>{}});var Kp=class Aj{constructor(){this._attachUnsupportedWarned=!1}static getInstance(){return this._instance||(this._instance=new Aj),this._instance}setGlobalContextManager(r){return Fp(Ob,r,Li.instance())}active(){return this._getContextManager().active()}with(r,n,s,...i){return this._getContextManager().with(r,n,s,...i)}bind(r,n){return this._getContextManager().bind(r,n)}attach(r){const n=this._getContextManager();return n.attach?n.attach(r):(this._attachUnsupportedWarned||(this._attachUnsupportedWarned=!0,Li.instance().warn("The current ContextManager does not implement attach(). The context will not be attached. Use a ContextManager that supports attach() (e.g. AsyncLocalStorageContextManager) or use with()/bind() instead.")),yO)}_getContextManager(){return Vc(Ob)||xO}disable(){this._getContextManager().disable(),Vp(Ob,Li.instance())}};const Gy=kj("OpenTelemetry Context Key SPAN");function Hy(e){return e.getValue(Gy)||void 0}function _O(){return Hy(Kp.getInstance().active())}function Fy(e,r){return e.setValue(Gy,r)}function vO(e){return e.deleteValue(Gy)}function wO(e,r){return Fy(e,new Wd(r))}function jj(e){var r;return(r=Hy(e))===null||r===void 0?void 0:r.spanContext()}const Pb=Kp.getInstance();var Tj=class{startSpan(e,r,n=Pb.active()){if(r?.root)return new Wd;const s=n&&jj(n);return SO(s)&&Nj(s)?new Wd(s):new Wd}startActiveSpan(e,r,n,s){var i;let c,d,f;if(arguments.length<2)return;arguments.length===2?f=r:arguments.length===3?(c=r,f=n):(c=r,d=n,f=s);const p=(i=d)!==null&&i!==void 0?i:Pb.active(),b=this.startSpan(e,c,p),x=Fy(p,b);return Pb.with(x,f,void 0,b)}};function SO(e){return e!==null&&typeof e=="object"&&"spanId"in e&&typeof e.spanId=="string"&&"traceId"in e&&typeof e.traceId=="string"&&"traceFlags"in e&&typeof e.traceFlags=="number"}const kO=new Tj;var CO=class{constructor(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}startSpan(e,r,n){return this._getTracer().startSpan(e,r,n)}startActiveSpan(e,r,n,s){const i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;const e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):kO}};let Yp=(function(e){return e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER",e})({}),ol=(function(e){return e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e})({});var NO=class{getTracer(e,r,n){return new Tj}};const AO=new NO;var vk=class{getTracer(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new CO(this,e,r,n)}getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:AO}setDelegate(e){this._delegate=e}getDelegateTracer(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)}};const Hs=Kp.getInstance();var jO=class{inject(e,r){}extract(e,r){return e}fields(){return[]}};const Vy=kj("OpenTelemetry Baggage Key");function Ej(e){return e.getValue(Vy)||void 0}function TO(){return Ej(Kp.getInstance().active())}function EO(e,r){return e.setValue(Vy,r)}function MO(e){return e.deleteValue(Vy)}const $b="propagation",RO=new jO;var zO=class Mj{constructor(){this.createBaggage=oO,this.getBaggage=Ej,this.getActiveBaggage=TO,this.setBaggage=EO,this.deleteBaggage=MO}static getInstance(){return this._instance||(this._instance=new Mj),this._instance}setGlobalPropagator(r){return Fp($b,r,Li.instance())}inject(r,n,s=uO){return this._getGlobalPropagator().inject(r,n,s)}extract(r,n,s=cO){return this._getGlobalPropagator().extract(r,n,s)}fields(){return this._getGlobalPropagator().fields()}disable(){Vp($b,Li.instance())}_getGlobalPropagator(){return Vc($b)||RO}};const Rj=zO.getInstance(),Ib="trace";var OO=class zj{constructor(){this._proxyTracerProvider=new vk,this.wrapSpanContext=gO,this.isSpanContextValid=Nj,this.deleteSpan=vO,this.getSpan=Hy,this.getActiveSpan=_O,this.getSpanContext=jj,this.setSpan=Fy,this.setSpanContext=wO}static getInstance(){return this._instance||(this._instance=new zj),this._instance}setGlobalTracerProvider(r){const n=Fp(Ib,this._proxyTracerProvider,Li.instance());return n&&this._proxyTracerProvider.setDelegate(r),n}getTracerProvider(){return Vc(Ib)||this._proxyTracerProvider}getTracer(r,n){return this.getTracerProvider().getTracer(r,n)}disable(){Vp(Ib,Li.instance()),this._proxyTracerProvider=new vk}};const ll=OO.getInstance();function PO(e){let r=0;for(const i of e)r+=i.length;const n=new Uint8Array(r);let s=0;for(const i of e)n.set(i,s),s+=i.length;return n}let wk;function Ky(e){let r;return(wk??(r=new globalThis.TextEncoder,wk=r.encode.bind(r)))(e)}let Sk;function Ux(e){let r;return(Sk??(r=new globalThis.TextDecoder,Sk=r.decode.bind(r)))(e)}var Rs,zs,Oj=(()=>{class e{constructor(){Rs.set(this,void 0),zs.set(this,void 0),se(this,Rs,new Uint8Array),se(this,zs,null)}decode(n){if(n==null)return[];const s=n instanceof ArrayBuffer?new Uint8Array(n):typeof n=="string"?Ky(n):n;se(this,Rs,PO([v(this,Rs,"f"),s]));const i=[];let c;for(;(c=$O(v(this,Rs,"f"),v(this,zs,"f")))!=null;){if(c.carriage&&v(this,zs,"f")==null){se(this,zs,c.index);continue}if(v(this,zs,"f")!=null&&(c.index!==v(this,zs,"f")+1||c.carriage)){i.push(Ux(v(this,Rs,"f").subarray(0,v(this,zs,"f")-1))),se(this,Rs,v(this,Rs,"f").subarray(v(this,zs,"f"))),se(this,zs,null);continue}const d=v(this,zs,"f")!==null?c.preceding-1:c.preceding,f=Ux(v(this,Rs,"f").subarray(0,d));i.push(f),se(this,Rs,v(this,Rs,"f").subarray(c.index)),se(this,zs,null)}return i}flush(){return v(this,Rs,"f").length?this.decode(`
515
+ `):[]}}return Rs=new WeakMap,zs=new WeakMap,e.NEWLINE_CHARS=new Set([`
516
+ `,"\r"]),e.NEWLINE_REGEXP=/\r\n|[\n\r]/g,e})();function $O(e,r){for(let i=r??0;i<e.length;i++){if(e[i]===10)return{preceding:i,index:i+1,carriage:!1};if(e[i]===13)return{preceding:i,index:i+1,carriage:!0}}return null}var IO={};const ot=e=>{if(typeof globalThis.process<"u")return IO?.[e]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()||void 0},_p="warn",vp={off:0,error:200,warn:300,info:400,debug:500},Bx=(e,r,n)=>{if(e){if(Uz(vp,e))return e;n.warn(`${r} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(vp))}`)}};function Tc(){}function nf(e,r,n){return!r||vp[e]>vp[n]?Tc:r[e].bind(r)}const DO={error:Tc,warn:Tc,info:Tc,debug:Tc};let kk=new WeakMap;function Gx(e,r){const n=kk.get(e);if(n&&n[0]===r)return n[1];const s={error:nf("error",e,r),warn:nf("warn",e,r),info:nf("info",e,r),debug:nf("debug",e,r)};return kk.set(e,[r,s]),s}function it(e){const r=e.logger,n=e.logLevel??"off";return r?Gx(r,n):DO}let Ck,Db;function Pj(){const e=ot("ANTHROPIC_LOG");return(!Db||e!==Ck)&&(Ck=e,Db=Gx(console,Bx(e,"process.env['ANTHROPIC_LOG']",Gx(console,_p))??_p)),Db}function $i(e,r,n){e.debug!==Tc&&e.debug(r,qO(n))}const qO=e=>(e.options&&(e.options={...e.options},delete e.options.headers,delete e.options.__span),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([r,n])=>[r,r.toLowerCase()==="authorization"||r.toLowerCase()==="proxy-authorization"||r.toLowerCase()==="api-key"||r.toLowerCase()==="x-api-key"||r.toLowerCase()==="x-amz-security-token"||r.toLowerCase()==="cookie"||r.toLowerCase()==="set-cookie"?"***":n]))),"retryOfRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var od,Hr=(()=>{class e{constructor(n,s,i){this.iterator=n,od.set(this,void 0),this.controller=s,se(this,od,i)}static rawEvents(n,s=new AbortController){return Nk(n,s)}static fromSSEResponse(n,s,i){let c=!1;const d=i?it(i):console;async function*f(){if(c)throw new De("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");c=!0;let p=!1;try{for await(const b of Nk(n,s))if(b.event!=="ping"&&b.event!==null)if(b.event==="error"){const x=yj(b.data)??b.data,g=x?.error?.type;throw new Gt(void 0,x,void 0,n.headers,g)}else{if(!b.data)continue;try{yield JSON.parse(b.data)}catch(x){throw d.error("Could not parse message into JSON:",b.data),d.error("From chunk:",b.raw),x}}p=!0}catch(b){if(Jo(b))return;throw b}finally{p||s.abort(),Yo(s)}}return new e(f,s,i)}static fromReadableStream(n,s,i){let c=!1;async function*d(){const p=new Oj,b=By(n);for await(const x of b)for(const g of p.decode(x))yield g;for(const x of p.flush())yield x}async function*f(){if(c)throw new De("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");c=!0;let p=!1;try{for await(const b of d())p||b&&(yield JSON.parse(b));p=!0}catch(b){if(Jo(b))return;throw b}finally{p||s.abort(),Yo(s)}}return new e(f,s,i)}[(od=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){const n=[],s=[],i=this[Symbol.asyncIterator](),c=d=>({next:()=>{if(d.length===0){const f=i.next();n.push(f),s.push(f)}return d.shift()}});return[new e(()=>c(n),this.controller,v(this,od,"f")),new e(()=>c(s),this.controller,v(this,od,"f"))]}toReadableStream(){const n=this;let s;return vj({async start(){s=n[Symbol.asyncIterator]()},async pull(i){try{const{value:c,done:d}=await s.next();if(d)return i.close();const f=Ky(JSON.stringify(c)+`
517
+ `);i.enqueue(f)}catch(c){i.error(c)}},async cancel(){await s.return?.()}})}}return e})();async function*Nk(e,r){if(!e.body)throw r.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new De("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new De("Attempted to iterate over a response with no body");const n=new TextDecoder("utf-8",{ignoreBOM:!0});let s="",i=null,c=[],d=[];const f=p=>{if(p.charCodeAt(0)===65279&&(p=p.slice(1)),!p){if(!i&&!c.length)return null;const _={event:i,data:c.join(`
518
+ `),raw:d};return i=null,c=[],d=[],_}d.push(p);const b=p.indexOf(":");if(b===0)return null;const x=b===-1?p:p.slice(0,b);if(x!=="event"&&x!=="data")return null;const g=b===-1?"":p.slice(p.charCodeAt(b+1)===32?b+2:b+1);return x==="event"?i=g:c.push(g),null};for await(const p of By(e.body)){if(p==null)continue;s+=n.decode(typeof p=="string"?Ky(p):p,{stream:!0});let b=0;if(s.includes("\r"))for(let x=0;x<s.length;x++){const g=s[x];if(g!==`
519
+ `&&g!=="\r")continue;if(g==="\r"&&x+1===s.length)break;const _=f(s.slice(b,x));g==="\r"&&s[x+1]===`
520
+ `&&x++,b=x+1,_&&(yield _)}else{let x;for(;(x=s.indexOf(`
521
+ `,b))!==-1;){const g=f(s.slice(b,x));b=x+1,g&&(yield g)}}s=s.slice(b)}if(s+=n.decode(),s)for(const p of s.replace(/\r$/,"").split(/\r\n|[\n\r]/)){const b=f(p);b&&(yield b)}}const $j=Symbol.for("brand.privateNullableHeaders");function*LO(e){if(!e)return;if($j in e){const{values:s,nulls:i}=e;yield*s.entries();for(const c of i)yield[c,null];return}let r=!1,n;e instanceof Headers?n=e.entries():qx(e)?n=e:(r=!0,n=Object.entries(e??{}));for(let s of n){const i=s[0];if(typeof i!="string")throw new TypeError("expected header name to be a string");const c=qx(s[1])?s[1]:[s[1]];let d=!1;for(const f of c)f!==void 0&&(r&&!d&&(d=!0,yield[i,ap]),yield[i,f])}}const ap=Symbol("clear"),UO=new Set(["x-stainless-helper"]),Ij=(e,r)=>{const n=e?e.split(",").map(s=>s.trim()).filter(Boolean):[];for(const s of r.split(",").map(i=>i.trim()))s&&!n.includes(s)&&n.push(s);return n.join(", ")},L=e=>{const r=new Headers,n=new Set;for(const s of e){const i=new Set;for(const[c,d]of LO(s)){const f=c.toLowerCase();if(UO.has(f)){if(d===ap)continue;d===null?(r.delete(c),n.add(f)):(r.set(c,Ij(r.get(c),d)),n.delete(f));continue}(d===ap||!i.has(f))&&(r.delete(c),i.add(f),d===ap)||(d===null?(r.delete(c),n.add(f)):(r.append(c,d),n.delete(f)))}}return{[$j]:!0,values:r,nulls:n}},Ak="com.anthropic.sdk.typescript",BO="error.type",Yy="gen_ai.conversation.id",Wp="gen_ai.provider.name",GO="http.request.method",HO="http.request.resend_count",Wy="http.response.status_code",FO="http.route",VO="server.address",KO="server.port",YO="url.full",WO="url.path",XO="url.query",QO="url.scheme",JO="anthropic.session.thread.id",ZO=75e4;function eP(e){const{tracerProvider:r,propagation:n,traces:s}=e===!1?{traces:!1}:e??tP(),{enabled:i,contentMode:c,maxContentBytes:d}=typeof s=="boolean"?{enabled:s}:s??{};return Object.freeze({tracerProvider:r,propagation:n??!0,traces:Object.freeze({enabled:i??!0,contentMode:c==="content"?"content":"metadata_only",maxContentBytes:d!==void 0&&Number.isInteger(d)&&d>=1?d:ZO})})}function tP(){return{propagation:ot("ANTHROPIC_OPEN_TELEMETRY_PROPAGATION")?.toLowerCase()!=="false",traces:{enabled:ot("ANTHROPIC_OPEN_TELEMETRY")?.toLowerCase()!=="false",contentMode:ot("ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE")?.toLowerCase()==="content"?"content":"metadata_only",maxContentBytes:Number(/^\d+$/.exec(ot("ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES")??"")?.[0]??NaN)}}}function nP(e,r,n){if(!e.traces.enabled)return;const s=n!==void 0?`${Ak}.${n}`:Ak;return(e.tracerProvider??ll.getTracerProvider()).getTracer(s,r)}function zt(e,r){try{return r()}catch(n){e&&it(e).debug("could not record telemetry",n);return}}function N(e,r,n,s){if(n?.__span)return n.__span;const i=e._tracer;if(i)return zt(e,()=>{const c=Date.now(),d=s?.attributes?.[JO],f=n?.openTelemetry?.conversationId??(typeof d=="string"?d:void 0),p=i.startSpan(r,{kind:Yp.CLIENT,attributes:{[Wp]:e._genAIProviderName,...iP(e.baseURL),...f!=null?{[Yy]:f}:void 0,...s?.route!=null?{[FO]:s.route}:void 0,...aP(e,r,s?.request),...s?.attributes}});if(!p.isRecording()&&!(e.openTelemetry.propagation?Object.keys(Uj(p)).length>0:ll.isSpanContextValid(p.spanContext())))return;const{request:b,...x}=s??{};return{...x,span:p,name:r,startTime:c}})}function sP(e,r){if(e.createdIDAttribute===void 0||typeof r!="object"||r===null)return;const n=r[e.createdIDField??"id"];typeof n=="string"&&e.span.setAttribute(e.createdIDAttribute,n)}const Xy={"anthropic.messages.create":{constants:{"gen_ai.operation.name":"chat"},request:[["gen_ai.request.model",["model"],"string"],["gen_ai.request.max_tokens",["max_tokens"],"integer"],["gen_ai.request.reasoning.level",["output_config","effort"],"string"],["anthropic.request.service_tier",["service_tier"],"string"],["anthropic.thinking.type",["thinking","type"],"string"],["anthropic.thinking.budget_tokens",["thinking","budget_tokens"],"integer"]],requestHeaders:[["anthropic.beta","anthropic-beta",{array:"string"}]],stream:"gen_ai.request.stream",response:[["gen_ai.response.id",["id"],"string"],["gen_ai.response.model",["model"],"string"],["gen_ai.usage.cache_write.input_tokens",["usage","cache_creation_input_tokens"],"integer"],["gen_ai.usage.cache_read.input_tokens",["usage","cache_read_input_tokens"],"integer"],["anthropic.usage.cache_creation.ephemeral_5m_input_tokens",["usage","cache_creation","ephemeral_5m_input_tokens"],"integer"],["anthropic.usage.cache_creation.ephemeral_1h_input_tokens",["usage","cache_creation","ephemeral_1h_input_tokens"],"integer"],["anthropic.response.service_tier",["usage","service_tier"],"string"],["gen_ai.usage.output_tokens",["usage","output_tokens"],"integer"],["gen_ai.usage.reasoning.output_tokens",["usage","output_tokens_details","thinking_tokens"],"integer"],["anthropic.message.stop_reason",["stop_reason"],"string"]]},"anthropic.messages.count_tokens":{request:[["gen_ai.request.model",["model"],"string"]],response:[["anthropic.message.count_tokens.input_tokens",["input_tokens"],"integer"]]},"anthropic.sessions.create":{request:[["anthropic.session.environment.id",["environment_id"],"string"]],response:[["gen_ai.agent.name",["agent","name"],"string"],["gen_ai.request.model",["agent","model","id"],"string"]]}};function aP(e,r,n){const s=Xy[r];if(!s)return{};const i={...s.constants};for(const[d,f,p]of s.request??[]){const b=zt(e,()=>Qy(qj(n?.body,f),p));b!==void 0&&(i[d]=b)}const{requestHeaders:c}=s;return c&&zt(e,()=>{const d=L([e._options.defaultHeaders,n?.headers]).values;for(const[f,p,b]of c){const x=rP(d.get(p),b);x!==void 0&&(i[f]=x)}}),s.stream!==void 0&&n?.stream&&(i[s.stream]=!0),i}function Dj(e,r,n){for(const[s,i,c]of Xy[r]?.response??[])try{const d=Qy(qj(n,i),c);d!==void 0&&e.setAttribute(s,d)}catch{}}function qj(e,r){let n=e;for(const s of r){if(typeof n!="object"||n===null)return;n=n[s]}return n}function Qy(e,r){if(typeof r=="object")return Array.isArray(e)&&e.every(n=>Qy(n,r.array)!==void 0)?[...e]:void 0;switch(typeof e){case"string":return r==="string"||r==="unknown"?e:void 0;case"boolean":return r==="boolean"||r==="unknown"?e:void 0;case"number":return r==="integer"||r==="number"||r==="unknown"?e:void 0;default:return}}function rP(e,r){const n=(e??"").split(",").map(s=>s.trim()).filter(Boolean);if(!(e==null||n.length===0))return typeof r=="object"?n:e}function iP(e){try{const{hostname:r,port:n,protocol:s}=new URL(e);return{[VO]:r.replace(/^\[(.*)\]$/,"$1"),[KO]:n?Number(n):s==="http:"?80:443}}catch{return{}}}function oP(e,r,n,s=!1){if(e.attempts=(e.attempts??0)+1,e.attempts>1){e.span.setAttribute(HO,e.attempts-1);return}e.span.setAttribute(GO,r);try{const{protocol:i,host:c,pathname:d,search:f}=new URL(n),p=cP(f.slice(1),e.queryParams,e.contentQueryParams);if(e.span.setAttributes({[QO]:i.slice(0,-1),[WO]:d}),p?.content&&!s)return;e.span.setAttributes({...p!==void 0?{[XO]:p.value}:void 0,[YO]:`${i}//${c}${d}${p!==void 0?`?${p.value}`:""}`})}catch{}}const lP=["email","path_prefix","expected_content_sha256"];function cP(e,r,n){if(!e||!r?.length)return;let s=!1;const i=e.split("&").filter(c=>{try{const d=decodeURIComponent(c.split("=",1)[0]),f=r.includes(d)||!d.endsWith("[]")?d:d.slice(0,-2);return r.includes(f)?(s||(s=lP.includes(f)||!!n?.includes(f)),!0):!1}catch{return!1}});return i.length?{value:i.join("&"),content:s}:void 0}function uP(e,r){const n=L([r]).values;for(const[s,i]of Object.entries(Uj(e)))n.set(s,i);return n}function Xd(e,r){if(e.isRecording())try{switch(hP(e,r),Jy(e,r.response??(r.status==="error"&&r.error instanceof Gt?r.error:void 0)),r.status){case"success":r.options.__span&&Dj(e,r.options.__span.name,r.data),e.setStatus({code:ol.OK});break;case"error":Ui(e,r.error);break}}finally{e.end()}}function Lj(e,r,n){const s=e[Symbol.asyncIterator];let i=!1;const c=p=>{if(!i){i=!0,r.removeEventListener("abort",d);try{n.onEnd(p)}catch{}}},d=()=>c({reason:"canceled"});if(r.aborted)return d();r.addEventListener("abort",d,{once:!0});let f=!1;e[Symbol.asyncIterator]=function(){const p=s.call(this);if(f)return p;f=!0,r.removeEventListener("abort",d);const b={async next(){let x;try{x=await p.next()}catch(g){throw c({reason:"failed",error:g}),g}if(x.done)c({reason:r.aborted?"canceled":"completed"});else if(!i)try{n.onItem?.(x.value)}catch{}return x},async return(x){return d(),await p.return?.(x)??{done:!0,value:x}},async throw(x){if(d(),p.throw)return p.throw(x);throw x},[Symbol.asyncIterator]:()=>b};return b}}function dP(e,r,n){if(!e.isRecording())return;e.setAttribute(Wy,n.response.status),Jy(e,n.response);const s=r instanceof Hr;Lj(r,n.controller.signal,{onEnd(i){i.reason==="failed"?Ui(e,i.error):i.reason==="completed"&&!s&&e.setStatus({code:ol.OK}),e.end()}})}function hP(e,r){const n=r.response?.status??(r.status==="error"&&r.error instanceof Gt?r.error.status:void 0);n!==void 0&&e.setAttribute(Wy,n)}const mP=[["anthropic.request.id","request-id"],["anthropic.organization.id","anthropic-organization-id"],["anthropic.workspace.id","anthropic-workspace-id"]];function Jy(e,r){let n;try{n=r?.headers}catch{return}for(const[s,i]of mP)try{const c=n?.get(i);c&&e.setAttribute(s,c)}catch{}}function Ui(e,r,n){r instanceof Ls||Jo(r)||(e.setStatus({code:ol.ERROR}),e.setAttribute(BO,n??fP(r)))}function Uj(e){const r={};return Rj.inject(ll.setSpan(Hs.active(),e),r),r}function fP(e){if(e instanceof Dx)return"client_timeout_error";if(e instanceof Hc)return"connection_error";if(e instanceof Gt){if(e.type)return e.type;if(e.status!==void 0)return String(e.status)}return"client_error"}const Bj="RFC3986",Gj=e=>String(e),jk={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:Gj},pP="RFC1738";let Hx=(e,r)=>(Hx=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Hx(e,r));const Ka=(()=>{const e=[];for(let r=0;r<256;++r)e.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return e})(),qb=1024,gP=(e,r,n,s,i)=>{if(e.length===0)return e;let c=e;if(typeof e=="symbol"?c=Symbol.prototype.toString.call(e):typeof e!="string"&&(c=String(e)),n==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(f){return"%26%23"+parseInt(f.slice(2),16)+"%3B"});let d="";for(let f=0;f<c.length;f+=qb){const p=c.length>=qb?c.slice(f,f+qb):c,b=[];for(let x=0;x<p.length;++x){let g=p.charCodeAt(x);if(g===45||g===46||g===95||g===126||g>=48&&g<=57||g>=65&&g<=90||g>=97&&g<=122||i===pP&&(g===40||g===41)){b[b.length]=p.charAt(x);continue}if(g<128){b[b.length]=Ka[g];continue}if(g<2048){b[b.length]=Ka[192|g>>6]+Ka[128|g&63];continue}if(g<55296||g>=57344){b[b.length]=Ka[224|g>>12]+Ka[128|g>>6&63]+Ka[128|g&63];continue}x+=1,g=65536+((g&1023)<<10|p.charCodeAt(x)&1023),b[b.length]=Ka[240|g>>18]+Ka[128|g>>12&63]+Ka[128|g>>6&63]+Ka[128|g&63]}d+=b.join("")}return d};function bP(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function Tk(e,r){if(xs(e)){const n=[];for(let s=0;s<e.length;s+=1)n.push(r(e[s]));return n}return r(e)}const Hj={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,r){return String(e)+"["+r+"]"},repeat(e){return String(e)}},Fj=function(e,r){Array.prototype.push.apply(e,xs(r)?r:[r])};let Ek;const gn={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:gP,encodeValuesOnly:!1,format:Bj,formatter:Gj,indices:!1,serializeDate(e){return(Ek??(Ek=Function.prototype.call.bind(Date.prototype.toISOString)))(e)},skipNulls:!1,strictNullHandling:!1};function xP(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}const Lb={};function Vj(e,r,n,s,i,c,d,f,p,b,x,g,_,y,S,k,E,T){let j=e,q=T,z=0,O=!1;for(;(q=q.get(Lb))!==void 0&&!O;){const Z=q.get(e);if(z+=1,typeof Z<"u"){if(Z===z)throw new RangeError("Cyclic object value");O=!0}typeof q.get(Lb)>"u"&&(z=0)}if(typeof b=="function"?j=b(r,j):j instanceof Date?j=_?.(j):n==="comma"&&xs(j)&&(j=Tk(j,function(Z){return Z instanceof Date?_?.(Z):Z})),j===null){if(c)return p&&!k?p(r,gn.encoder,E,"key",y):r;j=""}if(xP(j)||bP(j)){if(p){const Z=k?r:p(r,gn.encoder,E,"key",y);return[S?.(Z)+"="+S?.(p(j,gn.encoder,E,"value",y))]}return[S?.(r)+"="+S?.(String(j))]}const V=[];if(typeof j>"u")return V;let P;if(n==="comma"&&xs(j))k&&p&&(j=Tk(j,p)),P=[{value:j.length>0?j.join(",")||null:void 0}];else if(xs(b))P=b;else{const Z=Object.keys(j);P=x?Z.sort(x):Z}const $=f?String(r).replace(/\./g,"%2E"):String(r),H=s&&xs(j)&&j.length===1?$+"[]":$;if(i&&xs(j)&&j.length===0)return H+"[]";for(let Z=0;Z<P.length;++Z){const G=P[Z],K=typeof G=="object"&&typeof G.value<"u"?G.value:j[G];if(d&&K===null)continue;const we=g&&f?G.replace(/\./g,"%2E"):G,Se=xs(j)?typeof n=="function"?n(H,we):H:H+(g?"."+we:"["+we+"]");T.set(e,z);const Q=new WeakMap;Q.set(Lb,T),Fj(V,Vj(K,Se,n,s,i,c,d,f,n==="comma"&&k&&xs(j)?null:p,b,x,g,_,y,S,k,E,Q))}return V}function yP(e=gn){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");const r=e.charset||gn.charset;if(typeof e.charset<"u"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=Bj;if(typeof e.format<"u"){if(!Hx(jk,e.format))throw new TypeError("Unknown format option provided.");n=e.format}const s=jk[n];let i=gn.filter;(typeof e.filter=="function"||xs(e.filter))&&(i=e.filter);let c;if(e.arrayFormat&&e.arrayFormat in Hj?c=e.arrayFormat:"indices"in e?c=e.indices?"indices":"repeat":c=gn.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const d=typeof e.allowDots>"u"?e.encodeDotInKeys?!0:gn.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:gn.addQueryPrefix,allowDots:d,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:gn.allowEmptyArrays,arrayFormat:c,charset:r,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:gn.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter>"u"?gn.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:gn.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:gn.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:gn.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:gn.encodeValuesOnly,filter:i,format:n,formatter:s,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:gn.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:gn.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:gn.strictNullHandling}}function _P(e,r={}){let n=e;const s=yP(r);let i,c;typeof s.filter=="function"?(c=s.filter,n=c("",n)):xs(s.filter)&&(c=s.filter,i=c);const d=[];if(typeof n!="object"||n===null)return"";const f=Hj[s.arrayFormat],p=f==="comma"&&s.commaRoundTrip;i||(i=Object.keys(n)),s.sort&&i.sort(s.sort);const b=new WeakMap;for(let _=0;_<i.length;++_){const y=i[_];s.skipNulls&&n[y]===null||Fj(d,Vj(n[y],y,f,p,s.allowEmptyArrays,s.strictNullHandling,s.skipNulls,s.encodeDotInKeys,s.encode?s.encoder:null,s.filter,s.sort,s.allowDots,s.serializeDate,s.format,s.formatter,s.encodeValuesOnly,s.charset,b))}const x=d.join(s.delimiter);let g=s.addQueryPrefix===!0?"?":"";return s.charsetSentinel&&(s.charset==="iso-8859-1"?g+="utf8=%26%2310003%3B&":g+="utf8=%E2%9C%93&"),x.length>0?g+x:""}function vP(e){return _P(e,{arrayFormat:"brackets"})}class ye{constructor(r){this._client=r}}async function Kj(e,r){const{response:n,requestLogID:s,retryOfRequestLogID:i,startTime:c}=r,d=await(async()=>{if(r.options.stream)return it(e).debug("response",n.status,n.url,n.headers,n.body),Hr.fromSSEResponse(n,r.controller,e);if(n.status===204)return null;if(r.options.__binaryResponse)return n;const p=n.headers.get("content-type")?.split(";")[0]?.trim();if(p?.includes("application/json")||p?.endsWith("+json")){if(n.headers.get("content-length")==="0")return;const _=await n.json();return Xp(_,n)}return await n.text()})().finally(()=>{!r.options.stream&&!r.options.__binaryResponse&&Yo(r.controller)});return $i(it(e),`[${s}] response parsed`,{retryOfRequestLogID:i,url:n.url,status:n.status,body:d,durationMs:Date.now()-c}),d}function Xp(e,r){return!e||typeof e!="object"||Array.isArray(e)?e:Object.defineProperties(e,{_request_id:{value:r.headers.get("request-id"),enumerable:!1},_workspace_id:{value:r.headers.get("anthropic-workspace-id"),enumerable:!1}})}const Yj=()=>{if(typeof File>"u"){const{process:e}=globalThis,r=typeof e?.versions?.node=="string"&&parseInt(e.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(r?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Pc(e,r,n){return Yj(),new File(e,r??"",n)}function rp(e,r){const n=typeof e=="object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(e.filename)||"path"in e&&e.path&&String(e.path))||"";return r?n.split(/[\\/]/).pop()||void 0:n}const Zy=e=>e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function",Kr=async(e,r,n=!0)=>{try{return{...e,body:await SP(e.body,r,n)}}catch(s){const i=e.__span?.span;throw i&&zt(typeof r=="function"?void 0:r,()=>Xd(i,{status:"error",options:e,error:s})),s}},Mk=new WeakMap;function wP(e){const r=typeof e=="function"?e:e.fetch,n=Mk.get(r);if(n)return n;const s=(async()=>{try{const i="Response"in r?r.Response:(await r("data:,")).constructor,c=new FormData;return c.toString()!==await new i(c).text()}catch{return!0}})();return Mk.set(r,s),s}const SP=async(e,r,n=!0)=>{if(!await wP(r))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");const s=new FormData;return await Promise.all(Object.entries(e||{}).map(([i,c])=>Fx(s,i,c,n))),s},Fx=async(e,r,n,s)=>{if(n!==void 0){if(n==null)throw new TypeError(`Received null for "${r}"; to pass null in FormData, you must use the string 'null'`);if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")e.append(r,String(n));else if(n instanceof Response){let i={};const c=n.headers.get("Content-Type");c&&(i={type:c}),e.append(r,Pc([await n.blob()],rp(n,s),i))}else if(Zy(n))e.append(r,Pc([await new Response(wj(n)).blob()],rp(n,s)));else if(n instanceof Blob){const c=typeof File<"u"&&n instanceof File?n.name:rp(n,s);e.append(r,Pc([n],c,{type:n.type}))}else if(Array.isArray(n))await Promise.all(n.map(i=>Fx(e,r+"[]",i,s)));else{if(typeof n.then=="function")throw new TypeError(`Received a Promise for "${r}"; await it first, e.g. \`await toFile(...)\``);if(n instanceof ArrayBuffer||ArrayBuffer.isView(n))throw new TypeError(`Received ${n.constructor.name} for "${r}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);if(typeof n=="object")await Promise.all(Object.entries(n).map(([i,c])=>Fx(e,`${r}[${i}]`,c,s)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${n} instead`)}}},kP="gen_ai.agent.id",ih="gen_ai.input.messages",Wj="gen_ai.operation.name",Kc="gen_ai.output.messages",Xj="gen_ai.output.type",CP="gen_ai.request.model",Vx="gen_ai.request.stop_sequences",NP="gen_ai.response.time_to_first_chunk",oh="gen_ai.system_instructions",AP="gen_ai.tool.call.arguments",jP="gen_ai.tool.call.id",TP="gen_ai.tool.description",EP="gen_ai.tool.name",MP="gen_ai.tool.type",RP="gen_ai.usage.input_tokens",zP="execute_tool",OP="invoke_agent",Qj="json",PP="function",$P="anthropic.content.truncated",Kx="anthropic.tool_result.content",IP="anthropic.toolset.name",DP="anthropic.usage.compaction.input_tokens",qP="anthropic.usage.compaction.output_tokens";function e_(e,r,n,s){const i=e.span,c=e.requestContentSize;if(n!==void 0&&c!==void 0){const f=JSON.stringify([{role:"assistant",parts:sf(n)}]);if(c+3*f.length<=s||c+Qp(f)<=s){i.setAttribute(Kc,f);return}}const d=Zj(i,{[Vx]:r.stop_sequences?.length?[...r.stop_sequences]:void 0,[oh]:r.system===void 0?void 0:sf(r.system),[ih]:r.messages.map(f=>({role:f.role,parts:sf(f.content)})),[Kc]:n===void 0?void 0:[{role:"assistant",parts:sf(n)}]},s);n===void 0&&(e.requestContentSize=d)}function sf(e){return typeof e=="string"?[{type:"text",content:e}]:e?.map(LP)??[]}function LP(e){switch(e.type){case"text":return{type:"text",content:e.text};case"thinking":return{type:"reasoning",content:e.thinking};case"tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,...typeof e.toolset_name=="string"?{anthropic_toolset_name:e.toolset_name}:void 0};case"server_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input};case"mcp_tool_use":return{type:"tool_call",id:e.id,name:e.name,arguments:e.input,anthropic_mcp_server_name:e.server_name};case"tool_result":return{type:"tool_call_response",id:e.tool_use_id,response:Jj(e.content)};default:return typeof e.type!="string"?{type:"anthropic_unknown"}:e.type.endsWith("_tool_result")&&"tool_use_id"in e?{type:"tool_call_response",id:e.tool_use_id,response:UP(e.content)}:{type:`anthropic_${e.type}`}}}function Jj(e){return e==null?[]:typeof e=="string"?[{type:"text",text:e}]:e.map(r=>r.type==="text"||r.type==="search_result"?lh(r):typeof r.type!="string"?{type:"unknown"}:{type:r.type})}function UP(e){return e==null?[]:typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.map(r=>r.type==="text"||r.type==="search_result"||r.type==="web_search_result"?lh(r):typeof r.type!="string"?{type:"unknown"}:{type:r.type}):[lh(e)]}function lh(e){if(Array.isArray(e))return e.map(lh);if(typeof e!="object"||e===null)return e;const{type:r,file_type:n}=e;if(r==="image"||r==="document")return{type:r};const s=r==="text_editor_code_execution_view_result"&&(n==="image"||n==="pdf");return Object.fromEntries(Object.entries(e).filter(([i])=>!i.startsWith("encrypted_")&&!(i==="content"&&s)).map(([i,c])=>[i,lh(c)]))}function Zj(e,r,n){const{[Vx]:s,[oh]:i,[ih]:c,[Kc]:d,[Kx]:f,...p}=r,b={[oh]:i,[ih]:c,[Kc]:d},x={},g=f?.map(z=>JSON.stringify(z)),y=3*([...s??[],...g??[]].reduce((z,O)=>z+O.length+1,2)+Ub(p,x)+Ub(b,x))<=n?z=>3*z.length:Qp,S=()=>Object.keys(b).reduce((z,O)=>z+y(x[O]??""),0),k=s?.reduce((z,O)=>z+y(O),0)??0,E=s!==void 0&&k<=n;let T=E?k:0,j=s!==void 0&&!E;for(const z of Object.keys(p)){const O=y(x[z]??"");O>n?(delete x[z],j=!0):T+=O}let q=S();if(T+q>n){const{truncated:z,...O}=BP(b,T+q-n);j||(j=z),Ub(O,x),q=S()}if(T+=q,g!==void 0){const z=HP(g,n-T,y);x[Kx]=z.json,T+=z.size,j||(j=z.truncated)}j&&e.setAttribute($P,!0),E&&e.setAttribute(Vx,s);for(const[z,O]of Object.entries(x))e.setAttribute(z,O);return T}function Ub(e,r){let n=0;for(const[s,i]of Object.entries(e))i!==void 0&&(r[s]=JSON.stringify(i),n+=r[s].length);return n}function BP(e,r){const n=b=>b?.map(x=>({...x,parts:[...x.parts]})),s=e[oh]?.slice(),i=n(e[ih]),c=n(e[Kc]),d=[s??[],...[...i??[],...c??[]].map(({parts:b})=>b)];let f=d.reduce((b,x)=>b+x.length,0),p=!1;for(const b of d){let x=0;for(;r>0&&x<b.length;){const g=b[x],_=Qp(JSON.stringify(g)),y=g.content;if(f===1&&g.type==="text"&&typeof y=="string"){const S=GP(g,y,_-r);S!==y&&(b[x]={...g,content:S},p=!0);break}r-=_+(x+1<b.length?1:0),x++,f--,p=!0}b.splice(0,x)}return{[oh]:s,[ih]:i,[Kc]:c,truncated:p}}function GP(e,r,n){const s=n-Qp(JSON.stringify({...e,content:""})),i=r.slice(0,Math.max(s,0)),c=JSON.stringify(i);let d=0,f=0,p=0;for(;d<i.length;){const b=c.codePointAt(1+f),x=b>65535?2:1,g=b!==92?x:c[2+f]==="u"?6:2;if(p+=b<128?g:b<2048?2:b<65536?3:4,p>s)break;f+=g,d+=x}return r.slice(0,d)}function HP(e,r,n){const s=[];let i=2;for(const c of e){const d=i+(s.length===0?0:1)+n(c);if(d>r)break;s.push(c),i=d}return{json:"["+s.join(",")+"]",size:i,truncated:s.length<e.length}}function Qp(e){let r=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);s<128?r+=1:s<2048?r+=2:s>=55296&&s<56320&&(e.charCodeAt(n+1)&64512)===56320?(r+=4,n++):r+=3}return r}function eT(e,r,n){if(!Hn(r)||(typeof r.input_tokens=="number"&&e.setAttribute(RP,Rk(r)),!n))return;const i=(Array.isArray(r.iterations)?r.iterations:[]).filter(c=>Hn(c)&&c.type==="compaction");i.length>0&&(e.setAttribute(DP,i.reduce((c,d)=>c+Rk(d),0)),e.setAttribute(qP,i.reduce((c,d)=>c+tT(d,"output_tokens"),0)))}const FP=["input_tokens","cache_read_input_tokens","cache_creation_input_tokens"];function Rk(e){return FP.reduce((r,n)=>r+tT(e,n),0)}function tT(e,r){const n=e[r];return typeof n=="number"?n:0}function Jp(e,r){const n=zt(e,()=>{const s=Hn(r.body)?r.body.output_config:void 0,i=Hn(s)?s.format:void 0;return Hn(i)&&i.type==="json_schema"?{[Xj]:Qj}:{}});return{route:"/v1/messages",request:r,attributes:n}}function VP(e){return zt(void 0,()=>{const r=Hn(e)?e.agent:void 0,n=Hn(r)?r.id:r;return typeof n=="string"?{[kP]:n}:{}})}function nT(e,r,n){if(!r?.span.isRecording())return r;try{const{contentMode:s,maxContentBytes:i}=e.openTelemetry.traces;s==="content"&&e_(r,n,void 0,i)}catch(s){it(e).debug("could not record the request on its span",s)}return r}function sT(e,r,n,s){if(!(!r?.span.isRecording()||s instanceof Hr))try{eT(r.span,s.usage,!0);const{contentMode:i,maxContentBytes:c}=e.openTelemetry.traces;i==="content"&&e_(r,n,s.content,c)}catch(i){it(e).debug("could not record the response on its span",i)}}function KP(){const e=new Set(["traceparent","tracestate","baggage"]);try{for(const r of Rj.fields())e.add(r.toLowerCase())}catch(r){Pj().debug("could not record telemetry",r)}return e}function aT(e){const r=KP(),n=Array.from(e.entries()).filter(([s])=>r.has(s));for(const[s]of n)e.delete(s);return n}function YP(e){return(r,n,s)=>{const i=new Headers(r.headers),c=aT(i);return e({...r,headers:i},d=>{const f=new Headers(d.headers);for(const[p,b]of c)f.set(p,b);return n({...d,headers:f})},s)}}function t_(e,r,n,s){if(!(!r.span.isRecording()||e.openTelemetry.traces.contentMode!=="content"))try{e_(r,n,s.content,e.openTelemetry.traces.maxContentBytes)}catch(i){it(e).debug("could not record the streamed message on its span",i)}}function WP(e,r,n,s){s.options.__span?.name==="anthropic.messages.create"&&n instanceof Hr?XP(e,r,n,s):dP(r,n,s)}function XP(e,r,n,s){if(!r.isRecording())return;r.setAttribute(Wy,s.response.status),Jy(r,s.response);const i=s.options.__span,c=i?.startTime;let d,f,p=!1,b=!1,x=!1;Lj(n,s.controller.signal,{onItem(g){try{switch(g.type){case"message_start":{const _={...g.message};f={...g.message.usage},d={};for(const[,[y]]of Xy[i?.name??""]?.response??[])y!==void 0&&y!=="usage"&&(d[y]=_[y]);break}case"content_block_start":{const _=g.content_block;d&&Hn(_)&&_.type==="fallback"&&Hn(_.to)&&(d.model=_.to.model);break}case"message_delta":if(d&&f){const _=Hn(g.usage)?g.usage:{};f.output_tokens=_.output_tokens;for(const y of JP)_[y]!=null&&(f[y]=_[y]);g.delta.stop_reason!=null&&(d.stop_reason=g.delta.stop_reason),b=!0}break;case"message_stop":x=!0;break;case"content_block_delta":!p&&c!==void 0&&r.setAttribute(NP,(Date.now()-c)/1e3),p=!0;break;case"content_block_stop":break;default:}}catch(_){it(e).debug("could not record the stream on its span",_)}},onEnd(g){try{if(d&&f&&i){const y=b||x;let S={...d,usage:f};if(!y)for(const k of QP)S=rT(S,k);Dj(r,i.name,S),eT(r,f,y)}}catch(y){it(e).debug("could not record the stream on its span",y)}const _=i?.failure;!x&&i?.streamed&&_===void 0&&t_(e,i,i.streamed.body,i.streamed.message),g.reason==="failed"?Ui(r,g.error):_!==void 0?Ui(r,_,"client_error"):g.reason==="completed"&&(x?r.setStatus({code:ol.OK}):Ui(r,new De("The stream ended before message_stop."),"api_error")),zt(e,()=>r.end())}})}const QP=[["stop_reason"],["usage","output_tokens"],["usage","output_tokens_details"]],JP=["input_tokens","cache_creation_input_tokens","cache_read_input_tokens","output_tokens_details","iterations"];function rT(e,r){const[n,...s]=r;if(n===void 0||!(n in e))return e;if(s.length===0){const{[n]:c,...d}=e;return d}const i=e[n];return Hn(i)?{...e,[n]:rT(i,s)}:e}function ZP(e,r,n){return e._tracer?.startSpan("anthropic.environment.work",{kind:Yp.INTERNAL,attributes:{[Wp]:e._genAIProviderName,"anthropic.environment.id":r.environment_id,"anthropic.environment.work.id":r.id,"anthropic.session.id":r.data.id}},n)}function iT(e,r){e?.isRecording()&&(r.aborted||e.setStatus({code:ol.OK}),e.end())}function oT(e,r,n){e?.isRecording()&&(r.aborted||Ui(e,n),e.end())}async function e8(e,r,n,s){if(!r)return s();try{await Hs.with(ll.setSpan(Hs.active(),r),s)}catch(i){throw zt(e,()=>oT(r,n,i)),i}zt(e,()=>iT(r,n))}const vh="x-stainless-helper",n_="x-stainless-helper-method";function s_(e){return{[vh]:e}}const Ir=Symbol("anthropic.sdk.stainlessHelper");function Ho(e){return typeof e=="object"&&e!==null&&Ir in e}function lT(e,r){const n=new Set;if(e)for(const s of e)Ho(s)&&n.add(s[Ir]);if(r)for(const s of r){Ho(s)&&n.add(s[Ir]);const i=s.content;if(Array.isArray(i))for(const c of i){Ho(c)&&n.add(c[Ir]);const d=c?.tool?.definition;Ho(d)&&n.add(d[Ir])}}return Array.from(n)}function cT(e,r){const n=lT(e,r);return n.length===0?{}:{[vh]:n.join(", ")}}function uT(e){return Ho(e)?{[vh]:e[Ir]}:{}}function t8(e,r,n){if(!e._tracer)return;const s=r.output_config?.format?.type==="json_schema"||r.output_format?.type==="json_schema";return e._tracer.startSpan("anthropic.messages.tool_runner",{kind:Yp.INTERNAL,attributes:{[Wj]:OP,[Wp]:e._genAIProviderName,[CP]:r.model,...s?{[Xj]:Qj}:void 0,...n!=null?{[Yy]:n}:void 0}})}async function a_(e,r,n,s,i){const c=e._tracer;if(!c)return i();const{signal:d,conversationId:f,sessionID:p,parentContext:b=Hs.active()}=s,x="description"in r?r.description:void 0,g={[Wj]:zP,[Wp]:e._genAIProviderName,[EP]:n.name,..."toolset_name"in n&&typeof n.toolset_name=="string"?{[IP]:n.toolset_name}:void 0,...x?{[TP]:x}:void 0,[jP]:n.id,[MP]:PP,...f!=null?{[Yy]:f}:void 0,...p!=null?{"anthropic.session.id":p}:void 0,..."session_thread_id"in n&&n.session_thread_id!=null?{"anthropic.session.thread.id":n.session_thread_id}:void 0},_=n.type==="agent.tool_use"?"anthropic.tool_use":Ho(r)&&r[Ir]==="mcpTool"?"anthropic.mcp_tool_use":"anthropic.custom_tool_use",y=zt(e,()=>c.startSpan(`${_} ${n.name}`,{kind:Yp.INTERNAL,attributes:g},b));if(!y)return i();let S;try{return S=await Hs.with(ll.setSpan(b,y),i),S}finally{const k=S!==void 0&&!S.isError,E=!k&&d?.aborted===!0,{contentMode:T,maxContentBytes:j}=e.openTelemetry.traces;if(T==="content"&&y.isRecording())try{Zj(y,{[AP]:n.input,[Kx]:S&&!E?Jj(S.content):void 0},j)}catch(q){it(e).debug("could not record the tool run on its span",q)}zt(e,()=>{k?y.setStatus({code:ol.OK}):E||Ui(y,S,"tool_error"),y.end()})}}var na,ch=(()=>{class e extends Promise{constructor(n,s,i=Kj){super(c=>{c(null)}),this.responsePromise=s,this.parseResponse=i,na.set(this,void 0),se(this,na,n)}_responseProps(){return this.responsePromise}_thenUnwrap(n){return new e(v(this,na,"f"),this.responsePromise,async(s,i)=>Xp(n(await this.parseResponse(s,i),i),i.response))}asResponse(){return this.responsePromise.then(n=>{const s=n.options.__span?.span;if(s&&!this.parsedPromise){const i={status:"success",...n,data:void 0};zt(v(this,na,"f"),()=>Xd(s,i))}return n.response})}async withResponse(){const[n,s]=await Promise.all([this.parse(),this.asResponse()]);return{data:n,response:s,request_id:s.headers.get("request-id"),workspace_id:s.headers.get("anthropic-workspace-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(n=>this.parseResponseTraced(n))),this.parsedPromise}async parseResponseTraced(n){const s=n.options.__span;if(!s)return this.parseResponse(v(this,na,"f"),n);const{span:i}=s;let c;try{c=await this.parseResponse(v(this,na,"f"),n)}catch(f){const p={status:"error",...n,error:f};throw zt(v(this,na,"f"),()=>Xd(i,p)),f}const d={status:"success",...n,data:c};return zt(v(this,na,"f"),()=>sP(s,c)),n.options.stream&&Zy(c)?zt(v(this,na,"f"),()=>WP(v(this,na,"f"),i,c,n)):zt(v(this,na,"f"),()=>Xd(i,d)),c}then(n,s){return this.parse().then(n,s)}catch(n){return this.parse().catch(n)}finally(n){return this.parse().finally(n)}}return na=new WeakMap,e})(),ld,Zp=(()=>{class e{constructor(n,s,i,c){ld.set(this,void 0),se(this,ld,n),this.options=c,this.response=s,this.body=i}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){const n=this.nextPageRequestOptions();if(!n)throw new De("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");const s=this.options.__span;return await v(this,ld,"f").requestAPIList(this.constructor,{...n,__span:s&&N(v(this,ld,"f"),s.name,{openTelemetry:this.options.openTelemetry},{route:s.route,queryParams:s.queryParams,contentQueryParams:s.contentQueryParams,attributes:s.attributes,request:n})})}async*iterPages(){let n=this;for(yield n;n.hasNextPage();)n=await n.getNextPage(),yield n}async*[(ld=new WeakMap,Symbol.asyncIterator)](){for await(const n of this.iterPages())for(const s of n.getPaginatedItems())yield s}}return e})(),zk=(()=>{class e extends ch{constructor(n,s,i){super(n,s,async(c,d)=>new i(c,d.response,await Kj(c,d),d.options))}async*[Symbol.asyncIterator](){const n=await this;for await(const s of n)yield s}}return e})();class ns extends Zp{constructor(r,n,s,i){super(r,n,s,i),this.data=s.data||[],this.has_more=s.has_more||!1,this.first_id=s.first_id||null,this.last_id=s.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){const n=this.first_id;return n?{...this.options,query:{...rh(this.options.query),before_id:n}}:null}const r=this.last_id;return r?{...this.options,query:{...rh(this.options.query),after_id:r}}:null}}class Me extends Zp{constructor(r,n,s,i){super(r,n,s,i),this.data=s.data||[],this.next_page=s.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.nextPageRequestOptions()!=null}nextPageRequestOptions(){const r=this.next_page;return r?{...this.options,query:{...rh(this.options.query),page:r}}:null}}class n8 extends Zp{constructor(r,n,s,i){super(r,n,s,i),this.data=s.data||[],this.next_page=s.next_page||null,this.prev_page=s.prev_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.nextPageRequestOptions()!=null}nextPageRequestOptions(){const r=this.next_page;return r?{...this.options,query:{...rh(this.options.query),page:r}}:null}}class tu extends Zp{constructor(r,n,s,i){super(r,n,s,i),this.data=s.data||[],this.next_page=s.next_page||null,this.has_more=s.has_more||!1,this.data_refreshed_at=s.data_refreshed_at||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:this.nextPageRequestOptions()!=null}nextPageRequestOptions(){const r=this.next_page;return r?{...this.options,query:{...rh(this.options.query),page:r}}:null}}function dT(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}const Ok=Object.freeze(Object.create(null)),s8=(e=dT)=>function(n,...s){if(n.length===1)return n[0];let i=!1;const c=[],d=n.reduce((x,g,_)=>{/[?#]/.test(g)&&(i=!0);const y=s[_];let S=(i?encodeURIComponent:e)(""+y);return _!==s.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??Ok)??Ok)?.toString)&&(S=y+"",c.push({start:x.length+g.length,length:S.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),!i&&(S===""||S.startsWith(";"))&&c.push({start:x.length+g.length,length:S.length,error:`Value "${S}" can't be safely passed as a path parameter`}),x+g+(_===s.length?"":S)},""),f=d.split(/[?#]/,1)[0],p=/(?<=^|\/)(?:\.|%2e){1,2}(?:;[^/]*)?(?=\/|$)/gi;let b;for(;(b=p.exec(f))!==null;)c.push({start:b.index,length:b[0].length,error:`Value "${b[0]}" can't be safely passed as a path parameter`});if(c.sort((x,g)=>x.start-g.start),c.length>0){const x=[];for(const _ of c)for(let y=_.start;y<_.start+Math.max(1,_.length);y++)x[y]="^";const g=Array.from(x,_=>_??" ").join("");throw new De(`Path parameters result in path with invalid segments:
522
+ ${c.map(_=>_.error).join(`
523
+ `)}
524
+ ${d}
525
+ ${g}`)}return d},U=s8(dT);var r_=(()=>{class e extends Ye{}return e._errorName="FileNotDownloadableError",e})(),i_=(()=>{class e extends Ye{}return e._errorName="StorageQuotaExceededError",e})(),o_=(()=>{class e extends Zc{}return e._errorName="FileExpiredError",e})(),Pk=(()=>{class e extends ye{list(n={},s){const{workspace_id:i,...c}=n??{};return this._client.getAPIList("/v1/files",Me,{query:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.files.list",s,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(n,s={},i){const{workspace_id:c}=s??{};return this._client.delete(U`/v1/files/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}download(n,s={},i){const{workspace_id:c}=s??{};return this._client.get(U`/v1/files/${n}/content`,{...i,headers:L([{Accept:"application/binary",...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__binaryResponse:!0,__span:N(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":n}})})}retrieveMetadata(n,s={},i){const{workspace_id:c}=s??{};return this._client.get(U`/v1/files/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}upload(n,s){const{workspace_id:i,...c}=n;return this._client.post("/v1/files",Kr({body:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},uT(c.file),s?.headers]),__span:N(this._client,"anthropic.files.upload",s,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return e.FileNotDownloadableError=r_,e.StorageQuotaExceededError=i_,e.FileExpiredError=o_,e})(),hT=(()=>{class e extends Ye{}return e._errorName="ClaudeCodeKeyCreatorNotMemberError",e})(),mT=(()=>{class e extends Ye{}return e._errorName="ClaudeCodeVersionTooOldError",e})(),fT=(()=>{class e extends Ye{}return e._errorName="CMEKKeyDisabledError",e})(),pT=(()=>{class e extends Ye{}return e._errorName="CMEKKeyNetworkBlockedError",e})(),gT=(()=>{class e extends Ye{}return e._errorName="OrganizationOnHoldError",e})(),bT=(()=>{class e extends Ye{}return e._errorName="OrganizationTypeNotSupportedError",e})(),xT=(()=>{class e extends Ye{}return e._errorName="RequestBodyEncodingInvalidError",e})(),yT=(()=>{class e extends Ye{}return e._errorName="RequestBodyEncodingUnsupportedError",e})(),_T=(()=>{class e extends vs{}return e._errorName="SandboxEgressRestrictedError",e})(),vT=(()=>{class e extends qy{}return e._errorName="RequestBodyTooLargeAfterDecodingError",e})(),wT=(()=>{class e extends Hp{}return e._errorName="EnforcedSpendLimitReachedError",e})(),ST=(()=>{class e extends Hp{}return e._errorName="RampLimitExceededError",e})(),kT=(()=>{class e extends _h{}return e._errorName="CMEKContextUnavailableError",e})(),CT=(()=>{class e extends _h{}return e._errorName="CMEKKeyUnreachableError",e})();class $k extends ye{retrieve(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/deployment_runs/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployment_runs.retrieve",s,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":r}})})}list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/deployment_runs",Me,{query:c,...n,headers:L([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployment_runs.list",n,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}}class Ik extends ye{create(r,n){const{betas:s,workspace_id:i,...c}=r;return this._client.post("/v1/deployments",{body:c,...n,headers:L([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.create",n,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/deployments/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.retrieve",s,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":r}})})}update(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/deployments/${r}`,{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.update",s,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":r}})})}list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/deployments",Me,{query:c,...n,headers:L([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.list",n,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/deployments/${r}/archive`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.archive",s,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":r}})})}pause(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/deployments/${r}/pause`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.pause",s,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":r}})})}run(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/deployments/${r}/run`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.run",s,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":r}})})}unpause(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/deployments/${r}/unpause`,{...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.deployments.unpause",s,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":r}})})}}class Dk extends ye{create(r,n){const{betas:s,workspace_id:i,...c}=r;return this._client.post("/v1/dreams",{body:c,...n,headers:L([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.dreams.create",n,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/dreams/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.dreams.retrieve",s,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":r}})})}list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/dreams",Me,{query:c,...n,headers:L([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.dreams.list",n,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/dreams/${r}/archive`,{...s,headers:L([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.dreams.archive",s,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":r}})})}cancel(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/dreams/${r}/cancel`,{...s,headers:L([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.dreams.cancel",s,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":r}})})}}class qk extends ye{list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/files",Me,{query:c,...n,headers:L([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.files.list",n,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.delete(U`/v1/files/${r}`,{...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.files.delete",s,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":r}})})}download(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/files/${r}/content`,{...s,headers:L([{Accept:"application/binary",...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:N(this._client,"anthropic.files.download",s,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":r}})})}retrieveMetadata(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/files/${r}`,{...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.files.retrieve_metadata",s,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":r}})})}upload(r,n){const{betas:s,workspace_id:i,...c}=r;return this._client.post("/v1/files",Kr({body:c,...n,headers:L([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},uT(c.file),n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.files.upload",n,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}let Lk=class extends ye{retrieve(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/models/${r}`,{...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.models.retrieve",s,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":r}})})}list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/models",ns,{query:c,...n,headers:L([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.models.list",n,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}};var Mo={},hs={},Uk;function a8(){if(Uk)return hs;Uk=1;var e=hs&&hs.__extends||(function(){var x=function(g,_){return x=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,S){y.__proto__=S}||function(y,S){for(var k in S)S.hasOwnProperty(k)&&(y[k]=S[k])},x(g,_)};return function(g,_){x(g,_);function y(){this.constructor=g}g.prototype=_===null?Object.create(_):(y.prototype=_.prototype,new y)}})();Object.defineProperty(hs,"__esModule",{value:!0});var r=256,n=(function(){function x(g){g===void 0&&(g="="),this._paddingCharacter=g}return x.prototype.encodedLength=function(g){return this._paddingCharacter?(g+2)/3*4|0:(g*8+5)/6|0},x.prototype.encode=function(g){for(var _="",y=0;y<g.length-2;y+=3){var S=g[y]<<16|g[y+1]<<8|g[y+2];_+=this._encodeByte(S>>>18&63),_+=this._encodeByte(S>>>12&63),_+=this._encodeByte(S>>>6&63),_+=this._encodeByte(S>>>0&63)}var k=g.length-y;if(k>0){var S=g[y]<<16|(k===2?g[y+1]<<8:0);_+=this._encodeByte(S>>>18&63),_+=this._encodeByte(S>>>12&63),k===2?_+=this._encodeByte(S>>>6&63):_+=this._paddingCharacter||"",_+=this._paddingCharacter||""}return _},x.prototype.maxDecodedLength=function(g){return this._paddingCharacter?g/4*3|0:(g*6+7)/8|0},x.prototype.decodedLength=function(g){return this.maxDecodedLength(g.length-this._getPaddingLength(g))},x.prototype.decode=function(g){if(g.length===0)return new Uint8Array(0);for(var _=this._getPaddingLength(g),y=g.length-_,S=new Uint8Array(this.maxDecodedLength(y)),k=0,E=0,T=0,j=0,q=0,z=0,O=0;E<y-4;E+=4)j=this._decodeChar(g.charCodeAt(E+0)),q=this._decodeChar(g.charCodeAt(E+1)),z=this._decodeChar(g.charCodeAt(E+2)),O=this._decodeChar(g.charCodeAt(E+3)),S[k++]=j<<2|q>>>4,S[k++]=q<<4|z>>>2,S[k++]=z<<6|O,T|=j&r,T|=q&r,T|=z&r,T|=O&r;if(E<y-1&&(j=this._decodeChar(g.charCodeAt(E)),q=this._decodeChar(g.charCodeAt(E+1)),S[k++]=j<<2|q>>>4,T|=j&r,T|=q&r),E<y-2&&(z=this._decodeChar(g.charCodeAt(E+2)),S[k++]=q<<4|z>>>2,T|=z&r),E<y-3&&(O=this._decodeChar(g.charCodeAt(E+3)),S[k++]=z<<6|O,T|=O&r),T!==0)throw new Error("Base64Coder: incorrect characters for decoding");return S},x.prototype._encodeByte=function(g){var _=g;return _+=65,_+=25-g>>>8&6,_+=51-g>>>8&-75,_+=61-g>>>8&-15,_+=62-g>>>8&3,String.fromCharCode(_)},x.prototype._decodeChar=function(g){var _=r;return _+=(42-g&g-44)>>>8&-r+g-43+62,_+=(46-g&g-48)>>>8&-r+g-47+63,_+=(47-g&g-58)>>>8&-r+g-48+52,_+=(64-g&g-91)>>>8&-r+g-65+0,_+=(96-g&g-123)>>>8&-r+g-97+26,_},x.prototype._getPaddingLength=function(g){var _=0;if(this._paddingCharacter){for(var y=g.length-1;y>=0&&g[y]===this._paddingCharacter;y--)_++;if(g.length<4||_>2)throw new Error("Base64Coder: incorrect padding")}return _},x})();hs.Coder=n;var s=new n;function i(x){return s.encode(x)}hs.encode=i;function c(x){return s.decode(x)}hs.decode=c;var d=(function(x){e(g,x);function g(){return x!==null&&x.apply(this,arguments)||this}return g.prototype._encodeByte=function(_){var y=_;return y+=65,y+=25-_>>>8&6,y+=51-_>>>8&-75,y+=61-_>>>8&-13,y+=62-_>>>8&49,String.fromCharCode(y)},g.prototype._decodeChar=function(_){var y=r;return y+=(44-_&_-46)>>>8&-r+_-45+62,y+=(94-_&_-96)>>>8&-r+_-95+63,y+=(47-_&_-58)>>>8&-r+_-48+52,y+=(64-_&_-91)>>>8&-r+_-65+0,y+=(96-_&_-123)>>>8&-r+_-97+26,y},g})(n);hs.URLSafeCoder=d;var f=new d;function p(x){return f.encode(x)}hs.encodeURLSafe=p;function b(x){return f.decode(x)}return hs.decodeURLSafe=b,hs.encodedLength=function(x){return s.encodedLength(x)},hs.maxDecodedLength=function(x){return s.maxDecodedLength(x)},hs.decodedLength=function(x){return s.decodedLength(x)},hs}var ip={exports:{}},r8=ip.exports,Bk;function i8(){return Bk||(Bk=1,(function(e){(function(r,n){var s={};n(s);var i=s.default;for(var c in s)i[c]=s[c];e.exports=i})(r8,function(r){r.__esModule=!0,r.digestLength=32,r.blockSize=64;var n=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(_,y,S,k,E){for(var T,j,q,z,O,V,P,$,H,Z,G,K,we;E>=64;){for(T=y[0],j=y[1],q=y[2],z=y[3],O=y[4],V=y[5],P=y[6],$=y[7],Z=0;Z<16;Z++)G=k+Z*4,_[Z]=(S[G]&255)<<24|(S[G+1]&255)<<16|(S[G+2]&255)<<8|S[G+3]&255;for(Z=16;Z<64;Z++)H=_[Z-2],K=(H>>>17|H<<15)^(H>>>19|H<<13)^H>>>10,H=_[Z-15],we=(H>>>7|H<<25)^(H>>>18|H<<14)^H>>>3,_[Z]=(K+_[Z-7]|0)+(we+_[Z-16]|0);for(Z=0;Z<64;Z++)K=(((O>>>6|O<<26)^(O>>>11|O<<21)^(O>>>25|O<<7))+(O&V^~O&P)|0)+($+(n[Z]+_[Z]|0)|0)|0,we=((T>>>2|T<<30)^(T>>>13|T<<19)^(T>>>22|T<<10))+(T&j^T&q^j&q)|0,$=P,P=V,V=O,O=z+K|0,z=q,q=j,j=T,T=K+we|0;y[0]+=T,y[1]+=j,y[2]+=q,y[3]+=z,y[4]+=O,y[5]+=V,y[6]+=P,y[7]+=$,k+=64,E-=64}return k}var i=(function(){function _(){this.digestLength=r.digestLength,this.blockSize=r.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return _.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},_.prototype.clean=function(){for(var y=0;y<this.buffer.length;y++)this.buffer[y]=0;for(var y=0;y<this.temp.length;y++)this.temp[y]=0;this.reset()},_.prototype.update=function(y,S){if(S===void 0&&(S=y.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var k=0;if(this.bytesHashed+=S,this.bufferLength>0){for(;this.bufferLength<64&&S>0;)this.buffer[this.bufferLength++]=y[k++],S--;this.bufferLength===64&&(s(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(S>=64&&(k=s(this.temp,this.state,y,k,S),S%=64);S>0;)this.buffer[this.bufferLength++]=y[k++],S--;return this},_.prototype.finish=function(y){if(!this.finished){var S=this.bytesHashed,k=this.bufferLength,E=S/536870912|0,T=S<<3,j=S%64<56?64:128;this.buffer[k]=128;for(var q=k+1;q<j-8;q++)this.buffer[q]=0;this.buffer[j-8]=E>>>24&255,this.buffer[j-7]=E>>>16&255,this.buffer[j-6]=E>>>8&255,this.buffer[j-5]=E>>>0&255,this.buffer[j-4]=T>>>24&255,this.buffer[j-3]=T>>>16&255,this.buffer[j-2]=T>>>8&255,this.buffer[j-1]=T>>>0&255,s(this.temp,this.state,this.buffer,0,j),this.finished=!0}for(var q=0;q<8;q++)y[q*4+0]=this.state[q]>>>24&255,y[q*4+1]=this.state[q]>>>16&255,y[q*4+2]=this.state[q]>>>8&255,y[q*4+3]=this.state[q]>>>0&255;return this},_.prototype.digest=function(){var y=new Uint8Array(this.digestLength);return this.finish(y),y},_.prototype._saveState=function(y){for(var S=0;S<this.state.length;S++)y[S]=this.state[S]},_.prototype._restoreState=function(y,S){for(var k=0;k<this.state.length;k++)this.state[k]=y[k];this.bytesHashed=S,this.finished=!1,this.bufferLength=0},_})();r.Hash=i;var c=(function(){function _(y){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var S=new Uint8Array(this.blockSize);if(y.length>this.blockSize)new i().update(y).finish(S).clean();else for(var k=0;k<y.length;k++)S[k]=y[k];for(var k=0;k<S.length;k++)S[k]^=54;this.inner.update(S);for(var k=0;k<S.length;k++)S[k]^=106;this.outer.update(S),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var k=0;k<S.length;k++)S[k]=0}return _.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},_.prototype.clean=function(){for(var y=0;y<this.istate.length;y++)this.ostate[y]=this.istate[y]=0;this.inner.clean(),this.outer.clean()},_.prototype.update=function(y){return this.inner.update(y),this},_.prototype.finish=function(y){return this.outer.finished?this.outer.finish(y):(this.inner.finish(y),this.outer.update(y,this.digestLength).finish(y)),this},_.prototype.digest=function(){var y=new Uint8Array(this.digestLength);return this.finish(y),y},_})();r.HMAC=c;function d(_){var y=new i().update(_),S=y.digest();return y.clean(),S}r.hash=d,r.default=d;function f(_,y){var S=new c(_).update(y),k=S.digest();return S.clean(),k}r.hmac=f;function p(_,y,S,k){var E=k[0];if(E===0)throw new Error("hkdf: cannot expand more");y.reset(),E>1&&y.update(_),S&&y.update(S),y.update(k),y.finish(_),k[0]++}var b=new Uint8Array(r.digestLength);function x(_,y,S,k){y===void 0&&(y=b),k===void 0&&(k=32);for(var E=new Uint8Array([1]),T=f(y,_),j=new c(T),q=new Uint8Array(j.digestLength),z=q.length,O=new Uint8Array(k),V=0;V<k;V++)z===q.length&&(p(q,j,S,E),z=0),O[V]=q[z++];return j.clean(),q.fill(0),E.fill(0),O}r.hkdf=x;function g(_,y,S,k){for(var E=new c(_),T=E.digestLength,j=new Uint8Array(4),q=new Uint8Array(T),z=new Uint8Array(T),O=new Uint8Array(k),V=0;V*T<k;V++){var P=V+1;j[0]=P>>>24&255,j[1]=P>>>16&255,j[2]=P>>>8&255,j[3]=P>>>0&255,E.reset(),E.update(y),E.update(j),E.finish(z);for(var $=0;$<T;$++)q[$]=z[$];for(var $=2;$<=S;$++){E.reset(),E.update(z).finish(z);for(var H=0;H<T;H++)q[H]^=z[H]}for(var $=0;$<T&&V*T+$<k;$++)O[V*T+$]=q[$]}for(var V=0;V<T;V++)q[V]=z[V]=0;for(var V=0;V<4;V++)j[V]=0;return E.clean(),O}r.pbkdf2=g})})(ip)),ip.exports}var af={},Gk;function o8(){if(Gk)return af;Gk=1,Object.defineProperty(af,"__esModule",{value:!0}),af.timingSafeEqual=r;function e(n,s=""){if(!n)throw new Error(s)}function r(n,s){if(n.byteLength!==s.byteLength)return!1;n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),s instanceof DataView||(s=new DataView(ArrayBuffer.isView(s)?s.buffer:s)),e(n instanceof DataView),e(s instanceof DataView);const i=n.byteLength;let c=0,d=-1;for(;++d<i;)c|=n.getUint8(d)^s.getUint8(d);return c===0}return af}var Hk;function l8(){if(Hk)return Mo;Hk=1,Object.defineProperty(Mo,"__esModule",{value:!0}),Mo.Webhook=Mo.WebhookVerificationError=void 0;const e=a8(),r=i8(),n=o8(),s=300;class i extends Error{constructor(p){super(p),Object.setPrototypeOf(this,i.prototype),this.name="ExtendableError",this.stack=new Error(p).stack}}class c extends i{constructor(p){super(p),Object.setPrototypeOf(this,c.prototype),this.name="WebhookVerificationError"}}Mo.WebhookVerificationError=c;class d{constructor(p,b){if(b?.format==="raw")p instanceof Uint8Array?this.key=p:this.key=Uint8Array.from(p,x=>x.charCodeAt(0));else{if(typeof p!="string")throw new Error("Expected secret to be of type string");p.startsWith(d.prefix)&&(p=p.substring(d.prefix.length)),this.key=e.decode(p)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(p,b,x){var g;const _=(g=x?.jsonParse)!==null&&g!==void 0?g:!0,y={};for(const V of Object.keys(b))y[V.toLowerCase()]=b[V];const S=y["webhook-id"],k=y["webhook-signature"],E=y["webhook-timestamp"];if(!k||!S||!E)throw new c("Missing required headers");const T=this.verifyTimestamp(E),q=this.sign(S,T,p).split(",")[1],z=k.split(" "),O=new globalThis.TextEncoder;for(const V of z){const[P,$]=V.split(",");if(P==="v1"&&(0,n.timingSafeEqual)(O.encode($),O.encode(q))){const H=p.toString();return H===""?void 0:_?JSON.parse(H):void 0}}throw new c("No matching signature found")}sign(p,b,x){if(typeof x!="string")if(x.constructor.name==="Buffer")x=x.toString();else throw new Error("Expected payload to be of type string or Buffer.");const g=new TextEncoder,_=Math.floor(b.getTime()/1e3),y=g.encode(`${p}.${_}.${x}`);return`v1,${e.encode(r.hmac(this.key,y))}`}verifyTimestamp(p){const b=Math.floor(Date.now()/1e3),x=parseInt(p,10);if(Number.isNaN(x))throw new c("Invalid Signature Headers");if(b-x>s)throw new c("Message timestamp too old");if(x>b+s)throw new c("Message timestamp too new");return new Date(x*1e3)}}return Mo.Webhook=d,d.prefix="whsec_",Mo}var c8=l8();let Fk=class extends ye{parseUnverified(r){return JSON.parse(r)}unwrap(r,n){const s=n?.headers;if(s==null)throw new Error("Webhook headers are required in order to verify the signature");const i=n.key===void 0?this._client.webhookKey:n.key;if(!i)throw new Error("Webhook key must not be null or empty in order to unwrap");return new c8.Webhook(i).verify(r,s),JSON.parse(r)}},Vk=class extends ye{list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/agents/${r}/versions`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.versions.list",s,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":r}})})}};var Kk=(()=>{class e extends ye{constructor(){super(...arguments),this.versions=new Vk(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/agents",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.create",s,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d,...f}=s??{};return this._client.get(U`/v1/agents/${n}`,{query:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.retrieve",i,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/agents/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.update",i,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/agents",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.list",s,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/agents/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.agents.archive",i,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":n}})})}}return e.Versions=Vk,e})();let Yx=function(){const{crypto:e}=globalThis;if(e?.randomUUID)return Yx=e.randomUUID.bind(e),e.randomUUID();const r=new Uint8Array(1),n=e?()=>e.getRandomValues(r)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,s=>(+s^n()&15>>+s/4).toString(16))};function uh(e,r){if(!e)return()=>{};if(e.aborted)return r.abort(),()=>{};const n=()=>r.abort();return e.addEventListener("abort",n),()=>e.removeEventListener("abort",n)}function $c(e,r){return e instanceof Gt&&e.status===r}function u8(e){return e instanceof Gt&&typeof e.status=="number"&&e.status>=400&&e.status<500}function wp(e){return u8(e)&&!$c(e,408)&&!$c(e,409)&&!$c(e,429)}function NT(e,r,n){return Math.min(r*2**e,n)}function d8(e,r){return e+Math.random()*(r-e)}function AT(e){return e*(1-Math.random()*.25)}function jT(e,{authToken:r,helper:n}){if(!r)throw new De(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(r)}`);const s=e._options.defaultHeaders,i=e._authState?.extraHeaders,c=i?Object.fromEntries(Object.entries(i).filter(([f])=>{const p=f.toLowerCase();return p!=="authorization"&&p!=="x-api-key"})):void 0,d=L([c,s,{[vh]:n}]);return d.values.delete("x-api-key"),d.values.delete("authorization"),d.nulls.delete("authorization"),e.withOptions({authToken:r,baseURL:e.baseURL,defaultHeaders:d})}var oc,rf,ms,of,lf,cf,cd,ud,lc,cc,uf,uc,dd;const h8=999,m8=1e3,f8=6e4,p8=3e5;var Wx=(()=>{class e{constructor(n){oc.set(this,void 0),rf.set(this,!1),ms.set(this,void 0),of.set(this,void 0),lf.set(this,void 0),cf.set(this,void 0),cd.set(this,void 0),ud.set(this,void 0),lc.set(this,void 0),this.client=n.client,this.environmentId=n.environmentId,this.environmentKey=n.environmentKey,this.workerId=n.workerId??x8(),se(this,oc,jT(n.client,{authToken:n.environmentKey,helper:"environments-work-poller"})),se(this,lf,n.autoStop??!0),se(this,cf,n.drain??!1),se(this,cd,n.blockMs===void 0?h8:n.blockMs),se(this,ud,n.reclaimOlderThanMs??null),se(this,lc,n.requestOptions),se(this,ms,new AbortController),se(this,of,uh(n.signal,v(this,ms,"f")))}get signal(){return v(this,ms,"f").signal}abort(){v(this,ms,"f").abort()}async*[(oc=new WeakMap,rf=new WeakMap,ms=new WeakMap,of=new WeakMap,lf=new WeakMap,cf=new WeakMap,cd=new WeakMap,ud=new WeakMap,lc=new WeakMap,Symbol.asyncIterator)](){if(v(this,rf,"f"))throw new De("Cannot iterate over a consumed WorkPoller");se(this,rf,!0);let n=Hs.active();const s=it(this.client);s.info("poller starting",{component:"work-poller",environment_id:this.environmentId});const i=new b8(s,this.environmentId);try{let c=0;for(;!v(this,ms,"f").signal.aborted;){let d;try{d=await v(this,oc,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...v(this,cd,"f")!==null?{block_ms:v(this,cd,"f")}:{},...v(this,ud,"f")!==null?{reclaim_older_than_ms:v(this,ud,"f")}:{}},{headers:L([v(this,lc,"f")?.headers]),signal:v(this,ms,"f").signal})}catch(f){if(v(this,ms,"f").signal.aborted)return;if(wp(f))throw s.error("poll failed permanently, stopping poller",{error:String(f)}),f;const p=AT(g8(c));s.warn("poll failed, backing off",{error:String(f),backoff_ms:p}),c++,await Ko(p,v(this,ms,"f").signal);continue}if(c=0,d==null){if(v(this,cf,"f"))return;i.onEmptyPoll(),await Ko(d8(1e3,3e3),v(this,ms,"f").signal);continue}i.onClaim(),this._workSpan=zt(this.client,()=>ZP(this.client,d,n)),s.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:d.id,work_type:d.data.type});try{await v(this,oc,"f").beta.environments.work.ack(d.id,{environment_id:d.environment_id},{headers:L([v(this,lc,"f")?.headers]),signal:v(this,ms,"f").signal})}catch(f){s.error("ack failed",{work_id:d.id,error:String(f)}),zt(this.client,()=>oT(this._workSpan,v(this,ms,"f").signal,f));continue}try{yield d,n=Hs.active()}finally{if(v(this,lf,"f"))try{await v(this,oc,"f").beta.environments.work.stop(d.id,{environment_id:d.environment_id},{headers:L([v(this,lc,"f")?.headers])})}catch(f){$c(f,409)||s.warn("stop failed",{work_id:d.id,error:String(f)})}zt(this.client,()=>iT(this._workSpan,v(this,ms,"f").signal))}}}finally{v(this,of,"f").call(this)}}}return e})();function g8(e){return NT(e,m8,f8)}var b8=(()=>{class e{constructor(n,s){cc.set(this,void 0),uf.set(this,void 0),uc.set(this,void 0),dd.set(this,0),se(this,cc,n),se(this,uf,s)}onEmptyPoll(){const n=Date.now(),s={component:"work-poller",environment_id:v(this,uf,"f")};v(this,uc,"f")===void 0?(se(this,uc,se(this,dd,n,"f")),v(this,cc,"f").info("idle; polling for work",s)):n-v(this,dd,"f")>=p8?(se(this,dd,n),v(this,cc,"f").info(`still polling; idle for ${Math.round((n-v(this,uc,"f"))/1e3)}s`,s)):v(this,cc,"f").debug("poll returned no work",s)}onClaim(){se(this,uc,void 0)}}return cc=new WeakMap,uf=new WeakMap,uc=new WeakMap,dd=new WeakMap,e})();function x8(){const r=globalThis.process?.env?.HOSTNAME;return r?`${r}-${Yx()}`:Yx()}const y8=e=>{if(typeof globalThis.Buffer<"u"){const r=globalThis.Buffer.from(e,"base64");return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}if(typeof atob<"u"){const r=atob(e),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return n}throw new De("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var dc,Ei,hc,_8=(()=>{class e{constructor(){dc.set(this,[]),Ei.set(this,[]),hc.set(this,!1)}push(n){if(v(this,hc,"f"))return!1;const s=v(this,Ei,"f").shift();return s?s({done:!1,value:n}):v(this,dc,"f").push(n),!0}close(){if(!v(this,hc,"f"))for(se(this,hc,!0);v(this,Ei,"f").length>0;)v(this,Ei,"f").shift()({done:!0,value:void 0})}next(n){return v(this,dc,"f").length>0?Promise.resolve({done:!1,value:v(this,dc,"f").shift()}):v(this,hc,"f")||n?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(s=>{const i=d=>{n?.removeEventListener("abort",c),s(d)},c=()=>{const d=v(this,Ei,"f").indexOf(i);d>=0&&v(this,Ei,"f").splice(d,1),s({done:!0,value:void 0})};v(this,Ei,"f").push(i),n?.addEventListener("abort",c,{once:!0})})}tryShift(){return v(this,dc,"f").shift()}}return dc=new WeakMap,Ei=new WeakMap,hc=new WeakMap,e})(),l_=(()=>{class e extends Error{constructor(n){const s=typeof n=="string"?n:n.map(i=>i.type==="text"?i.text:`[${i.type}]`).join(" ");super(s),this.name="ToolError",this.content=n}}return e})();const v8="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",w8=new RegExp(`[${v8}]+`,"g"),S8=/[\uD800-\uDFFF]/gu;function Sp(e){return e.replace(S8,"�")}const TT=4096,k8=200;function C8(e,r=TT){return MT(Sp(e).replace(w8," ").trim(),r)}function N8(e){return C8(e,k8)}function Bi(e){return N8(e).replace(/[' ]+/g," ").trim()}function ET(e){return`Error: ${e instanceof Error?e.message:String(e)}`}function A8(e){return MT(Sp(ET(e)),TT)}function MT(e,r){if(e.length<=r)return e;let n=0,s=0;for(const i of e){if(s===r)break;s+=1,n+=i.length}return e.slice(0,n)}function j8(e){return typeof e=="string"?Sp(e):e.filter(r=>r.type==="text"&&r.text!=="").map(r=>({...r,text:Sp(r.text)}))}function Yk(e){return"name"in e?e.name:"mcp_server_name"in e?e.mcp_server_name:e.type}function T8(e){return e instanceof l_?e.content:ET(e)}async function RT(e,r,n){try{const s=e.parse?e.parse(r):r;return{content:await e.run(s,n),isError:!1}}catch(s){return{content:T8(s),isError:!0}}}var hd,df,mc,Ro,_a,Ft,hf,vn,mf,fc,ff,mn,pc,Os,gc,Mi,bc,Sr,pf,md,Ps,gf,fd,pd,bf,Wk,Xk,Qk,Bb,Jk,Gb,Zk,xf,yf,Hb,eC,tC;const nC=500,E8=1e4,M8=12e4,R8=3e4,z8=1e3,O8=3e4,P8=5*6e4,$8=6e4;function zT(e){return e.type!=="session.status_idle"?!1:e.stop_reason?.type!=="requires_action"}var I8=(()=>{class e{constructor(n,s){hd.set(this,void 0),df.set(this,void 0),mc.set(this,new Set),Ro.set(this,!1),_a.set(this,void 0),se(this,hd,n),se(this,df,s)}noteEvent(n){n.type!=="user.tool_confirmation"&&(zT(n)?this.arm():this.disarm())}block(n){v(this,mc,"f").add(n),v(this,_a,"f")!==void 0&&(se(this,Ro,!0),clearTimeout(v(this,_a,"f")),se(this,_a,void 0))}unblock(n){v(this,mc,"f").delete(n),v(this,mc,"f").size===0&&v(this,Ro,"f")&&this.arm()}arm(){if(!(v(this,hd,"f")<=0)){if(v(this,mc,"f").size>0){se(this,Ro,!0);return}se(this,Ro,!1),v(this,_a,"f")!==void 0&&clearTimeout(v(this,_a,"f")),se(this,_a,setTimeout(v(this,df,"f"),v(this,hd,"f")))}}disarm(){se(this,Ro,!1),v(this,_a,"f")!==void 0&&(clearTimeout(v(this,_a,"f")),se(this,_a,void 0))}}return hd=new WeakMap,df=new WeakMap,mc=new WeakMap,Ro=new WeakMap,_a=new WeakMap,e})(),Xx=(()=>{class e{constructor(n,s){Ft.add(this),hf.set(this,!1),vn.set(this,void 0),mf.set(this,void 0),fc.set(this,void 0),ff.set(this,void 0),mn.set(this,void 0),pc.set(this,new Set),Os.set(this,new Set),gc.set(this,new Map),Mi.set(this,new Map),bc.set(this,new _8),Sr.set(this,0),pf.set(this,P8),md.set(this,null),Ps.set(this,void 0),gf.set(this,void 0),fd.set(this,void 0),pd.set(this,!1),this.client=s.client,this.sessionId=n,this.tools=s.tools,this.maxIdleMs=s.maxIdleMs??$8,se(this,mn,it(s.client)),se(this,ff,new Map(s.tools.map(i=>[Yk(i),i]))),se(this,vn,new AbortController),se(this,mf,uh(s.signal,v(this,vn,"f"))),se(this,fc,s.requestOptions),se(this,Ps,new I8(this.maxIdleMs,()=>{v(this,mn,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),v(this,vn,"f").abort()}))}get signal(){return v(this,vn,"f").signal}abort(){v(this,vn,"f").abort()}_setSendRetryWindow(n){se(this,pf,n)}async*[(hf=new WeakMap,vn=new WeakMap,mf=new WeakMap,fc=new WeakMap,ff=new WeakMap,mn=new WeakMap,pc=new WeakMap,Os=new WeakMap,gc=new WeakMap,Mi=new WeakMap,bc=new WeakMap,Sr=new WeakMap,pf=new WeakMap,md=new WeakMap,Ps=new WeakMap,gf=new WeakMap,fd=new WeakMap,pd=new WeakMap,Ft=new WeakSet,Symbol.asyncIterator)](){if(v(this,hf,"f"))throw new De("Cannot iterate over a consumed SessionToolRunner");se(this,hf,!0),se(this,gf,this.client._tracer?Hs.active():void 0),v(this,mn,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});const n=v(this,Ft,"m",Wk).call(this).catch(s=>{v(this,vn,"f").signal.aborted||v(this,mn,"f").error("stream loop failed",{error:String(s)}),v(this,vn,"f").abort()});try{for(;;){const i=await v(this,bc,"f").next(v(this,vn,"f").signal);if(i.done)break;yield i.value}await n;let s;for(;(s=v(this,bc,"f").tryShift())!==void 0;)yield s}finally{v(this,vn,"f").abort(),v(this,Ps,"f").disarm(),await n;try{await v(this,Ft,"m",tC).call(this)}catch(s){v(this,mn,"f").warn("drain failed",{error:String(s)})}v(this,bc,"f").close();for(const s of this.tools)try{await s.close?.()}catch(i){v(this,mn,"f").warn("tool.close failed",{tool:Yk(s),error:String(i)})}v(this,mf,"f").call(this)}}}return bf=function(){return{...v(this,fc,"f"),headers:L([s_("session-tool-runner"),v(this,fc,"f")?.headers]),signal:v(this,vn,"f").signal}},Wk=async function(){const n=v(this,vn,"f");let s=nC;for(;!n.signal.aborted;){try{const i=await this.client.beta.sessions.events.stream(this.sessionId,{},v(this,Ft,"m",bf).call(this));await v(this,Ft,"m",Xk).call(this);for await(const c of i)if(s=nC,await v(this,Ft,"m",Jk).call(this,c))return}catch(i){if(n.signal.throwIfAborted(),wp(i))throw v(this,mn,"f").error("permanent stream failure, shutting down",{error:String(i)}),n.abort(),i;v(this,mn,"f").warn("stream disconnected, reconnecting",{error:String(i),backoff_ms:s})}n.signal.throwIfAborted(),await Ko(s,n.signal),s=Math.min(s*2,E8)}},Xk=async function(){const n=v(this,vn,"f"),s=[];let i=!1;se(this,pd,!1);try{for await(const f of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},v(this,Ft,"m",bf).call(this)))v(this,Ft,"m",Qk).call(this,f,s),f.type!=="user.tool_confirmation"&&(i=zT(f))}catch(f){n.signal.throwIfAborted(),v(this,mn,"f").warn("reconcile list failed",{error:String(f)});for(const p of s)v(this,pc,"f").delete(p.id);return}se(this,pd,!0);const c=s.filter(f=>!v(this,Os,"f").has(f.id));v(this,Ps,"f").disarm();for(const f of c)await v(this,Ft,"m",Gb).call(this,f);for(const f of[...v(this,Mi,"f").values()]){const p=v(this,gc,"f").get(f.id);p!==void 0&&await v(this,Ft,"m",xf).call(this,f,p)}const d=c.filter(f=>!v(this,Os,"f").has(f.id)&&!v(this,Mi,"f").has(f.id));i&&d.length===0?v(this,Ps,"f").arm():v(this,Ps,"f").disarm()},Qk=function(n,s){v(this,Ft,"m",Bb).call(this,n),n.type==="agent.tool_use"||n.type==="agent.custom_tool_use"?(v(this,pc,"f").add(n.id),v(this,Os,"f").has(n.id)||s.push(n)):n.type==="user.tool_result"?v(this,Os,"f").add(n.tool_use_id):n.type==="user.custom_tool_result"?v(this,Os,"f").add(n.custom_tool_use_id):n.type==="user.tool_confirmation"&&(v(this,Os,"f").has(n.tool_use_id)||v(this,gc,"f").set(n.tool_use_id,n.result))},Bb=function(n){if(!(!this.client._tracer||v(this,fd,"f")!==void 0))switch(n.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":se(this,fd,n.session_thread_id)}},Jk=async function(n){switch(v(this,Ps,"f").noteEvent(n),v(this,pd,"f")&&v(this,Ft,"m",Bb).call(this,n),n.type){case"agent.tool_use":case"agent.custom_tool_use":return v(this,pc,"f").has(n.id)||(v(this,pc,"f").add(n.id),await v(this,Ft,"m",Gb).call(this,n)),!1;case"user.tool_confirmation":return await v(this,Ft,"m",Zk).call(this,n),!1;case"user.tool_result":return v(this,Os,"f").add(n.tool_use_id),!1;case"user.custom_tool_result":return v(this,Os,"f").add(n.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return v(this,mn,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),v(this,vn,"f").abort(),!0;default:return!1}},Gb=async function(n){const s=n.evaluated_permission,i=s==="deny"?"deny":v(this,gc,"f").get(n.id);if(i===void 0){s===void 0||s==="allow"?await v(this,Ft,"m",Hb).call(this,n,void 0):v(this,Mi,"f").has(n.id)||(v(this,mn,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:n.name,tool_use_id:n.id}),v(this,Mi,"f").set(n.id,n),v(this,Ps,"f").block(n.id));return}await v(this,Ft,"m",xf).call(this,n,i)},Zk=async function(n){v(this,gc,"f").set(n.tool_use_id,n.result);const s=v(this,Mi,"f").get(n.tool_use_id);s!==void 0&&await v(this,Ft,"m",xf).call(this,s,n.result)},xf=async function(n,s){const i=v(this,Mi,"f").delete(n.id);if(s==="allow"){v(this,mn,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:n.name,tool_use_id:n.id}),i||v(this,Ps,"f").block(n.id);try{await v(this,Ft,"m",Hb).call(this,n,"allow")}finally{v(this,Ps,"f").unblock(n.id)}return}i&&v(this,Ps,"f").unblock(n.id),v(this,Os,"f").add(n.id),v(this,mn,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:n.name,tool_use_id:n.id}),v(this,Ft,"m",yf).call(this,{event:n,toolUseId:n.id,name:n.name,isError:!1,posted:!1,confirmation:"deny"})},yf=function(n){v(this,bc,"f").push(n)},Hb=async function(n,s){var i,c;if(!v(this,Os,"f").has(n.id)){v(this,mn,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:n.name,tool_use_id:n.id}),se(this,Sr,(i=v(this,Sr,"f"),i++,i));try{const d=v(this,ff,"f").get(n.name);if(!d){v(this,mn,"f").info("tool not owned by this runner; leaving the tool_use_id pending for its owner",{component:"session-tool-runner",session_id:this.sessionId,tool:n.name,tool_use_id:n.id}),s==="allow"&&v(this,Ps,"f").disarm(),v(this,Ft,"m",yf).call(this,{event:n,toolUseId:n.id,name:n.name,isError:!1,posted:!1,confirmation:s});return}let f,p;const b=v(this,fc,"f")?.openTelemetry?.conversationId??(n.session_thread_id||v(this,fd,"f")),x=new AbortController,g=uh(v(this,vn,"f").signal,x),_=setTimeout(()=>x.abort(),M8);try{const k={signal:v(this,vn,"f").signal,conversationId:b,sessionID:this.sessionId,parentContext:v(this,gf,"f")},E=await a_(this.client,d,n,k,async()=>{const T=await RT(d,n.input,{toolUse:n,toolUseBlock:n,signal:x.signal}),j=q8(T.content),q=this.client._tracer?j.map((z,O)=>{const V=typeof T.content=="string"?void 0:T.content[O];return V&&V.type!=="text"&&z.type==="text"?V:z}):j;return{sent:j,content:q,isError:T.isError}});f=E.sent,p=E.isError}finally{clearTimeout(_),g()}const y=D8(n,p,f),S=await v(this,Ft,"m",eC).call(this,y,n.id,b);v(this,Ft,"m",yf).call(this,{event:n,result:y,toolUseId:n.id,name:n.name,isError:p,posted:S,confirmation:s})}finally{se(this,Sr,(c=v(this,Sr,"f"),c--,c)),v(this,Sr,"f")===0&&v(this,md,"f")?.call(this)}}},eC=async function(n,s,i){const c=v(this,vn,"f"),d=Date.now();let f,p=0;for(;;){p++,c.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[n]},{...v(this,Ft,"m",bf).call(this),openTelemetry:{conversationId:i}}),v(this,Os,"f").add(s),!0}catch(b){if(f=b,wp(b))break;const x=v(this,pf,"f")-(Date.now()-d);if(x<=0)break;const g=Math.min(AT(NT(p-1,z8,O8)),x);v(this,mn,"f").warn("tool result send failed; retrying",{tool_use_id:s,attempt:p,backoff_ms:g,error:String(b)}),await Ko(g,c.signal)}}return v(this,mn,"f").error("failed to send tool result",{tool_use_id:s,attempts:p,error:String(f)}),!1},tC=async function(){v(this,Sr,"f")!==0&&(await Promise.race([new Promise(n=>se(this,md,n)),Ko(R8)]),se(this,md,null),v(this,Sr,"f")>0&&v(this,mn,"f").warn("drain timeout exceeded"))},e})();function D8(e,r,n){return e.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:e.id,is_error:r,content:n}:{type:"user.tool_result",tool_use_id:e.id,is_error:r,content:n}}function q8(e){if(typeof e=="string")return[{type:"text",text:e||"(no output)"}];const r=e.map(n=>n.type==="text"?{type:"text",text:n.text||"(no output)"}:n.type==="image"||n.type==="document"?n:n.type==="search_result"?{type:"search_result",source:n.source,title:n.title,content:n.content.map(s=>({type:"text",text:s.text})),citations:{enabled:n.citations?.enabled??!1}}:{type:"text",text:JSON.stringify(n)});return r.length>0?r:[{type:"text",text:"(no output)"}]}const eU=15e3,sC=5e3;function L8(e,r){if(!(e>=sC))throw new De(`${r} must be at least ${sC}ms (got ${e}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var _f,gd,Fb,bd,zo;const aC=3e4,U8=9e4,B8="NO_HEARTBEAT";function G8(e){return e.resources.some(r=>r.type==="memory_store")}function H8(e){if(!e)return null;let r;try{const s=e.replace(/-/g,"+").replace(/_/g,"/"),i=s.padEnd(Math.ceil(s.length/4)*4,"=");r=JSON.parse(Ux(y8(i)))}catch{return null}if(r===null||typeof r!="object"||Array.isArray(r))return null;const n=r.sessions_token;return typeof n=="string"&&n!==""?n:null}var rC=(()=>{class e{constructor(n){if(_f.add(this),gd.set(this,void 0),n.unrestrictedPaths!==void 0)throw new De("The `unrestrictedPaths` option you passed to EnvironmentWorker (or client.beta.environments.work.worker()) is no longer supported. The worker's file tools (read, write, edit, glob, grep) are now always confined to `workdir` plus the session's memory folders. Remove `unrestrictedPaths` from your options; to let the file tools reach any other directory, add it to `AgentToolContext.allowedRoots` from a `tools` factory.");this.client=n.client,this.environmentId=n.environmentId,this.environmentKey=n.environmentKey,this.tools=n.tools,this.workdir=n.workdir??process.cwd(),this.maxFileBytes=n.maxFileBytes,this.maxIdleMs=n.maxIdleMs,n.memorySyncIntervalMs!=null&&L8(n.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=n.memorySyncIntervalMs,this.memorySyncDeletions=n.memorySyncDeletions??"enabled",this.workerId=n.workerId,this.requestOptions=n.requestOptions,se(this,gd,n.signal)}async run(n){const{environmentId:s,environmentKey:i}=this;if(s===void 0||i===void 0)throw new De("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");const c=n??v(this,gd,"f"),d=new Wx({client:this.client,environmentId:s,environmentKey:i,...this.workerId!==void 0?{workerId:this.workerId}:{},...c?{signal:c}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(const f of d){const p=d._workSpan;try{await e8(this.client,p,d.signal,()=>v(this,_f,"m",Fb).call(this,f,i,d.signal,p))}catch(b){if(d.signal?.aborted)throw b;it(this.client).error("work item failed",{work_id:f.id,error:String(b)})}}}async handleItem(n){const s=n?.workId??ot("ANTHROPIC_WORK_ID"),i=n?.environmentId??ot("ANTHROPIC_ENVIRONMENT_ID"),c=n?.sessionId??ot("ANTHROPIC_SESSION_ID"),d=(n?.environmentKey??this.environmentKey??ot("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,f=n?.workSecret||ot("ANTHROPIC_WORK_SECRET")||null;if(!s)throw new De("handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID");if(!i)throw new De("handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!c)throw new De("handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID");if(!d&&!f)throw new De("handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");const p={id:s,environment_id:i,secret:f,data:{type:"session",id:c}};await v(this,_f,"m",Fb).call(this,p,d,n?.signal??v(this,gd,"f"))}}return gd=new WeakMap,_f=new WeakSet,Fb=async function(n,s,i,c){const d=it(this.client),f=H8(n.secret),p=f??s;if(p===void 0)throw new De("handleItem: the work item carried a secret payload but no sessions token could be extracted, and there is no environment key to fall back to; the poller must issue a secret whose payload carries `sessions_token`, or provide the environment key (pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY)");n.secret&&f===null&&d.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:n.id});const b=jT(this.client,{authToken:p,helper:"environments-worker"}),x=n.data.id,g=new AbortController,_=uh(i,g),y=new V8(g),S=await Aa(()=>import("./node.browser-BoI8HeAS.js"),[]);let k,E;const T=Y8(b,n,y,d,this.requestOptions,O=>{k=O,E?._setSendRetryWindow(O)}).catch(O=>{g.signal.aborted||d.error("heartbeat loop failed",{work_id:n.id,error:String(O)}),g.abort()});let j=async()=>{},q,z=!1;try{if(n.data.type!=="session"){d.debug("skipping non-session work item",{work_id:n.id,type:n.data.type});return}const O=await b.beta.sessions.retrieve(x);if(f===null&&this.memorySyncIntervalMs!==null&&G8(O))throw new S.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${n.id}, session_id=${x}); the memory endpoints reject the environment key, so the poller must issue a per-item \`secret\` carrying \`sessions_token\`, or set \`memorySyncIntervalMs: null\` to run without memory`);const V={workdir:this.workdir,client:b,session:O,...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}};try{j=await S.setupSkills(V)}catch($){d.warn("skill setup failed",{session_id:x,work_id:n.id,error:String($)})}f!==null&&this.memorySyncIntervalMs!==null?(q=new S.SessionMemoryStores(b,{workdir:this.workdir,...this.memorySyncIntervalMs!==void 0?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await q.download(O),V.allowedRoots=q.roots,V.readOnlyRoots=q.readOnlyRoots):d.debug("memory stores disabled for this item",{work_id:n.id});const P=typeof this.tools=="function"?this.tools(V):this.tools??S.betaAgentToolset20260401(V);E=new Xx(x,{client:b,tools:P,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:g.signal}),k!==void 0&&E._setSendRetryWindow(k);for await(const $ of E)q&&await q.syncIfDue();z=!g.signal.aborted}finally{try{await j().catch(O=>{d.warn("skill cleanup failed",{session_id:x,work_id:n.id,error:String(O)})})}finally{if(q){const O=S.MEMORY_FLUSH_TIMEOUT_MS;z&&await iC(q.finish(),O)&&d.warn(`final memory sync cut off after ${O}ms; the flush that follows still uploads changed files`,{session_id:x,work_id:n.id});const V=new AbortController;await iC(q.flushWrites(V.signal),O)&&(V.abort(),d.warn(`memory flush cut off after ${O}ms; changed files it had not uploaded yet are not saved`,{session_id:x,work_id:n.id})),await q.dispose().catch($=>{d.warn("memory store cleanup failed",{session_id:x,work_id:n.id,error:String($)})})}}y.finish("runner_done"),_(),await T,y.lost?d.info("lease lost; released without stopping it",{session_id:x,work_id:n.id}):await F8(b,n,d,this.requestOptions),(y.lost||y.rejected)&&zt(this.client,()=>c?.end())}},e})();async function iC(e,r){let n;try{return await Promise.race([e.then(()=>!1,()=>!1),new Promise(s=>{n=setTimeout(()=>s(!0),r)})])}finally{n!==void 0&&clearTimeout(n)}}async function F8(e,r,n,s){try{await e.beta.environments.work.stop(r.id,{environment_id:r.environment_id,force:!0},{...s,headers:L([s?.headers])})}catch(i){$c(i,409)||n.error("force-stop on exit failed",{work_id:r.id,error:String(i)})}}var V8=(()=>{class e{constructor(n){bd.set(this,void 0),zo.set(this,void 0),se(this,bd,n)}get signal(){return v(this,bd,"f").signal}finish(n){se(this,zo,v(this,zo,"f")??n),v(this,bd,"f").abort()}get lost(){return v(this,zo,"f")==="lease_lost"||v(this,zo,"f")==="assumed_lost"}get rejected(){return v(this,zo,"f")==="heartbeat_rejected"}}return bd=new WeakMap,zo=new WeakMap,e})();function K8(e){let r=e instanceof Gt?e.error:void 0;for(const n of["error","details","current_state"]){if(!Hn(r))return{};r=r[n]}return Hn(r)?r:{}}async function Y8(e,r,n,s,i,c){let d=aC,f=U8,p=Date.now(),b=B8;const x=async()=>{const g=new AbortController,_=uh(n.signal,g),y=setTimeout(()=>g.abort(),d);try{const S=await e.beta.environments.work.heartbeat(r.id,{environment_id:r.environment_id,expected_last_heartbeat:b},{...i,headers:L([i?.headers]),signal:g.signal});p=Date.now(),b=S.last_heartbeat,S.ttl_seconds>0&&(f=S.ttl_seconds*1e3,d=Math.max(1e3,Math.min(f/2,aC)),c?.(f)),(S.state==="stopping"||S.state==="stopped")&&(s.info("heartbeat signals shutdown",{work_id:r.id,state:S.state}),n.finish("heartbeat_stop")),S.lease_extended||(s.warn("lease not extended, shutting down",{work_id:r.id}),n.finish("heartbeat_stop"))}catch(S){if(n.signal.throwIfAborted(),$c(S,412)){const k=K8(S);s.error("lease lost: heartbeat precondition failed",{work_id:r.id,server_state:k.state,server_ttl_seconds:k.ttl_seconds,server_last_heartbeat:k.last_heartbeat}),n.finish("lease_lost");return}if(wp(S))throw s.error("permanent heartbeat failure",{work_id:r.id,error:String(S)}),n.finish("heartbeat_rejected"),S;if(Date.now()-p>f){s.error("lease assumed lost: no successful heartbeat in ttl",{work_id:r.id,ttl_ms:f,error:String(S)}),n.finish("assumed_lost");return}s.warn("transient heartbeat failure",{work_id:r.id,error:String(S)})}finally{clearTimeout(y),_()}};for(await x();!n.signal.aborted;)await Ko(d,n.signal),n.signal.throwIfAborted(),await x()}var c_=(()=>{class e extends Dy{}return e._errorName="BetaHeartbeatPreconditionFailedError",e})(),oC=(()=>{class e extends ye{retrieve(n,s,i){const{environment_id:c,betas:d,workspace_id:f}=s;return this._client.get(U`/v1/environments/${c}/work/${n}`,{...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.retrieve",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":c,"anthropic.environment.work.id":n}})})}update(n,s,i){const{environment_id:c,betas:d,workspace_id:f,...p}=s;return this._client.post(U`/v1/environments/${c}/work/${n}`,{body:p,...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.update",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":c,"anthropic.environment.work.id":n}})})}list(n,s={},i){const{betas:c,...d}=s??{};return this._client.getAPIList(U`/v1/environments/${n}/work`,Me,{query:d,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.list",i,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":n}})})}ack(n,s,i){const{environment_id:c,betas:d}=s;return this._client.post(U`/v1/environments/${c}/work/${n}/ack`,{...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.ack",i,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":c,"anthropic.environment.work.id":n}})})}heartbeat(n,s,i){const{environment_id:c,desired_ttl_seconds:d,expected_last_heartbeat:f,betas:p}=s;return this._client.post(U`/v1/environments/${c}/work/${n}/heartbeat`,{query:{desired_ttl_seconds:d,expected_last_heartbeat:f},...i,headers:L([{"anthropic-beta":[...p??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.heartbeat",i,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":c,"anthropic.environment.work.id":n}})})}poll(n,s={},i){const{betas:c,"Anthropic-Worker-ID":d,...f}=s??{};return this._client.get(U`/v1/environments/${n}/work/poll`,{query:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"Anthropic-Worker-ID":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.poll",i,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":n}})})}stats(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/environments/${n}/work/stats`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.stats",i,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":n}})})}stop(n,s,i){const{environment_id:c,betas:d,workspace_id:f,...p}=s;return this._client.post(U`/v1/environments/${c}/work/${n}/stop`,{body:p,...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.work.stop",i,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":c,"anthropic.environment.work.id":n}})})}poller(n){return new Wx({...n,client:this._client})}worker(n){return new rC({...n,client:this._client})}}return e.BetaHeartbeatPreconditionFailedError=c_,e.WorkPoller=Wx,e.EnvironmentWorker=rC,e})(),u_=(()=>{class e extends Ye{}return e._errorName="BetaEnvironmentArchivedError",e})(),d_=(()=>{class e extends Ye{}return e._errorName="BetaInvalidConfigTypeChangeError",e})(),h_=(()=>{class e extends Ye{}return e._errorName="BetaInvalidMetadataError",e})(),m_=(()=>{class e extends vs{}return e._errorName="BetaEnvironmentCreateDisabledError",e})(),f_=(()=>{class e extends vs{}return e._errorName="BetaEnvironmentUpdateDisabledError",e})(),p_=(()=>{class e extends Zc{}return e._errorName="BetaEnvironmentNotFoundError",e})(),lC=(()=>{class e extends ye{constructor(){super(...arguments),this.work=new oC(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/environments",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.create",s,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/environments/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.retrieve",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/environments/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.update",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/environments",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.list",s,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/environments/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.delete",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":n}})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/environments/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.environments.archive",i,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":n}})})}}return e.BetaEnvironmentArchivedError=u_,e.BetaInvalidConfigTypeChangeError=d_,e.BetaInvalidMetadataError=h_,e.BetaEnvironmentCreateDisabledError=m_,e.BetaEnvironmentUpdateDisabledError=f_,e.BetaEnvironmentNotFoundError=p_,e.Work=oC,e.BetaHeartbeatPreconditionFailedError=c_,e})();class cC extends ye{create(r,n,s){const{view:i,betas:c,workspace_id:d,...f}=n;return this._client.post(U`/v1/memory_stores/${r}/memories`,{query:{view:i},body:f,...s,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memories.create",s,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":r},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(r,n,s){const{memory_store_id:i,betas:c,workspace_id:d,...f}=n;return this._client.get(U`/v1/memory_stores/${i}/memories/${r}`,{query:f,...s,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memories.retrieve",s,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":r}})})}update(r,n,s){const{memory_store_id:i,view:c,betas:d,workspace_id:f,...p}=n;return this._client.post(U`/v1/memory_stores/${i}/memories/${r}`,{query:{view:c},body:p,...s,headers:L([{"anthropic-beta":[...d??[],"agent-memory-2026-07-22"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memories.update",s,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/memory_stores/${r}/memories`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memories.list",s,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":r}})})}delete(r,n,s){const{memory_store_id:i,expected_content_sha256:c,betas:d,workspace_id:f}=n;return this._client.delete(U`/v1/memory_stores/${i}/memories/${r}`,{query:{expected_content_sha256:c},...s,headers:L([{"anthropic-beta":[...d??[],"agent-memory-2026-07-22"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memories.delete",s,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":r}})})}}class uC extends ye{retrieve(r,n,s){const{memory_store_id:i,betas:c,workspace_id:d,...f}=n;return this._client.get(U`/v1/memory_stores/${i}/memory_versions/${r}`,{query:f,...s,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memory_versions.retrieve",s,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/memory_stores/${r}/memory_versions`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memory_versions.list",s,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":r}})})}redact(r,n,s){const{memory_store_id:i,betas:c,workspace_id:d}=n;return this._client.post(U`/v1/memory_stores/${i}/memory_versions/${r}/redact`,{...s,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.memory_versions.redact",s,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":r}})})}}var dC=(()=>{class e extends ye{constructor(){super(...arguments),this.memories=new cC(this._client),this.memoryVersions=new uC(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/memory_stores",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.create",s,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/memory_stores/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/memory_stores/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.update",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/memory_stores",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.list",s,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/memory_stores/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.delete",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":n}})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/memory_stores/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"agent-memory-2026-07-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.memory_stores.archive",i,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":n}})})}}return e.Memories=cC,e.MemoryVersions=uC,e})(),OT=(()=>{class e{constructor(n,s,i){this.iterator=n,this.response=i,this.controller=s}async*decoder(){const n=this.iterator;if(!n)throw new De("Cannot iterate over a consumed stream.");this.iterator=void 0;const s=new Oj;for await(const i of n)for(const c of s.decode(i))yield JSON.parse(c);for(const i of s.flush())yield JSON.parse(i)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(n,s){if(!n.body)throw s.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new De("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new De("Attempted to iterate over a response with no body");return new e(By(n.body),s,n)}}return e})();let hC=class extends ye{create(r,n){const{betas:s,user_profile_id:i,workspace_id:c,...d}=r;return this._client.post("/v1/messages/batches",{body:d,...n,headers:L([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),...i!=null?{"anthropic-user-profile-id":i}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.messages.batches.create",n,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":d.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.get(U`/v1/messages/batches/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.messages.batches.retrieve",s,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":r}})})}list(r={},n){const{betas:s,workspace_id:i,...c}=r??{};return this._client.getAPIList("/v1/messages/batches",ns,{query:c,...n,headers:L([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.messages.batches.list",n,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.delete(U`/v1/messages/batches/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.messages.batches.delete",s,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":r}})})}cancel(r,n={},s){const{betas:i,workspace_id:c}=n??{};return this._client.post(U`/v1/messages/batches/${r}/cancel`,{...s,headers:L([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.messages.batches.cancel",s,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":r}})})}async results(r,n={},s){const i=await this.retrieve(r,n,s);if(!i.results_url)throw new De(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{betas:c,workspace_id:d}=n??{};return this._client.get(i.results_url,{...s,headers:L([{"anthropic-beta":[...c??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:N(this._client,"anthropic.messages.batches.results",s,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":r}})})._thenUnwrap((f,p)=>OT.fromResponse(p.response,p.controller))}};const PT={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function $T(e){return e?.output_format??e?.output_config?.format}function mC(e,r,n){const s=$T(r);return!r||!("parse"in(s??{}))?{...e,content:e.content.map(i=>{if(i.type==="text"){const c=Object.defineProperty({...i},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(c,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return i}),parsed_output:null}:g_(e,r,n)}function g_(e,r,n){let s=null;const i=e.content.map(c=>{if(c.type==="text"){const d=W8(r,c.text);s===null&&(s=d);const f=Object.defineProperty({...c},"parsed_output",{value:d,enumerable:!1});return Object.defineProperty(f,"parsed",{get(){return n.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),d},enumerable:!1})}return c});return{...e,content:i,parsed_output:s}}function W8(e,r){const n=$T(e);if(n?.type!=="json_schema")return null;try{return"parse"in n?n.parse(r):JSON.parse(r)}catch(s){throw new De(`Failed to parse structured output: ${s}`)}}function IT(e,r){const{betas:n,user_profile_id:s,workspace_id:i,tools:c,messages:d}=e;return L([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-user-profile-id":s}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},cT(c,d),r?.headers])}function X8(e,r,n){if(!e._tracer)return;const s=IT(r,n);return N(e,"anthropic.messages.create",n,Jp(e,{body:Qx(r),headers:s,stream:!0}))}function Qx(e){if(!e.output_format)return e;b_(e);const{output_format:r,...n}=e;return{...n,output_config:{...e.output_config,format:r}}}function b_(e){if(e.output_format&&e.output_config?.format)throw new De("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}const Q8=e=>{let r=0,n=[];for(;r<e.length;){let s=e[r];if(s==="\\"){r++;continue}if(s==="{"){n.push({type:"brace",value:"{"}),r++;continue}if(s==="}"){n.push({type:"brace",value:"}"}),r++;continue}if(s==="["){n.push({type:"paren",value:"["}),r++;continue}if(s==="]"){n.push({type:"paren",value:"]"}),r++;continue}if(s===":"){n.push({type:"separator",value:":"}),r++;continue}if(s===","){n.push({type:"delimiter",value:","}),r++;continue}if(s==='"'){const f=r+1;let p=f,b=!1;for(;;){if(p=e.indexOf('"',p),p===-1){b=!0;break}let x=0,g=p-1;for(;g>=f&&e[g]==="\\";)x++,g--;if(x%2===0)break;p++}b?r=e.length:(n.push({type:"string",value:e.slice(f,p)}),r=p+1);continue}if(s&&/\s/.test(s)){r++;continue}let c=/[0-9]/;if(s&&c.test(s)||s==="-"||s==="."){let f="";for(s==="-"&&(f+=s,s=e[++r]);s&&(c.test(s)||s==="."||s==="e"||s==="E"||(s==="-"||s==="+")&&(f[f.length-1]==="e"||f[f.length-1]==="E"));)f+=s,s=e[++r];n.push({type:"number",value:f,unterminated:r===e.length});continue}let d=/[a-z]/i;if(s&&d.test(s)){let f="";for(;s&&d.test(s)&&r!==e.length;)f+=s,s=e[++r];if(f=="true"||f=="false"||f==="null")n.push({type:"name",value:f});else{r++;continue}continue}r++}return n},J8=e=>{let r=[];for(const c of e)(c.type==="brace"||c.type==="paren")&&(c.value==="{"||c.value==="["?r.push(c.value):r.pop());let n=r[r.length-1],s=e.length,i=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;s>0;){let c=e[s-1];switch(c.type){case"separator":s--;continue;case"number":if(c.unterminated||!i.test(c.value)){s--;continue}break;case"string":let d=e[s-2];if(n==="{"&&(d?.type==="delimiter"||d?.type==="brace"&&d.value==="{")){s--;continue}break;case"delimiter":s--;break}break}return e.slice(0,s)},Z8=e=>{let r=[];return e.map(n=>{n.type==="brace"&&(n.value==="{"?r.push("}"):r.splice(r.lastIndexOf("}"),1)),n.type==="paren"&&(n.value==="["?r.push("]"):r.splice(r.lastIndexOf("]"),1))}),r.length>0&&r.reverse().map(n=>{n==="}"?e.push({type:"brace",value:"}"}):n==="]"&&e.push({type:"paren",value:"]"})}),e},e$=e=>{let r="";return e.map(n=>{switch(n.type){case"string":r+='"'+n.value+'"';break;default:r+=n.value;break}}),r},t$=e=>JSON.parse(e$(Z8(J8(Q8(e))))),Ic="__json_buf";function DT(e,r){const n={};for(const c of Object.keys(e))c!=="input"&&(n[c]=e[c]);Object.defineProperty(n,Ic,{value:r,enumerable:!1,writable:!0});let s,i=!1;return Object.defineProperty(n,"input",{enumerable:!0,configurable:!0,get(){return i||(s=r?t$(r):{},i=!0),s}}),n}var fs,Ri,Ya,xd,vf,yd,_d,wf,vd,Wa,wd,Sf,kf,Oo,Cf,Nf,Af,Sd,Xa,Wn,kd,Vb,fC,Cd,Kb,Yb,Wb,pC,Xb;function Qb(e){return e.type==="tool_use"||e.type==="server_tool_use"||e.type==="mcp_tool_use"}var x_=(()=>{class e{constructor(n,s){fs.add(this),this.messages=[],this.receivedMessages=[],Ri.set(this,void 0),Ya.set(this,null),this.controller=new AbortController,xd.set(this,void 0),vf.set(this,()=>{}),yd.set(this,()=>{}),_d.set(this,void 0),wf.set(this,()=>{}),vd.set(this,()=>{}),Wa.set(this,{}),wd.set(this,!1),Sf.set(this,!1),kf.set(this,!1),Oo.set(this,!1),Cf.set(this,void 0),Nf.set(this,void 0),Af.set(this,void 0),Sd.set(this,void 0),Xa.set(this,void 0),Wn.set(this,void 0),kd.set(this,void 0),Cd.set(this,i=>{if(se(this,Sf,!0),v(this,Wn,"f")&&(v(this,Wn,"f").streamed=void 0),Jo(i)&&(i=new Ls),i instanceof Ls)return se(this,kf,!0),this._emit("abort",i);if(i instanceof De)return this._emit("error",i);if(i instanceof Error){const c=new De(i.message);return c.cause=i,this._emit("error",c)}return this._emit("error",new De(String(i)))}),se(this,xd,new Promise((i,c)=>{se(this,vf,i,"f"),se(this,yd,c,"f")})),se(this,_d,new Promise((i,c)=>{se(this,wf,i,"f"),se(this,vd,c,"f")})),v(this,xd,"f").catch(()=>{}),v(this,_d,"f").catch(()=>{}),se(this,Ya,n),se(this,Sd,s?.logger??console),se(this,Xa,s?.client)}get response(){return v(this,Cf,"f")}get request_id(){return v(this,Nf,"f")}get workspace_id(){return v(this,Af,"f")}async withResponse(){se(this,Oo,!0);const n=await v(this,xd,"f");if(!n)throw new Error("Could not resolve a `Response` object");return{data:this,response:n,request_id:n.headers.get("request-id"),workspace_id:n.headers.get("anthropic-workspace-id")}}static fromReadableStream(n){const s=new e(null);return s._run(()=>s._fromReadableStream(n)),s}static createMessage(n,s,i,{logger:c,client:d}={}){const f=new e(s,{logger:c,client:d});for(const p of s.messages)f._addMessageParam(p);return se(f,Ya,{...s,stream:!0}),f._run(()=>f._createMessage((p,b)=>n.create(p,b),{...s,stream:!0},{...i,headers:{...i?.headers,[n_]:"stream"}})),f}_start(n,s,i,c){for(const p of s.messages)this._addMessageParam(p);const d=v(this,Xa,"f");se(this,Xa,void 0);const f=(p,b)=>n(p,b)._thenUnwrap((x,{options:g})=>(se(this,Xa,d),se(this,Wn,g.__span),se(this,kd,g.body),x));this._run(()=>this._createMessage(f,{...s,stream:!0},i).finally(c))}_run(n){n().then(()=>{this._emitFinal(),this._emit("end")},v(this,Cd,"f"))}_addMessageParam(n){this.messages.push(n)}_addMessage(n,s=!0){this.receivedMessages.push(n),s&&this._emit("message",n)}async _createMessage(n,s,i){const c=i?.signal;let d;c&&(c.aborted&&this.controller.abort(),d=this.controller.abort.bind(this.controller),c.addEventListener("abort",d));try{v(this,fs,"m",Kb).call(this),se(this,Wn,i?.__span??(v(this,Xa,"f")&&X8(v(this,Xa,"f"),s,i)),"f");const{response:f,data:p}=await n({...s,stream:!0},{...i,__span:v(this,Wn,"f"),signal:this.controller.signal}).withResponse();try{this._connected(f)}catch(b){throw v(this,Wn,"f")&&(v(this,Wn,"f").failure=b),p.controller.abort(),b}for await(const b of p)try{v(this,fs,"m",Yb).call(this,b)}catch(x){throw v(this,Wn,"f")&&(v(this,Wn,"f").failure=x),x}if(p.controller.signal?.aborted)throw new Ls;v(this,fs,"m",Wb).call(this)}finally{c&&d&&c.removeEventListener("abort",d)}}_connected(n){this.ended||(se(this,Cf,n),se(this,Nf,n?.headers.get("request-id")),se(this,Af,n?.headers.get("anthropic-workspace-id")),v(this,vf,"f").call(this,n),this._emit("connect"))}get ended(){return v(this,wd,"f")}get errored(){return v(this,Sf,"f")}get aborted(){return v(this,kf,"f")}abort(){this.controller.abort()}on(n,s){return(v(this,Wa,"f")[n]||(v(this,Wa,"f")[n]=[])).push({listener:s}),this}off(n,s){const i=v(this,Wa,"f")[n];if(!i)return this;const c=i.findIndex(d=>d.listener===s);return c>=0&&i.splice(c,1),this}once(n,s){return(v(this,Wa,"f")[n]||(v(this,Wa,"f")[n]=[])).push({listener:s,once:!0}),this}emitted(n){return new Promise((s,i)=>{se(this,Oo,!0),n!=="error"&&this.once("error",i),this.once(n,s)})}async done(){se(this,Oo,!0),await v(this,_d,"f")}get currentMessage(){return v(this,Ri,"f")}async finalMessage(){return await this.done(),v(this,fs,"m",Vb).call(this)}async finalText(){return await this.done(),v(this,fs,"m",fC).call(this)}_emit(n,...s){if(v(this,wd,"f"))return;n==="end"&&(se(this,wd,!0),v(this,wf,"f").call(this));const i=v(this,Wa,"f")[n];if(i&&(v(this,Wa,"f")[n]=i.filter(c=>!c.once),i.forEach(({listener:c})=>c(...s))),n==="abort"){const c=s[0];!v(this,Oo,"f")&&!i?.length&&Promise.reject(c),v(this,yd,"f").call(this,c),v(this,vd,"f").call(this,c),this._emit("end");return}if(n==="error"){const c=s[0];!v(this,Oo,"f")&&!i?.length&&Promise.reject(c),v(this,yd,"f").call(this,c),v(this,vd,"f").call(this,c),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",v(this,fs,"m",Vb).call(this))}_deliverEvent(n,s){this._emit("_rawEvent",n),s&&this._emit("streamEvent",n,s)}async _fromReadableStream(n,s){const i=s?.signal;let c;i&&(i.aborted&&this.controller.abort(),c=this.controller.abort.bind(this.controller),i.addEventListener("abort",c));try{v(this,fs,"m",Kb).call(this),this._connected(null);const d=Hr.fromReadableStream(n,this.controller);for await(const f of d)v(this,fs,"m",Yb).call(this,f);if(d.controller.signal?.aborted)throw new Ls;v(this,fs,"m",Wb).call(this)}finally{i&&c&&i.removeEventListener("abort",c)}}[(Ri=new WeakMap,Ya=new WeakMap,xd=new WeakMap,vf=new WeakMap,yd=new WeakMap,_d=new WeakMap,wf=new WeakMap,vd=new WeakMap,Wa=new WeakMap,wd=new WeakMap,Sf=new WeakMap,kf=new WeakMap,Oo=new WeakMap,Cf=new WeakMap,Nf=new WeakMap,Af=new WeakMap,Sd=new WeakMap,Xa=new WeakMap,Wn=new WeakMap,kd=new WeakMap,Cd=new WeakMap,fs=new WeakSet,Vb=function(){if(this.receivedMessages.length===0)throw new De("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},fC=function(){if(this.receivedMessages.length===0)throw new De("stream ended without producing a Message with role=assistant");const s=this.receivedMessages.at(-1).content.filter(i=>i.type==="text").map(i=>i.text);if(s.length===0)throw new De("stream ended without producing a content block with type=text");return s.join(" ")},Kb=function(){this.ended||se(this,Ri,void 0)},Yb=function(s){if(this.ended)return;const i=v(this,fs,"m",pC).call(this,s);if(this._deliverEvent(s,i),!!i)switch(s.type){case"content_block_delta":{const c=i.content.at(-1);switch(s.delta.type){case"text_delta":{c.type==="text"&&this._emit("text",s.delta.text,c.text||"");break}case"citations_delta":{c.type==="text"&&this._emit("citation",s.delta.citation,c.citations??[]);break}case"input_json_delta":{if(Qb(c)&&v(this,Wa,"f").inputJson?.length){let d;try{d=c.input}catch(f){v(this,Cd,"f").call(this,v(this,fs,"m",Xb).call(this,c,f));break}this._emit("inputJson",s.delta.partial_json,d)}break}case"thinking_delta":{c.type==="thinking"&&this._emit("thinking",s.delta.thinking,c.thinking);break}case"signature_delta":{c.type==="thinking"&&this._emit("signature",c.signature);break}case"compaction_delta":{c.type==="compaction"&&c.content&&this._emit("compaction",c.content);break}default:s.delta}break}case"message_stop":{v(this,Xa,"f")&&v(this,Wn,"f")&&v(this,Ya,"f")&&t_(v(this,Xa,"f"),v(this,Wn,"f"),v(this,kd,"f")??v(this,Ya,"f"),i),this._addMessageParam(i),this._addMessage(mC(i,v(this,Ya,"f"),{logger:v(this,Sd,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",i.content.at(-1));break}case"message_start":{se(this,Ri,i),v(this,Wn,"f")&&v(this,Ya,"f")&&(v(this,Wn,"f").streamed={body:v(this,kd,"f")??v(this,Ya,"f"),message:i});break}}},Wb=function(){if(this.ended)throw new De("stream has ended, this shouldn't happen");const s=v(this,Ri,"f");if(!s)throw new De("request ended without sending any chunks");return se(this,Ri,void 0),mC(s,v(this,Ya,"f"),{logger:v(this,Sd,"f")})},pC=function(s){let i=v(this,Ri,"f");if(s.type==="message_start"){if(i)throw new De(`Unexpected event order, got ${s.type} before receiving "message_stop"`);return s.message}if(i)switch(s.type){case"message_stop":return i;case"message_delta":return i.stop_reason=s.delta.stop_reason,i.stop_sequence=s.delta.stop_sequence,i.stop_details=s.delta.stop_details,i.usage.output_tokens=s.usage.output_tokens,s.delta.container!=null&&(i.container=s.delta.container),s.context_management!=null&&(i.context_management=s.context_management),s.input_transformations!=null&&(i.input_transformations=s.input_transformations),s.usage.input_tokens!=null&&(i.usage.input_tokens=s.usage.input_tokens),s.usage.cache_creation_input_tokens!=null&&(i.usage.cache_creation_input_tokens=s.usage.cache_creation_input_tokens),s.usage.cache_read_input_tokens!=null&&(i.usage.cache_read_input_tokens=s.usage.cache_read_input_tokens),s.usage.server_tool_use!=null&&(i.usage.server_tool_use=s.usage.server_tool_use),s.usage.iterations!=null&&(i.usage.iterations=s.usage.iterations),s.usage.fallback_credit!=null&&(i.usage.fallback_credit=s.usage.fallback_credit),s.usage.output_tokens_details!=null&&(i.usage.output_tokens_details=s.usage.output_tokens_details),i;case"content_block_start":return i.content.push(s.content_block),s.content_block.type==="fallback"&&(i.model=s.content_block.to.model),i;case"content_block_delta":{const c=i.content.at(s.index);switch(s.delta.type){case"text_delta":{c?.type==="text"&&(i.content[s.index]={...c,text:(c.text||"")+s.delta.text});break}case"citations_delta":{c?.type==="text"&&(i.content[s.index]={...c,citations:[...c.citations??[],s.delta.citation]});break}case"input_json_delta":{if(c&&Qb(c)){const d=(c[Ic]||"")+s.delta.partial_json;i.content[s.index]=DT(c,d)}break}case"thinking_delta":{c?.type==="thinking"&&(i.content[s.index]={...c,thinking:c.thinking+s.delta.thinking});break}case"signature_delta":{c?.type==="thinking"&&(i.content[s.index]={...c,signature:s.delta.signature});break}case"compaction_delta":{if(c?.type==="compaction"){const d={...c,content:s.delta.content};"encrypted_content"in s.delta&&(d.encrypted_content=s.delta.encrypted_content),i.content[s.index]=d}break}default:s.delta}return i}case"content_block_stop":{const c=i.content.at(s.index);if(c&&Qb(c)&&Ic in c){let d;try{d=c.input}catch(f){d={},v(this,Cd,"f").call(this,v(this,fs,"m",Xb).call(this,c,f))}Object.defineProperty(c,"input",{value:d,enumerable:!0,configurable:!0,writable:!0})}return i}default:return i}},Xb=function(s,i){const c=s[Ic];return new De(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${i}. JSON: ${c}`)},Symbol.asyncIterator)](){const n=[],s=[];let i=!1;return this.on("_rawEvent",c=>{const d=s.shift();d?d.resolve(c):n.push(c)}),this.on("end",()=>{i=!0;for(const c of s)c.resolve(void 0);s.length=0}),this.on("abort",c=>{i=!0;for(const d of s)d.reject(c);s.length=0}),this.on("error",c=>{i=!0;for(const d of s)d.reject(c);s.length=0}),{next:async()=>n.length?{value:n.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((d,f)=>s.push({resolve:d,reject:f})).then(d=>d?{value:d,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Hr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})();const qT={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function Yc(e){return qT[e.type]}function dh(e){return"run"in e&&e.type!=null&&Object.prototype.hasOwnProperty.call(qT,e.type)}var LT=(()=>{class e extends De{constructor(n,s){super(n),s&&"cause"in s&&(this.cause=s.cause)}}return e._errorName="ToolsetUsageError",e})(),op=(()=>{class e extends LT{}return e._errorName="ToolsetContractError",e})();const UT="Not executed: an earlier action in this turn failed.",gC={browser:UT,computer:"Not executed: an earlier computer action in this turn failed."};function n$(e){return Object.prototype.hasOwnProperty.call(gC,e)?gC[e]:UT}function kp(e,r,n=!1){return n&&(r===""||Array.isArray(r)&&r.length===0)&&(r="The tool call failed with an empty error message."),{type:"tool_result",tool_use_id:e.id,toolset_name:e.toolset_name??null,content:r,...n?{is_error:!0}:{}}}function s$(e,r){if(e instanceof LT)throw e;a$(r.signal)}function a$(e){if(e?.aborted)throw new Ls}async function r$(e,r,n={}){const s=Yc(e);if(r.toolset_name!==s)throw new op(`tool_use ${JSON.stringify(r.id)} (toolset_name=${JSON.stringify(r.toolset_name??null)}, name=${JSON.stringify(r.name)}) is not a member call of the ${JSON.stringify(s)} toolset`);const i={...n,toolUse:r,toolUseBlock:r};try{return kp(r,await e.run(i,r))}catch(c){return s$(c,i),kp(r,j8(c instanceof l_?c.content:A8(c)),!0)}}let bC=class extends ye{retrieve(r,n){return this._client.get(U`/v1/organizations/api_keys/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.api_keys.retrieve",n,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":r}})})}update(r,n,s){return this._client.post(U`/v1/organizations/api_keys/${r}`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.api_keys.update",s,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/api_keys",ns,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.api_keys.list",n,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}},xC=class extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/artifacts",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.artifacts.list",n,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}},yC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/connectors",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.connectors.list",n,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};class _C extends ye{list(r,n){const{betas:s,...i}=r;return this._client.getAPIList("/v1/organizations/analytics/cost",tu,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"analytics-usage-cost-2026-08-24"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.cost.list",n,{route:"/v1/organizations/analytics/cost",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class vC extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/cost_report",tu,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.cost_report.list",n,{route:"/v1/organizations/analytics/cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}let wC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/plugins",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.plugins.list",n,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}},SC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/skills",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.skills.list",n,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}},kC=class extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/summaries",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.summaries.list",n,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}};class CC extends ye{list(r,n){const{betas:s,...i}=r;return this._client.getAPIList("/v1/organizations/analytics/usage",tu,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"analytics-usage-cost-2026-08-24"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.usage.list",n,{route:"/v1/organizations/analytics/usage",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class NC extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/usage_report",tu,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.usage_report.list",n,{route:"/v1/organizations/analytics/usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class AC extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report",tu,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.user_cost_report.list",n,{route:"/v1/organizations/analytics/user_cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class jC extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report",tu,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.user_usage_report.list",n,{route:"/v1/organizations/analytics/user_usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}let TC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/users",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.users.list",n,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}},EC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.analytics.apps.chat.projects.list",n,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}};var MC=(()=>{class e extends ye{constructor(){super(...arguments),this.projects=new EC(this._client)}}return e.Projects=EC,e})(),RC=(()=>{class e extends ye{constructor(){super(...arguments),this.chat=new MC(this._client)}}return e.Chat=MC,e})(),zC=(()=>{class e extends ye{constructor(){super(...arguments),this.summaries=new kC(this._client),this.users=new TC(this._client),this.apps=new RC(this._client),this.connectors=new yC(this._client),this.plugins=new wC(this._client),this.skills=new SC(this._client),this.artifacts=new xC(this._client),this.usage=new CC(this._client),this.cost=new _C(this._client),this.usageReport=new NC(this._client),this.userUsageReport=new jC(this._client),this.costReport=new vC(this._client),this.userCostReport=new AC(this._client)}}return e.Summaries=kC,e.Users=TC,e.Apps=RC,e.Connectors=yC,e.Plugins=wC,e.Skills=SC,e.Artifacts=xC,e.Usage=CC,e.Cost=_C,e.UsageReport=NC,e.UserUsageReport=jC,e.CostReport=vC,e.UserCostReport=AC,e})(),y_=(()=>{class e extends Ye{}return e._errorName="BetaCannotSignOutPrimaryOwnerError",e})(),__=(()=>{class e extends Ye{}return e._errorName="BetaCannotSignOutSelfError",e})(),v_=(()=>{class e extends vs{}return e._errorName="BetaCannotSignOutManagedMemberError",e})(),w_=(()=>{class e extends vs{}return e._errorName="BetaCannotSignOutMembershipAdminError",e})(),S_=(()=>{class e extends vs{}return e._errorName="BetaCannotSignOutOwnerError",e})(),k_=(()=>{class e extends vs{}return e._errorName="BetaCannotSignOutPrivilegedMemberError",e})(),OC=(()=>{class e extends ye{retrieve(n,s){return this._client.get(U`/v1/organizations/users/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.users.retrieve",s,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/users/${n}`,{body:s,...i,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/users",ns,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.users.list",s,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(n,s){return this._client.delete(U`/v1/organizations/users/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.users.remove",s,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}signOut(n,s={},i){const{betas:c}=s??{};return this._client.post(U`/v1/organizations/users/${n}/sign_out`,{...i,headers:L([{"anthropic-beta":[...c??[],"admin-user-sign-out-2026-10-08"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.users.sign_out",i,{route:"/v1/organizations/users/{user_id}/sign_out",attributes:{"anthropic.organization.user.id":n}})})}}return e.BetaCannotSignOutPrimaryOwnerError=y_,e.BetaCannotSignOutSelfError=__,e.BetaCannotSignOutManagedMemberError=v_,e.BetaCannotSignOutMembershipAdminError=w_,e.BetaCannotSignOutOwnerError=S_,e.BetaCannotSignOutPrivilegedMemberError=k_,e})();class PC extends ye{list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/plugins/${r}/installation_settings`,Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.installation_settings.list",s,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":r}})})}remove(r,n,s){const{plugin_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/plugins/${i}/installation_settings/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.installation_settings.remove",s,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.installation_setting.id":r}})})}set(r,n,s){const{plugin_id:i,betas:c,...d}=n;return this._client.post(U`/v1/organizations/plugins/${i}/installation_settings/${r}`,{body:d,...s,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.installation_settings.set",s,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.installation_setting.id":r}})})}}class $C extends ye{list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/plugins/${r}/shares`,Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.shares.list",s,{route:"/v1/organizations/plugins/{plugin_id}/shares",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":r}})})}}let IC=class extends ye{create(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/plugins/${r}/versions`,Kr({body:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.versions.create",s,{route:"/v1/organizations/plugins/{plugin_id}/versions",attributes:{"anthropic.organization.plugin.id":r},createdIDAttribute:"anthropic.organization.plugin.version.id"})},this._client))}retrieve(r,n,s){const{plugin_id:i,betas:c,...d}=n;return this._client.get(U`/v1/organizations/plugins/${i}/versions/${r}`,{query:d,...s,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.versions.retrieve",s,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.version.id":r}})})}list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/plugins/${r}/versions`,Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.versions.list",s,{route:"/v1/organizations/plugins/{plugin_id}/versions",queryParams:["limit","organization_id","page"],attributes:{"anthropic.organization.plugin.id":r}})})}download(r,n,s){const{plugin_id:i,betas:c,...d}=n;return this._client.get(U`/v1/organizations/plugins/${i}/versions/${r}/content`,{query:d,...s,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},s?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:N(this._client,"anthropic.organization.plugins.versions.download",s,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}/content",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.version.id":r}})})}};var C_=(()=>{class e extends Ye{}return e._errorName="BetaScanFailedError",e})(),N_=(()=>{class e extends Vr{}return e._errorName="BetaPluginNameTakenError",e})(),A_=(()=>{class e extends Vr{}return e._errorName="BetaScanPendingError",e})(),j_=(()=>{class e extends Vr{}return e._errorName="BetaSkillNameTakenError",e})(),T_=(()=>{class e extends _h{}return e._errorName="BetaRegistrationPendingError",e})(),DC=(()=>{class e extends ye{constructor(){super(...arguments),this.versions=new IC(this._client),this.installationSettings=new PC(this._client),this.shares=new $C(this._client)}create(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/plugins",Kr({body:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.create",s,{route:"/v1/organizations/plugins",createdIDAttribute:"anthropic.organization.plugin.id"})},this._client))}retrieve(n,s={},i){const{betas:c,...d}=s??{};return this._client.get(U`/v1/organizations/plugins/${n}`,{query:d,...i,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":n}})})}update(n,s,i){const{betas:c,...d}=s;return this._client.post(U`/v1/organizations/plugins/${n}`,{body:d,...i,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.update",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/plugins",Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.list",s,{route:"/v1/organizations/plugins",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","marketplace_id","organization_id","owner_type","owner_user_id","page"]})})}delete(n,s={},i){const{betas:c}=s??{};return this._client.delete(U`/v1/organizations/plugins/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugins.delete",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":n}})})}}return e.BetaScanFailedError=C_,e.BetaPluginNameTakenError=N_,e.BetaScanPendingError=A_,e.BetaSkillNameTakenError=j_,e.BetaRegistrationPendingError=T_,e.Versions=IC,e.InstallationSettings=PC,e.Shares=$C,e})();class qC extends ye{create(r,n){const{betas:s,...i}=r;return this._client.post("/v1/organizations/claude_tag/slack_channels",{body:i,...n,headers:L([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_channels.create",n,{route:"/v1/organizations/claude_tag/slack_channels",createdIDAttribute:"anthropic.organization.claude_tag.slack_channel.id"})})}retrieve(r,n={},s){const{betas:i,...c}=n??{};return this._client.get(U`/v1/organizations/claude_tag/slack_channels/${r}`,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_channels.retrieve",s,{route:"/v1/organizations/claude_tag/slack_channels/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_channel.id":r}})})}update(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/claude_tag/slack_channels/${r}`,{body:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_channels.update",s,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":r}})})}list(r,n){const{betas:s,...i}=r;return this._client.getAPIList("/v1/organizations/claude_tag/slack_channels",Me,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_channels.list",n,{route:"/v1/organizations/claude_tag/slack_channels",queryParams:["include_inherited","limit","page","slack_channel_id","slack_workspace_id"]})})}delete(r,n={},s){const{betas:i}=n??{};return this._client.delete(U`/v1/organizations/claude_tag/slack_channels/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_channels.delete",s,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":r}})})}}class LC extends ye{retrieve(r,n={},s){const{betas:i,...c}=n??{};return this._client.get(U`/v1/organizations/claude_tag/slack_workspaces/${r}`,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_workspaces.retrieve",s,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_workspace.id":r}})})}update(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/claude_tag/slack_workspaces/${r}`,{body:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_workspaces.update",s,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",attributes:{"anthropic.organization.claude_tag.slack_workspace.id":r}})})}list(r={},n){const{betas:s,...i}=r??{};return this._client.getAPIList("/v1/organizations/claude_tag/slack_workspaces",Me,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.slack_workspaces.list",n,{route:"/v1/organizations/claude_tag/slack_workspaces",queryParams:["include_inherited","limit","page","slack_workspace_id"]})})}}class UC extends ye{create(r,n,s){const{target:i,betas:c}=n;return this._client.post(U`/v1/organizations/claude_tag/bundles/${r}/targets`,{body:i,...s,headers:L([{"anthropic-beta":[...c??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.targets.create",s,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",attributes:{"anthropic.organization.claude_tag.bundle.id":r}})})}retrieve(r,n,s){const{bundle_id:i,betas:c}=n;return this._client.get(U`/v1/organizations/claude_tag/bundles/${i}/targets/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.targets.retrieve",s,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":i,"anthropic.organization.claude_tag.bundle.target.id":r}})})}list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/claude_tag/bundles/${r}/targets`,Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.targets.list",s,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",queryParams:["limit","page"],attributes:{"anthropic.organization.claude_tag.bundle.id":r}})})}delete(r,n,s){const{bundle_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/claude_tag/bundles/${i}/targets/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.targets.delete",s,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":i,"anthropic.organization.claude_tag.bundle.target.id":r}})})}}var BC=(()=>{class e extends ye{constructor(){super(...arguments),this.targets=new UC(this._client)}retrieve(n,s={},i){const{betas:c}=s??{};return this._client.get(U`/v1/organizations/claude_tag/bundles/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/claude_tag/bundles",Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.claude_tag.bundles.list",s,{route:"/v1/organizations/claude_tag/bundles",queryParams:["limit","page"]})})}}return e.Targets=UC,e})(),E_=(()=>{class e extends Ye{}return e._errorName="BetaSlackChannelSetUpSettingsRefusedError",e})(),M_=(()=>{class e extends vs{}return e._errorName="BetaAPIKeyScopeMissingError",e})(),R_=(()=>{class e extends vs{}return e._errorName="BetaClaudeTagWritesNotEnabledError",e})(),z_=(()=>{class e extends vs{}return e._errorName="BetaComplianceConfigurationRestrictedError",e})(),O_=(()=>{class e extends vs{}return e._errorName="BetaOrganizationLevelScopedAPIKeyRequiredError",e})(),P_=(()=>{class e extends Zc{}return e._errorName="BetaSlackChannelSetUpEnvironmentNotFoundError",e})(),$_=(()=>{class e extends Vr{}return e._errorName="BetaSlackChannelSetUpSettingsConflictError",e})(),GC=(()=>{class e extends ye{constructor(){super(...arguments),this.slackChannels=new qC(this._client),this.slackWorkspaces=new LC(this._client),this.bundles=new BC(this._client)}}return e.BetaSlackChannelSetUpSettingsRefusedError=E_,e.BetaAPIKeyScopeMissingError=M_,e.BetaClaudeTagWritesNotEnabledError=R_,e.BetaComplianceConfigurationRestrictedError=z_,e.BetaOrganizationLevelScopedAPIKeyRequiredError=O_,e.BetaSlackChannelSetUpEnvironmentNotFoundError=P_,e.BetaSlackChannelSetUpSettingsConflictError=$_,e.SlackChannels=qC,e.SlackWorkspaces=LC,e.Bundles=BC,e})();let HC=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/spend_limits/effective",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.effective.list",n,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}},FC=class extends ye{retrieve(r,n){return this._client.get(U`/v1/organizations/spend_limit_increase_requests/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",n,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.list",n,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(r,n,s){return this._client.post(U`/v1/organizations/spend_limit_increase_requests/${r}/approve`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.approve",s,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}deny(r,n,s){return this._client.post(U`/v1/organizations/spend_limit_increase_requests/${r}/deny`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.deny",s,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}};var I_=(()=>{class e extends vs{}return e._errorName="BetaSpendLimitsAdminAPIWritesNotEnabledError",e})(),VC=(()=>{class e extends ye{constructor(){super(...arguments),this.effective=new HC(this._client),this.increaseRequests=new FC(this._client)}retrieve(n,s){return this._client.get(U`/v1/organizations/spend_limits/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.retrieve",s,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/spend_limits",Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"spend-limit-reads-2026-09-26"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.list",s,{route:"/v1/organizations/spend_limits",queryParams:["limit","page","scope_type","workspace_id"]})})}delete(n,s){return this._client.delete(U`/v1/organizations/spend_limits/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.delete",s,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":n}})})}set(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/spend_limits",{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.spend_limits.set",s,{route:"/v1/organizations/spend_limits",createdIDAttribute:"anthropic.organization.spend_limit.id"})})}}return e.BetaSpendLimitsAdminAPIWritesNotEnabledError=I_,e.Effective=HC,e.IncreaseRequests=FC,e})();let KC=class extends ye{retrieve(r){return this._client.get("/v1/organizations/compliance_settings",{...r,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.compliance_settings.retrieve",r,{route:"/v1/organizations/compliance_settings"})})}update(r,n){return this._client.post("/v1/organizations/compliance_settings",{body:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.compliance_settings.update",n,{route:"/v1/organizations/compliance_settings"})})}},YC=class extends ye{create(r,n){return this._client.post("/v1/organizations/external_keys",{body:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.create",n,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(r,n){return this._client.get(U`/v1/organizations/external_keys/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.retrieve",n,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":r}})})}update(r,n,s){return this._client.post(U`/v1/organizations/external_keys/${r}`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.update",s,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/external_keys",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.list",n,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(r,n){return this._client.delete(U`/v1/organizations/external_keys/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.delete",n,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":r}})})}validate(r,n){return this._client.post(U`/v1/organizations/external_keys/${r}/validate`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.external_keys.validate",n,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":r}})})}},WC=class extends ye{create(r,n){const{betas:s,...i}=r;return this._client.post("/v1/organizations/federation_issuers",{body:i,...n,headers:L([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.issuers.create",n,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(r,n={},s){const{betas:i}=n??{};return this._client.get(U`/v1/organizations/federation_issuers/${r}`,{...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.issuers.retrieve",s,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":r}})})}update(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/federation_issuers/${r}`,{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.issuers.update",s,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":r}})})}list(r={},n){const{betas:s,...i}=r??{};return this._client.getAPIList("/v1/organizations/federation_issuers",Me,{query:i,...n,headers:L([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.issuers.list",n,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(r,n={},s){const{betas:i}=n??{};return this._client.post(U`/v1/organizations/federation_issuers/${r}/archive`,{...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.issuers.archive",s,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":r}})})}},XC=class extends ye{list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/federation_rules/${r}/workspaces`,Me,{query:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.workspaces.list",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":r}})})}add(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/federation_rules/${r}/workspaces`,{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.workspaces.add",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":r},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(r,n,s){const{federation_rule_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/federation_rules/${i}/workspaces/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.workspaces.remove",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":i,"anthropic.organization.federation_rule.workspace.id":r}})})}};var QC=(()=>{class e extends ye{constructor(){super(...arguments),this.workspaces=new XC(this._client)}create(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/federation_rules",{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.create",s,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(n,s={},i){const{betas:c}=s??{};return this._client.get(U`/v1/organizations/federation_rules/${n}`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.retrieve",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":n}})})}update(n,s,i){const{betas:c,...d}=s;return this._client.post(U`/v1/organizations/federation_rules/${n}`,{body:d,...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/federation_rules",Me,{query:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.list",s,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(n,s={},i){const{betas:c}=s??{};return this._client.post(U`/v1/organizations/federation_rules/${n}/archive`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.federation.rules.archive",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":n}})})}}return e.Workspaces=XC,e})(),JC=(()=>{class e extends ye{constructor(){super(...arguments),this.issuers=new WC(this._client),this.rules=new QC(this._client)}}return e.Issuers=WC,e.Rules=QC,e})();let ZC=class extends ye{create(r,n){return this._client.post("/v1/organizations/invites",{body:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.invites.create",n,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(r,n){return this._client.get(U`/v1/organizations/invites/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.invites.retrieve",n,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/invites",ns,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.invites.list",n,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(r,n){return this._client.delete(U`/v1/organizations/invites/${r}`,{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.invites.delete",n,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":r}})})}};class eN extends ye{retrieve(r,n={},s){const{betas:i,...c}=n??{};return this._client.get(U`/v1/organizations/plugin_marketplaces/${r}`,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugin_marketplaces.retrieve",s,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin_marketplace.id":r}})})}update(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/plugin_marketplaces/${r}`,{body:c,...s,headers:L([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugin_marketplaces.update",s,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",attributes:{"anthropic.organization.plugin_marketplace.id":r}})})}list(r={},n){const{betas:s,...i}=r??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces",Me,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugin_marketplaces.list",n,{route:"/v1/organizations/plugin_marketplaces",queryParams:["limit","organization_id","owner_type","page","source"]})})}validateArchive(r,n){const{betas:s,...i}=r;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive",Kr({body:i,...n,headers:L([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugin_marketplaces.validate_archive",n,{route:"/v1/organizations/plugin_marketplaces/validate_archive"})},this._client))}validateRepository(r,n){const{betas:s,...i}=r;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository",{body:i,...n,headers:L([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.plugin_marketplaces.validate_repository",n,{route:"/v1/organizations/plugin_marketplaces/validate_repository"})})}}let tN=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/rate_limits",Me,{query:r,...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rate_limits.list",n,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};class nN extends ye{create(r,n){const{betas:s,...i}=r;return this._client.post("/v1/organizations/webhooks",{body:i,...n,headers:L([{"anthropic-beta":[...s??[],"webhooks-2026-10-07"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.create",n,{route:"/v1/organizations/webhooks",createdIDAttribute:"anthropic.organization.webhook.id"})})}retrieve(r,n={},s){const{betas:i}=n??{};return this._client.get(U`/v1/organizations/webhooks/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.retrieve",s,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":r}})})}update(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/webhooks/${r}`,{body:c,...s,headers:L([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.update",s,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":r}})})}list(r={},n){const{betas:s,...i}=r??{};return this._client.getAPIList("/v1/organizations/webhooks",ns,{query:i,...n,headers:L([{"anthropic-beta":[...s??[],"webhooks-2026-10-07"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.list",n,{route:"/v1/organizations/webhooks",queryParams:["after_id","before_id","limit","order"]})})}delete(r,n={},s){const{betas:i}=n??{};return this._client.delete(U`/v1/organizations/webhooks/${r}`,{...s,headers:L([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.delete",s,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":r}})})}regenerateSigningSecret(r,n={},s){const{betas:i}=n??{};return this._client.post(U`/v1/organizations/webhooks/${r}/regenerate_signing_secret`,{...s,headers:L([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.webhooks.regenerate_signing_secret",s,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret",attributes:{"anthropic.organization.webhook.id":r}})})}}let sN=class extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/rbac_groups/${r}/members`,Me,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.members.list",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/rbac_groups/${r}/members`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.members.add",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":r},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(r,n,s){const{rbac_group_id:i}=n;return this._client.delete(U`/v1/organizations/rbac_groups/${i}/members/${r}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.members.remove",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":i,"anthropic.organization.rbac_group.member.id":r}})})}};var aN=(()=>{class e extends ye{constructor(){super(...arguments),this.members=new sN(this._client)}create(n,s){return this._client.post("/v1/organizations/rbac_groups",{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.create",s,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/rbac_groups/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.retrieve",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/rbac_groups/${n}`,{body:s,...i,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/rbac_groups",Me,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.list",s,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(n,s){return this._client.delete(U`/v1/organizations/rbac_groups/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_groups.delete",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}}return e.Members=sN,e})();let rN=class extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/rbac_roles/${r}/permissions`,Me,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_roles.permissions.list",s,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":r}})})}};var iN=(()=>{class e extends ye{constructor(){super(...arguments),this.permissions=new rN(this._client)}retrieve(n,s){return this._client.get(U`/v1/organizations/rbac_roles/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_roles.retrieve",s,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/rbac_roles",Me,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.rbac_roles.list",s,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return e.Permissions=rN,e})();let oN=class extends ye{list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/service_accounts/${r}/workspaces`,Me,{query:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.workspaces.list",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":r}})})}add(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/service_accounts/${r}/workspaces`,{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.workspaces.add",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":r},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(r,n,s){const{service_account_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/service_accounts/${i}/workspaces/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.workspaces.remove",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":i,"anthropic.organization.service_account.workspace.id":r}})})}};var lN=(()=>{class e extends ye{constructor(){super(...arguments),this.workspaces=new oN(this._client)}create(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/service_accounts",{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.create",s,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(n,s={},i){const{betas:c}=s??{};return this._client.get(U`/v1/organizations/service_accounts/${n}`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.retrieve",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":n}})})}update(n,s,i){const{betas:c,...d}=s;return this._client.post(U`/v1/organizations/service_accounts/${n}`,{body:d,...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/service_accounts",Me,{query:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.list",s,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(n,s={},i){const{betas:c}=s??{};return this._client.post(U`/v1/organizations/service_accounts/${n}/archive`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.service_accounts.archive",i,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":n}})})}}return e.Workspaces=oN,e})();let cN=class extends ye{list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/telemetry_destinations/${r}/workspaces`,Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.workspaces.list",s,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.telemetry_destination.id":r}})})}add(r,n,s){const{destination_id:i,betas:c}=n;return this._client.post(U`/v1/organizations/telemetry_destinations/${i}/workspaces/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.workspaces.add",s,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":i,"anthropic.organization.telemetry_destination.workspace.id":r}})})}remove(r,n,s){const{destination_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/telemetry_destinations/${i}/workspaces/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.workspaces.remove",s,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":i,"anthropic.organization.telemetry_destination.workspace.id":r}})})}};var uN=(()=>{class e extends ye{constructor(){super(...arguments),this.workspaces=new cN(this._client)}create(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/telemetry_destinations",{body:c,...s,headers:L([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.create",s,{route:"/v1/organizations/telemetry_destinations",createdIDAttribute:"anthropic.organization.telemetry_destination.id"})})}retrieve(n,s={},i){const{betas:c}=s??{};return this._client.get(U`/v1/organizations/telemetry_destinations/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.retrieve",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":n}})})}update(n,s,i){const{betas:c,...d}=s;return this._client.post(U`/v1/organizations/telemetry_destinations/${n}`,{body:d,...i,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.update",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":n}})})}list(n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList("/v1/organizations/telemetry_destinations",Me,{query:c,...s,headers:L([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.list",s,{route:"/v1/organizations/telemetry_destinations",queryParams:["limit","page","workspace_ids"]})})}delete(n,s={},i){const{betas:c}=s??{};return this._client.delete(U`/v1/organizations/telemetry_destinations/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.delete",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":n}})})}test(n,s={},i){const{betas:c}=s??{};return this._client.post(U`/v1/organizations/telemetry_destinations/${n}/test`,{...i,headers:L([{"anthropic-beta":[...c??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.telemetry_destinations.test",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/test",attributes:{"anthropic.organization.telemetry_destination.id":n}})})}}return e.Workspaces=cN,e})();let dN=class extends ye{retrieve(r,n,s){const{workspace_id:i}=n;return this._client.get(U`/v1/organizations/workspaces/${i}/members/${r}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.members.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}update(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/members/${r}`,{body:c,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.members.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/members`,ns,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.members.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/workspaces/${r}/members`,{body:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.members.add",s,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":r},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(r,n,s){const{workspace_id:i}=n;return this._client.delete(U`/v1/organizations/workspaces/${i}/members/${r}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.members.remove",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}},hN=class extends ye{update(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/rate_limits/${r}`,{body:c,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.rate_limits.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.rate_limit.id":r}})})}list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/rate_limits`,Me,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.rate_limits.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":r}})})}},mN=class extends ye{retrieve(r,n,s){const{workspace_id:i,betas:c}=n;return this._client.get(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}update(r,n,s){const{workspace_id:i,betas:c,...d}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{body:d,...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.service_accounts.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}list(r,n={},s){const{betas:i,...c}=n??{};return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/service_accounts`,Me,{query:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.service_accounts.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":r}})})}add(r,n,s){const{betas:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${r}/service_accounts`,{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.service_accounts.add",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":r},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(r,n,s){const{workspace_id:i,betas:c}=n;return this._client.delete(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.service_accounts.remove",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}};var fN=(()=>{class e extends ye{constructor(){super(...arguments),this.rateLimits=new hN(this._client),this.members=new dN(this._client),this.serviceAccounts=new mN(this._client)}create(n,s){const{betas:i,...c}=n;return this._client.post("/v1/organizations/workspaces",{body:c,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.create",s,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/workspaces/${n}`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/workspaces/${n}`,{body:s,...i,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/workspaces",ns,{query:n,...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.list",s,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(n,s){return this._client.post(U`/v1/organizations/workspaces/${n}/archive`,{...s,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.workspaces.archive",s,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":n}})})}}return e.RateLimits=hN,e.Members=dN,e.ServiceAccounts=mN,e})(),pN=(()=>{class e extends ye{constructor(){super(...arguments),this.apiKeys=new bC(this._client),this.externalKeys=new YC(this._client),this.federation=new JC(this._client),this.invites=new ZC(this._client),this.serviceAccounts=new lN(this._client),this.users=new OC(this._client),this.workspaces=new fN(this._client),this.rateLimits=new tN(this._client),this.complianceSettings=new KC(this._client),this.analytics=new zC(this._client),this.spendLimits=new VC(this._client),this.rbacGroups=new aN(this._client),this.rbacRoles=new iN(this._client),this.plugins=new DC(this._client),this.pluginMarketplaces=new eN(this._client),this.telemetryDestinations=new uN(this._client),this.webhooks=new nN(this._client),this.claudeTag=new GC(this._client)}retrieve(n){return this._client.get("/v1/organizations/me",{...n,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.organization.retrieve",n,{route:"/v1/organizations/me"})})}}return e.APIKeys=bC,e.ExternalKeys=YC,e.Federation=JC,e.Invites=ZC,e.ServiceAccounts=lN,e.Users=OC,e.BetaCannotSignOutPrimaryOwnerError=y_,e.BetaCannotSignOutSelfError=__,e.BetaCannotSignOutManagedMemberError=v_,e.BetaCannotSignOutMembershipAdminError=w_,e.BetaCannotSignOutOwnerError=S_,e.BetaCannotSignOutPrivilegedMemberError=k_,e.Workspaces=fN,e.RateLimits=tN,e.ComplianceSettings=KC,e.Analytics=zC,e.SpendLimits=VC,e.BetaSpendLimitsAdminAPIWritesNotEnabledError=I_,e.RBACGroups=aN,e.RBACRoles=iN,e.Plugins=DC,e.BetaScanFailedError=C_,e.BetaPluginNameTakenError=N_,e.BetaScanPendingError=A_,e.BetaSkillNameTakenError=j_,e.BetaRegistrationPendingError=T_,e.PluginMarketplaces=eN,e.TelemetryDestinations=uN,e.Webhooks=nN,e.ClaudeTag=GC,e.BetaSlackChannelSetUpSettingsRefusedError=E_,e.BetaAPIKeyScopeMissingError=M_,e.BetaClaudeTagWritesNotEnabledError=R_,e.BetaComplianceConfigurationRestrictedError=z_,e.BetaOrganizationLevelScopedAPIKeyRequiredError=O_,e.BetaSlackChannelSetUpEnvironmentNotFoundError=P_,e.BetaSlackChannelSetUpSettingsConflictError=$_,e})(),gN=(()=>{class e extends ye{list(n,s={},i){const{betas:c,workspace_id:d,...f}=s??{};return this._client.getAPIList(U`/v1/sessions/${n}/events`,Me,{query:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.events.list",i,{route:"/v1/sessions/{session_id}/events",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page","types"],attributes:{"anthropic.session.id":n}})})}send(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/sessions/${n}/events`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.events.send",i,{route:"/v1/sessions/{session_id}/events",attributes:{"anthropic.session.id":n}})})}stream(n,s={},i){const{betas:c,workspace_id:d,...f}=s??{};return this._client.get(U`/v1/sessions/${n}/events/stream`,{query:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.events.stream",i,{route:"/v1/sessions/{session_id}/events/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":n}})})}toolRunner(n,s){return new Xx(n,{...s,client:this._client})}}return e.SessionToolRunner=Xx,e})();class bN extends ye{retrieve(r,n,s){const{session_id:i,betas:c,workspace_id:d}=n;return this._client.get(U`/v1/sessions/${i}/resources/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.resources.retrieve",s,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":r}})})}update(r,n,s){const{session_id:i,betas:c,workspace_id:d,...f}=n;return this._client.post(U`/v1/sessions/${i}/resources/${r}`,{body:f,...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.resources.update",s,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/sessions/${r}/resources`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.resources.list",s,{route:"/v1/sessions/{session_id}/resources",queryParams:["limit","page"],attributes:{"anthropic.session.id":r}})})}delete(r,n,s){const{session_id:i,betas:c,workspace_id:d}=n;return this._client.delete(U`/v1/sessions/${i}/resources/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.resources.delete",s,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":r}})})}add(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/sessions/${r}/resources`,{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.resources.add",s,{route:"/v1/sessions/{session_id}/resources",attributes:{"anthropic.session.id":r},createdIDAttribute:"anthropic.session.resource.id"})})}}class xN extends ye{list(r,n,s){const{session_id:i,betas:c,workspace_id:d,...f}=n;return this._client.getAPIList(U`/v1/sessions/${i}/threads/${r}/events`,Me,{query:f,...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.threads.events.list",s,{route:"/v1/sessions/{session_id}/threads/{thread_id}/events",queryParams:["limit","page"],attributes:{"anthropic.session.id":i,"anthropic.session.thread.id":r}})})}stream(r,n,s){const{session_id:i,betas:c,workspace_id:d,...f}=n;return this._client.get(U`/v1/sessions/${i}/threads/${r}/stream`,{query:f,...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.threads.events.stream",s,{route:"/v1/sessions/{session_id}/threads/{thread_id}/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":i,"anthropic.session.thread.id":r}})})}}var yN=(()=>{class e extends ye{constructor(){super(...arguments),this.events=new xN(this._client)}retrieve(n,s,i){const{session_id:c,betas:d,workspace_id:f}=s;return this._client.get(U`/v1/sessions/${c}/threads/${n}`,{...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.threads.retrieve",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}",attributes:{"anthropic.session.id":c,"anthropic.session.thread.id":n}})})}list(n,s={},i){const{betas:c,workspace_id:d,...f}=s??{};return this._client.getAPIList(U`/v1/sessions/${n}/threads`,Me,{query:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.threads.list",i,{route:"/v1/sessions/{session_id}/threads",queryParams:["limit","page","statuses"],attributes:{"anthropic.session.id":n}})})}archive(n,s,i){const{session_id:c,betas:d,workspace_id:f}=s;return this._client.post(U`/v1/sessions/${c}/threads/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...d??[],"managed-agents-2026-04-01"].toString(),...f!=null?{"anthropic-workspace-id":f}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.threads.archive",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/archive",attributes:{"anthropic.session.id":c,"anthropic.session.thread.id":n}})})}}return e.Events=xN,e})(),_N=(()=>{class e extends ye{constructor(){super(...arguments),this.events=new gN(this._client),this.resources=new bN(this._client),this.threads=new yN(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n,f={body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/sessions",{...f,__span:N(this._client,"anthropic.sessions.create",s,{route:"/v1/sessions",attributes:VP(d),createdIDAttribute:"anthropic.session.id",request:f})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/sessions/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.retrieve",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/sessions/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.update",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/sessions",n8,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.list",s,{route:"/v1/sessions",queryParams:["agent_id","agent_version","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","include_archived","limit","memory_store_id","order","page","statuses"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/sessions/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.delete",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":n}})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/sessions/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.sessions.archive",i,{route:"/v1/sessions/{session_id}/archive",attributes:{"anthropic.session.id":n}})})}}return e.Events=gN,e.Resources=bN,e.Threads=yN,e})();let vN=class extends ye{create(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/skills/${r}/versions`,Kr({body:d,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.versions.create",s,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":r},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(r,n,s){const{skill_id:i,betas:c,workspace_id:d}=n;return this._client.get(U`/v1/skills/${i}/versions/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0,...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.versions.retrieve",s,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/skills/${r}/versions`,Me,{query:d,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.versions.list",s,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":r}})})}delete(r,n,s){const{skill_id:i,betas:c,workspace_id:d}=n;return this._client.delete(U`/v1/skills/${i}/versions/${r}`,{...s,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0,...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.versions.delete",s,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":r}})})}download(r,n,s){const{skill_id:i,betas:c,workspace_id:d}=n;return this._client.get(U`/v1/skills/${i}/versions/${r}/content`,{...s,headers:L([{Accept:"application/binary",...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0,...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:N(this._client,"anthropic.skills.versions.download",s,{route:"/v1/skills/{skill_id}/versions/{version}/content",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":r}})})}};var wN=(()=>{class e extends ye{constructor(){super(...arguments),this.versions=new vN(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/skills",Kr({body:d,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.create",s,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/skills/${n}`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0,...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/skills",Me,{query:d,...s,headers:L([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.list",s,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/skills/${n}`,{...i,headers:L([{...c?.toString()!=null?{"anthropic-beta":c?.toString()}:void 0,...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":n}})})}}return e.Versions=vN,e})();class SN extends ye{create(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/tunnels/${r}/certificates`,{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.certificates.create",s,{route:"/v1/tunnels/{tunnel_id}/certificates",attributes:{"anthropic.tunnel.id":r},createdIDAttribute:"anthropic.tunnel.certificate.id"})})}retrieve(r,n,s){const{tunnel_id:i,betas:c,workspace_id:d}=n;return this._client.get(U`/v1/tunnels/${i}/certificates/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.certificates.retrieve",s,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}",attributes:{"anthropic.tunnel.id":i,"anthropic.tunnel.certificate.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/tunnels/${r}/certificates`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.certificates.list",s,{route:"/v1/tunnels/{tunnel_id}/certificates",queryParams:["include_archived","limit","page"],attributes:{"anthropic.tunnel.id":r}})})}archive(r,n,s){const{tunnel_id:i,betas:c,workspace_id:d}=n;return this._client.post(U`/v1/tunnels/${i}/certificates/${r}/archive`,{...s,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.certificates.archive",s,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive",attributes:{"anthropic.tunnel.id":i,"anthropic.tunnel.certificate.id":r}})})}}var kN=(()=>{class e extends ye{constructor(){super(...arguments),this.certificates=new SN(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/tunnels",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.create",s,{route:"/v1/tunnels",createdIDAttribute:"anthropic.tunnel.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/tunnels/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.retrieve",i,{route:"/v1/tunnels/{tunnel_id}",attributes:{"anthropic.tunnel.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/tunnels",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.list",s,{route:"/v1/tunnels",queryParams:["include_archived","limit","page"]})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/tunnels/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.archive",i,{route:"/v1/tunnels/{tunnel_id}/archive",attributes:{"anthropic.tunnel.id":n}})})}revealToken(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/tunnels/${n}/reveal_token`,{...i,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.reveal_token",i,{route:"/v1/tunnels/{tunnel_id}/reveal_token",attributes:{"anthropic.tunnel.id":n}})})}rotateToken(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/tunnels/${n}/rotate_token`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"mcp-tunnels-2026-06-22"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.tunnels.rotate_token",i,{route:"/v1/tunnels/{tunnel_id}/rotate_token",attributes:{"anthropic.tunnel.id":n}})})}}return e.Certificates=SN,e})();let CN=class extends ye{create(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/user_profiles/${r}/action_urls`,{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.action_urls.create",s,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":r}})})}};var NN=(()=>{class e extends ye{constructor(){super(...arguments),this.actionURLs=new CN(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/user_profiles",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.create",s,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/user_profiles/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"user-profiles-2026-08-18"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/user_profiles/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"user-profiles-2026-08-18"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/user_profiles",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.list",s,{route:"/v1/user_profiles",queryParams:["limit","order","order_by","page"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/user_profiles/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"user-profiles-2026-08-18"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}createEnrollmentURL(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/user_profiles/${n}/enrollment_url`,{...i,headers:L([{"anthropic-beta":[...c??[],"user-profiles-2026-08-18"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.user_profiles.create_enrollment_url",i,{route:"/v1/user_profiles/{user_profile_id}/enrollment_url",attributes:{"anthropic.user_profile.id":n}})})}}return e.ActionURLs=CN,e})();class AN extends ye{create(r,n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post(U`/v1/vaults/${r}/credentials`,{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.create",s,{route:"/v1/vaults/{vault_id}/credentials",attributes:{"anthropic.vault.id":r},createdIDAttribute:"anthropic.vault.credential.id"})})}retrieve(r,n,s){const{vault_id:i,betas:c,workspace_id:d}=n;return this._client.get(U`/v1/vaults/${i}/credentials/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.retrieve",s,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":r}})})}update(r,n,s){const{vault_id:i,betas:c,workspace_id:d,...f}=n;return this._client.post(U`/v1/vaults/${i}/credentials/${r}`,{body:f,...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.update",s,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":r}})})}list(r,n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList(U`/v1/vaults/${r}/credentials`,Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.list",s,{route:"/v1/vaults/{vault_id}/credentials",queryParams:["include_archived","limit","page"],attributes:{"anthropic.vault.id":r}})})}delete(r,n,s){const{vault_id:i,betas:c,workspace_id:d}=n;return this._client.delete(U`/v1/vaults/${i}/credentials/${r}`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.delete",s,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":r}})})}archive(r,n,s){const{vault_id:i,betas:c,workspace_id:d}=n;return this._client.post(U`/v1/vaults/${i}/credentials/${r}/archive`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.archive",s,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/archive",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":r}})})}mcpOAuthValidate(r,n,s){const{vault_id:i,betas:c,workspace_id:d}=n;return this._client.post(U`/v1/vaults/${i}/credentials/${r}/mcp_oauth_validate`,{...s,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.credentials.mcp_oauth_validate",s,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":r}})})}}var jN=(()=>{class e extends ye{constructor(){super(...arguments),this.credentials=new AN(this._client)}create(n,s){const{betas:i,workspace_id:c,...d}=n;return this._client.post("/v1/vaults",{body:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.create",s,{route:"/v1/vaults",createdIDAttribute:"anthropic.vault.id"})})}retrieve(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.get(U`/v1/vaults/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.retrieve",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":n}})})}update(n,s,i){const{betas:c,workspace_id:d,...f}=s;return this._client.post(U`/v1/vaults/${n}`,{body:f,...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.update",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":n}})})}list(n={},s){const{betas:i,workspace_id:c,...d}=n??{};return this._client.getAPIList("/v1/vaults",Me,{query:d,...s,headers:L([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.list",s,{route:"/v1/vaults",queryParams:["include_archived","limit","page"]})})}delete(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.delete(U`/v1/vaults/${n}`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.delete",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":n}})})}archive(n,s={},i){const{betas:c,workspace_id:d}=s??{};return this._client.post(U`/v1/vaults/${n}/archive`,{...i,headers:L([{"anthropic-beta":[...c??[],"managed-agents-2026-04-01"].toString(),...d!=null?{"anthropic-workspace-id":d}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:N(this._client,"anthropic.vaults.archive",i,{route:"/v1/vaults/{vault_id}/archive",attributes:{"anthropic.vault.id":n}})})}}return e.Credentials=AN,e})(),kr,jf,Po,xc,Tf,$o,yc,Ef,TN,Mf,Rf,EN=(()=>{class e extends x_{constructor(n,s,i){super(n,{client:i}),kr.add(this),jf.set(this,void 0),Po.set(this,0),xc.set(this,[]),Tf.set(this,[]),$o.set(this,void 0),yc.set(this,[]),Ef.set(this,!1),se(this,jf,s)}get toolCalls(){return v(this,Tf,"f")}_deliverEvent(n,s){var i;se(this,Po,(i=v(this,Po,"f"),i++,i));const c=n.type==="content_block_stop"?s?.content[n.index]:void 0,d=c?.type==="tool_use"?c:void 0;d&&v(this,Tf,"f").push(d),super._deliverEvent(n,s),v(this,kr,"m",TN).call(this,n,d),v(this,kr,"m",Mf).call(this)}[(jf=new WeakMap,Po=new WeakMap,xc=new WeakMap,Tf=new WeakMap,$o=new WeakMap,yc=new WeakMap,Ef=new WeakMap,kr=new WeakSet,Symbol.asyncIterator)](){const n=super[Symbol.asyncIterator](),s={handled:v(this,Po,"f")};v(this,xc,"f").push(s);let i=!1;return{next:async()=>{i&&(i=!1,s.handled++,v(this,kr,"m",Mf).call(this));try{const c=await n.next();return i=!c.done,c.done&&v(this,kr,"m",Rf).call(this,s),c}catch(c){throw v(this,kr,"m",Rf).call(this,s),c}},return:async()=>{const c=n.return?.();return v(this,kr,"m",Rf).call(this,s),await c??{value:void 0,done:!0}}}}}return TN=function(n,s){if(v(this,Ef,"f"))return;if(n.type==="content_block_start"&&n.content_block.type==="fallback"){se(this,Ef,!0),se(this,$o,void 0);return}const i=n.type==="content_block_start"||n.type==="message_delta"&&n.delta.stop_reason==="tool_use";v(this,$o,"f")&&i&&(v(this,yc,"f").push({toolUse:v(this,$o,"f"),event:v(this,Po,"f")}),se(this,$o,void 0)),s&&se(this,$o,s)},Mf=function(){if(this.errored||this.controller.signal.aborted)return;const n=Math.min(v(this,Po,"f"),...v(this,xc,"f").map(s=>s.handled));for(;v(this,yc,"f")[0]&&v(this,yc,"f")[0].event<=n;)v(this,jf,"f").call(this,v(this,yc,"f").shift().toolUse)},Rf=function(n){const s=v(this,xc,"f").indexOf(n);s>=0&&(v(this,xc,"f").splice(s,1),v(this,kr,"m",Mf).call(this))},e})();function MN(){let e,r;return{promise:new Promise((s,i)=>{e=s,r=i}),resolve:e,reject:r}}var wn,Pn,rn,nn,Vt,Xt,zi,RN,Jb,Nd,zN,Zb,ex,ON,tx,PN;class i${constructor(r,n,s){this.fields=r,this.ownMessages=n,this.ownCreateOnly=s,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=HT(r)}}var BT=(()=>{class e{constructor({params:n,options:s,threading:i,logger:c}){wn.add(this),Pn.set(this,void 0),rn.set(this,[]),nn.set(this,[]),Vt.set(this,void 0),Xt.set(this,null),zi.set(this,void 0);const{messages:d,unsupportedRequestBehavior:f,...p}=n;lp(p),this.options=s,this.unsupportedRequestBehavior=f??"error",se(this,Pn,p),se(this,Vt,i?{type:"create",replacesLostThread:!1}:{type:"never_threaded"}),se(this,zi,c),this.push(d??[])}get threading(){return v(this,Vt,"f").type==="create"||v(this,Vt,"f").type==="continue"}get previousMessageId(){return v(this,Vt,"f").type==="continue"?v(this,Vt,"f").previousMessageId:null}get messages(){const n=v(this,Xt,"f")?.replacementHistory?.slice()??[...v(this,rn,"f"),...v(this,nn,"f")].map(s=>s.param);return v(this,Xt,"f")&&n.push(...v(this,Xt,"f").deferredMessages.map(Ec)),n}get params(){const n=v(this,Vt,"f").type==="create"?v(this,Xt,"f")?.ownCreateOnly:void 0;return{...v(this,Pn,"f"),...n,messages:this.messages}}push(n){if(v(this,Xt,"f")){v(this,Xt,"f").deferredMessages.push(...n);return}for(const s of n)v(this,wn,"m",Jb).call(this,s)||v(this,nn,"f").push({param:Ec(s),reply:null})}update(n={},s={}){lp(n),se(this,Pn,{...v(this,Pn,"f"),...Go(n)}),this.options={...this.options,...Go(s)};for(const i of nx)n[i]!==void 0&&delete v(this,Xt,"f")?.ownCreateOnly[i]}fork(n=v(this,Pn,"f")){const s=new e({params:{...n,unsupportedRequestBehavior:this.unsupportedRequestBehavior},options:this.options,threading:v(this,Vt,"f").type!=="never_threaded",logger:v(this,zi,"f")});return this.threading||s.stopThreading(),v(this,Xt,"f")?.replacementHistory?se(s,nn,v(this,Xt,"f").replacementHistory.map(i=>({param:i,reply:null}))):(se(s,rn,[...v(this,rn,"f")]),se(s,nn,[...v(this,nn,"f")])),v(this,Xt,"f")&&s.push(v(this,Xt,"f").deferredMessages),s}setParams({messages:n,...s}){se(this,Pn,s),v(this,Xt,"f")&&(v(this,Xt,"f").ownCreateOnly={}),this.setMessages(n)}setMessages(n){const s=[...v(this,rn,"f"),...v(this,nn,"f")];if(v(this,Xt,"f")){const c=s.map(d=>d.param);$N(n,c)?(v(this,Xt,"f").replacementHistory=null,v(this,Xt,"f").deferredMessages=n.slice(c.length)):(v(this,Xt,"f").replacementHistory=n,v(this,Xt,"f").deferredMessages=[]);return}$N(n,v(this,rn,"f").map(c=>c.param))||(se(this,rn,[]),this.threading&&se(this,Vt,{type:"create",replacesLostThread:!1})),se(this,nn,[]);const i=new Map(s.filter(c=>c.reply).map(c=>[c.param.content,c]));for(const c of n.slice(v(this,rn,"f").length))v(this,wn,"m",Jb).call(this,c)||v(this,nn,"f").push({...i.get(c.content)??{reply:null},param:Ec(c)})}get hasTurnToSend(){return v(this,nn,"f").length>0||GT(v(this,rn,"f").at(-1)?.reply?.stop_reason)}startTurn(n,s){if(v(this,Xt,"f"))throw new De("Another `send()`, `parse()` or `stream()` is already in progress on this thread");lp(s);const i=v(this,nn,"f").length;this.push(n);const c=v(this,nn,"f").slice(i);v(this,wn,"m",zN).call(this);const d={};return s.system!==void 0&&(d.system=s.system),s.tools!==void 0&&(d.tools=s.tools),se(this,Xt,new i$({...v(this,Pn,"f"),...Go(s)},c,d))}endTurn(n){se(this,Xt,null),se(this,nn,v(this,nn,"f").filter(s=>!n.ownMessages.includes(s))),n.replacementHistory&&this.setMessages(n.replacementHistory),this.push(n.deferredMessages)}recoversFrom(n){if(!(n instanceof Gt))return!1;const s=this.unsupportedRequestBehavior==="continue_unthreaded",i=c$(n);if(i!==null&&v(this,Vt,"f").type==="continue")return i==="thread_not_found"&&v(this,Vt,"f").replacesLostThread&&s?(v(this,zi,"f").info(`The server lost the thread again right after a replay; continuing without a thread: previous_message_id=${v(this,Vt,"f").previousMessageId}`),this.stopThreading()):v(this,wn,"m",Nd).call(this,i),!0;const c=d$(n);return c!==null&&this.threading&&s?(v(this,zi,"f").info(`The server cannot thread this request; continuing without a thread: unsupported=${c.join(",")}`),this.stopThreading(),!0):!1}stopThreading(){this.threading&&se(this,Vt,{type:"unthreaded"})}recordPartialReply(n,s){v(this,wn,"m",Zb).call(this,n)||(v(this,wn,"m",ex).call(this,h$(n,s),{partial:!0}),this.previousMessageId!==null&&v(this,wn,"m",Nd).call(this,"stream_ended_before_message_stop"))}recordReply(n,s){v(this,wn,"m",Zb).call(this,s)||(v(this,wn,"m",ex).call(this,s,{partial:!1}),v(this,Vt,"f").type==="create"&&se(this,Pn,{...v(this,Pn,"f"),...n.ownCreateOnly}),this.threading&&(se(this,Vt,{type:"continue",previousMessageId:s.id,createdWith:n.createOnly,replacesLostThread:v(this,Vt,"f").type==="create"&&v(this,Vt,"f").replacesLostThread}),s.usage.iterations?.some(i=>i.type==="fallback_message")&&v(this,wn,"m",Nd).call(this,"fallback_message")),s.container&&v(this,wn,"m",ON).call(this,s.container.id))}buildCreateArguments(n,s,{stream:i}){v(this,wn,"m",tx).call(this,n.createOnly);const c=v(this,Vt,"f");let d=c.type==="continue"?[]:v(this,rn,"f").map(p=>p.param);if(c.type!=="never_threaded"){const p=v(this,rn,"f").map(b=>b.reply!==null).lastIndexOf(!0)+1;d=d.map((b,x)=>x<p?Zx(b):b)}const f={...n.fields,messages:[...d,...v(this,nn,"f").map(p=>p.param)]};if(this.threading&&!f.betas?.includes(Jx)&&(f.betas=[...f.betas??[],Jx]),c.type==="create")f.thread={type:"create"};else if(c.type==="continue"){f.thread={type:"continue",previous_message_id:c.previousMessageId};for(const p of nx)delete f[p]}return{params:f,options:v(this,wn,"m",PN).call(this,s,{stream:i})}}checkNextTurn(n){v(this,wn,"m",tx).call(this,HT({...v(this,Pn,"f"),...Go(n)}))}}return Pn=new WeakMap,rn=new WeakMap,nn=new WeakMap,Vt=new WeakMap,Xt=new WeakMap,zi=new WeakMap,wn=new WeakSet,RN=function(){for(const n of[v(this,nn,"f"),v(this,rn,"f")])for(let s=n.length-1;s>=0;s--)if(n[s].reply)return n[s].reply;return null},Jb=function(n){if("id"in n)return n.id===v(this,wn,"a",RN)?.id;const s=v(this,nn,"f").at(-1)??v(this,rn,"f").at(-1);return s?.reply!=null&&e0(n,s.param)},Nd=function(n){v(this,zi,"f").info(`Replaying the full message history under a new thread: reason=${n} previous_message_id=${this.previousMessageId}`),se(this,Vt,{type:"create",replacesLostThread:n==="thread_not_found"})},zN=function(){const n=v(this,rn,"f").at(-1);if(v(this,nn,"f").length||!n||n.reply&&!n.partial)return;n.reply&&v(this,rn,"f").pop();let s=v(this,rn,"f").length;for(;s>0&&!v(this,rn,"f")[s-1].reply;)s-=1;se(this,nn,v(this,rn,"f").splice(s)),v(this,zi,"f").info(`Re-sending the turn whose reply ended before \`message_stop\`: partial_reply_id=${n.reply?.id??null}`)},Zb=function(n){return n.stop_reason!=="refusal"||v(this,Vt,"f").type==="never_threaded"?!1:(this.previousMessageId!==null&&v(this,wn,"m",Nd).call(this,"refusal"),!0)},ex=function(n,{partial:s}){v(this,rn,"f").push(...v(this,nn,"f")),se(this,nn,[]),n&&v(this,rn,"f").push({param:Ec(n),reply:n,partial:s})},ON=function(n){const{container:s}=v(this,Pn,"f");s==null?se(this,Pn,{...v(this,Pn,"f"),container:n}):typeof s=="object"&&s.id==null&&se(this,Pn,{...v(this,Pn,"f"),container:{...s,id:n}})},tx=function(n){if(v(this,Vt,"f").type!=="continue")return;const{createdWith:s}=v(this,Vt,"f"),i=nx.filter(c=>n[c]!==s[c]);if(i.length){const c=i.map(d=>`\`${d}\``).join(" and ");throw new De(`Cannot change ${c} on a thread: the server keeps the \`system\` and \`tools\` the thread was created with. To change them, start a new thread from \`thread.params\`.`+(i.includes("tools")?" To add or remove tools on this thread, send `tool_addition` or `tool_removal` blocks in a `system` message.":""))}},PN=function(n,{stream:s}){const i={...this.options,...Go(n)};return s&&(i.headers=L([{[n_]:"stream"},i.headers])),v(this,Vt,"f").type!=="never_threaded"&&(i.headers=L([i.headers,s_("message-thread")])),this.threading&&(i.headers=l$(i.headers)),i},e})();const o$=["pause_turn","compaction"];function GT(e){return o$.some(r=>r===e)}const Jx="message-threads-2026-08-12",nx=["system","tools"];function HT(e){return{system:JSON.stringify(e.system),tools:JSON.stringify(e.tools)}}function l$(e){const r=L([e]).values.get("anthropic-beta");return r===null?e:L([e,{"anthropic-beta":Ij(r,Jx)}])}function c$(e){const r=FT(e)?.error_code;return u$.find(n=>n===r)??null}const u$=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function d$(e){const r=FT(e);if(r?.error_code!=="thread_unsupported_request")return null;const n=r.unsupported;return Array.isArray(n)?n.map(String):[]}function FT(e){const n=e.error?.error?.details;return Hn(n)?n:null}function lp(e){if("thread"in e&&e.thread!==void 0)throw new TypeError("`thread` cannot be set here. The message thread sets it for each request itself.")}function Go(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}function h$(e,r){const n=e.content.slice(0,r),s=e.content[r];return s?.type==="text"&&s.text&&n.push(s),n.length?{...e,content:n}:null}function Zx(e){if(!Hn(e))return e;const{cache_control:r,...n}=e;for(const s of["content","source","tool","definition","tool_references"]){const i=n[s];Array.isArray(i)?n[s]=i.map(Zx):Hn(i)&&(n[s]=Zx(i))}return n}function $N(e,r){return r.length<=e.length&&r.every((n,s)=>e0(n,e[s]))}function e0(e,r){const[n,s]=[Ec(e),Ec(r)];return Object.keys({...n,...s}).every(c=>n[c]===s[c]||JSON.stringify(n[c])===JSON.stringify(s[c]))}function Ec(e){return"id"in e?{role:e.role,content:e.content}:e}function IN(e){return e===void 0?[]:qx(e)?e:[e]}function VT(e){const{stream:r,max_iterations:n,runToolsEagerly:s,thread:i,...c}=e;if(i!==void 0&&i!==!1)throw new TypeError("`thread` cannot be set in the params of a tool runner. The runner sets it for each request itself. To run without a message thread, pass `thread: false`.");return{settings:{stream:r,max_iterations:n,runToolsEagerly:s},thread:i,threadParams:c}}var mt,_c,Io,nt,Cr,Xn,zf,va,ps,Nr,Qa,Oi,Ad,Ar,$s,Ja,vc,wc,Do,jd,sx,Of,DN,ax,rx,qN,Td,Pf,LN,UN,ix,$f,If,BN,ox;const GN="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner",m$="a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it";var ey=(()=>{class e{constructor(n,s,i){mt.add(this),_c.set(this,!1),Io.set(this,!1),nt.set(this,void 0),Cr.set(this,void 0),Xn.set(this,void 0),zf.set(this,void 0),va.set(this,void 0),ps.set(this,void 0),Nr.set(this,void 0),Qa.set(this,void 0),Oi.set(this,void 0),Ad.set(this,0),Ar.set(this,void 0),$s.set(this,{status:"idle"}),Ja.set(this,void 0),vc.set(this,null),wc.set(this,new Map),Do.set(this,[]);const{thread:c,settings:d}="_state"in n?{thread:n,settings:s}:n.beta.messages._toolRunnerThread(s);HN(c._state.params),FN(d),se(this,nt,c),se(this,Cr,Go(d));const{tools:f,messages:p}=c._state.params,b=lT(f,p);"_state"in n||c._state.setMessages(JSON.parse(JSON.stringify(VN(p)))),se(this,Xn,{...i}),se(this,zf,L([s_("BetaToolRunner"),b.length?{[vh]:b.join(", ")}:void 0])),se(this,Oi,MN())}async*[(_c=new WeakMap,Io=new WeakMap,nt=new WeakMap,Cr=new WeakMap,Xn=new WeakMap,zf=new WeakMap,va=new WeakMap,ps=new WeakMap,Nr=new WeakMap,Qa=new WeakMap,Oi=new WeakMap,Ad=new WeakMap,Ar=new WeakMap,$s=new WeakMap,Ja=new WeakMap,vc=new WeakMap,wc=new WeakMap,Do=new WeakMap,mt=new WeakSet,jd=function(s){return v(this,Ar,"f")?Hs.with(v(this,Ar,"f"),s):s()},Symbol.asyncIterator)](){var n;if(v(this,_c,"f"))throw new De("Cannot iterate over a consumed stream");se(this,_c,!0),se(this,Io,!0),se(this,Qa,void 0);const s=zt(v(this,nt,"f")._client,()=>t8(v(this,nt,"f")._client,this.params,v(this,Xn,"f").openTelemetry?.conversationId));se(this,Ar,s&&ll.setSpan(Hs.active(),s));try{for(;;)try{if(v(this,Cr,"f").max_iterations&&v(this,Ad,"f")>=v(this,Cr,"f").max_iterations)break;if(v(this,mt,"m",BN).call(this),v(this,$s,"f").status==="scheduled"&&WN(v(this,vc,"f"))!=="resume"){yield*v(this,mt,"m",rx).call(this,v(this,$s,"f").config);continue}se(this,Io,!1,"f"),se(this,Qa,void 0,"f"),se(this,Ad,(n=v(this,Ad,"f"),n++,n),"f"),se(this,ps,void 0,"f"),yield*v(this,mt,"m",sx).call(this,v(this,nt,"f"));const i=v(this,va,"f");if(se(this,va,void 0,"f"),await v(this,mt,"m",jd).call(this,async()=>{let d;if(v(this,Io,"f"))se(this,vc,null,"f"),v(this,Nr,"f")?.abort(),v(this,nt,"f")._state.checkNextTurn(Ed(v(this,nt,"f"))),v(this,nt,"f")._state.setMessages(i),d=i.at(-1);else{const p=await v(this,ps,"f"),b=WN(p.stop_reason);if(se(this,vc,p.stop_reason,"f"),b==="stop")return"stop";if(b==="resume")return"continue";d=y$(v(this,nt,"f").messages)}KN(d)&&v(this,nt,"f")._state.checkNextTurn(Ed(v(this,nt,"f")));const f=await v(this,mt,"m",ix).call(this,d,v(this,Xn,"f").signal,v(this,Ar,"f"));if(f){const p=v(this,nt,"f").messages,b=p.map(x=>x.role).lastIndexOf("assistant")+1;v(this,nt,"f")._state.setMessages([...p.slice(0,b),f,...p.slice(b)])}else if(!v(this,Io,"f")&&!v(this,nt,"f")._state.hasTurnToSend)return"stop";return"continue"})==="stop"){yield*v(this,mt,"m",UN).call(this);break}}finally{v(this,Nr,"f")?.abort(),se(this,Nr,void 0,"f")}if(await v(this,mt,"m",ax).call(this),!v(this,ps,"f"))throw new De("ToolRunner concluded without a message from the server");v(this,Oi,"f").resolve(await v(this,ps,"f")),zt(v(this,nt,"f")._client,()=>s?.setStatus({code:ol.OK}))}catch(i){throw s&&zt(v(this,nt,"f")._client,()=>Ui(s,i)),se(this,_c,!1),se(this,va,void 0),v(this,Oi,"f").promise.catch(()=>{}),v(this,Oi,"f").reject(i),se(this,Oi,MN()),i}finally{zt(v(this,nt,"f")._client,()=>s?.end()),se(this,Ar,void 0)}}setMessagesParams(n){const s=typeof n=="function"?n(this.params):n;if(HN(s),v(this,$s,"f").status!=="idle"&&lx(s),v(this,$s,"f").status==="in_flight"&&!p$(s.messages,v(this,nt,"f").messages))throw new De(f$);const{settings:i,threadParams:c}=VT(s);FN(i),se(this,Cr,Go(i)),v(this,va,"f")?(se(this,va,c.messages),v(this,nt,"f")._state.setParams({...c,messages:v(this,nt,"f").messages})):v(this,nt,"f")._state.setParams(c),se(this,Io,!0),se(this,Qa,void 0)}setRequestOptions(n){typeof n=="function"?se(this,Xn,n(v(this,Xn,"f"))):se(this,Xn,{...v(this,Xn,"f"),...n})}async generateToolResponse(n=v(this,Xn,"f").signal){const s=v(this,nt,"f")._client._tracer?Hs.active():void 0,i=await v(this,ps,"f")??v(this,nt,"f").messages.at(-1);return i?v(this,mt,"m",ix).call(this,i,n,s):null}deferToolCall(n){const s=typeof n=="string"?n:n.id;v(this,Ja,"f")&&!v(this,Ja,"f").has(s)&&v(this,Ja,"f").set(s,{status:"held"})}get deferredToolCalls(){const n=v(this,Nr,"f"),s=v(this,Ja,"f");return!(n instanceof EN)||!s?[]:n.toolCalls.filter(i=>s.get(i.id)?.status==="held")}done(){return v(this,Oi,"f").promise}async runUntilDone(){if(!v(this,_c,"f"))for await(const n of this);return this.done()}get params(){return{...v(this,nt,"f")._state.params,...v(this,va,"f")&&{messages:[...v(this,va,"f")]},...v(this,Cr,"f")}}pushMessages(...n){this.setMessagesParams(s=>({...s,messages:[...s.messages,...n]}))}compactBeforeNextTurn(n){v(this,$s,"f").status!=="in_flight"&&(lx(this.params),se(this,$s,{status:"scheduled",config:n??{type:"summarize"}}))}addTools(...n){const s=v(this,mt,"m",$f).call(this);for(const i of n){if(dh(i))throw new op(`addTools() can't add the '${Bi(Yc(i))}' toolset: ${GN}`);const c=_$(i);if(s.has(c))throw new op(`addTools() can't replace the '${Bi(c)}' toolset: ${GN}`)}for(const i of n)"name"in i&&v(this,wc,"f").set(i.name,"run"in i?i:null),v(this,Do,"f").push({type:"addition",tool:i})}removeTools(...n){const s=v(this,mt,"m",$f).call(this);for(const i of n){const c=typeof i=="string"?i:i.name;if(s.has(c))throw new op(`removeTools() can't remove the '${Bi(c)}' toolset: ${m$}`)}for(const i of n){const c=typeof i=="string"?i:i.name;v(this,wc,"f").set(c,null),v(this,Do,"f").push({type:"removal",name:c})}}then(n,s){return this.runUntilDone().then(n,s)}}return sx=async function*(n){await v(this,mt,"m",ax).call(this),se(this,Ja,void 0);const s=n.messages;s.some(b$)&&v(this,mt,"m",jd).call(this,()=>n._state.setMessages(VN(s)));const{tools:i}=n._state.params;v(this,Cr,"f").stream?(se(this,Nr,v(this,mt,"m",jd).call(this,()=>v(this,Cr,"f").runToolsEagerly?v(this,mt,"m",DN).call(this,n):n.stream(void 0,Ed(n),v(this,mt,"m",Of).call(this,n)))),i&&n.update({tools:i}),n===v(this,nt,"f")&&se(this,va,n.messages),se(this,ps,v(this,Nr,"f").finalMessage()),v(this,ps,"f").catch(()=>{}),yield v(this,Nr,"f")):(se(this,ps,v(this,mt,"m",jd).call(this,()=>n.send(void 0,Ed(n),v(this,mt,"m",Of).call(this,n)))),i&&n.update({tools:i}),n===v(this,nt,"f")&&se(this,va,n.messages),yield v(this,ps,"f"))},Of=function(n){const{headers:s=n._state.options.headers}=v(this,Xn,"f");return{...v(this,Xn,"f"),headers:L([v(this,zf,"f"),s])}},DN=function(n){const s=new Map;se(this,Ja,s);const i=new Map,c=f=>{const p=s.has(f.id),b=!f.toolset_name&&v(this,mt,"m",$f).call(this).has(f.name),x=b?f.name:f.toolset_name;if(x){if(p||b||i.has(x)){i.set(x,"waiting");return}i.set(x,"running");const _=KT(v(this,mt,"m",If).call(this),x,f,v(this,Xn,"f"),v(this,nt,"f")._client,v(this,Ar,"f"));s.set(f.id,{status:"started",result:_}),_.then(({is_error:y})=>{y||i.get(x)==="waiting"?i.set(x,"waiting"):i.delete(x)},()=>i.set(x,"waiting"));return}if(p)return;const g=YT(v(this,mt,"m",Td).call(this),v(this,mt,"m",Pf).call(this),f,v(this,Xn,"f"),v(this,nt,"f")._client,v(this,Ar,"f"));g.catch(()=>{}),s.set(f.id,{status:"started",result:g})},d=new EN(n._state.params,c,n._client);return n._stream(d,void 0,Ed(n),v(this,mt,"m",Of).call(this,n)),d},ax=async function(){const n=[...v(this,Ja,"f")?.values()??[]].filter(s=>s.status==="started");await Promise.allSettled(n.map(s=>s.result))},rx=async function*(n){lx(this.params),se(this,$s,{status:"in_flight"}),se(this,Qa,void 0);const s=v(this,ps,"f"),i=v(this,mt,"m",qN).call(this,n),c=v(this,nt,"f").messages.length;try{yield*v(this,mt,"m",sx).call(this,i);const d=await v(this,ps,"f");if(d.content.some(f=>f.type==="compaction"&&f.content)){v(this,mt,"m",LN).call(this);const f={role:d.role,content:d.content},p=v(this,nt,"f").messages.slice(c).filter(b=>!e0(b,f));v(this,nt,"f")._state.setMessages([f,...p])}else it(v(this,nt,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),se(this,ps,s,"f")}finally{se(this,$s,{status:"idle"}),i._state.threading||v(this,nt,"f")._state.stopThreading()}},qN=function(n){const{messages:s,...i}=g$(v(this,nt,"f")._state.params),c=v(this,nt,"f").fork();return c._state=v(this,nt,"f")._state.fork({...i,compaction:n}),c},Td=function(){const n=new Map;for(const s of v(this,nt,"f")._state.params.tools??[])"run"in s&&"name"in s&&n.set(s.name,s);for(const[s,i]of v(this,wc,"f"))i?n.set(s,i):n.delete(s);return n},Pf=function(){const n=new Set(v(this,mt,"m",Td).call(this).keys());for(const s of[...this.params.messages,v(this,mt,"m",ox).call(this)])if(Array.isArray(s.content)){for(const i of s.content)if(s.role==="system")YN(i,n);else if(s.role==="assistant"&&i.type==="compaction")for(const c of i.tool_changes??[])YN(c,n)}return n},LN=function(){const n=v(this,mt,"m",Pf).call(this);for(const s of v(this,mt,"m",Td).call(this).keys())n.has(s)||v(this,wc,"f").set(s,null)},UN=async function*(){if(v(this,$s,"f").status==="scheduled"){if(KN(v(this,nt,"f").messages.at(-1))){it(v(this,nt,"f")._client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),se(this,$s,{status:"idle"});return}yield*v(this,mt,"m",rx).call(this,v(this,$s,"f").config)}},ix=async function(n,s,i){return v(this,Qa,"f")!==void 0?v(this,Qa,"f"):(se(this,Qa,x$(v(this,mt,"m",If).call(this),v(this,mt,"m",Td).call(this),v(this,mt,"m",Pf).call(this),n,{...v(this,Xn,"f"),signal:s},v(this,Ja,"f"),v(this,nt,"f")._client,i)),v(this,Qa,"f"))},$f=function(){return new Set(v(this,mt,"m",If).call(this).tools.filter(dh).map(Yc))},If=function(){return{...this.params,tools:v(this,nt,"f")._state.params.tools??[]}},BN=function(){v(this,vc,"f")==="pause_turn"||v(this,Do,"f").length===0||(v(this,nt,"f").append(v(this,mt,"m",ox).call(this)),se(this,Do,[]))},ox=function(){const n=[];for(const s of v(this,Do,"f")){if(s.type==="removal"){n.push({type:"tool_removal",tool:{type:"tool_reference",name:s.name}});continue}const i=D_(s.tool);n.push({type:"tool_addition",tool:{type:"tool_definition",definition:i}})}return{role:"system",content:n}},e})();const f$="Message params can't be changed while the conversation is being compacted, because the compaction response is about to replace them. Change them after this iteration instead.";function p$(e,r){return e.length===r.length&&e.every((n,s)=>e0(n,r[s]))}function HN(e){if("compaction"in e&&e.compaction!=null)throw new De("`compaction` cannot be set on a tool runner: every request in the loop would compact again. Call `runner.compactBeforeNextTurn()` when the conversation should be compacted instead.")}function FN(e){if(e.runToolsEagerly&&!e.stream)throw new TypeError("`runToolsEagerly: true` needs `stream: true` in the tool runner's params, because a reply that isn't streamed arrives whole.")}function lx(e){if(e.context_management?.edits?.some(r=>r.type.startsWith("compact_")))throw new De("`compactBeforeNextTurn()` can't be used while `context_management` has a compaction edit, because the API doesn't accept a compaction block together with one. Remove the edit first.")}function g$(e){const{context_management:r,stop_sequences:n,output_format:s,...i}=e,c=({format:d,...f})=>f;return(i.tool_choice?.type==="any"||i.tool_choice?.type==="tool")&&delete i.tool_choice,i.output_config&&(i.output_config=c(i.output_config)),Array.isArray(i.fallbacks)&&(i.fallbacks=i.fallbacks.map(d=>d.output_config?{...d,output_config:c(d.output_config)}:d)),i}function D_(e){if(!("run"in e))return e;const r=A$,n="toJSON"in e&&typeof e.toJSON=="function"?e.toJSON():e;return{...Object.fromEntries(Object.entries(n).filter(([s])=>r.includes(s))),...Ho(e)&&{[Ir]:e[Ir]}}}function Ed(e){const{tools:r}=e._state.params;return r?{tools:r.map(D_)}:{}}function VN(e){return e.map(r=>{if(r.role!=="system"||!Array.isArray(r.content))return r;const n=r.content.map(s=>s.type==="tool_addition"&&s.tool.type==="tool_definition"?{...s,tool:{...s.tool,definition:D_(s.tool.definition)}}:s);return{...r,content:n}})}function b$(e){return e.role==="system"&&Array.isArray(e.content)&&e.content.some(r=>r.type==="tool_addition"&&r.tool.type==="tool_definition"&&"run"in r.tool.definition)}async function x$(e,r,n,s,i,c,d,f){if(!s||s.role!=="assistant"||!s.content||typeof s.content=="string")return null;const p=s.content.filter(g=>g.type==="tool_use");if(p.length===0)return null;const b=new Map;return{role:"user",content:await Promise.all(p.map(async g=>{const _=c?.get(g.id),y=_?.status==="started"?_.result:void 0;if(g.toolset_name){const E=g.toolset_name,T=b.get(E)??{tail:Promise.resolve(),failed:!1};b.set(E,T);const j=e.tools.some(z=>dh(z)&&Yc(z)===E),q=y??T.tail.then(()=>T.failed?kp(g,n$(E),!0):KT(e,E,g,i,d,f));return T.tail=q.then(({is_error:z})=>{z&&j&&(T.failed=!0)},()=>{T.failed=!0}),c?.set(g.id,{status:"started",result:q}),q}if(y)return y;if(!(n.has(g.name)?r.get(g.name):void 0)&&e.tools.some(E=>dh(E)&&Yc(E)===g.name)){const E=b.get(g.name)??{tail:Promise.resolve(),failed:!1};return b.set(g.name,E),E.tail=E.tail.then(()=>{E.failed=!0}),w$(g)}const k=YT(r,n,g,i,d,f);return c?.set(g.id,{status:"started",result:k}),k}))}}async function KT(e,r,n,s,i,c){const d=e.tools.find(b=>dh(b)&&Yc(b)===r);if(!d)return kp(n,`Error: Toolset '${Bi(r)}' member '${Bi(n.name)}' not found`,!0);const f={signal:s?.signal,conversationId:s?.openTelemetry?.conversationId,parentContext:c};return(await a_(i,d,n,f,async()=>{const b=await r$(d,n,{signal:s?.signal});return{block:b,content:b.content??[],isError:b.is_error===!0}})).block}async function YT(e,r,n,s,i,c){const d=r.has(n.name)?e.get(n.name):void 0;if(!d)return v$(n);const f={signal:s?.signal,conversationId:s?.openTelemetry?.conversationId,parentContext:c},p=await a_(i,d,n,f,()=>RT(d,n.input,{toolUse:n,toolUseBlock:n,signal:s?.signal}));return{type:"tool_result",tool_use_id:n.id,content:p.content,...p.isError?{is_error:!0}:void 0}}function y$(e){for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.role==="assistant")return n;if(n.role==="user"&&Array.isArray(n.content)&&n.content.some(s=>s.type==="tool_result"))return}}function KN(e){return Array.isArray(e?.content)&&e.content.some(r=>r.type==="tool_use")}function _$(e){return(e.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"")}function v$(e){return{type:"tool_result",tool_use_id:e.id,content:`Error: Tool '${e.name}' not found`,is_error:!0}}function w$(e){return{type:"tool_result",tool_use_id:e.id,content:`Error: the '${Bi(e.name)}' toolset could not run this call${S$(e.input)}; nothing in the batch was executed`,is_error:!0}}function S$(e){const r=typeof e=="object"&&e!==null?e:{};if(!("actions"in r)){const c="action"in r?r.action:void 0;return typeof c=="string"?`: the call has no 'actions' list (action: '${Bi(c)}')`:": the call has no 'actions' list"}const{actions:n}=r;if(typeof n=="string")return": 'actions' is text, not a list of actions";if(!Array.isArray(n))return": 'actions' is not a list of actions";if(n.length===0)return": the 'actions' list is empty";const s=[];for(const[c,d]of n.entries()){const f=typeof d=="object"&&d!==null&&"action"in d?d.action:void 0;if(typeof f!="string")return`: action ${c} must be an object with a string 'action' field`;s.push(`'${Bi(f)}'`)}const i=s.length>10?`, and ${s.length-10} more`:"";return`: its actions could not be run as sent (actions: ${s.slice(0,10).join(", ")}${i})`}function YN(e,r){switch(e.type){case"tool_removal":case"tool_addition":k$(e,r);break}}function k$(e,r){const n=C$(e.tool);n!==void 0&&(e.type==="tool_removal"?r.delete(n):r.add(n))}function C$(e){switch(e.type){case"tool_reference":return e.name;case"tool_definition":return"name"in e.definition?e.definition.name:void 0;default:return}}function WN(e){if(e===null)return"stop";if(GT(e))return"resume";switch(e){case"tool_use":return"run_tools";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return"stop"}}class hh{constructor(r,n,s){if(!r._supportsMessageThreads)throw new De("Message threads are not available on this client; use `client.beta.messages.create()` with the full `messages` instead");b_(n),this._client=r,this._state=new BT({params:n,options:s??{},threading:!0,logger:it(r)})}static _fromState(r,n){const s=Object.create(hh.prototype);return Object.assign(s,{_client:r,_state:n})}get messages(){return this._state.messages}get previousMessageId(){return this._state.previousMessageId}get params(){return{...this._state.params,unsupportedRequestBehavior:this._state.unsupportedRequestBehavior}}append(...r){this._state.push(r)}send(r,n={},s={}){return this._send(r,n,s,i=>i)}parse(r,n={},s={}){return this._send(r,n,s,i=>g_(i,this._state.params,{logger:it(this._client)}))}_send(r,n,s,i){const c=this._state.startTurn(IN(r),n),d=(async()=>{try{const{request:f,props:p}=await this._createWithRecovery(c,s,{stream:!1}),b=await f;return this._state.recordReply(c,b),{props:p,reply:b}}finally{this._state.endTurn(c)}})();return new ch(this._client,d.then(({props:f})=>f),async()=>{const{props:f,reply:p}=await d;return Xp(i(p),f.response)})}stream(r,n={},s={}){const i=new x_(this._state.params,{logger:it(this._client),client:this._client});return this._stream(i,r,n,s),i}_stream(r,n,s,i){const c=this._state.startTurn(IN(n),s);let d,f=0,p=!1;r.on("streamEvent",(g,_)=>{p||(d=_,g.type==="content_block_stop"&&(f+=1),g.type==="message_stop"&&(p=!0,this._state.recordReply(c,_),this._state.endTurn(c)))});const b=()=>{p||(p=!0,d&&this._state.recordPartialReply(d,f),this._state.endTurn(c))};r.controller.signal.addEventListener("abort",b,{once:!0});const x=(g,_)=>new ch(this._client,this._createWithRecovery(c,{...i,signal:_?.signal},{stream:!0}).then(({props:y})=>y));r._start(x,this._state.params,{signal:i.signal??this._state.options.signal},b)}update(r={},n={}){this._state.update(r,n)}toolRunner(r={},n={}){return lp(r),new ey(this,r,n)}fork(){return hh._fromState(this._client,this._state.fork())}async _createWithRecovery(r,n,{stream:s}){for(;;){const{params:i,options:c}=this._state.buildCreateArguments(r,n,{stream:s}),d=this._client.beta.messages.create({...i,stream:s},c);try{return{request:d,props:await d._responseProps()}}catch(f){if(!this._state.recoversFrom(f))throw f}}}}const XN={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},N$=["claude-mythos-preview","claude-opus-4-6"];var QN=(()=>{class e extends ye{constructor(){super(...arguments),this.batches=new hC(this._client)}create(n,s){const i=Qx(n),{betas:c,user_profile_id:d,workspace_id:f,...p}=i;p.model in XN&&console.warn(`The model '${p.model}' is deprecated and will reach end-of-life on ${XN[p.model]}
526
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),N$.includes(p.model)&&p.thinking&&p.thinking.type==="enabled"&&console.warn(`Using Claude with ${p.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let b=s?.timeout??this._client._options.timeout;if(!p.stream&&b==null){const y=PT[p.model]??void 0;b=this._client.calculateNonstreamingTimeout(p.max_tokens,y)}const x={body:p,timeout:b??6e5,...s,headers:IT(i,s),stream:i.stream??!1,__qualifiers:{beta:"true"}},g=this._client._tracer&&N(this._client,"anthropic.messages.create",s,Jp(this._client,x));nT(this._client,g,p);const _=this._client.post("/v1/messages",{...x,__span:g});return g?_._thenUnwrap(y=>(sT(this._client,g,p,y),y)):_}parse(n,s){return s={...s,headers:L([{"anthropic-beta":[...n.betas??[],"structured-outputs-2025-12-15"].toString()},s?.headers])},this.create(n,s).then(i=>g_(i,n,{logger:this._client.logger??console}))}stream(n,s){return x_.createMessage(this,n,s,{client:this._client})}countTokens(n,s){const i=Qx(n),{betas:c,user_profile_id:d,workspace_id:f,...p}=i,b={body:p,...s,headers:L([{"anthropic-beta":[...c??[],"token-counting-2024-11-01"].toString(),...d!=null?{"anthropic-user-profile-id":d}:void 0,...f!=null?{"anthropic-workspace-id":f}:void 0},s?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/messages/count_tokens",{...b,__span:N(this._client,"anthropic.messages.count_tokens",s,{route:"/v1/messages/count_tokens",request:b})})}toolRunner(n,s){return new ey(this._client,n,s)}_toolRunnerThread(n){b_(n);const{settings:s,thread:i,threadParams:c}=VT(n),d=new BT({params:{...c,unsupportedRequestBehavior:"continue_unthreaded"},options:{},threading:i!==!1&&this._client._supportsMessageThreads,logger:it(this._client)});return{thread:hh._fromState(this._client,d),settings:s}}thread(n,s){return new hh(this._client,n,s)}}return e.Batches=hC,e.BetaToolRunner=ey,e.ToolError=l_,e})();const A$=["input_schema","name","allowed_callers","cache_control","defer_loading","description","eager_input_streaming","input_examples","strict","type","configs","display_height_px","display_width_px","display_number","enable_zoom","max_characters"];var q_=(()=>{class e extends Ye{}return e._errorName="BetaOrganizationNotEnrolledInBetaError",e})(),L_=(()=>{class e extends Ye{}return e._errorName="BetaUnsupportedCharsetError",e})(),JN=(()=>{class e extends ye{constructor(){super(...arguments),this.models=new Lk(this._client),this.messages=new QN(this._client),this.agents=new Kk(this._client),this.environments=new lC(this._client),this.sessions=new _N(this._client),this.deployments=new Ik(this._client),this.deploymentRuns=new $k(this._client),this.vaults=new jN(this._client),this.memoryStores=new dC(this._client),this.files=new qk(this._client),this.skills=new wN(this._client),this.webhooks=new Fk(this._client),this.userProfiles=new NN(this._client),this.dreams=new Dk(this._client),this.tunnels=new kN(this._client),this.organization=new pN(this._client)}}return e.BetaOrganizationNotEnrolledInBetaError=q_,e.BetaUnsupportedCharsetError=L_,e.Models=Lk,e.Messages=QN,e.Agents=Kk,e.Environments=lC,e.BetaEnvironmentArchivedError=u_,e.BetaInvalidConfigTypeChangeError=d_,e.BetaInvalidMetadataError=h_,e.BetaEnvironmentCreateDisabledError=m_,e.BetaEnvironmentUpdateDisabledError=f_,e.BetaEnvironmentNotFoundError=p_,e.Sessions=_N,e.Deployments=Ik,e.DeploymentRuns=$k,e.Vaults=jN,e.MemoryStores=dC,e.Files=qk,e.Skills=wN,e.Webhooks=Fk,e.UserProfiles=NN,e.Dreams=Dk,e.Tunnels=kN,e.Organization=pN,e})();function WT(e,r){const{user_profile_id:n,workspace_id:s,tools:i,messages:c}=e;return L([{...n!=null?{"anthropic-user-profile-id":n}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},cT(i,c),r?.headers])}function j$(e,r,n){if(!e._tracer)return;const s=WT(r,n);return N(e,"anthropic.messages.create",n,Jp(e,{body:r,headers:s,stream:!0}))}function XT(e){return e?.output_config?.format}function ZN(e,r,n){const s=XT(r);return!r||!("parse"in(s??{}))?{...e,content:e.content.map(i=>i.type==="text"?Object.defineProperty({...i},"parsed_output",{value:null,enumerable:!1}):i),parsed_output:null}:QT(e,r)}function QT(e,r,n){let s=null;const i=e.content.map(c=>{if(c.type==="text"){const d=T$(r,c.text);return s===null&&(s=d),Object.defineProperty({...c},"parsed_output",{value:d,enumerable:!1})}return c});return{...e,content:i,parsed_output:s}}function T$(e,r){const n=XT(e);if(n?.type!=="json_schema")return null;try{return"parse"in n?n.parse(r):JSON.parse(r)}catch(s){throw new De(`Failed to parse structured output: ${s}`)}}var sa,Pi,Za,Md,Df,Rd,zd,qf,Od,er,Pd,Lf,Uf,qo,Bf,Gf,Hf,$d,Lo,gs,cx,e5,ux,dx,hx,mx,t5;function fx(e){return e.type==="tool_use"||e.type==="server_tool_use"}var E$=(()=>{class e{constructor(n,s){sa.add(this),this.messages=[],this.receivedMessages=[],Pi.set(this,void 0),Za.set(this,null),this.controller=new AbortController,Md.set(this,void 0),Df.set(this,()=>{}),Rd.set(this,()=>{}),zd.set(this,void 0),qf.set(this,()=>{}),Od.set(this,()=>{}),er.set(this,{}),Pd.set(this,!1),Lf.set(this,!1),Uf.set(this,!1),qo.set(this,!1),Bf.set(this,void 0),Gf.set(this,void 0),Hf.set(this,void 0),$d.set(this,void 0),Lo.set(this,void 0),gs.set(this,void 0),ux.set(this,i=>{if(se(this,Lf,!0),v(this,gs,"f")&&(v(this,gs,"f").streamed=void 0),Jo(i)&&(i=new Ls),i instanceof Ls)return se(this,Uf,!0),this._emit("abort",i);if(i instanceof De)return this._emit("error",i);if(i instanceof Error){const c=new De(i.message);return c.cause=i,this._emit("error",c)}return this._emit("error",new De(String(i)))}),se(this,Md,new Promise((i,c)=>{se(this,Df,i,"f"),se(this,Rd,c,"f")})),se(this,zd,new Promise((i,c)=>{se(this,qf,i,"f"),se(this,Od,c,"f")})),v(this,Md,"f").catch(()=>{}),v(this,zd,"f").catch(()=>{}),se(this,Za,n),se(this,$d,s?.logger??console),se(this,Lo,s?.client)}get response(){return v(this,Bf,"f")}get request_id(){return v(this,Gf,"f")}get workspace_id(){return v(this,Hf,"f")}async withResponse(){se(this,qo,!0);const n=await v(this,Md,"f");if(!n)throw new Error("Could not resolve a `Response` object");return{data:this,response:n,request_id:n.headers.get("request-id"),workspace_id:n.headers.get("anthropic-workspace-id")}}static fromReadableStream(n){const s=new e(null);return s._run(()=>s._fromReadableStream(n)),s}static createMessage(n,s,i,{logger:c,client:d}={}){const f=new e(s,{logger:c,client:d});for(const p of s.messages)f._addMessageParam(p);return se(f,Za,{...s,stream:!0}),f._run(()=>f._createMessage(n,{...s,stream:!0},{...i,headers:{...i?.headers,[n_]:"stream"}})),f}_run(n){n().then(()=>{this._emitFinal(),this._emit("end")},v(this,ux,"f"))}_addMessageParam(n){this.messages.push(n)}_addMessage(n,s=!0){this.receivedMessages.push(n),s&&this._emit("message",n)}async _createMessage(n,s,i){const c=i?.signal;let d;c&&(c.aborted&&this.controller.abort(),d=this.controller.abort.bind(this.controller),c.addEventListener("abort",d));try{v(this,sa,"m",dx).call(this),se(this,gs,i?.__span??(v(this,Lo,"f")&&j$(v(this,Lo,"f"),s,i)),"f");const{response:f,data:p}=await n.create({...s,stream:!0},{...i,__span:v(this,gs,"f"),signal:this.controller.signal}).withResponse();try{this._connected(f)}catch(b){throw v(this,gs,"f")&&(v(this,gs,"f").failure=b),p.controller.abort(),b}for await(const b of p)try{v(this,sa,"m",hx).call(this,b)}catch(x){throw v(this,gs,"f")&&(v(this,gs,"f").failure=x),x}if(p.controller.signal?.aborted)throw new Ls;v(this,sa,"m",mx).call(this)}finally{c&&d&&c.removeEventListener("abort",d)}}_connected(n){this.ended||(se(this,Bf,n),se(this,Gf,n?.headers.get("request-id")),se(this,Hf,n?.headers.get("anthropic-workspace-id")),v(this,Df,"f").call(this,n),this._emit("connect"))}get ended(){return v(this,Pd,"f")}get errored(){return v(this,Lf,"f")}get aborted(){return v(this,Uf,"f")}abort(){this.controller.abort()}on(n,s){return(v(this,er,"f")[n]||(v(this,er,"f")[n]=[])).push({listener:s}),this}off(n,s){const i=v(this,er,"f")[n];if(!i)return this;const c=i.findIndex(d=>d.listener===s);return c>=0&&i.splice(c,1),this}once(n,s){return(v(this,er,"f")[n]||(v(this,er,"f")[n]=[])).push({listener:s,once:!0}),this}emitted(n){return new Promise((s,i)=>{se(this,qo,!0),n!=="error"&&this.once("error",i),this.once(n,s)})}async done(){se(this,qo,!0),await v(this,zd,"f")}get currentMessage(){return v(this,Pi,"f")}async finalMessage(){return await this.done(),v(this,sa,"m",cx).call(this)}async finalText(){return await this.done(),v(this,sa,"m",e5).call(this)}_emit(n,...s){if(v(this,Pd,"f"))return;n==="end"&&(se(this,Pd,!0),v(this,qf,"f").call(this));const i=v(this,er,"f")[n];if(i&&(v(this,er,"f")[n]=i.filter(c=>!c.once),i.forEach(({listener:c})=>c(...s))),n==="abort"){const c=s[0];!v(this,qo,"f")&&!i?.length&&Promise.reject(c),v(this,Rd,"f").call(this,c),v(this,Od,"f").call(this,c),this._emit("end");return}if(n==="error"){const c=s[0];!v(this,qo,"f")&&!i?.length&&Promise.reject(c),v(this,Rd,"f").call(this,c),v(this,Od,"f").call(this,c),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",v(this,sa,"m",cx).call(this))}async _fromReadableStream(n,s){const i=s?.signal;let c;i&&(i.aborted&&this.controller.abort(),c=this.controller.abort.bind(this.controller),i.addEventListener("abort",c));try{v(this,sa,"m",dx).call(this),this._connected(null);const d=Hr.fromReadableStream(n,this.controller);for await(const f of d)v(this,sa,"m",hx).call(this,f);if(d.controller.signal?.aborted)throw new Ls;v(this,sa,"m",mx).call(this)}finally{i&&c&&i.removeEventListener("abort",c)}}[(Pi=new WeakMap,Za=new WeakMap,Md=new WeakMap,Df=new WeakMap,Rd=new WeakMap,zd=new WeakMap,qf=new WeakMap,Od=new WeakMap,er=new WeakMap,Pd=new WeakMap,Lf=new WeakMap,Uf=new WeakMap,qo=new WeakMap,Bf=new WeakMap,Gf=new WeakMap,Hf=new WeakMap,$d=new WeakMap,Lo=new WeakMap,gs=new WeakMap,ux=new WeakMap,sa=new WeakSet,cx=function(){if(this.receivedMessages.length===0)throw new De("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},e5=function(){if(this.receivedMessages.length===0)throw new De("stream ended without producing a Message with role=assistant");const s=this.receivedMessages.at(-1).content.filter(i=>i.type==="text").map(i=>i.text);if(s.length===0)throw new De("stream ended without producing a content block with type=text");return s.join(" ")},dx=function(){this.ended||se(this,Pi,void 0)},hx=function(s){if(this.ended)return;const i=v(this,sa,"m",t5).call(this,s);if(this._emit("_rawEvent",s),!!i)switch(this._emit("streamEvent",s,i),s.type){case"content_block_delta":{const c=i.content.at(-1);switch(s.delta.type){case"text_delta":{c.type==="text"&&this._emit("text",s.delta.text,c.text||"");break}case"citations_delta":{c.type==="text"&&this._emit("citation",s.delta.citation,c.citations??[]);break}case"input_json_delta":{fx(c)&&v(this,er,"f").inputJson?.length&&this._emit("inputJson",s.delta.partial_json,c.input);break}case"thinking_delta":{c.type==="thinking"&&this._emit("thinking",s.delta.thinking,c.thinking);break}case"signature_delta":{c.type==="thinking"&&this._emit("signature",c.signature);break}default:s.delta}break}case"message_stop":{v(this,Lo,"f")&&v(this,gs,"f")&&v(this,Za,"f")&&t_(v(this,Lo,"f"),v(this,gs,"f"),v(this,Za,"f"),i),this._addMessageParam(i),this._addMessage(ZN(i,v(this,Za,"f"),{logger:v(this,$d,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",i.content.at(-1));break}case"message_start":{se(this,Pi,i),v(this,gs,"f")&&v(this,Za,"f")&&(v(this,gs,"f").streamed={body:v(this,Za,"f"),message:i});break}}},mx=function(){if(this.ended)throw new De("stream has ended, this shouldn't happen");const s=v(this,Pi,"f");if(!s)throw new De("request ended without sending any chunks");return se(this,Pi,void 0),ZN(s,v(this,Za,"f"),{logger:v(this,$d,"f")})},t5=function(s){let i=v(this,Pi,"f");if(s.type==="message_start"){if(i)throw new De(`Unexpected event order, got ${s.type} before receiving "message_stop"`);return s.message}if(i)switch(s.type){case"message_stop":return i;case"message_delta":return i.stop_reason=s.delta.stop_reason,i.stop_sequence=s.delta.stop_sequence,i.stop_details=s.delta.stop_details,i.usage.output_tokens=s.usage.output_tokens,s.delta.container!=null&&(i.container=s.delta.container),s.usage.input_tokens!=null&&(i.usage.input_tokens=s.usage.input_tokens),s.usage.cache_creation_input_tokens!=null&&(i.usage.cache_creation_input_tokens=s.usage.cache_creation_input_tokens),s.usage.cache_read_input_tokens!=null&&(i.usage.cache_read_input_tokens=s.usage.cache_read_input_tokens),s.usage.server_tool_use!=null&&(i.usage.server_tool_use=s.usage.server_tool_use),s.usage.output_tokens_details!=null&&(i.usage.output_tokens_details=s.usage.output_tokens_details),i;case"content_block_start":return i.content.push({...s.content_block}),i;case"content_block_delta":{const c=i.content.at(s.index);switch(s.delta.type){case"text_delta":{c?.type==="text"&&(i.content[s.index]={...c,text:(c.text||"")+s.delta.text});break}case"citations_delta":{c?.type==="text"&&(i.content[s.index]={...c,citations:[...c.citations??[],s.delta.citation]});break}case"input_json_delta":{if(c&&fx(c)){const d=(c[Ic]||"")+s.delta.partial_json;i.content[s.index]=DT(c,d)}break}case"thinking_delta":{c?.type==="thinking"&&(i.content[s.index]={...c,thinking:c.thinking+s.delta.thinking});break}case"signature_delta":{c?.type==="thinking"&&(i.content[s.index]={...c,signature:s.delta.signature});break}default:s.delta}return i}case"content_block_stop":{const c=i.content.at(s.index);return c&&fx(c)&&Ic in c&&Object.defineProperty(c,"input",{value:c.input,enumerable:!0,configurable:!0,writable:!0}),i}default:return i}},Symbol.asyncIterator)](){const n=[],s=[];let i=!1;return this.on("_rawEvent",c=>{const d=s.shift();d?d.resolve(c):n.push(c)}),this.on("end",()=>{i=!0;for(const c of s)c.resolve(void 0);s.length=0}),this.on("abort",c=>{i=!0;for(const d of s)d.reject(c);s.length=0}),this.on("error",c=>{i=!0;for(const d of s)d.reject(c);s.length=0}),{next:async()=>n.length?{value:n.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((d,f)=>s.push({resolve:d,reject:f})).then(d=>d?{value:d,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Hr(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return e})();class n5 extends ye{create(r,n){const{user_profile_id:s,workspace_id:i,...c}=r;return this._client.post("/v1/messages/batches",{body:c,...n,headers:L([{...s!=null?{"anthropic-user-profile-id":s}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},n?.headers]),__span:N(this._client,"anthropic.messages.batches.create",n,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":c.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(r,n={},s){const{workspace_id:i}=n??{};return this._client.get(U`/v1/messages/batches/${r}`,{...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.messages.batches.retrieve",s,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":r}})})}list(r={},n){const{workspace_id:s,...i}=r??{};return this._client.getAPIList("/v1/messages/batches",ns,{query:i,...n,headers:L([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:N(this._client,"anthropic.messages.batches.list",n,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(r,n={},s){const{workspace_id:i}=n??{};return this._client.delete(U`/v1/messages/batches/${r}`,{...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.messages.batches.delete",s,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":r}})})}cancel(r,n={},s){const{workspace_id:i}=n??{};return this._client.post(U`/v1/messages/batches/${r}/cancel`,{...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.messages.batches.cancel",s,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":r}})})}async results(r,n={},s){const i=await this.retrieve(r,n,s);if(!i.results_url)throw new De(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{workspace_id:c}=n??{};return this._client.get(i.results_url,{...s,headers:L([{Accept:"application/binary",...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),stream:!0,__binaryResponse:!0,__span:N(this._client,"anthropic.messages.batches.results",s,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":r}})})._thenUnwrap((d,f)=>OT.fromResponse(f.response,f.controller))}}var U_=(()=>{class e extends Ye{}return e._errorName="AvailableToolsLimitExceededError",e})(),B_=(()=>{class e extends Ye{}return e._errorName="CompactionBlockAmbiguousError",e})(),G_=(()=>{class e extends Ye{}return e._errorName="CompactionBlockMisplacedError",e})(),H_=(()=>{class e extends Ye{}return e._errorName="CompactionContentMismatchError",e})(),F_=(()=>{class e extends Ye{}return e._errorName="CompactionIncompleteTurnError",e})(),V_=(()=>{class e extends Ye{}return e._errorName="CompactionNothingToSummarizeError",e})(),K_=(()=>{class e extends Ye{}return e._errorName="CompactionSignatureInvalidError",e})(),Y_=(()=>{class e extends Ye{}return e._errorName="CompactionTooManyToolReferencesError",e})(),W_=(()=>{class e extends Ye{}return e._errorName="CompactionToolChangesMismatchError",e})(),X_=(()=>{class e extends Ye{}return e._errorName="ThreadAlreadyContinuedError",e})(),Q_=(()=>{class e extends Ye{}return e._errorName="ThreadContinueInFlightError",e})(),J_=(()=>{class e extends Ye{}return e._errorName="ThreadFingerprintMismatchError",e})(),Z_=(()=>{class e extends Ye{}return e._errorName="ThreadUnsupportedRequestError",e})(),ev=(()=>{class e extends Ye{}return e._errorName="ToolNameConflictError",e})(),tv=(()=>{class e extends Ye{}return e._errorName="ToolReferenceUnresolvedError",e})(),nv=(()=>{class e extends Zc{}return e._errorName="ThreadNotFoundError",e})(),sv=(()=>{class e extends Ly{}return e._errorName="CompactionUnavailableError",e})(),s5=(()=>{class e extends ye{constructor(){super(...arguments),this.batches=new n5(this._client)}create(n,s){const{user_profile_id:i,workspace_id:c,...d}=n;d.model in a5&&console.warn(`The model '${d.model}' is deprecated and will reach end-of-life on ${a5[d.model]}
527
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),M$.includes(d.model)&&d.thinking&&d.thinking.type==="enabled"&&console.warn(`Using Claude with ${d.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let f=s?.timeout??this._client._options.timeout;if(!d.stream&&f==null){const g=PT[d.model]??void 0;f=this._client.calculateNonstreamingTimeout(d.max_tokens,g)}const p={body:d,timeout:f??6e5,...s,headers:WT(n,s),stream:n.stream??!1},b=this._client._tracer&&N(this._client,"anthropic.messages.create",s,Jp(this._client,p));nT(this._client,b,d);const x=this._client.post("/v1/messages",{...p,__span:b});return b?x._thenUnwrap(g=>(sT(this._client,b,d,g),g)):x}parse(n,s){return this.create(n,s).then(i=>QT(i,n,{logger:this._client.logger??console}))}stream(n,s){const i=n;return E$.createMessage(this,i,s,{logger:this._client.logger??console,client:this._client})}countTokens(n,s){const{user_profile_id:i,workspace_id:c,...d}=n,f={body:d,...s,headers:L([{...i!=null?{"anthropic-user-profile-id":i}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])};return this._client.post("/v1/messages/count_tokens",{...f,__span:N(this._client,"anthropic.messages.count_tokens",s,{route:"/v1/messages/count_tokens",request:f})})}}return e.AvailableToolsLimitExceededError=U_,e.CompactionBlockAmbiguousError=B_,e.CompactionBlockMisplacedError=G_,e.CompactionContentMismatchError=H_,e.CompactionIncompleteTurnError=F_,e.CompactionNothingToSummarizeError=V_,e.CompactionSignatureInvalidError=K_,e.CompactionTooManyToolReferencesError=Y_,e.CompactionToolChangesMismatchError=W_,e.ThreadAlreadyContinuedError=X_,e.ThreadContinueInFlightError=Q_,e.ThreadFingerprintMismatchError=J_,e.ThreadUnsupportedRequestError=Z_,e.ToolNameConflictError=ev,e.ToolReferenceUnresolvedError=tv,e.ThreadNotFoundError=nv,e.CompactionUnavailableError=sv,e.Batches=n5,e})();const a5={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},M$=["claude-mythos-preview","claude-opus-4-6"];var av=(()=>{class e extends Ye{}return e._errorName="OrgAPIKeyLimitExceededError",e})(),rv=(()=>{class e extends Ye{}return e._errorName="WorkspaceAPIKeyLimitExceededError",e})(),r5=(()=>{class e extends ye{retrieve(n,s){return this._client.get(U`/v1/organizations/api_keys/${n}`,{...s,__span:N(this._client,"anthropic.organization.api_keys.retrieve",s,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/api_keys/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/api_keys",ns,{query:n,...s,__span:N(this._client,"anthropic.organization.api_keys.list",s,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}return e.OrgAPIKeyLimitExceededError=av,e.WorkspaceAPIKeyLimitExceededError=rv,e})(),iv=(()=>{class e extends Ye{}return e._errorName="ExternalKeyInWorkspacePolicyError",e})(),ov=(()=>{class e extends Ye{}return e._errorName="ExternalKeyValidationFailedError",e})(),lv=(()=>{class e extends Ye{}return e._errorName="ExternalKeyValidationTimedOutError",e})(),cv=(()=>{class e extends Vr{}return e._errorName="ExternalKeyChangedError",e})(),i5=(()=>{class e extends ye{create(n,s){return this._client.post("/v1/organizations/external_keys",{body:n,...s,__span:N(this._client,"anthropic.organization.external_keys.create",s,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/external_keys/${n}`,{...s,__span:N(this._client,"anthropic.organization.external_keys.retrieve",s,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/external_keys/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/external_keys",Me,{query:n,...s,__span:N(this._client,"anthropic.organization.external_keys.list",s,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(n,s){return this._client.delete(U`/v1/organizations/external_keys/${n}`,{...s,__span:N(this._client,"anthropic.organization.external_keys.delete",s,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}validate(n,s){return this._client.post(U`/v1/organizations/external_keys/${n}/validate`,{...s,__span:N(this._client,"anthropic.organization.external_keys.validate",s,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":n}})})}}return e.ExternalKeyInWorkspacePolicyError=iv,e.ExternalKeyValidationFailedError=ov,e.ExternalKeyValidationTimedOutError=lv,e.ExternalKeyChangedError=cv,e})(),uv=(()=>{class e extends Ye{}return e._errorName="AlreadyMemberError",e})(),dv=(()=>{class e extends Ye{}return e._errorName="CannotInviteEmailsWithUnverifiedDomainsError",e})(),hv=(()=>{class e extends Ye{}return e._errorName="EmailDomainNotAllowedError",e})(),mv=(()=>{class e extends Ye{}return e._errorName="InviteAlreadyExistsError",e})(),o5=(()=>{class e extends ye{create(n,s){return this._client.post("/v1/organizations/invites",{body:n,...s,__span:N(this._client,"anthropic.organization.invites.create",s,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/invites/${n}`,{...s,__span:N(this._client,"anthropic.organization.invites.retrieve",s,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/invites",ns,{query:n,...s,__span:N(this._client,"anthropic.organization.invites.list",s,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(n,s){return this._client.delete(U`/v1/organizations/invites/${n}`,{...s,__span:N(this._client,"anthropic.organization.invites.delete",s,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":n}})})}}return e.AlreadyMemberError=uv,e.CannotInviteEmailsWithUnverifiedDomainsError=dv,e.EmailDomainNotAllowedError=hv,e.InviteAlreadyExistsError=mv,e})();class l5 extends ye{retrieve(r){return this._client.get("/v1/organizations/compliance_settings",{...r,__span:N(this._client,"anthropic.organization.compliance_settings.retrieve",r,{route:"/v1/organizations/compliance_settings"})})}update(r,n){return this._client.post("/v1/organizations/compliance_settings",{body:r,...n,__span:N(this._client,"anthropic.organization.compliance_settings.update",n,{route:"/v1/organizations/compliance_settings"})})}}let c5=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/rate_limits",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.rate_limits.list",n,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var fv=(()=>{class e extends Ye{}return e._errorName="CannotRemoveLastMemberError",e})(),u5=(()=>{class e extends ye{retrieve(n,s){return this._client.get(U`/v1/organizations/users/${n}`,{...s,__span:N(this._client,"anthropic.organization.users.retrieve",s,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/users/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/users",ns,{query:n,...s,__span:N(this._client,"anthropic.organization.users.list",s,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(n,s){return this._client.delete(U`/v1/organizations/users/${n}`,{...s,__span:N(this._client,"anthropic.organization.users.remove",s,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":n}})})}}return e.CannotRemoveLastMemberError=fv,e})();class d5 extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/artifacts",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.artifacts.list",n,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}}class h5 extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/connectors",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.connectors.list",n,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class m5 extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/plugins",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.plugins.list",n,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}let f5=class extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/skills",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.skills.list",n,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};class p5 extends ye{list(r,n){return this._client.getAPIList("/v1/organizations/analytics/summaries",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.summaries.list",n,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}}class g5 extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/users",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.users.list",n,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}}class b5 extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.analytics.apps.chat.projects.list",n,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}}var x5=(()=>{class e extends ye{constructor(){super(...arguments),this.projects=new b5(this._client)}}return e.Projects=b5,e})(),y5=(()=>{class e extends ye{constructor(){super(...arguments),this.chat=new x5(this._client)}}return e.Chat=x5,e})(),_5=(()=>{class e extends ye{constructor(){super(...arguments),this.summaries=new p5(this._client),this.users=new g5(this._client),this.apps=new y5(this._client),this.connectors=new h5(this._client),this.plugins=new m5(this._client),this.skills=new f5(this._client),this.artifacts=new d5(this._client)}}return e.Summaries=p5,e.Users=g5,e.Apps=y5,e.Connectors=h5,e.Plugins=m5,e.Skills=f5,e.Artifacts=d5,e})();class v5 extends ye{create(r,n){return this._client.post("/v1/organizations/federation_issuers",{body:r,...n,__span:N(this._client,"anthropic.organization.federation.issuers.create",n,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(r,n){return this._client.get(U`/v1/organizations/federation_issuers/${r}`,{...n,__span:N(this._client,"anthropic.organization.federation.issuers.retrieve",n,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":r}})})}update(r,n,s){return this._client.post(U`/v1/organizations/federation_issuers/${r}`,{body:n,...s,__span:N(this._client,"anthropic.organization.federation.issuers.update",s,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/federation_issuers",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.federation.issuers.list",n,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(r,n){return this._client.post(U`/v1/organizations/federation_issuers/${r}/archive`,{...n,__span:N(this._client,"anthropic.organization.federation.issuers.archive",n,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":r}})})}}let w5=class extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/federation_rules/${r}/workspaces`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.federation.rules.workspaces.list",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/federation_rules/${r}/workspaces`,{body:n,...s,__span:N(this._client,"anthropic.organization.federation.rules.workspaces.add",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":r},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(r,n,s){const{federation_rule_id:i}=n;return this._client.delete(U`/v1/organizations/federation_rules/${i}/workspaces/${r}`,{...s,__span:N(this._client,"anthropic.organization.federation.rules.workspaces.remove",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":i,"anthropic.organization.federation_rule.workspace.id":r}})})}};var S5=(()=>{class e extends ye{constructor(){super(...arguments),this.workspaces=new w5(this._client)}create(n,s){return this._client.post("/v1/organizations/federation_rules",{body:n,...s,__span:N(this._client,"anthropic.organization.federation.rules.create",s,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/federation_rules/${n}`,{...s,__span:N(this._client,"anthropic.organization.federation.rules.retrieve",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/federation_rules/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/federation_rules",Me,{query:n,...s,__span:N(this._client,"anthropic.organization.federation.rules.list",s,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(n,s){return this._client.post(U`/v1/organizations/federation_rules/${n}/archive`,{...s,__span:N(this._client,"anthropic.organization.federation.rules.archive",s,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":n}})})}}return e.Workspaces=w5,e})(),k5=(()=>{class e extends ye{constructor(){super(...arguments),this.issuers=new v5(this._client),this.rules=new S5(this._client)}}return e.Issuers=v5,e.Rules=S5,e})();let C5=class extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/rbac_groups/${r}/members`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.rbac_groups.members.list",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/rbac_groups/${r}/members`,{body:n,...s,__span:N(this._client,"anthropic.organization.rbac_groups.members.add",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":r},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(r,n,s){const{rbac_group_id:i}=n;return this._client.delete(U`/v1/organizations/rbac_groups/${i}/members/${r}`,{...s,__span:N(this._client,"anthropic.organization.rbac_groups.members.remove",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":i,"anthropic.organization.rbac_group.member.id":r}})})}};var pv=(()=>{class e extends Ye{}return e._errorName="RBACGroupGrantsOwnerAccessError",e})(),gv=(()=>{class e extends Ye{}return e._errorName="RBACGroupOwnerAccessUnconfirmedError",e})(),N5=(()=>{class e extends ye{constructor(){super(...arguments),this.members=new C5(this._client)}create(n,s){return this._client.post("/v1/organizations/rbac_groups",{body:n,...s,__span:N(this._client,"anthropic.organization.rbac_groups.create",s,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/rbac_groups/${n}`,{...s,__span:N(this._client,"anthropic.organization.rbac_groups.retrieve",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/rbac_groups/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/rbac_groups",Me,{query:n,...s,__span:N(this._client,"anthropic.organization.rbac_groups.list",s,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(n,s){return this._client.delete(U`/v1/organizations/rbac_groups/${n}`,{...s,__span:N(this._client,"anthropic.organization.rbac_groups.delete",s,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":n}})})}}return e.RBACGroupGrantsOwnerAccessError=pv,e.RBACGroupOwnerAccessUnconfirmedError=gv,e.Members=C5,e})();class A5 extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/rbac_roles/${r}/permissions`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.rbac_roles.permissions.list",s,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":r}})})}}var j5=(()=>{class e extends ye{constructor(){super(...arguments),this.permissions=new A5(this._client)}retrieve(n,s){return this._client.get(U`/v1/organizations/rbac_roles/${n}`,{...s,__span:N(this._client,"anthropic.organization.rbac_roles.retrieve",s,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/rbac_roles",Me,{query:n,...s,__span:N(this._client,"anthropic.organization.rbac_roles.list",s,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return e.Permissions=A5,e})();let T5=class extends ye{list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/service_accounts/${r}/workspaces`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.service_accounts.workspaces.list",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/service_accounts/${r}/workspaces`,{body:n,...s,__span:N(this._client,"anthropic.organization.service_accounts.workspaces.add",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":r},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(r,n,s){const{service_account_id:i}=n;return this._client.delete(U`/v1/organizations/service_accounts/${i}/workspaces/${r}`,{...s,__span:N(this._client,"anthropic.organization.service_accounts.workspaces.remove",s,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":i,"anthropic.organization.service_account.workspace.id":r}})})}};var E5=(()=>{class e extends ye{constructor(){super(...arguments),this.workspaces=new T5(this._client)}create(n,s){return this._client.post("/v1/organizations/service_accounts",{body:n,...s,__span:N(this._client,"anthropic.organization.service_accounts.create",s,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/service_accounts/${n}`,{...s,__span:N(this._client,"anthropic.organization.service_accounts.retrieve",s,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/service_accounts/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/service_accounts",Me,{query:n,...s,__span:N(this._client,"anthropic.organization.service_accounts.list",s,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(n,s){return this._client.post(U`/v1/organizations/service_accounts/${n}/archive`,{...s,__span:N(this._client,"anthropic.organization.service_accounts.archive",s,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":n}})})}}return e.Workspaces=T5,e})();class M5 extends ye{list(r={},n){return this._client.getAPIList("/v1/organizations/spend_limits/effective",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.spend_limits.effective.list",n,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}}class R5 extends ye{retrieve(r,n){return this._client.get(U`/v1/organizations/spend_limit_increase_requests/${r}`,{...n,__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",n,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}list(r={},n){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",Me,{query:r,...n,__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.list",n,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(r,n,s){return this._client.post(U`/v1/organizations/spend_limit_increase_requests/${r}/approve`,{body:n,...s,__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.approve",s,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}deny(r,n,s){return this._client.post(U`/v1/organizations/spend_limit_increase_requests/${r}/deny`,{body:n,...s,__span:N(this._client,"anthropic.organization.spend_limits.increase_requests.deny",s,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":r}})})}}var z5=(()=>{class e extends ye{constructor(){super(...arguments),this.effective=new M5(this._client),this.increaseRequests=new R5(this._client)}}return e.Effective=M5,e.IncreaseRequests=R5,e})();class O5 extends ye{retrieve(r,n,s){const{workspace_id:i}=n;return this._client.get(U`/v1/organizations/workspaces/${i}/members/${r}`,{...s,__span:N(this._client,"anthropic.organization.workspaces.members.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}update(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/members/${r}`,{body:c,...s,__span:N(this._client,"anthropic.organization.workspaces.members.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/members`,ns,{query:n,...s,__span:N(this._client,"anthropic.organization.workspaces.members.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/workspaces/${r}/members`,{body:n,...s,__span:N(this._client,"anthropic.organization.workspaces.members.add",s,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":r},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(r,n,s){const{workspace_id:i}=n;return this._client.delete(U`/v1/organizations/workspaces/${i}/members/${r}`,{...s,__span:N(this._client,"anthropic.organization.workspaces.members.remove",s,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":r}})})}}class P5 extends ye{update(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/rate_limits/${r}`,{body:c,...s,__span:N(this._client,"anthropic.organization.workspaces.rate_limits.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.rate_limit.id":r}})})}list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/rate_limits`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.workspaces.rate_limits.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":r}})})}}class $5 extends ye{retrieve(r,n,s){const{workspace_id:i}=n;return this._client.get(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{...s,__span:N(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}update(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{body:c,...s,__span:N(this._client,"anthropic.organization.workspaces.service_accounts.update",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}list(r,n={},s){return this._client.getAPIList(U`/v1/organizations/workspaces/${r}/service_accounts`,Me,{query:n,...s,__span:N(this._client,"anthropic.organization.workspaces.service_accounts.list",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":r}})})}add(r,n,s){return this._client.post(U`/v1/organizations/workspaces/${r}/service_accounts`,{body:n,...s,__span:N(this._client,"anthropic.organization.workspaces.service_accounts.add",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":r},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(r,n,s){const{workspace_id:i}=n;return this._client.delete(U`/v1/organizations/workspaces/${i}/service_accounts/${r}`,{...s,__span:N(this._client,"anthropic.organization.workspaces.service_accounts.remove",s,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":r}})})}}var bv=(()=>{class e extends Ye{}return e._errorName="KeyProfileMismatchError",e})(),xv=(()=>{class e extends Ye{}return e._errorName="WorkspaceMemberLimitExceededError",e})(),yv=(()=>{class e extends Ye{}return e._errorName="WorkspacePolicyViolationError",e})(),I5=(()=>{class e extends ye{constructor(){super(...arguments),this.rateLimits=new P5(this._client),this.members=new O5(this._client),this.serviceAccounts=new $5(this._client)}create(n,s){return this._client.post("/v1/organizations/workspaces",{body:n,...s,__span:N(this._client,"anthropic.organization.workspaces.create",s,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(n,s){return this._client.get(U`/v1/organizations/workspaces/${n}`,{...s,__span:N(this._client,"anthropic.organization.workspaces.retrieve",s,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":n}})})}update(n,s,i){return this._client.post(U`/v1/organizations/workspaces/${n}`,{body:s,...i,__span:N(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":n}})})}list(n={},s){return this._client.getAPIList("/v1/organizations/workspaces",ns,{query:n,...s,__span:N(this._client,"anthropic.organization.workspaces.list",s,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(n,s){return this._client.post(U`/v1/organizations/workspaces/${n}/archive`,{...s,__span:N(this._client,"anthropic.organization.workspaces.archive",s,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":n}})})}}return e.KeyProfileMismatchError=bv,e.WorkspaceMemberLimitExceededError=xv,e.WorkspacePolicyViolationError=yv,e.RateLimits=P5,e.Members=O5,e.ServiceAccounts=$5,e})(),_v=(()=>{class e extends Ye{}return e._errorName="OrgMemberLimitExceededError",e})(),vv=(()=>{class e extends Vr{}return e._errorName="ConcurrentMembershipChangeError",e})(),D5=(()=>{class e extends ye{constructor(){super(...arguments),this.apiKeys=new r5(this._client),this.externalKeys=new i5(this._client),this.federation=new k5(this._client),this.invites=new o5(this._client),this.serviceAccounts=new E5(this._client),this.users=new u5(this._client),this.workspaces=new I5(this._client),this.rateLimits=new c5(this._client),this.complianceSettings=new l5(this._client),this.analytics=new _5(this._client),this.spendLimits=new z5(this._client),this.rbacGroups=new N5(this._client),this.rbacRoles=new j5(this._client)}retrieve(n){return this._client.get("/v1/organizations/me",{...n,__span:N(this._client,"anthropic.organization.retrieve",n,{route:"/v1/organizations/me"})})}}return e.OrgMemberLimitExceededError=_v,e.ConcurrentMembershipChangeError=vv,e.APIKeys=r5,e.OrgAPIKeyLimitExceededError=av,e.WorkspaceAPIKeyLimitExceededError=rv,e.ExternalKeys=i5,e.ExternalKeyInWorkspacePolicyError=iv,e.ExternalKeyValidationFailedError=ov,e.ExternalKeyValidationTimedOutError=lv,e.ExternalKeyChangedError=cv,e.Federation=k5,e.Invites=o5,e.AlreadyMemberError=uv,e.CannotInviteEmailsWithUnverifiedDomainsError=dv,e.EmailDomainNotAllowedError=hv,e.InviteAlreadyExistsError=mv,e.ServiceAccounts=E5,e.Users=u5,e.CannotRemoveLastMemberError=fv,e.Workspaces=I5,e.KeyProfileMismatchError=bv,e.WorkspaceMemberLimitExceededError=xv,e.WorkspacePolicyViolationError=yv,e.RateLimits=c5,e.ComplianceSettings=l5,e.Analytics=_5,e.SpendLimits=z5,e.RBACGroups=N5,e.RBACGroupGrantsOwnerAccessError=pv,e.RBACGroupOwnerAccessUnconfirmedError=gv,e.RBACRoles=j5,e})();class q5 extends ye{create(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/skills/${r}/versions`,Kr({body:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.versions.create",s,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":r},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(r,n,s){const{skill_id:i,workspace_id:c}=n;return this._client.get(U`/v1/skills/${i}/versions/${r}`,{...s,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.versions.retrieve",s,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":r}})})}list(r,n={},s){const{workspace_id:i,...c}=n??{};return this._client.getAPIList(U`/v1/skills/${r}/versions`,Me,{query:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.versions.list",s,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":r}})})}delete(r,n,s){const{skill_id:i,workspace_id:c}=n;return this._client.delete(U`/v1/skills/${i}/versions/${r}`,{...s,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.versions.delete",s,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":r}})})}}var wv=(()=>{class e extends Vr{}return e._errorName="SkillReadBlockedUndecryptableError",e})(),L5=(()=>{class e extends ye{constructor(){super(...arguments),this.versions=new q5(this._client)}create(n,s){const{workspace_id:i,...c}=n;return this._client.post("/v1/skills",Kr({body:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.create",s,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(n,s={},i){const{workspace_id:c}=s??{};return this._client.get(U`/v1/skills/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":n}})})}list(n={},s){const{workspace_id:i,...c}=n??{};return this._client.getAPIList("/v1/skills",Me,{query:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.skills.list",s,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(n,s={},i){const{workspace_id:c}=s??{};return this._client.delete(U`/v1/skills/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":n}})})}}return e.SkillReadBlockedUndecryptableError=wv,e.Versions=q5,e})();class U5 extends ye{create(r,n,s){const{workspace_id:i,...c}=n;return this._client.post(U`/v1/user_profiles/${r}/action_urls`,{body:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.user_profiles.action_urls.create",s,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":r}})})}}var Sv=(()=>{class e extends Ye{}return e._errorName="UserProfileNotFoundError",e})(),B5=(()=>{class e extends ye{constructor(){super(...arguments),this.actionURLs=new U5(this._client)}create(n,s){const{workspace_id:i,...c}=n;return this._client.post("/v1/user_profiles",{body:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.user_profiles.create",s,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(n,s={},i){const{workspace_id:c}=s??{};return this._client.get(U`/v1/user_profiles/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}update(n,s,i){const{workspace_id:c,...d}=s;return this._client.post(U`/v1/user_profiles/${n}`,{body:d,...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}list(n={},s){const{workspace_id:i,...c}=n??{};return this._client.getAPIList("/v1/user_profiles",Me,{query:c,...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.user_profiles.list",s,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(n,s={},i){const{workspace_id:c}=s??{};return this._client.delete(U`/v1/user_profiles/${n}`,{...i,headers:L([{...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__span:N(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":n}})})}}return e.UserProfileNotFoundError=Sv,e.ActionURLs=U5,e})();const R$=new Map([["400 already_member",uv],["400 available_tools_limit_exceeded",U_],["400 cannot_invite_emails_with_unverified_domains",dv],["400 cannot_remove_last_member",fv],["400 cannot_sign_out_primary_owner",y_],["400 cannot_sign_out_self",__],["400 claude_code_key_creator_not_member",hT],["400 claude_code_version_too_old",mT],["400 cmek_key_disabled",fT],["400 cmek_key_network_blocked",pT],["400 compaction_block_ambiguous",B_],["400 compaction_block_misplaced",G_],["400 compaction_content_mismatch",H_],["400 compaction_incomplete_turn",F_],["400 compaction_nothing_to_summarize",V_],["400 compaction_signature_invalid",K_],["400 compaction_too_many_tool_references",Y_],["400 compaction_tool_changes_mismatch",W_],["400 email_domain_not_allowed",hv],["400 environment_archived",u_],["400 external_key_in_workspace_policy",iv],["400 external_key_validation_failed",ov],["400 external_key_validation_timed_out",lv],["400 file_not_downloadable",r_],["400 invalid_config_type_change",d_],["400 invalid_metadata",h_],["400 invite_already_exists",mv],["400 key_profile_mismatch",bv],["400 org_api_key_limit_exceeded",av],["400 org_member_limit_exceeded",_v],["400 organization_not_enrolled_in_beta",q_],["400 organization_on_hold",gT],["400 organization_type_not_supported",bT],["400 rbac_group_grants_owner_access",pv],["400 rbac_group_owner_access_unconfirmed",gv],["400 request_body_encoding_invalid",xT],["400 request_body_encoding_unsupported",yT],["400 scan_failed",C_],["400 slack_channel_set_up_settings_refused",E_],["400 storage_quota_exceeded",i_],["400 thread_already_continued",X_],["400 thread_continue_in_flight",Q_],["400 thread_fingerprint_mismatch",J_],["400 thread_unsupported_request",Z_],["400 tool_name_conflict",ev],["400 tool_reference_unresolved",tv],["400 unsupported_charset",L_],["400 user_profile_not_found",Sv],["400 workspace_api_key_limit_exceeded",rv],["400 workspace_member_limit_exceeded",xv],["400 workspace_policy_violation",yv],["403 api_key_scope_missing",M_],["403 cannot_sign_out_managed_member",v_],["403 cannot_sign_out_membership_admin",w_],["403 cannot_sign_out_owner",S_],["403 cannot_sign_out_privileged_member",k_],["403 claude_tag_writes_not_enabled",R_],["403 compliance_configuration_restricted",z_],["403 environment_create_disabled",m_],["403 environment_update_disabled",f_],["403 organization_level_scoped_api_key_required",O_],["403 sandbox_egress_restricted",_T],["403 spend_limits_admin_api_writes_not_enabled",I_],["404 environment_not_found",p_],["404 file_expired",o_],["404 slack_channel_set_up_environment_not_found",P_],["404 thread_not_found",nv],["409 concurrent_membership_change",vv],["409 external_key_changed",cv],["409 plugin_name_taken",N_],["409 scan_pending",A_],["409 skill_name_taken",j_],["409 skill_read_blocked_undecryptable",wv],["409 slack_channel_set_up_settings_conflict",$_],["412 heartbeat_precondition_failed",c_],["413 request_body_too_large_after_decoding",vT],["429 enforced_spend_limit_reached",wT],["429 ramp_limit_exceeded",ST],["503 cmek_context_unavailable",kT],["503 cmek_key_unreachable",CT],["503 registration_pending",T_],["529 compaction_unavailable",sv]]),z$="urn:ietf:params:oauth:grant-type:jwt-bearer",O$="refresh_token",JT="/v1/oauth/token",Cp="oauth-2025-04-20",P$="oidc-federation-2026-04-01",$$=120,kv=30,I$=5,G5=1<<20;function ZT(e){if(!e)return;let r;try{r=new URL(e)}catch(s){throw new Bt(`Invalid token endpoint base URL "${e}": ${s}`)}if(r.protocol==="https:")return;const n=r.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(r.protocol==="http:"&&(n==="localhost"||n==="127.0.0.1"||n==="::1")))throw new Bt(`Refusing to send credential over non-https token endpoint "${e}"`)}async function e3(e,r){const n=await q$(e);let s;try{s=JSON.parse(n)}catch{throw new Bt(`Token endpoint returned non-JSON response (status ${e.status})`,e.status,ra(n),r)}if(!s.access_token)throw new Bt(`Token endpoint response missing access_token: ${JSON.stringify(ra(s))}`,e.status,ra(s),r);if(s.token_type&&s.token_type.toLowerCase()!=="bearer")throw new Bt(`Token endpoint response: unsupported token_type "${s.token_type}" (want Bearer)`,e.status,ra(s),r);return s}const px=2e3,D$=new Set(["error","error_description","error_uri"]);function ra(e){if(e==null)return e;if(typeof e=="string"){let r;try{r=JSON.parse(e)}catch{return e.length<=px?e:e.slice(0,px)+`... <${e.length-px} more chars>`}return JSON.stringify(ra(r))}if(typeof e=="object"&&!Array.isArray(e)){const r={};for(const[n,s]of Object.entries(e))D$.has(n)&&(r[n]=s);return r}return null}async function t3(e,r=n=>console.warn(`anthropic-sdk: ${n}`)){if(typeof process>"u"||process.platform==="win32")return;const{fs:n}=await Aa(async()=>{const{fs:d}=await import("./node.browser-BFtyutLR.js");return{fs:d}},[]);let s=e,i;try{s=await n.promises.realpath(e),i=await n.promises.stat(s)}catch{return}const c=i.mode&511;if(c&18)throw new Bt(`Credentials file at ${s} is group/world-writable (mode 0o${c.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${s}\`.`);if(c&36)throw new Bt(`Credentials file at ${s} is group/world-readable (mode 0o${c.toString(8)}); run \`chmod 600 ${s}\` before retrying.`);typeof process.getuid=="function"&&i.uid!==process.getuid()&&r(`credentials file at ${s} is owned by uid ${i.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function n3(e,r){const{fs:n,path:s}=await Aa(async()=>{const{fs:d,path:f}=await import("./node.browser-BFtyutLR.js");return{fs:d,path:f}},[]),i=s.dirname(e);await n.promises.mkdir(i,{recursive:!0,mode:448});const c=`${e}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{const d=await n.promises.open(c,"w",384);try{await d.writeFile(JSON.stringify(r,null,2)),await d.sync()}finally{await d.close()}await n.promises.rename(c,e)}catch(d){throw await n.promises.unlink(c).catch(()=>{}),d}try{const d=await n.promises.open(i,"r");try{await d.sync()}finally{await d.close()}}catch{}}async function q$(e){if(!e.body)return"";const r=e.body.getReader(),n=[];let s=0;for(;;){const{done:c,value:d}=await r.read();if(c)break;if(s+d.length>G5){const f=G5-s;f>0&&n.push(d.subarray(0,f)),await r.cancel();break}n.push(d),s+=d.length}let i;if(n.length===1)i=n[0];else{i=new Uint8Array(n.reduce((d,f)=>d+f.length,0));let c=0;for(const d of n)i.set(d,c),c+=d.length}return new TextDecoder("utf-8").decode(i)}var Bt=(()=>{class e extends De{constructor(n,s=null,i=null,c=null){super(n),this.statusCode=s,this.body=i,this.requestId=c}}return e._errorName="WorkloadIdentityError",e})();function Wo(){return Math.floor(Date.now()/1e3)}class L${constructor(r,n){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=r,this.onAdvisoryRefreshError=n}async getToken(){const r=this.nextForce;this.nextForce=!1;const n=this.cached;if(r||n==null)return(await this.refresh(r)).token;if(n.expiresAt==null)return n.token;const s=n.expiresAt-Wo();return s>$$?n.token:s>kv?(this.backgroundRefresh(),n.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(r=!1){return this.pendingRefresh&&!r?this.pendingRefresh:this.doRefresh(r)}backgroundRefresh(){this.pendingRefresh||Wo()-this.lastAdvisoryError<I$||this.doRefresh().catch(r=>{this.lastAdvisoryError=Wo(),this.onAdvisoryRefreshError?.(r)})}doRefresh(r=!1){return this.pendingRefresh=this.provider(r?{forceRefresh:!0}:void 0).then(n=>(this.cached=n,this.pendingRefresh=null,n),n=>{throw this.pendingRefresh=null,n}),this.pendingRefresh}}const s3="1.0",U$=/^[A-Za-z0-9_.-]+$/;function a3(e){if(!e)throw new Error("profile name is empty");if(e==="."||e==="..")throw new Error(`profile name "${e}" is not allowed`);if(e.includes("/")||e.includes("\\"))throw new Error(`profile name "${e}" must not contain path separators`);if(!U$.test(e))throw new Error(`profile name "${e}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}const B$=async e=>{var r,n;const s=await Cv();if(s===null)return null;const i=e==null&&ot("ANTHROPIC_PROFILE")!=null;let c=null;if(e==null&&!i){const y=ot("ANTHROPIC_ORGANIZATION_ID"),S=ot("ANTHROPIC_IDENTITY_TOKEN_FILE"),k=ot("ANTHROPIC_FEDERATION_RULE_ID");if(k&&y&&(c={fromFile:!1,config:{organization_id:y,workspace_id:ot("ANTHROPIC_WORKSPACE_ID"),base_url:ot("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:k,service_account_id:ot("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:S?{source:"file",path:S}:void 0,scope:ot("ANTHROPIC_SCOPE")}}},S||ot("ANTHROPIC_IDENTITY_TOKEN")))return c}const d=e??await r3();if(d===null)return null;a3(d);const{fs:f,path:p}=await Aa(async()=>{const{fs:y,path:S}=await import("./node.browser-BFtyutLR.js");return{fs:y,path:S}},[]),b=p.join(s,"configs",`${d}.json`);let x;try{x=await f.promises.readFile(b,"utf-8")}catch(y){if(y?.code!=="ENOENT")throw new Error(`failed to read config file ${b}: ${y}`);if(i)throw new De(`ANTHROPIC_PROFILE names the profile "${d}", but ${b} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:y});return c}let g;try{g=JSON.parse(x)}catch(y){throw new Error(`failed to parse config file ${b}: ${y}`)}if(!g.authentication)throw new Error(`config file ${b} is missing "authentication"`);const _=g.authentication.type;if(_!=="oidc_federation"&&_!=="user_oauth")throw new Error(`authentication.type "${_}" is not a known authentication type`);if(g.organization_id??(g.organization_id=ot("ANTHROPIC_ORGANIZATION_ID")),g.workspace_id??(g.workspace_id=ot("ANTHROPIC_WORKSPACE_ID")),g.base_url??(g.base_url=ot("ANTHROPIC_BASE_URL")),(r=g.authentication).scope??(r.scope=ot("ANTHROPIC_SCOPE")),g.authentication.type==="oidc_federation"){if(!g.authentication.identity_token){const y=ot("ANTHROPIC_IDENTITY_TOKEN_FILE");y&&(g.authentication.identity_token={source:"file",path:y})}g.authentication.federation_rule_id||(g.authentication.federation_rule_id=ot("ANTHROPIC_FEDERATION_RULE_ID")??""),(n=g.authentication).service_account_id??(n.service_account_id=ot("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:g,fromFile:!0}},G$=async(e,r)=>{if(e?.authentication.credentials_path)return e.authentication.credentials_path;const n=await Cv();if(!n)return null;const s=r??await r3();if(!s)return null;a3(s);const{path:i}=await Aa(async()=>{const{path:c}=await import("./node.browser-BFtyutLR.js");return{path:c}},[]);return i.join(n,"credentials",`${s}.json`)},Cv=async()=>{if(!H$())return null;const{path:e}=await Aa(async()=>{const{path:c}=await import("./node.browser-BFtyutLR.js");return{path:c}},[]),r=ot("ANTHROPIC_CONFIG_DIR");if(r)return r;if(Uy()["X-Stainless-OS"]==="Windows"){const c=ot("APPDATA");if(c)return e.join(c,"Anthropic");const d=ot("USERPROFILE");return d?e.join(d,"AppData","Roaming","Anthropic"):null}const s=ot("XDG_CONFIG_HOME");if(s)return e.join(s,"anthropic");const i=ot("HOME");return i?e.join(i,".config","anthropic"):null},H$=()=>{const e=Uy()["X-Stainless-Runtime"];return e==="node"||e==="deno"},r3=async()=>{const e=await Cv();if(!e)return null;const r=ot("ANTHROPIC_PROFILE");if(r)return r;const{fs:n,path:s}=await Aa(async()=>{const{fs:c,path:d}=await import("./node.browser-BFtyutLR.js");return{fs:c,path:d}},[]),i=s.join(e,"active_config");try{return(await n.promises.readFile(i,"utf-8")).trim()||"default"}catch(c){if(c?.code!=="ENOENT")throw new Error(`failed to read ${i}: ${c}`);return"default"}};function H5(e){if(!e)throw new De("Identity token file path is empty");return async()=>{const{fs:r}=await Aa(async()=>{const{fs:i}=await import("./node.browser-BFtyutLR.js");return{fs:i}},[]);let n;try{n=await r.promises.readFile(e,"utf-8")}catch(i){throw new De(`Failed to read identity token file at ${e}: ${i}`)}const s=n.trim();if(!s)throw new De(`Identity token file at ${e} is empty`);return s}}function F$(e){if(!e)throw new De("Identity token value is empty");return()=>e}function V$(e){return async()=>{ZT(e.baseURL);const r=await e.identityTokenProvider();if(r.length>16*1024)throw new Bt(`Identity token is ${Math.ceil(r.length/1024)} KiB, exceeds the 16 KiB assertion limit`);const n={grant_type:z$,assertion:r,federation_rule_id:e.federationRuleId,organization_id:e.organizationId};e.serviceAccountId&&(n.service_account_id=e.serviceAccountId),e.workspaceId&&(n.workspace_id=e.workspaceId);const s=`${e.baseURL}${JT}`;let i;try{i=await e.fetch(s,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${Cp},${P$}`,"User-Agent":e.userAgent||`anthropic-sdk-typescript/${Pr} oidcFederationProvider`},body:JSON.stringify(n)})}catch(p){throw new Bt(`Failed to reach token endpoint ${s}: ${p}`)}const c=i.headers.get("Request-Id");if(!i.ok){const p=await i.text().catch(()=>""),b=ra(p);let x="";throw i.status===401&&(x=` Ensure your federation rule matches your identity token. ${e.workspaceId?"":"If your federation rule is scoped to multiple workspaces, set the ANTHROPIC_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Claude Console for more details.`),new Bt(`Token exchange failed with status ${i.status}${c?` (request-id ${c})`:""}: ${b}${x}`,i.status,b,c)}const d=await e3(i,c),f=Number(d.expires_in);if(!Number.isFinite(f))throw new Bt(`Token endpoint response missing required fields: ${JSON.stringify(ra(d))}`,i.status,ra(d),c);return{token:d.access_token,expiresAt:Wo()+f}}}function K$(e){return async r=>{const{fs:n}=await Aa(async()=>{const{fs:E}=await import("./node.browser-BFtyutLR.js");return{fs:E}},[]);await t3(e.credentialsPath,e.onSafetyWarning);let s;try{s=await n.promises.readFile(e.credentialsPath,"utf-8")}catch(E){throw new Bt(`Credentials file not found at ${e.credentialsPath}: ${E}`)}let i;try{i=JSON.parse(s)}catch(E){throw new Bt(`Credentials file at ${e.credentialsPath} is not valid JSON: ${E}`)}const c=i.access_token;if(!c)throw new Bt(`Credentials file at ${e.credentialsPath} must include 'access_token'`);const d=i.expires_at;if(!r?.forceRefresh&&(d==null||Wo()<d-kv))return{token:c,expiresAt:d??null};const f=i.refresh_token;if(!e.clientId||!f)throw new Bt(`Access token at ${e.credentialsPath} has expired and no refresh is available (client_id ${e.clientId?"set":"empty"}, refresh_token ${f?"set":"empty"})`);ZT(e.baseURL);const p={grant_type:O$,refresh_token:f,client_id:e.clientId},b=`${e.baseURL}${JT}`;let x;try{x=await e.fetch(b,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":Cp,"User-Agent":e.userAgent||`anthropic-sdk-typescript/${Pr} userOAuthProvider`},body:JSON.stringify(p)})}catch(E){throw new Bt(`User OAuth refresh failed to reach token endpoint: ${E}`)}const g=x.headers.get("Request-Id");if(!x.ok){const E=await x.text().catch(()=>"");throw new Bt(`User OAuth refresh failed (HTTP ${x.status}): ${ra(E)}`,x.status,ra(E),g)}const _=await e3(x,g),y=Number(_.expires_in);if(!Number.isFinite(y))throw new Bt(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(ra(_))}`,x.status,ra(_),g);const S=Wo()+y,k=_.refresh_token||f;return await n3(e.credentialsPath,{...i,version:s3,type:"oauth_token",access_token:_.access_token,expires_at:S,refresh_token:k}),{token:_.access_token,expiresAt:S}}}function i3(e,r){const n=e.authentication.credentials_path??null,s=(e.base_url||r.baseURL).replace(/\/+$/,""),i=W$(e,n,s,r),c={};return e.workspace_id&&e.authentication.type==="user_oauth"&&(c["anthropic-workspace-id"]=e.workspace_id),{provider:i,extraHeaders:c,baseURL:e.base_url||void 0}}async function Y$(e,r){const n=await B$(r);if(!n)return null;const{config:s,fromFile:i}=n,c=s.authentication.credentials_path||!i?s:{...s,authentication:{...s.authentication,credentials_path:await G$(s,r)??void 0}};return i3(c,e)}function W$(e,r,n,s){switch(e.authentication.type){case"oidc_federation":{const i=e.authentication,c=X$(i);if(!c)throw new Bt("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!i.federation_rule_id)throw new Bt("oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via ANTHROPIC_FEDERATION_RULE_ID (profile takes precedence).");if(!e.organization_id)throw new Bt("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");const d=V$({identityTokenProvider:c,federationRuleId:i.federation_rule_id,organizationId:e.organization_id,serviceAccountId:i.service_account_id,workspaceId:e.workspace_id,baseURL:n,fetch:s.fetch,userAgent:s.userAgent});return r?Q$(d,r,s.onCacheWriteError,s.onSafetyWarning):d}case"user_oauth":{if(!r)throw new Bt("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return K$({credentialsPath:r,clientId:e.authentication.client_id,baseURL:n,fetch:s.fetch,userAgent:s.userAgent,onSafetyWarning:s.onSafetyWarning})}default:{const i=e.authentication.type;throw new Bt(`authentication.type "${i}" is not a known authentication type`)}}}function X$(e){if(e.identity_token){const s=e.identity_token.source;if(s!=="file")throw new Bt(`identity_token.source "${s}" is not supported by this SDK version (only "file")`);if(!e.identity_token.path)throw new Bt('identity_token.source "file" requires a non-empty path');return H5(e.identity_token.path)}const r=ot("ANTHROPIC_IDENTITY_TOKEN_FILE");if(r)return H5(r);const n=ot("ANTHROPIC_IDENTITY_TOKEN");return n?F$(n):null}function Q$(e,r,n,s){return async i=>{const{fs:c}=await Aa(async()=>{const{fs:p}=await import("./node.browser-BFtyutLR.js");return{fs:p}},[]);await t3(r,s);let d;try{const p=await c.promises.readFile(r,"utf-8");d=JSON.parse(p);const b=d?.access_token;if(b&&!i?.forceRefresh){const x=d?.expires_at;if(x==null||Wo()<x-kv)return{token:b,expiresAt:x??null}}}catch(p){p?.code!=="ENOENT"&&!(p instanceof SyntaxError)&&n?.(p)}const f=await e(i);try{await n3(r,{...d??{},version:s3,type:"oauth_token",access_token:f.token,expires_at:f.expiresAt})}catch(p){n?.(p)}return f}}const o3=new WeakSet;function l3(e){return typeof e=="object"&&e!==null&&o3.has(e)}function J$(e){const r=new Set;for(;typeof e=="object"&&e!==null&&!r.has(e);){if(r.add(e),l3(e)||Jo(e)||e instanceof Hc||e instanceof Iz)return!0;e=e.cause}return!1}function F5(e,r,n,s){return async(i,c={})=>{if(r.length===0)return e.call(void 0,i,c);const d=c.headers instanceof Headers?c.headers:new Headers(c.headers),f=await eI(e,r,n,s)({...c,headers:d,url:typeof i=="string"?i:i instanceof URL?i.href:i.url});if(f.bodyUsed||f.body?.locked)throw new De("middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it");return f}}function Z$(e,r){const n=new WeakMap;return{options:e,logger:r?it(r):Pj(),parse(s){if(e?.stream&&s.ok)return V5(s,e,r);let i=n.get(s);return i||(i=V5(s,e,r),n.set(s,i)),i}}}async function V5(e,r,n){if(e.bodyUsed||e.body?.locked)throw new De("cannot ctx.parse() a response whose body was already consumed; call ctx.parse() instead of reading the body, or read via response.clone()");if(r?.stream&&e.ok)return Hr.fromSSEResponse(e.clone(),new AbortController,n);if(e.status===204)return null;if(r?.__binaryResponse)return e;const i=e.headers.get("content-type")?.split(";")[0]?.trim();return i?.includes("application/json")||i?.endsWith("+json")?e.headers.get("content-length")==="0"?void 0:Xp(await e.clone().json(),e):await e.clone().text()}function eI(e,r,n,s){let i=async({url:d,...f})=>{try{return await e.call(void 0,d,f)}catch(p){const b=Yd(p);throw o3.add(b),b}};const c=Z$(n,s);for(let d=r.length-1;d>=0;d--){const f=r[d],p=i;i=async b=>f(b,p,c)}return i}const c3=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.slice=="function"&&typeof e.arrayBuffer=="function",tI=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.lastModified=="number"&&c3(e),nI=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function sI(e,r,n){if(Yj(),e=await e,r||(r=e instanceof File?e.name:rp(e,!0)),tI(e))return e instanceof File&&r==null&&n==null?e:Pc([await e.arrayBuffer()],r??e.name,{type:e.type,lastModified:e.lastModified,...n});if(nI(e)){const i=await e.blob();return r||(r=new URL(e.url).pathname.split(/[\\/]/).pop()),Pc(await ty(i),r,n)}const s=await ty(e);if(!n?.type){const i=s.find(c=>typeof c=="object"&&"type"in c&&c.type);typeof i=="string"&&(n={...n,type:i})}return Pc(s,r,n)}async function ty(e){let r=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)r.push(e);else if(c3(e))r.push(e instanceof Blob?e:await e.arrayBuffer());else if(Zy(e))for await(const n of e)r.push(...await ty(n));else{const n=e?.constructor?.name;throw new Error(`Unexpected data type: ${typeof e}${n?`; constructor: ${n}`:""}${aI(e)}`)}return r}function aI(e){return typeof e!="object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(n=>`"${n}"`).join(", ")}]`}class K5 extends ye{retrieve(r,n={},s){const{workspace_id:i}=n??{};return this._client.get(U`/v1/models/${r}`,{...s,headers:L([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers]),__span:N(this._client,"anthropic.models.retrieve",s,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":r}})})}list(r={},n){const{workspace_id:s,...i}=r??{};return this._client.getAPIList("/v1/models",ns,{query:i,...n,headers:L([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:N(this._client,"anthropic.models.list",n,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}var gx,bx,Ff,Sc,Uo,Y5;let W5=!1;var rI=(()=>{class e{get credentials(){return this._authState.provider}get openTelemetry(){return v(this,Uo,"f")}_instrumentationScope(){return{version:Pr}}constructor({baseURL:n=ot("ANTHROPIC_BASE_URL"),apiKey:s,authToken:i,webhookKey:c=ot("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...d}={}){gx.add(this),this._requestAuthFlags=new WeakMap,Ff.set(this,void 0),Sc.set(this,void 0),Uo.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;const f={apiKey:s,authToken:i,...d},p=ic.filter(E=>f[E]!=null);if(p.length>1){const E=T=>T.map(j=>`\`${j}\``).join(", ");throw new TypeError(`Pass at most one of ${E(ic)}. Received ${E(p)}.`)}const[b]=p,x=b!=null?null:{apiKey:s===void 0?ot("ANTHROPIC_API_KEY"):void 0,authToken:i===void 0?ot("ANTHROPIC_AUTH_TOKEN"):void 0},g=b!=null?{type:b,value:f[b]}:x?.apiKey!=null?{type:"apiKey",value:x.apiKey}:x?.authToken!=null?{type:"authToken",value:x.authToken}:{type:"defaultChain"},_={apiKey:g.type==="apiKey"?g.value:null,authToken:g.type==="authToken"?g.value:null,webhookKey:c,...d,baseURL:n||"https://api.anthropic.com"};if(!_.dangerouslyAllowBrowser&&Bz())throw new De(`It looks like you're running in a browser-like environment.
528
+
529
+ This is disabled by default, as it risks exposing your secret API credentials to attackers.
530
+ If you understand the risks and have appropriate mitigations in place,
531
+ you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
532
+
533
+ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
534
+ `);this.baseURL=_.baseURL,this._baseURLIsExplicit=d.__baseURLIsExplicit??!!n,this.timeout=_.timeout??bx.DEFAULT_TIMEOUT,this.logger=_.logger??console,this.logLevel=_p,this.logLevel=Bx(_.logLevel,"ClientOptions.logLevel",it(this))??Bx(ot("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",it(this))??_p,x?.apiKey!=null&&x.authToken!=null&&!W5&&(W5=!0,it(this).warn("Anthropic: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are both set. Using ANTHROPIC_API_KEY.")),this.fetchOptions=_.fetchOptions,this.maxRetries=zb("maxRetries",_.maxRetries??2);const y=this._instrumentationScope();se(this,Uo,eP(_.openTelemetry)),_.openTelemetry=v(this,Uo,"f"),this._tracer=zt(this,()=>nP(v(this,Uo,"f"),y.version,y.platform)),this.fetch=_.fetch??Wz(),se(this,Ff,Jz),this.middleware=[..._.middleware??[]];const S=ot("ANTHROPIC_CUSTOM_HEADERS");if(S){const E={};for(const T of S.split(`
535
+ `)){const j=T.indexOf(":");j>=0&&(E[T.substring(0,j).trim()]=T.substring(j+1).trim())}_.defaultHeaders={...E,..._.defaultHeaders}}const k=d.__auth;if(delete _.__auth,delete _.__baseURLIsExplicit,this._options=_,this.apiKey=typeof _.apiKey=="string"?_.apiKey:null,se(this,Sc,typeof _.apiKey=="function"?_.apiKey:null),this.authToken=_.authToken??null,this.webhookKey=c,k)this._authState=k,!this._baseURLIsExplicit&&k.baseURL&&(this.baseURL=k.baseURL);else switch(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},g.type){case"apiKey":case"authToken":break;case"credentials":this._authState.provider=g.value,this._authState.tokenCache=this._makeTokenCache(g.value);break;case"config":{const E=i3(g.value,this._credentialResolverOptions());this._authState.provider=E.provider,this._authState.tokenCache=this._makeTokenCache(E.provider),this._authState.extraHeaders=E.extraHeaders,this._applyCredentialBaseURL(E.baseURL);break}case"profile":this._authState.resolution=this._resolveDefaultCredentials(g.value);break;case"defaultChain":this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials());break}}_shouldResolveDefaultCredentials(){return!0}_applyCredentialBaseURL(n){if(!n)return;const s=n.replace(/\/+$/,"");this._authState.baseURL=s,this._baseURLIsExplicit||(this.baseURL=s)}_credentialResolverOptions(){return{baseURL:this.baseURL,fetch:this._credentialsFetch(),userAgent:this.getUserAgent(),onCacheWriteError:n=>{it(this).debug("credential cache write failed (best-effort)",n)},onSafetyWarning:n=>{it(this).warn(n)}}}_credentialsFetch(){return F5(this.fetch,this.middleware,void 0,this)}_makeTokenCache(n){return new L$(n,s=>{it(this).debug("advisory token refresh failed; serving cached token",s)})}withOptions(n){n={...n};for(const d of ic)n[d]===void 0&&delete n[d];const s=ic.some(d=>d in n),i=ic.some(d=>n[d]!=null),c={...this._options,...this._baseURLIsExplicit?{baseURL:this.baseURL}:{},maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,middleware:this.middleware,apiKey:this.apiKey??v(this,Sc,"f"),authToken:this.authToken,webhookKey:this.webhookKey,...i?Object.fromEntries(ic.map(d=>[d,null])):{},...n,openTelemetry:n.openTelemetry??v(this,Uo,"f"),__auth:s?void 0:this._authState,__baseURLIsExplicit:"baseURL"in n?!0:this._baseURLIsExplicit};return new this.constructor(c)}async _resolveDefaultCredentials(n){try{const s=await Y$(this._credentialResolverOptions(),n);if(s)this._authState.provider=s.provider,this._authState.tokenCache=this._makeTokenCache(s.provider),this._authState.extraHeaders=s.extraHeaders,this._applyCredentialBaseURL(s.baseURL);else if(n!=null)throw new De(`Profile "${n}" could not be resolved (no <config_dir>/configs/${n}.json found).`)}catch(s){this._authState.error=s}finally{this._authState.resolution=null}}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:n,nulls:s}){if(!(n.get("x-api-key")||n.get("authorization"))){if(this._authState.error)throw this._authState.error;if(!(this._authState.tokenCache||this._authState.resolution)&&!(this.apiKey&&n.get("authorization"))&&!s.has("authorization")&&!(this.authToken&&n.get("authorization"))&&!s.has("authorization"))throw new Error('Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for the "Authorization" header to be explicitly omitted')}}_authFlags(n){let s=this._requestAuthFlags.get(n);return s||(s={usedTokenCache:!1,didRefreshFor401:!1},this._requestAuthFlags.set(n,s)),s}async authHeaders(n){if(this._authState.resolution&&await this._authState.resolution,!this._authState.error){if(v(this,Sc,"f")&&this.apiKey==null){let s;try{s=await v(this,Sc,"f").call(this)}catch(i){throw new De(`The \`apiKey\` function failed: ${Yd(i).message}`,{cause:i})}if(!s)throw new De(`The \`apiKey\` function must return a non-empty string. It returned ${JSON.stringify(s)}.`);return L([{Authorization:`Bearer ${s}`}])}if(this._authState.tokenCache&&this.apiKey==null){const s=await this._authState.tokenCache.getToken();return this._authFlags(n).usedTokenCache=!0,L([{Authorization:`Bearer ${s}`}])}return L([await this.bearerAuth(n),await this.apiKeyAuth(n)])}}async apiKeyAuth(n){if(this.apiKey!=null)return L([{Authorization:`Bearer ${this.apiKey}`}])}async bearerAuth(n){if(this.authToken!=null)return L([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(n){return vP(n)}getUserAgent(){return`Anthropic/JS ${Pr}`}makeStatusError(n,s,i,c){const f=(s??{}).error?.details?.error_code,p=typeof f=="string"?R$.get(`${n} ${f}`):void 0;return p?new p(n,s,i,c):Gt.generate(n,s,i,c)}buildURL(n,s,i){const c=!v(this,gx,"m",Y5).call(this)&&i||this.baseURL,d=Lz(n)?new URL(n):new URL(c+(c.endsWith("/")&&n.startsWith("/")?n.slice(1):n)),f=this.defaultQuery(),p=Object.fromEntries(d.searchParams);return(!fk(f)||!fk(p))&&(s={...p,...f,...s}),typeof s=="object"&&s&&!Array.isArray(s)&&(d.search=this.stringifyQuery(s)),d.toString()}_calculateNonstreamingTimeout(n){if(3600*n/128e3>600)throw new De("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(n){}async prepareRequest(n,{url:s,options:i}){if(this._authState.tokenCache&&this.apiKey==null){const c=n.headers instanceof Headers?n.headers:new Headers(n.headers);for(const[f,p]of Object.entries(this._authState.extraHeaders))c.has(f)||c.set(f,p);const d=c.get("anthropic-beta")?.split(",").map(f=>f.trim());d?.includes(Cp)||c.set("anthropic-beta",[...d??[],Cp].join(",")),n.headers=c}}backendMiddleware(){return[]}get(n,s){return this.methodRequest("get",n,s)}post(n,s){return this.methodRequest("post",n,s)}patch(n,s){return this.methodRequest("patch",n,s)}put(n,s){return this.methodRequest("put",n,s)}delete(n,s){return this.methodRequest("delete",n,s)}methodRequest(n,s,i){return this.request(Promise.resolve(i).then(c=>({method:n,path:s,...c})))}request(n,s=null){return this._tracer?new ch(this,this.makeTracedRequest(n,s)):new ch(this,this.makeRequest(n,s,void 0))}async makeTracedRequest(n,s){const i=await n,c=i.__span?.span;if(!c)return this.makeRequest(i,s,void 0);try{return await Hs.with(ll.setSpan(Hs.active(),c),()=>this.makeRequest(i,s,void 0,c))}catch(d){const f={status:"error",options:i,error:d};throw zt(this,()=>Xd(c,f)),d}}async makeRequest(n,s,i,c){const d=await n;let f=zb("maxRetries",d.maxRetries??this.maxRetries);this.isStreamBody(d.body)&&(f=0),s==null&&(s=f,this._requestAuthFlags.delete(d)),await this.prepareOptions(d);const{req:p,url:b,timeout:x}=await this.buildRequest(d,{retryCount:f-s}),g="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),_=i===void 0?"":`, retryOf: ${i}`;c&&this.openTelemetry.propagation&&(p.headers=zt(this,()=>uP(c,p.headers))??p.headers);const y=Date.now();if(d.signal?.aborted)throw new Ls;const S=new AbortController,k=await this.fetchWithTimeout(b,p,x,S,d,{requestLogID:g,retryOfRequestLogID:i}).catch(Yd),E=Date.now();if(k instanceof globalThis.Error){Yo(S);const q=`retrying, ${s} attempts remaining`;if(d.signal?.aborted)throw new Ls;const z=Jo(k)||/timed? ?out/i.test(String(k)+("cause"in k?String(k.cause):"")),O=this.middleware.length>0||!!d.middleware?.length||this.backendMiddleware().length>0;if(O&&!z&&!J$(k))throw it(this).info(`[${g}] middleware error (not retryable)`),$i(it(this),`[${g}] middleware error (not retryable)`,{retryOfRequestLogID:i,url:b,durationMs:E-y,message:k.message}),k;if(s)return it(this).info(`[${g}] connection ${z?"timed out":"failed"} - ${q}`),$i(it(this),`[${g}] connection ${z?"timed out":"failed"} (${q})`,{retryOfRequestLogID:i,url:b,durationMs:E-y,message:k.message}),this.retryRequest(d,s,i??g,c);throw it(this).info(`[${g}] connection ${z?"timed out":"failed"} - error; no more retries left`),$i(it(this),`[${g}] connection ${z?"timed out":"failed"} (error; no more retries left)`,{retryOfRequestLogID:i,url:b,durationMs:E-y,message:k.message}),z?new Dx:O&&!l3(k)?k:new Hc({cause:k})}const T=[...k.headers.entries()].filter(([q])=>q==="request-id"||q==="anthropic-workspace-id").map(([q,z])=>", "+q+": "+JSON.stringify(z)).join(""),j=`[${g}${_}${T}] ${p.method} ${b} ${k.ok?"succeeded":"failed"} with status ${k.status} in ${E-y}ms`;if(!k.ok){const q=await this.shouldRetry(k,d);if(s&&q){const H=`retrying, ${s} attempts remaining`;return await Qz(k.body),Yo(S),it(this).info(`${j} - ${H}`),$i(it(this),`[${g}] response error (${H})`,{retryOfRequestLogID:i,url:k.url,status:k.status,headers:k.headers,durationMs:E-y}),this.retryRequest(d,s,i??g,c,k.headers)}const z=q?"error; no more retries left":"error; not retryable";it(this).info(`${j} - ${z}`);const O=await k.text().catch(H=>Yd(H).message),V=yj(O),P=V?void 0:O;throw $i(it(this),`[${g}] response error (${z})`,{retryOfRequestLogID:i,url:k.url,status:k.status,headers:k.headers,body:V??O,durationMs:Date.now()-y}),Yo(S),this.makeStatusError(k.status,V,P,k.headers)}return it(this).info(j),$i(it(this),`[${g}] response start`,{retryOfRequestLogID:i,url:k.url,status:k.status,headers:k.headers,durationMs:E-y}),Yz(k.body??k,S),{response:k,options:d,controller:S,requestLogID:g,retryOfRequestLogID:i,startTime:y}}getAPIList(n,s,i){return this.requestAPIList(s,i&&"then"in i?i.then(c=>({method:"get",path:n,...c})):{method:"get",path:n,...i})}requestAPIList(n,s){if(!this._tracer){const c=this.makeRequest(s,null,void 0);return new zk(this,c,n)}const i=this.makeTracedRequest(s,null);return new zk(this,i,n)}async fetchWithTimeout(n,s,i,c,d,f){const{signal:p,method:b,...x}=s||{},g=this._makeAbort(c);p&&(p.addEventListener("abort",g,{once:!0}),Kz(c,p,g));const _=globalThis.ReadableStream&&x.body instanceof globalThis.ReadableStream||typeof x.body=="object"&&x.body!==null&&Symbol.asyncIterator in x.body,y={signal:c.signal,..._?{duplex:"half"}:{},method:"GET",...x};b&&(y.method=b.toUpperCase());const S=this.fetch,k=async(z,O)=>{const V=setTimeout(g,i);try{return await S.call(void 0,z,O)}finally{clearTimeout(V)}},E=d===void 0?k:(async(z,O={})=>{const V=typeof z=="string"?z:z instanceof URL?z.href:z.url;O.headers=O.headers instanceof Headers?O.headers:new Headers(O.headers);let P=[];d.__span&&(O.headers=new Headers(O.headers),P=aT(O.headers)),await this.prepareRequest(O,{url:V,options:d}),P.length&&(O.headers=L([O.headers,P]).values);const $=d.__span;return $&&zt(this,()=>oP($,O.method??"GET",V,this.openTelemetry.traces.contentMode==="content")),f&&$i(it(this),`[${f.requestLogID}] sending request`,{retryOfRequestLogID:f.retryOfRequestLogID,method:O.method,url:V,options:d,headers:O.headers}),k(z,O)}),T=d?.middleware,j=d?.__span?this.backendMiddleware().map(YP):this.backendMiddleware(),q=T?.length||j.length?[...this.middleware,...T??[],...j]:this.middleware;return await F5(E,q,d,this)(n,y)}async shouldRetry(n,s){const i=this._authFlags(s);if(n.status===401&&this._authState.tokenCache&&i.usedTokenCache&&!i.didRefreshFor401)return i.didRefreshFor401=!0,this._authState.tokenCache.invalidate(),!0;const c=n.headers.get("x-should-retry");return c==="true"?!0:c==="false"?!1:n.status===408||n.status===409||n.status===429||n.status>=500}async retryRequest(n,s,i,c,d){let f;const p=d?.get("retry-after-ms");if(p){const x=parseFloat(p);Number.isNaN(x)||(f=x)}const b=d?.get("retry-after");if(b&&!f){const x=parseFloat(b);Number.isNaN(x)?f=Date.parse(b)-Date.now():f=x*1e3}if(f===void 0||!(f>0&&f<=2**31-1)){const x=n.maxRetries??this.maxRetries;f=this.calculateDefaultRetryTimeoutMillis(s,x)}return await Ko(f,n.signal??void 0),this.makeRequest(n,s-1,i,c)}calculateDefaultRetryTimeoutMillis(n,s){const d=s-n,f=Math.min(.5*Math.pow(2,d),8),p=1-Math.random()*.25;return f*p*1e3}calculateNonstreamingTimeout(n,s){if(36e5*n/128e3>6e5||s!=null&&n>s)throw new De("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#long-requests for more details");return 6e5}async buildRequest(n,{retryCount:s=0}={}){const i={...n},{method:c,path:d,query:f,defaultBaseURL:p}=i;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);const b=this.buildURL(d,f,p);"timeout"in i&&zb("timeout",i.timeout),i.timeout=i.timeout??this.timeout;const{bodyHeaders:x,body:g}=this.buildBody({options:i}),_=await this.buildHeaders({options:n,method:c,bodyHeaders:x,retryCount:s,timeout:i.timeout});return{req:{method:c,headers:_,...i.signal&&{signal:i.signal},...globalThis.ReadableStream&&g instanceof globalThis.ReadableStream&&{duplex:"half"},...g&&{body:g},...this.fetchOptions??{},...i.fetchOptions??{}},url:b,timeout:i.timeout}}async buildHeaders({options:n,method:s,bodyHeaders:i,retryCount:c,timeout:d}){const f=L([{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(c),"X-Stainless-Timeout":String(Math.trunc(d/1e3)),...Uy(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2026-10-21"},await this.authHeaders(n),this._options.defaultHeaders,i,n.headers]);return this.validateHeaders(f),f.values}_makeAbort(n){return()=>n.abort()}buildBody({options:{body:n,headers:s}}){if(!n)return{bodyHeaders:void 0,body:void 0};const i=L([s]);return ArrayBuffer.isView(n)||n instanceof ArrayBuffer||n instanceof DataView||typeof n=="string"&&i.values.has("content-type")||globalThis.Blob&&n instanceof globalThis.Blob||n instanceof FormData||n instanceof URLSearchParams||globalThis.ReadableStream&&n instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:n}:this.isStreamBody(n)?{bodyHeaders:void 0,body:wj(n)}:typeof n=="object"&&i.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(n)}:v(this,Ff,"f").call(this,{body:n,headers:i})}isStreamBody(n){return globalThis.ReadableStream&&n instanceof globalThis.ReadableStream?!0:typeof n=="object"&&n!==null&&(Symbol.asyncIterator in n||Symbol.iterator in n&&"next"in n&&typeof n.next=="function")}}return bx=e,Ff=new WeakMap,Sc=new WeakMap,Uo=new WeakMap,gx=new WeakSet,Y5=function(){return this.baseURL!=="https://api.anthropic.com"},e.Anthropic=bx,e.DEFAULT_TIMEOUT=6e5,e.AnthropicError=De,e.APIError=Gt,e.APIConnectionError=Hc,e.APIConnectionTimeoutError=Dx,e.APIUserAbortError=Ls,e.NotFoundError=Zc,e.ConflictError=Vr,e.RateLimitError=Hp,e.BadRequestError=Ye,e.OverloadedError=Ly,e.AuthenticationError=hj,e.RequestTimeoutError=mj,e.InternalServerError=eu,e.NotImplementedError=bj,e.GatewayTimeoutError=xj,e.ContentTooLargeError=qy,e.PermissionDeniedError=vs,e.PreconditionFailedError=Dy,e.ServiceUnavailableError=_h,e.UnprocessableEntityError=fj,e.ClientClosedRequestError=gj,e.RequestHeaderFieldsTooLargeError=pj,e.toFile=sI,e})(),aa=(()=>{class e extends rI{constructor(){super(...arguments),this._supportsMessageThreads=!0,this.messages=new s5(this),this.models=new K5(this),this.files=new Pk(this),this.skills=new L5(this),this.userProfiles=new B5(this),this.organization=new D5(this),this.beta=new JN(this)}}return e.Messages=s5,e.AvailableToolsLimitExceededError=U_,e.CompactionBlockAmbiguousError=B_,e.CompactionBlockMisplacedError=G_,e.CompactionContentMismatchError=H_,e.CompactionIncompleteTurnError=F_,e.CompactionNothingToSummarizeError=V_,e.CompactionSignatureInvalidError=K_,e.CompactionTooManyToolReferencesError=Y_,e.CompactionToolChangesMismatchError=W_,e.ThreadAlreadyContinuedError=X_,e.ThreadContinueInFlightError=Q_,e.ThreadFingerprintMismatchError=J_,e.ThreadUnsupportedRequestError=Z_,e.ToolNameConflictError=ev,e.ToolReferenceUnresolvedError=tv,e.ThreadNotFoundError=nv,e.CompactionUnavailableError=sv,e.Models=K5,e.Files=Pk,e.FileNotDownloadableError=r_,e.StorageQuotaExceededError=i_,e.FileExpiredError=o_,e.Skills=L5,e.SkillReadBlockedUndecryptableError=wv,e.UserProfiles=B5,e.UserProfileNotFoundError=Sv,e.Organization=D5,e.OrgMemberLimitExceededError=_v,e.ConcurrentMembershipChangeError=vv,e.Beta=JN,e.BetaOrganizationNotEnrolledInBetaError=q_,e.BetaUnsupportedCharsetError=L_,e.ClaudeCodeKeyCreatorNotMemberError=hT,e.ClaudeCodeVersionTooOldError=mT,e.CMEKKeyDisabledError=fT,e.CMEKKeyNetworkBlockedError=pT,e.OrganizationOnHoldError=gT,e.OrganizationTypeNotSupportedError=bT,e.RequestBodyEncodingInvalidError=xT,e.RequestBodyEncodingUnsupportedError=yT,e.SandboxEgressRestrictedError=_T,e.RequestBodyTooLargeAfterDecodingError=vT,e.EnforcedSpendLimitReachedError=wT,e.RampLimitExceededError=ST,e.CMEKContextUnavailableError=kT,e.CMEKKeyUnreachableError=CT,e})();const Cn="RESEARCH USE ONLY (RUO). Not intended for clinical diagnosis, treatment selection, medical device use, or patient management.",iI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function Ee(e){return(e==null?"":String(e)).replace(/[&<>"'/]/g,n=>iI[n]??n)}function u3(e){return e?/^data:image\/png;base64,[A-Za-z0-9+/=]+$/.test(e.trim()):!1}function oI(e){const r={schemaVersion:"1.0.0",reportKind:"synlexa-studio-ruo-manifest",ruoDisclaimer:Cn,generatedAtUtc:e.generatedAtUtc??new Date().toISOString(),comparison:e.comparison,peptideEngineering:e.peptide??null,geneCrispr:e.crispr??null,smallMolecule:e.smiles??null,hasEmbeddedViewportFigure:u3(e.viewportPngDataUrl)};return JSON.stringify(r,null,2)}function lI(e){const{comparison:r,peptide:n,crispr:s,smiles:i,viewportPngDataUrl:c}=e,d=e.generatedAtUtc??new Date().toISOString(),f=u3(c)?c.trim():null,p=r.transform.matrixRowMajor4x4.map(S=>`<td>${Ee(S.toFixed(6))}</td>`).reduce((S,k,E)=>{const T=Math.floor(E/4);return S[T]||(S[T]=[]),S[T].push(k),S},[]).map(S=>`<tr>${S.join("")}</tr>`).join(`
536
+ `),b=[...r.matchedResidues].sort((S,k)=>k.distanceAngstrom-S.distanceAngstrom).slice(0,12).map(S=>`<tr>
537
+ <td>${Ee(S.refSeqId)}${Ee(S.refInsCode)}</td>
538
+ <td>${Ee(S.resName3)} (${Ee(S.resCode1)})</td>
539
+ <td>${Ee(S.mobSeqId)}</td>
540
+ <td>${Ee(S.distanceAngstrom.toFixed(3))} &Aring;</td>
541
+ <td>${S.refBFactor!=null?Ee(S.refBFactor.toFixed(2)):"n/a"}</td>
542
+ <td>${S.mobPlddt!=null?Ee(S.mobPlddt.toFixed(2)):"n/a"}</td>
543
+ </tr>`).join(`
544
+ `),x=r.refContacts&&r.refContacts.length>0?`<table>
545
+ <thead><tr><th>Ligand</th><th>Ligand Atom</th><th>Residue</th><th>Protein Atom</th><th>Distance (&Aring;)</th></tr></thead>
546
+ <tbody>
547
+ ${r.refContacts.slice(0,24).map(S=>`<tr>
548
+ <td>${Ee(S.ligandResName)} ${Ee(S.ligandChainId)}:${Ee(S.ligandSeqId)}</td>
549
+ <td>${Ee(S.ligandAtom)}</td>
550
+ <td>${Ee(S.proteinResName3)} ${Ee(S.proteinSeqId)}</td>
551
+ <td>${Ee(S.proteinAtom)}</td>
552
+ <td>${Ee(S.distanceAngstrom.toFixed(3))}</td>
553
+ </tr>`).join(`
554
+ `)}
555
+ </tbody>
556
+ </table>`:'<p class="muted">No non-water ligand contacts recorded within 4.5 &Aring;.</p>',g=n?`<section class="card">
557
+ <h2>Peptide &amp; Protein Engineering Summary</h2>
558
+ <p class="muted">Applied mutations: ${n.appliedMutations.length>0?n.appliedMutations.map(S=>Ee(S.notation)).join(", "):"Wild-type (no mutations)"}</p>
559
+ <table>
560
+ <thead><tr><th>Descriptor</th><th>Wild-Type</th><th>Engineered</th><th>Delta</th></tr></thead>
561
+ <tbody>
562
+ <tr><td>Length</td><td>${Ee(n.wildType.length)} aa</td><td>${Ee(n.engineered.length)} aa</td><td>${Ee(n.engineered.length-n.wildType.length)}</td></tr>
563
+ <tr><td>Avg MW (Da)</td><td>${Ee(n.wildType.mwAverageDa.toFixed(2))}</td><td>${Ee(n.engineered.mwAverageDa.toFixed(2))}</td><td>${Ee(n.deltas.mwAverageDa.toFixed(2))}</td></tr>
564
+ <tr><td>Isoelectric Point (pI)</td><td>${Ee(n.wildType.pi.toFixed(2))}</td><td>${Ee(n.engineered.pi.toFixed(2))}</td><td>${Ee(n.deltas.pi.toFixed(3))}</td></tr>
565
+ <tr><td>Charge at pH 7.4</td><td>${Ee(n.wildType.chargeAtPh74.toFixed(2))}</td><td>${Ee(n.engineered.chargeAtPh74.toFixed(2))}</td><td>${Ee(n.deltas.chargeAtPh74.toFixed(2))}</td></tr>
566
+ <tr><td>GRAVY</td><td>${Ee(n.wildType.gravy.toFixed(3))}</td><td>${Ee(n.engineered.gravy.toFixed(3))}</td><td>${Ee(n.deltas.gravy.toFixed(3))}</td></tr>
567
+ <tr><td>Steric Volume Delta</td><td>&mdash;</td><td>&mdash;</td><td>${Ee(n.deltas.stericVolumeDeltaA3.toFixed(1))} &Aring;&sup3;</td></tr>
568
+ </tbody>
569
+ </table>
570
+ </section>`:"",_=s?`<section class="card">
571
+ <h2>Gene Editing &amp; CRISPR Target Summary</h2>
572
+ <p><strong>Transcript:</strong> ${Ee(s.transcriptId)} (${Ee(s.geneSymbol)}, ${Ee(s.assembly)}) &middot; ${Ee(s.cdsLengthBp)} bp / ${Ee(s.proteinLengthAa)} aa</p>
573
+ <p><strong>Codon ${Ee(s.targetCodon.codonIndex1)}:</strong> ${Ee(s.targetCodon.wtCodon)} (${Ee(s.targetCodon.wtAa)}) &rarr; ${Ee(s.targetCodon.editedCodon)} (${Ee(s.targetCodon.editedAa)}) [<strong>${Ee(s.targetCodon.consequence)}</strong>]</p>
574
+ <p class="muted">Candidate PAM sites within window: ${Ee(s.pamSites.length)}</p>
575
+ </section>`:"",y=i?`<section class="card">
576
+ <h2>Small-Molecule Chemistry Summary</h2>
577
+ <p><strong>Name:</strong> ${Ee(i.name)} &middot; <strong>SMILES:</strong> <code>${Ee(i.smiles)}</code></p>
578
+ <p><strong>Formula:</strong> ${Ee(i.formula)} &middot; <strong>MW:</strong> ${Ee(i.molecularWeight.toFixed(2))} Da &middot; <strong>TPSA:</strong> ${Ee(i.tpsa.toFixed(2))} &Aring;&sup2; &middot; <strong>cLogP:</strong> ${Ee(i.crippenLogP.toFixed(2))}</p>
579
+ <p><strong>HBD/HBA:</strong> ${Ee(i.hbd)} / ${Ee(i.hba)} &middot; <strong>Lipinski Violations:</strong> ${Ee(i.lipinskiViolations)} &middot; <strong>Veber Compliant:</strong> ${i.veberCompliant?"Yes":"No"}</p>
580
+ </section>`:"";return`<!doctype html>
581
+ <html lang="en">
582
+ <head>
583
+ <meta charset="utf-8" />
584
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
585
+ <title>Synlexa Studio RUO Report — ${Ee(r.reference.label)} vs ${Ee(r.mobile.label)}</title>
586
+ <style>
587
+ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #090d14; color: #e2e8f0; margin: 0; padding: 32px; line-height: 1.5; }
588
+ .wrap { max-width: 980px; margin: 0 auto; }
589
+ .banner { background: #2c1d07; border: 1px solid #f59e0b; color: #fde68a; padding: 12px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; margin-bottom: 20px; }
590
+ h1 { font-size: 22px; margin: 0 0 6px; color: #f8fafc; }
591
+ h2 { font-size: 15px; margin: 0 0 10px; color: #67e8f9; text-transform: uppercase; letter-spacing: 0.04em; }
592
+ .muted { color: #94a3b8; font-size: 13px; }
593
+ .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }
594
+ .metric { background: #111827; border: 1px solid #1e293b; border-radius: 8px; padding: 12px; }
595
+ .metric .label { font-size: 11px; color: #94a3b8; text-transform: uppercase; }
596
+ .metric .val { font-size: 20px; font-weight: 700; font-family: ui-monospace, monospace; color: #f8fafc; margin-top: 4px; }
597
+ .card { background: #0f1623; border: 1px solid #1e293b; border-radius: 8px; padding: 16px; margin-top: 16px; }
598
+ table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
599
+ th, td { border-bottom: 1px solid #1e293b; text-align: left; padding: 6px 8px; font-family: ui-monospace, monospace; }
600
+ th { color: #94a3b8; font-weight: 600; }
601
+ code { background: #1e293b; padding: 2px 5px; border-radius: 4px; font-size: 12px; word-break: break-all; }
602
+ img.figure { max-width: 100%; border-radius: 6px; border: 1px solid #1e293b; margin-top: 8px; }
603
+ </style>
604
+ </head>
605
+ <body>
606
+ <div class="wrap">
607
+ <div class="banner">${Ee(Cn)}</div>
608
+ <h1>Synlexa Studio Comparison Report</h1>
609
+ <p class="muted">Result ID: <code>${Ee(r.resultId)}</code> &middot; Engine: ${Ee(r.engine.name)} ${Ee(r.engine.version)} (${Ee(r.engine.target)}, ${Ee(r.engine.floatPrecision)}) &middot; Generated: ${Ee(d)}</p>
610
+
611
+ <div class="grid">
612
+ <div class="metric"><div class="label">C&alpha; RMSD</div><div class="val">${Ee(r.metrics.rmsdAngstrom.toFixed(4))} &Aring;</div></div>
613
+ <div class="metric"><div class="label">Matched C&alpha;</div><div class="val">${Ee(r.metrics.matchedCaCount)}</div></div>
614
+ <div class="metric"><div class="label">Ref Coverage</div><div class="val">${Ee(r.metrics.refCoverage.numerator)} / ${Ee(r.metrics.refCoverage.denominator)}</div><div class="muted">${Ee(r.metrics.refCoverage.denominatorKind)}</div></div>
615
+ <div class="metric"><div class="label">Mob Coverage</div><div class="val">${Ee(r.metrics.mobCoverage.numerator)} / ${Ee(r.metrics.mobCoverage.denominator)}</div><div class="muted">${Ee(r.metrics.mobCoverage.denominatorKind)}</div></div>
616
+ </div>
617
+
618
+ ${f?`<section class="card"><h2>3D Structural Superposition Figure</h2><img class="figure" src="${Ee(f)}" alt="3D Structural Superposition" /></section>`:""}
619
+
620
+ <section class="card">
621
+ <h2>Input Provenance &amp; SHA-256 Digests</h2>
622
+ <table>
623
+ <thead><tr><th>Role</th><th>Label</th><th>Chain</th><th>Confidence Metric</th><th>License</th><th>SHA-256</th></tr></thead>
624
+ <tbody>
625
+ <tr>
626
+ <td>Reference</td>
627
+ <td>${Ee(r.reference.label)}</td>
628
+ <td>${Ee(r.reference.chainId)}</td>
629
+ <td>${Ee(r.reference.confidenceKind)}</td>
630
+ <td>${Ee(r.reference.license??"user-supplied")}</td>
631
+ <td><code>${Ee(r.reference.sha256)}</code></td>
632
+ </tr>
633
+ <tr>
634
+ <td>Mobile</td>
635
+ <td>${Ee(r.mobile.label)}</td>
636
+ <td>${Ee(r.mobile.chainId)}</td>
637
+ <td>${Ee(r.mobile.confidenceKind)}</td>
638
+ <td>${Ee(r.mobile.license??"user-supplied")}</td>
639
+ <td><code>${Ee(r.mobile.sha256)}</code></td>
640
+ </tr>
641
+ </tbody>
642
+ </table>
643
+ </section>
644
+
645
+ <section class="card">
646
+ <h2>Rigid Transform Matrix (mobile_to_reference, row-major 4&times;4)</h2>
647
+ <table><tbody>${p}</tbody></table>
648
+ </section>
649
+
650
+ <section class="card">
651
+ <h2>Active-Site &amp; Ligand Pocket Contacts (&le; 4.5 &Aring;)</h2>
652
+ ${x}
653
+ </section>
654
+
655
+ <section class="card">
656
+ <h2>Highest Per-Residue C&alpha; Deviations (Top 12)</h2>
657
+ <table>
658
+ <thead><tr><th>Ref Seq</th><th>Residue</th><th>Mob Seq</th><th>&Delta;d</th><th>Ref B-Factor (&Aring;&sup2;)</th><th>Mob pLDDT</th></tr></thead>
659
+ <tbody>${b}</tbody>
660
+ </table>
661
+ </section>
662
+
663
+ ${g}
664
+ ${_}
665
+ ${y}
666
+ </div>
667
+ </body>
668
+ </html>`}function d3(e,r){const n=e.trim(),s=n.toLowerCase(),i=new Date().toISOString(),c=()=>`msg-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;if(s==="list_artifacts"||s.includes("list artifacts")||s==="artifacts"){const x=r.comparison?.reference.sha256??r.refInspect?.sha256??"unloaded",g=r.comparison?.mobile.sha256??r.mobInspect?.sha256??"unloaded",_=["Active Artifacts (RUO):",`• Reference: ${r.refLabel} | chain=${r.comparison?.reference.chainId??r.refInspect?.chains[0]?.chainId??"?"} | sha256=${x.slice(0,12)}… | metric=${r.comparison?.reference.confidenceKind??r.refInspect?.confidenceKind??"none"}`,`• Mobile: ${r.mobLabel} | chain=${r.comparison?.mobile.chainId??r.mobInspect?.chains[0]?.chainId??"?"} | sha256=${g.slice(0,12)}… | metric=${r.comparison?.mobile.confidenceKind??r.mobInspect?.confidenceKind??"none"}`];return r.smiles&&_.push(`• Ligand SMILES: ${r.smiles.name} (${r.smiles.formula}, MW ${r.smiles.molecularWeight.toFixed(2)} Da)`),r.crispr&&_.push(`• Transcript: ${r.crispr.transcriptId} (${r.crispr.geneSymbol}, ${r.crispr.cdsLengthBp} bp)`),{actions:[],reply:{id:c(),role:"assistant",command:"list_artifacts",text:_.join(`
669
+ `),citations:[`ref:sha256:${x}`,`mob:sha256:${g}`],actionTaken:"Listed active verified artifacts",timestampUtc:i}}}const d=n.match(/^(?:focus_residues|focus)\s+([0-9,\s]+)/i);if(d){const x=d[1].split(/[,\s]+/).map(_=>Number.parseInt(_,10)).filter(_=>Number.isFinite(_)&&_>0);if(x.length===0)return{actions:[],reply:{id:c(),role:"assistant",command:"focus_residues",text:"Provide one or more positive residue sequence IDs, e.g. `focus_residues 94, 96, 119`.",timestampUtc:i}};const g=x.map(_=>{const y=r.comparison?.matchedResidues.find(S=>S.refSeqId===_);return y?`${y.resName3}${y.refSeqId}: Δd=${y.distanceAngstrom.toFixed(3)} Å, B=${y.refBFactor!=null?y.refBFactor.toFixed(2):"n/a"} Ų, pLDDT=${y.mobPlddt!=null?y.mobPlddt.toFixed(1):"n/a"}`:`res ${_}: not in matched Cα set`});return{actions:[{type:"focus_residues",seqIds:x}],reply:{id:c(),role:"assistant",command:"focus_residues",text:`Focused residue(s) ${x.join(", ")} in 3D, Sequence, and PAE views.
670
+ ${g.join(`
671
+ `)}`,citations:r.comparison?[`resultId:${r.comparison.resultId}`]:[],actionTaken:`focus_residues(${x.join(",")})`,timestampUtc:i}}}if(s==="compare_structures"||s==="compare")return{actions:[{type:"compare_structures"}],reply:{id:c(),role:"assistant",command:"compare_structures",text:`Dispatched Kabsch float64 superposition on ${r.refLabel} vs ${r.mobLabel}.`,actionTaken:"compare_structures()",timestampUtc:i}};if(s.startsWith("request_report")||s.includes("export report")){const x=s.includes("json")?"json":"html";return{actions:[{type:"request_report",format:x}],reply:{id:c(),role:"assistant",command:"request_report",text:`Prepared self-contained RUO ${x.toUpperCase()} report from verified engine output (${r.comparison?.resultId??"no active run"}).`,citations:r.comparison?[`resultId:${r.comparison.resultId}`]:[],actionTaken:`request_report(${x})`,timestampUtc:i}}}const f=n.match(/^(?:mutate|peptide)\s+([ACDEFGHIKLMNPQRSTVWY]\d+[ACDEFGHIKLMNPQRSTVWY])/i);if(f){const x=f[1].toUpperCase();return{actions:[{type:"switch_tab",tab:"peptide"},{type:"apply_peptide_mutation",notation:x}],reply:{id:c(),role:"assistant",command:"analyze_peptide",text:`Applying point mutation ${x} in Peptide & Protein Engineering workbench (Wasm recalculation queued).`,actionTaken:`apply_peptide_mutation(${x})`,timestampUtc:i}}}const p=n.match(/^smiles\s+(\S+)(?:\s+(.+))?$/i);if(p){const x=p[1],g=p[2]?.trim();return{actions:[{type:"switch_tab",tab:"chemistry"},{type:"analyze_smiles",smiles:x,name:g}],reply:{id:c(),role:"assistant",command:"analyze_molecule_smiles",text:`Queued deterministic Wasm SMILES graph & descriptor evaluation for \`${x}\`.`,actionTaken:`analyze_smiles(${x})`,timestampUtc:i}}}const b=n.match(/^crispr(?:\s+codon)?\s+(\d+)$/i);if(b){const x=Number.parseInt(b[1],10);return{actions:[{type:"switch_tab",tab:"crispr"},{type:"focus_crispr_codon",codonIndex:x}],reply:{id:c(),role:"assistant",command:"analyze_gene_crispr",text:`Focused coding transcript codon #${x} and scanned PAM sites.`,actionTaken:`focus_crispr_codon(${x})`,timestampUtc:i}}}if(s.includes("deviat")||s.includes("outlier")||s.includes("ramachandran")||s.includes("contact")){const x=[],g=[];if(r.comparison&&(s.includes("deviat")||!s.includes("ramachandran"))){const _=[...r.comparison.matchedResidues].sort((y,S)=>S.distanceAngstrom-y.distanceAngstrom).slice(0,5);x.push(`Top deviating Cα residues (${r.refLabel} vs ${r.mobLabel}):
672
+ `+_.map(y=>`• ${y.resName3}${y.refSeqId}: Δd=${y.distanceAngstrom.toFixed(3)} Å (B=${y.refBFactor?.toFixed(1)??"n/a"}, pLDDT=${y.mobPlddt?.toFixed(1)??"n/a"})`).join(`
673
+ `)),_[0]&&g.push({type:"focus_residues",seqIds:[_[0].refSeqId]})}if(r.comparison?.refContacts?.length&&s.includes("contact")){const _=[...r.comparison.refContacts].sort((y,S)=>y.distanceAngstrom-S.distanceAngstrom).slice(0,6);x.push(`Active-site contacts (≤ 4.5 Å, ${r.comparison.refContacts.length} total):
674
+ `+_.map(y=>`• ${y.ligandResName}.${y.ligandAtom} ↔ ${y.proteinResName3}${y.proteinSeqId}.${y.proteinAtom}: ${y.distanceAngstrom.toFixed(2)} Å`).join(`
675
+ `))}if(r.ramachandran&&s.includes("ramachandran")){const _=r.ramachandran,y=_.residues.filter(S=>S.region==="outlier").slice(0,6);x.push(`Ramachandran geometry (${_.chainId}, ${_.residueCount} residues): Favored ${_.regionCounts.favored}, Allowed ${_.regionCounts.allowed}, Outliers ${_.regionCounts.outlier}.`+(y.length?`
676
+ Outlier residues: ${y.map(S=>`${S.resName3}${S.seqId} (φ=${S.phiDeg?.toFixed(1)??"n/a"}°, ψ=${S.psiDeg?.toFixed(1)??"n/a"}°)`).join(", ")}`:"")),g.push({type:"switch_tab",tab:"ramachandran"})}if(x.length>0)return{actions:g,reply:{id:c(),role:"assistant",command:"get_workspace_state",text:`${x.join(`
677
+
678
+ `)}
679
+
680
+ _${Cn}_`,citations:r.comparison?[`resultId:${r.comparison.resultId}`]:[],actionTaken:"Inspected deterministic workspace telemetry",timestampUtc:i}}}if(s.includes("mcp"))return{actions:[{type:"switch_tab",tab:"mcp"}],reply:{id:c(),role:"assistant",command:"open_mcp_server",text:`Opened the In-App MCP Server panel. Studio exposes 11 JSON-RPC 2.0 tools, 8 live workspace resources, and 4 prompts for both the internal AI Assistant and external clients (Claude Desktop, Claude Code, OpenAI Codex CLI, Cursor). ${Cn}`,actionTaken:"Opened MCP Server workbench",timestampUtc:i}};if(s==="explain_result"||s.includes("explain")||s.includes("summary")||s.includes("metric")){if(!r.comparison)return{actions:[],reply:{id:c(),role:"assistant",command:"explain_result",text:"No active structural comparison result yet. Run `compare_structures` first.",timestampUtc:i}};const x=r.comparison,g=x.matchedResidues.reduce((y,S)=>S.distanceAngstrom>y.distanceAngstrom?S:y,x.matchedResidues[0]),_=x.refContacts?.length??0;return{actions:[],reply:{id:c(),role:"assistant",command:"explain_result",text:[`Verified Comparison Summary (${Cn}):`,`• Cα RMSD: ${x.metrics.rmsdAngstrom.toFixed(4)} Å across ${x.metrics.matchedCaCount} matched Cα residues (${x.engine.target}, ${x.engine.floatPrecision}).`,`• Reference Coverage: ${x.metrics.refCoverage.numerator}/${x.metrics.refCoverage.denominator} (${(x.metrics.refCoverage.ratio*100).toFixed(1)}%, ${x.metrics.refCoverage.denominatorKind}).`,`• Mobile Coverage: ${x.metrics.mobCoverage.numerator}/${x.metrics.mobCoverage.denominator} (${(x.metrics.mobCoverage.ratio*100).toFixed(1)}%, ${x.metrics.mobCoverage.denominatorKind}).`,`• Peak Residue Δd: ${g?`${g.resName3}${g.refSeqId} (${g.distanceAngstrom.toFixed(3)} Å)`:"n/a"} · PAE status: ${x.metrics.paeStatus}.`,`• Active-site ligand/metal contacts (≤4.5 Å): ${_} atom contacts recorded.`,`• Confidence Separation: Reference uses ${x.reference.confidenceKind} (Ų); Mobile uses ${x.mobile.confidenceKind}.`].join(`
681
+ `),citations:[`resultId:${x.resultId}`,`ref:sha256:${x.reference.sha256}`,`mob:sha256:${x.mobile.sha256}`],actionTaken:"explain_result()",timestampUtc:i}}}return{actions:[],reply:{id:c(),role:"assistant",text:["Available deterministic commands (RUO):","• `list_artifacts` — Show loaded structures, SHA-256 digests, and confidence types","• `focus_residues 94, 96, 119` — Highlight residue(s) across 3D, Sequence, and PAE","• `compare_structures` — Re-run float64 Kabsch alignment in Wasm worker","• `explain_result` — Summarize verified RMSD, coverage, contacts, and provenance","• `which residues deviate most` — Inspect top Cα deviations and active-site contacts","• `ramachandran outliers` — Check backbone φ/ψ geometry & outliers","• `mutate H94A` — Apply point mutation in Peptide Engineering tab","• `crispr codon 94` — Jump to coding codon & scan Cas9/Cas12a PAMs","• `smiles CC(=O)Nc1nnc(S(N)(=O)=O)s1` — Depict & analyze SMILES ligand","• `mcp` — Open the In-App MCP Server & external client setup","• `request_report html` or `request_report json` — Export RUO report"].join(`
682
+ `),timestampUtc:i}}}const h3="state.vscdb",cI=1,Us="ItemTable",Mc="VaultKeyStore",X5="synlexa.studio.master.aes256gcm",ny="secret://synlexa.studio.vault/",sy="secret://synlexa.studio.vault/custom/",m3={gemini:"synlexa.studio.gemini.apiKey",anthropic:"synlexa.studio.anthropic.apiKey",openai:"synlexa.studio.openai.apiKey"},Np=["anthropic","gemini","openai"],Gi=new Map,Dc=new Map,Ap=new Map,ay=new Set;let wa={initialized:!1,backend:"memory-fallback",dbName:h3,tableName:Us,dbPath:"IndexedDB://state.vscdb/ItemTable",encrypted:!0,cipher:"AES-256-GCM",storedProviders:[],entries:{},migratedLegacyCount:0},Vf=null,Kf=null;function Nv(){for(const e of ay)e()}function f3(e){return ay.add(e),()=>ay.delete(e)}function Zo(){return{...wa,storedProviders:Np.filter(e=>Gi.has(e)&&!!Gi.get(e)),entries:Object.fromEntries(Dc.entries())}}function xx(e){return Gi.get(e)??""}function uI(e){return Ap.get(e)??""}async function p3(e,r){const n=e.trim().replace(/[^a-zA-Z0-9._:-]/g,"_");if(!n)return;const s=r.trim(),i=new Date().toISOString();s?Ap.set(n,s):Ap.delete(n);const c=await Av();if(c){const d=await jv(c),f=`${sy}${n}`;if(s){const p=await g3(s,d),b=await jp(s),x={key:f,value:{v:1,alg:p.alg,iv:p.iv,ct:p.ct,fingerprint:b,updatedAtUtc:i}},g=c.transaction(Us,"readwrite");await el(g.objectStore(Us).put(x))}else{const p=c.transaction(Us,"readwrite");await el(p.objectStore(Us).delete(f))}}Nv()}function Yf(e){let r="";for(let n=0;n<e.length;n++)r+=String.fromCharCode(e[n]);return btoa(r)}function Q5(e){const r=atob(e),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return n}function Av(){return Kf||(Kf=new Promise(e=>{if(typeof indexedDB>"u")return e(null);try{const r=indexedDB.open(h3,cI);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(Us)||n.createObjectStore(Us,{keyPath:"key"}),n.objectStoreNames.contains(Mc)||n.createObjectStore(Mc,{keyPath:"id"})},r.onsuccess=()=>e(r.result),r.onerror=()=>e(null)}catch{e(null)}}),Kf)}function el(e){return new Promise((r,n)=>{e.onsuccess=()=>r(e.result),e.onerror=()=>n(e.error)})}async function jv(e){const r=globalThis.crypto?.subtle;if(!r)return null;try{const n=e.transaction(Mc,"readonly"),s=await el(n.objectStore(Mc).get(X5))??null;if(s?.key)return s.key;const i=await r.generateKey({name:"AES-GCM",length:256},!1,["encrypt","decrypt"]),c=e.transaction(Mc,"readwrite");return await el(c.objectStore(Mc).put({id:X5,key:i})),i}catch{return null}}async function g3(e,r){const n=new TextEncoder().encode(e);if(r&&globalThis.crypto?.subtle&&globalThis.crypto?.getRandomValues){const c=globalThis.crypto.getRandomValues(new Uint8Array(12)),d=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:c},r,n);return{alg:"AES-GCM-256",iv:Yf(c),ct:Yf(new Uint8Array(d))}}const s=new Uint8Array(12);globalThis.crypto?.getRandomValues?.(s);const i=new Uint8Array(n.length);for(let c=0;c<n.length;c++)i[c]=n[c]^s[c%s.length]^90;return{alg:"LOCAL-OBF-V1",iv:Yf(s),ct:Yf(i)}}async function J5(e,r){try{const n=Q5(e.iv),s=Q5(e.ct);if(e.alg==="AES-GCM-256"){if(!r||!globalThis.crypto?.subtle)return null;const c=await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:n},r,s);return new TextDecoder().decode(c)}const i=new Uint8Array(s.length);for(let c=0;c<s.length;c++)i[c]=s[c]^n[c%n.length]^90;return new TextDecoder().decode(i)}catch{return null}}async function jp(e){return(await Jc(`synlexa-vault-fp:${e}`)).slice(0,12)}function b3(){if(typeof window>"u")return!1;const e=window.location?.hostname??"";return e==="127.0.0.1"||e==="localhost"}async function dI(){if(!b3()||typeof fetch!="function")return{available:!1};try{const e=await fetch("/api/local-vault/keys",{method:"GET"});if(!e.ok)return{available:!1};if(!(e.headers.get("content-type")??"").includes("application/json"))return{available:!1};const n=await e.json();return n?.ok?{available:!0,dbPath:n.dbPath,keys:n.keys??{}}:{available:!1}}catch{return{available:!1}}}async function hI(e,r){if(!b3()||typeof fetch!="function")return null;try{const n=await fetch("/api/local-vault/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:e,apiKey:r})});if(!n.ok)return null;const s=await n.json();return s?.ok?s.dbPath??"~/.synlexa-studio/state.vscdb":null}catch{return null}}function mI(){const e=[];try{if(typeof localStorage>"u")return e;for(const r of Np){const n=m3[r],s=localStorage.getItem(n)?.trim();s&&(e.push({provider:r,key:s}),localStorage.removeItem(n))}}catch{}return e}async function cp(e,r){const n=r.trim(),s=new Date().toISOString();try{typeof localStorage<"u"&&localStorage.removeItem(m3[e])}catch{}if(!n)Gi.delete(e),Dc.delete(e);else{Gi.set(e,n);const f=await jp(n);Dc.set(e,{provider:e,fingerprint:f,updatedAtUtc:s,cipher:wa.cipher})}const i=await Av();if(i){const f=await jv(i),p=`${ny}${e}`;if(n){const b=await g3(n,f),x=Dc.get(e)?.fingerprint??await jp(n),g={key:p,value:{v:1,alg:b.alg,iv:b.iv,ct:b.ct,fingerprint:x,updatedAtUtc:s}},_=i.transaction(Us,"readwrite");await el(_.objectStore(Us).put(g))}else{const b=i.transaction(Us,"readwrite");await el(b.objectStore(Us).delete(p))}}const c=await hI(e,n);return c?wa={...wa,backend:"sqlite-state.vscdb",dbPath:`${c} (ItemTable)`,cipher:"AES-256-GCM + vscdb-enc-v1"}:i&&(wa={...wa,backend:"indexeddb-state.vscdb-aes256gcm",dbPath:"IndexedDB://state.vscdb/ItemTable",cipher:globalThis.crypto?.subtle?"AES-256-GCM":"LOCAL-OBF-V1"}),wa={...Zo(),initialized:!0},Nv(),wa}async function fI(){return Vf||(Vf=(async()=>{const e=await Av();let r=null;if(e){r=await jv(e);try{const c=e.transaction(Us,"readonly"),d=await el(c.objectStore(Us).getAll())??[];for(const f of d){if(!f?.key?.startsWith(ny))continue;if(f.key.startsWith(sy)){const x=f.key.slice(sy.length),g=await J5(f.value,r);g&&x&&Ap.set(x,g);continue}const p=f.key.slice(ny.length);if(!Np.includes(p))continue;const b=await J5(f.value,r);b&&(Gi.set(p,b),Dc.set(p,{provider:p,fingerprint:f.value.fingerprint,updatedAtUtc:f.value.updatedAtUtc,cipher:f.value.alg}))}}catch{}}const n=await dI();if(n.available&&n.keys)for(const c of Np){const d=n.keys[c]?.trim();d&&!Gi.has(c)&&(Gi.set(c,d),Dc.set(c,{provider:c,fingerprint:await jp(d),updatedAtUtc:new Date().toISOString(),cipher:"vscdb-enc-v1"}))}const s=mI();for(const c of s)await cp(c.provider,c.key);wa={...wa,initialized:!0,backend:n.available?"sqlite-state.vscdb":e?"indexeddb-state.vscdb-aes256gcm":"memory-fallback",dbPath:n.available?`${n.dbPath??"~/.synlexa-studio/state.vscdb"} (ItemTable)`:e?"IndexedDB://state.vscdb/ItemTable":"memory://state.vscdb/ItemTable",cipher:n.available?"AES-256-GCM + SQLite state.vscdb":e&&r?"AES-256-GCM":"In-memory sealed session",migratedLegacyCount:s.length};const i={...Zo(),initialized:!0};return wa=i,Nv(),i})(),Vf)}const x3="synlexa.studio.aiPermissions.v1",Bo={safe_read:"always-allow",external_network:"ask",workspace_mutate:"always-allow",remote_compute:"ask"},Z5={safe_read:{label:"Workspace inspection & UI navigation",description:"Read loaded metrics, switch tabs/views, focus residues, and run offline RDKit/Wasm checks."},workspace_mutate:{label:"Project changes, plugins & exports",description:"Create/modify projects, split structures, toggle plugins, or download HTML/JSON reports."},external_network:{label:"External web & public databases",description:"Fetch structures/compounds from RCSB/AlphaFold/PubChem/ChEMBL or search Europe PMC & ClinicalTrials.gov."},remote_compute:{label:"External GPU / Colab & multi-step pipelines",description:"Dispatch jobs to connected GPU Compute Nodes (AutoDock Vina, OpenMM, Boltz-2, RFdiffusion, PySCF)."}};function pI(e,r={}){switch(e){case"fetch_from_database":return{category:"external_network",title:`Fetch from ${String(r.source??"public database").toUpperCase()}`,detail:`Query "${String(r.query??"")}"${r.autoImport!==!1?" and import into workspace":""}.`};case"search_scientific_web":return{category:"external_network",title:"Search scientific literature & trials",detail:`Query Europe PMC / ClinicalTrials.gov for "${String(r.query??"")}".`};case"run_compute_job":return{category:"remote_compute",title:`Dispatch GPU / Compute job (${String(r.toolId??"adapter")})`,detail:"Submit computation to the active connected Compute Node."};case"run_workflow_pipeline":return{category:"remote_compute",title:`Execute workflow pipeline (${String(r.templateId??"active")})`,detail:"Run multi-step DAG workflow across configured compute tiers."};case"export_ruo_report":return{category:"workspace_mutate",title:`Export RUO ${String(r.format??"html").toUpperCase()} artifact`,detail:"Generate and download report/manifest/bundle file."};case"manage_project":{const n=String(r.action??"list");return{category:n==="list"?"safe_read":"workspace_mutate",title:`Project action: ${n}`,detail:`Modify or split project assets (${String(r.name??r.projectId??"active project")}).`}}case"manage_plugins":{const n=String(r.action??"list");return{category:n==="list"?"safe_read":"workspace_mutate",title:`Plugin manager: ${n}`,detail:`Inspect or toggle plugin "${String(r.pluginId??"catalog")}".`}}default:return{category:"safe_read",title:`Run ${e}`,detail:"Deterministic local workspace / UI action."}}}function t0(e){let r=null;if(!r)try{r=typeof localStorage<"u"?localStorage:null}catch{r=null}if(!r)return{...Bo};try{const n=r.getItem(x3);if(!n)return{...Bo};const s=JSON.parse(n);return{safe_read:s.safe_read??Bo.safe_read,external_network:s.external_network??Bo.external_network,workspace_mutate:s.workspace_mutate??Bo.workspace_mutate,remote_compute:s.remote_compute??Bo.remote_compute}}catch{return{...Bo}}}function gI(e,r){const n={...t0(),...e};let s=null;if(!s)try{s=typeof localStorage<"u"?localStorage:null}catch{s=null}try{s?.setItem(x3,JSON.stringify(n))}catch{}return n}const ry="gemini-3.1-flash-lite",eA=[{id:"gemini-3.1-flash-lite",label:"Gemini 3.1 Flash-Lite",note:"Fastest · default for quick answers"},{id:"gemini-3-flash-preview",label:"Gemini 3 Flash",note:"Multi-step reasoning & tool use · preview"},{id:"gemini-3.1-pro-preview",label:"Gemini 3.1 Pro",note:"Deep reasoning, 1M-token context · preview"},{id:"gemini-4-hydrogen",label:"Gemini 4 Hydrogen",note:"Fast, efficient agentic workflows"},{id:"gemini-4-argon",label:"Gemini 4 Argon",note:"Efficient frontier reasoning for math & science"},{id:"gemini-4-carbon",label:"Gemini 4 Carbon",note:"Strongest reasoning · complex scientific work"}],y3="https://generativelanguage.googleapis.com/v1beta/models",_3="synlexa.studio.gemini.model",bI=[{name:"fetch_from_database",description:"Search or import a verified public structure or compound from RCSB PDB, AlphaFold DB, UniProtKB, or PubChem (or pinned local cache if offline).",parameters:{type:"OBJECT",properties:{source:{type:"STRING",description:"Public database source to query.",enum:["rcsb","alphafold","uniprot","pubchem"]},query:{type:"STRING",description:'PDB ID, UniProt accession, protein name, or compound name (e.g. "1UBQ", "P0CG48", "imatinib").'},role:{type:"STRING",description:"When importing a structure, whether to assign it as reference or mobile.",enum:["reference","mobile"]},autoImport:{type:"BOOLEAN",description:"If true, immediately import the top matching record into the IDE workspace."}},required:["source","query"]}},{name:"run_structure_superposition",description:"Run deterministic float64 Kabsch 3D rigid superposition between the currently loaded Reference and Mobile structures.",parameters:{type:"OBJECT",properties:{refChain:{type:"STRING",description:"Optional explicit polymer chain ID for the reference structure."},mobChain:{type:"STRING",description:"Optional explicit polymer chain ID for the mobile structure."}}}},{name:"focus_3d_residues",description:"Highlight and center one or more residue sequence numbers across the 3D viewport, sequence Δd track, PAE matrix, and Ramachandran plot.",parameters:{type:"OBJECT",properties:{seqIds:{type:"ARRAY",description:"Positive 1-based residue sequence IDs to focus.",items:{type:"INTEGER"}}},required:["seqIds"]}},{name:"engineer_peptide_mutation",description:"Apply one or more point mutations (e.g. H94A, T199V, E7V) in the Peptide Engineering workbench and compute deterministic biophysical deltas.",parameters:{type:"OBJECT",properties:{mutations:{type:"ARRAY",description:'Point mutations in <WT><pos><Mut> format, e.g. ["H94A"].',items:{type:"STRING"}},focusSeqId:{type:"INTEGER",description:"Optional residue ID for 5.0 Å local 3D contact shell inspection."}},required:["mutations"]}},{name:"design_crispr_edit",description:"Evaluate a coding-transcript nucleotide edit consequence (synonymous/missense/nonsense) and scan SpCas9, SaCas9, or Cas12a PAM sites.",parameters:{type:"OBJECT",properties:{transcriptId:{type:"STRING",description:"RefSeq transcript ID (NM_000067.3 CA2, NM_000518.5 HBB, NM_000546.6 TP53).",enum:["NM_000067.3","NM_000518.5","NM_000546.6"]},targetCodonIndex:{type:"INTEGER",description:"1-based target codon index in the CDS."},baseEditOffset:{type:"INTEGER",description:"Codon base offset (0, 1, or 2)."},newBase:{type:"STRING",description:"Substituted DNA nucleotide.",enum:["A","C","G","T"]},nuclease:{type:"STRING",description:"CRISPR nuclease PAM scanner.",enum:["SpCas9","SaCas9","Cas12a"]}},required:["targetCodonIndex"]}},{name:"inspect_chemical_smiles",description:"Parse a SMILES string in the deterministic Wasm chemistry engine to compute formula, MW, TPSA, cLogP, Lipinski/Veber metrics, and 2D layout.",parameters:{type:"OBJECT",properties:{smiles:{type:"STRING",description:"Canonical or isomeric SMILES string."},name:{type:"STRING",description:"Human-readable compound label."}},required:["smiles"]}},{name:"analyze_ramachandran",description:"Compute backbone (φ, ψ) dihedral angles, secondary structure counts (Helix/Sheet/Loop), Ramachandran favored/allowed/outlier counts, and Cα–Cα contacts.",parameters:{type:"OBJECT",properties:{target:{type:"STRING",description:"Which loaded structure to analyze.",enum:["reference","mobile"]},chainId:{type:"STRING",description:"Optional polymer chain ID."}}}},{name:"export_ruo_report",description:"Export a self-contained Research-Use-Only (RUO) HTML report, JSON provenance manifest, or versioned .synlexa.bundle.json project file.",parameters:{type:"OBJECT",properties:{format:{type:"STRING",description:"Export format.",enum:["html","json","bundle"]}},required:["format"]}}],xI=[{name:"get_workspace_state",description:"Inspect the complete live deterministic workspace state via the in-app MCP server: top deviating residues, ligand/metal active-site contacts, Ramachandran outliers, peptide deltas, CRISPR PAM sites, SMILES descriptors, and saved library items.",parameters:{type:"OBJECT",properties:{section:{type:"STRING",description:"Which slice of workspace telemetry to inspect.",enum:["all","comparison","contacts","peptide","crispr","chemistry","ramachandran","library"]},topN:{type:"INTEGER",description:"Maximum number of residue/contact/PAM rows to include (default 10)."}}}},{name:"search_scientific_web",description:"Search live peer-reviewed scientific literature (Europe PMC / PubMed) and trial registries (ClinicalTrials.gov API v2) with verified PMIDs, DOIs, NCT IDs, source URLs, and UTC timestamps.",parameters:{type:"OBJECT",properties:{query:{type:"STRING",description:'Scientific search query (e.g. "carbonic anhydrase II acetazolamide 3HS4", "hashimoto autoimmune thyroid biomarker").'},scope:{type:"STRING",description:"Sources to query.",enum:["all","literature","trials"]},limit:{type:"INTEGER",description:"Maximum results per source (1-8)."}},required:["query"]}},{name:"query_local_library",description:"List or filter saved structures, ligands, and sequences in the local IndexedDB molecule library with SHA-256 checksums and provenance.",parameters:{type:"OBJECT",properties:{kind:{type:"STRING",description:"Filter by item kind.",enum:["all","structure","compound","sequence"]},query:{type:"STRING",description:"Optional substring filter by name, accession, or tag."}}}},{name:"list_compute_nodes",description:"List paired external GPU / Colab / local Compute Nodes, detected GPUs/VRAM, and installed bioinformatics engines (Vina, OpenMM, Boltz-2, RFdiffusion, PySCF, GROMACS).",parameters:{type:"OBJECT",properties:{}}},{name:"run_compute_job",description:"Submit a scientific compute job (vina_docking, openmm_md, boltz_predict, rfdiffusion_design, pyscf_qm, rdkit_3d, gromacs_md) to the currently active connected Compute Node.",parameters:{type:"OBJECT",properties:{toolId:{type:"STRING",description:"Compute adapter ID on the connected node.",enum:["vina_docking","openmm_md","boltz_predict","rfdiffusion_design","pyscf_qm","rdkit_3d","gromacs_md"]},smiles:{type:"STRING",description:"Optional ligand SMILES (defaults to active Chemistry Workbench SMILES)."},steps:{type:"INTEGER",description:"Optional OpenMM MD steps (default 1000)."}},required:["toolId"]}},{name:"control_app_ui",description:'Navigate and control the Synlexa Studio UI ("octopus arms"): open/split any workbench tab, switch the 3D engine (Fast WebGL2 vs Mol* Pro), change 3D layout/style/colorMode/camera preset, switch sidebar view, or open the interactive Tutorial.',parameters:{type:"OBJECT",properties:{openTab:{type:"STRING",description:"Tab to open or focus.",enum:["home","viewer","results","sequence","ramachandran","peptide","crispr","chemistry","workflow","compute","plugins","assistant","mcp","library"]},toSide:{type:"BOOLEAN",description:"If true, open the tab in a split side pane."},viewportEngine:{type:"STRING",description:"Switch 3D engine between Fast WebGL2 and Mol* Pro.",enum:["webgl2","molstar"]},viewportLayout:{type:"STRING",description:"Set 3D comparison layout.",enum:["overlay","split","reference","mobile"]},renderStyle:{type:"STRING",description:"Set 3D representation style.",enum:["ribbon","trace","pocket"]},colorMode:{type:"STRING",description:"Set 3D coloring mode.",enum:["identity","plddt","bfactor","deviation"]},cameraPreset:{type:"STRING",description:"Move 3D camera to preset.",enum:["overview","active-site","n-terminus","reset"]},sidebarView:{type:"STRING",description:"Switch left sidebar view.",enum:["explorer","library","tools","history"]},openTutorial:{type:"BOOLEAN",description:"Open the interactive Studio guided tutorial."}}}},{name:"manage_project",description:"Create, list, or switch multi-asset research projects; save designed molecules/peptides; split multi-chain/ligand structures into individual parts; or bind a receptor and ligand for docking.",parameters:{type:"OBJECT",properties:{action:{type:"STRING",description:"Project action to perform.",enum:["list","create","switch","add_molecule","split_chains","stage_binding"]},projectId:{type:"STRING",description:"Target project ID when switching."},name:{type:"STRING",description:"Project or molecule name."},description:{type:"STRING",description:"Project description."},template:{type:"STRING",description:"Project starter template.",enum:["blank","structure-compare","ligand-docking","peptide-crispr"]},smiles:{type:"STRING",description:"SMILES string when adding a molecule."},target:{type:"STRING",description:"Which loaded structure to split (reference or mobile).",enum:["reference","mobile"]}},required:["action"]}},{name:"design_molecule_rdkit",description:"Analyze, validate, screen for PAINS/Brenk alerts, or run SMARTS substructure search on a molecule using the in-browser RDKit WASM engine, and optionally save it into the active project.",parameters:{type:"OBJECT",properties:{smiles:{type:"STRING",description:"SMILES or MOL block to analyze/design."},name:{type:"STRING",description:"Molecule label."},smartsQuery:{type:"STRING",description:"Optional SMARTS pattern for substructure matching/highlighting."},saveToProject:{type:"BOOLEAN",description:"Save molecule to the active project."}},required:["smiles"]}},{name:"run_workflow_pipeline",description:"Open Workflow Canvas and inspect, export (Nextflow/Snakemake), or execute a multi-step scientific DAG workflow template.",parameters:{type:"OBJECT",properties:{templateId:{type:"STRING",description:"Workflow template ID.",enum:["tpl-structure-audit","tpl-hit-to-lead","tpl-binder-design","tpl-quantum-ligand"]},action:{type:"STRING",description:"Whether to run, export Nextflow, or export Snakemake.",enum:["run","export_nextflow","export_snakemake"]}},required:["action"]}},{name:"manage_plugins",description:"List all open-source biochemistry plugins & license status, or enable/disable an add-on.",parameters:{type:"OBJECT",properties:{action:{type:"STRING",description:"Plugin action to perform.",enum:["list","enable","disable"]},pluginId:{type:"STRING",description:"Plugin ID (e.g. org.synlexa.autodock-vina)."}},required:["action"]}}],Tp=[...bI,...xI];function yI(e){return`${y3}/${encodeURIComponent(e)}:generateContent`}function Tv(e){const r=[`Active Reference: ${e.refLabel||"none"} (chain=${e.refChain||"unselected"}, sha256=${e.comparison?.reference.sha256??e.refInspect?.sha256??"none"}, confidence=${e.comparison?.reference.confidenceKind??e.refInspect?.confidenceKind??"none"})`,`Active Mobile: ${e.mobLabel||"none"} (chain=${e.mobChain||"unselected"}, sha256=${e.comparison?.mobile.sha256??e.mobInspect?.sha256??"none"}, confidence=${e.comparison?.mobile.confidenceKind??e.mobInspect?.confidenceKind??"none"})`];if(e.comparison){const n=e.comparison.metrics,s=e.comparison.matchedResidues.map(p=>p.mobPlddt).filter(p=>p!==null&&Number.isFinite(p)),i=s.length>0?s.reduce((p,b)=>p+b,0)/s.length:null,c=e.comparison.refDisplayAtoms?.ligands.map(p=>`${p.resName}(${p.chainId}:${p.seqId})`).join(", ")||"none";r.push(`Comparison (${e.comparison.resultId.slice(0,12)}): RMSD=${n.rmsdAngstrom.toFixed(4)} Å across ${n.matchedCaCount} Cα, refCov=${n.refCoverage.numerator}/${n.refCoverage.denominator} (${n.refCoverage.denominatorKind}), mobCov=${n.mobCoverage.numerator}/${n.mobCoverage.denominator}, meanPlddt=${i!==null?i.toFixed(1):"n/a"}, PAE=${n.paeStatus}, ligands=[${c}]`);const d=[...e.comparison.matchedResidues].sort((p,b)=>b.distanceAngstrom-p.distanceAngstrom).slice(0,6);d.length>0&&r.push(`Top Cα Deviations: ${d.map(p=>`${p.resName3}${p.refSeqId}=${p.distanceAngstrom.toFixed(3)}Å${p.mobPlddt!==null?`(pLDDT ${p.mobPlddt.toFixed(1)})`:""}`).join(", ")}`);const f=e.comparison.refContacts??[];if(f.length>0){const p=[...f].sort((b,x)=>b.distanceAngstrom-x.distanceAngstrom).slice(0,6).map(b=>`${b.ligandResName}.${b.ligandAtom}–${b.proteinResName3}${b.proteinSeqId}.${b.proteinAtom}(${b.distanceAngstrom.toFixed(2)}Å)`);r.push(`Active-Site Ligand/Metal Contacts (≤4.5 Å, total=${f.length}): ${p.join(", ")}`)}}if(e.peptide){const n=e.peptide;r.push(`Peptide: len=${n.engineered.length}, mutations=[${n.appliedMutations.map(s=>s.notation).join(",")||"none"}], WT_MW=${n.wildType.mwAverageDa.toFixed(1)} Da, ΔMW=${n.deltas.mwAverageDa.toFixed(2)} Da, pI=${n.engineered.pi.toFixed(2)} (Δ${n.deltas.pi.toFixed(2)}), charge@7.4=${n.engineered.chargeAtPh74.toFixed(2)}, GRAVY=${n.engineered.gravy.toFixed(3)}, 3D_contacts=${n.local3dContacts.slice(0,5).map(s=>`${s.resName3}${s.seqId}(${s.distanceAngstrom.toFixed(2)}Å)`).join(", ")||"none"}`)}if(e.crispr){const n=e.crispr,s=n.pamSites.slice(0,4).map(i=>`${i.nuclease}:${i.pam}(${i.strand},cut=${i.cutBp1},Δ=${i.distanceToTargetCodonBp}bp,GC=${i.gcPercent.toFixed(0)}%)`);r.push(`CRISPR: ${n.geneSymbol} (${n.transcriptId}, ${n.cdsLengthBp} bp), codon=${n.targetCodon.codonIndex1} (${n.targetCodon.wtCodon}/${n.targetCodon.wtAa} -> ${n.targetCodon.editedCodon}/${n.targetCodon.editedAa}, ${n.targetCodon.consequence}), PAMs=${n.pamSites.length} [${s.join("; ")}]`)}if(e.smiles){const n=e.smiles;r.push(`SMILES: ${n.name}, formula=${n.formula}, MW=${n.molecularWeight.toFixed(2)} Da, exactMass=${n.exactMass.toFixed(4)} Da, TPSA=${n.tpsa.toFixed(2)} Ų, cLogP=${n.crippenLogP.toFixed(2)}, HBD=${n.hbd}, HBA=${n.hba}, rotBonds=${n.rotatableBonds}, rings=${n.ringCount}, LipinskiViol=${n.lipinskiViolations}, Veber=${n.veberCompliant?"pass":"fail"}`)}if(e.ramachandran){const n=e.ramachandran,s=n.residues.filter(i=>i.region==="outlier").slice(0,5).map(i=>`${i.resName3}${i.seqId}(φ=${i.phiDeg?.toFixed(1)??"n/a"},ψ=${i.psiDeg?.toFixed(1)??"n/a"})`);r.push(`Ramachandran: chain=${n.chainId}, residues=${n.residueCount}, H/S/L=${n.secondaryCounts.helix}/${n.secondaryCounts.sheet}/${n.secondaryCounts.loop}, favored/allowed/outlier=${n.regionCounts.favored}/${n.regionCounts.allowed}/${n.regionCounts.outlier}, contacts=${n.contactPairs.length}${s.length?`, outliers=[${s.join(", ")}]`:""}`)}return r.join(`
683
+ `)}const Ev=["You are the autonomous AI scientific assistant inside Synlexa Studio, a Research-Use-Only (RUO) computational biology and chemistry IDE powered by an in-app MCP server.","STRICT RULES:","1. NEVER make diagnostic, therapeutic, clinical-decision, drug-efficacy, or FDA-clearance claims.","2. NEVER fabricate or guess PMIDs, DOIs, ClinicalTrials.gov NCT IDs, p-values, cohorts, or structural numbers.","3. Ground every quantitative statement in the live workspace summary or MCP tool execution outputs (get_workspace_state, run_structure_superposition, analyze_ramachandran, engineer_peptide_mutation, design_crispr_edit, inspect_chemical_smiles, design_molecule_rdkit, manage_project, run_workflow_pipeline, query_local_library).","4. Use your tools like octopus arms: you can inspect the workspace, switch UI tabs/panels/compare modes (`control_app_ui`), organize multi-structure/ligand projects and split chains or stage binding (`manage_project`), design and score molecules (`design_molecule_rdkit`), manage plugins (`manage_plugins`), and run multi-step workflows (`run_workflow_pipeline`). Run tests across rounds to verify inside the UI.","5. Before calling tools, write a brief 1-2 sentence plan/reasoning note so the user sees your thinking process step-by-step.","6. If the user denies permission for an external fetch or remote GPU/workflow tool, respect the denial immediately and continue with local/offline tools or propose alternatives.","7. When the user asks for recent papers, literature context, citations, or registered studies, call `search_scientific_web` and include the exact returned PMID/DOI/NCT ID and sourceUrl.","8. Clearly distinguish source-observed facts, deterministic engine numbers, and model-generated synthesis.","9. Always end or annotate with a concise Research-Use-Only (RUO) reminder.","10. Format responses in clean, well-structured Markdown: use concise section headings (##/###), bullet or numbered lists, GFM pipe tables for multi-item comparisons or structural metrics, fenced code blocks for sequences/SMILES/commands, and [label](url) links for verified references."].join(`
684
+ `);function Ds(e,r){e?.(r.map(n=>({...n})))}function Mv(e,r,n,s){const i=Date.now(),c={round:r,phase:"thinking",title:`Reasoning (round ${r})`,detail:`Analyzing request with ${n}…`,status:"running",startedAtMs:i};return e.push(c),Ds(s,e),{step:c,startedAtMs:i}}function Wc(e,r){const n=e.indexOf(r);n!==-1&&e.splice(n,1)}function Rv(e){let r=!1;for(const s of e.thoughts){const i=s.trim();i&&(e.thinkingTrace.push(i),e.stepTrace.push({round:e.round,phase:"thinking",title:`${e.thoughtTitle??"Model reasoning"} (round ${e.round})`,detail:i,status:"done",...!r&&e.roundDurationMs?{durationMs:e.roundDurationMs}:{}}),r=!0)}const n=e.preToolRationale?.trim();n&&(e.thinkingTrace.push(n),e.stepTrace.push({round:e.round,phase:"thinking",title:`Pre-tool rationale (round ${e.round})`,detail:n,status:"done",...!r&&e.roundDurationMs?{durationMs:e.roundDurationMs}:{}}))}async function zv(e,r,n){const s=pI(r,n);let i="auto";const d=(e.permissionPolicies??t0())[s.category]??"ask";if(e.sessionApprovedCategories?.has(s.category))i="allowed-session";else if(d==="deny"){i="denied";const g={ok:!1,summary:`Blocked by permission policy (${s.category})`,data:{denied:!0,category:s.category,reason:"Denied by Studio permission policy"}};return e.executedTools.push({name:r,args:n,ok:!1,summary:g.summary,result:g.data,durationMs:0,permissionStatus:i}),e.stepTrace.push({round:e.round,phase:"permission",title:`Blocked: ${s.title}`,detail:g.summary,toolName:r,args:n,ok:!1,status:"error"}),Ds(e.onProgress,e.stepTrace),g}else if(d==="ask"&&e.requestToolPermission){const g={round:e.round,phase:"permission",title:`Permission requested: ${s.title}`,detail:s.detail,toolName:r,args:n,status:"running",startedAtMs:Date.now()};e.stepTrace.push(g),Ds(e.onProgress,e.stepTrace);const _=await e.requestToolPermission({id:`perm-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,toolName:r,category:s.category,title:s.title,detail:s.detail,args:n});if(_==="deny"){i="denied",g.ok=!1,g.status="error",g.detail=`${s.detail} — Denied by user.`;const y={ok:!1,summary:`Permission denied by user for ${r}`,data:{denied:!0,category:s.category,reason:"User denied permission"}};return e.executedTools.push({name:r,args:n,ok:!1,summary:y.summary,result:y.data,durationMs:0,permissionStatus:i}),Ds(e.onProgress,e.stepTrace),y}_==="allow_session"?(i="allowed-session",e.sessionApprovedCategories?.add(s.category),g.ok=!0,g.status="done",g.detail=`${s.detail} — Allowed for this session.`):(i="allowed-once",g.ok=!0,g.status="done",g.detail=`${s.detail} — Allowed once.`),Ds(e.onProgress,e.stepTrace)}const f=Date.now(),p={round:e.round,phase:"tool",title:`${r} · running`,toolName:r,args:n,status:"running",startedAtMs:f};e.stepTrace.push(p),Ds(e.onProgress,e.stepTrace);let b;try{b=await e.executeTool(r,n)}catch(g){b={ok:!1,summary:g instanceof Error?g.message:String(g),data:{error:g instanceof Error?g.message:String(g)}}}const x=Math.max(1,Date.now()-f);return e.executedTools.push({name:r,args:n,ok:b.ok,summary:b.summary,result:b.data,durationMs:x,permissionStatus:i}),p.phase=b.ok?"tool":"error",p.title=`${r} · ${b.ok?"ok":"failed"}`,p.detail=b.summary,p.durationMs=x,p.ok=b.ok,p.status=b.ok?"done":"error",Ds(e.onProgress,e.stepTrace),b}function Ov(e=!0){return e?Tp:Tp.filter(r=>r.name!=="search_scientific_web")}async function tA(e){const r=new Date().toISOString(),n=`agent-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,s=(e.apiKey??"").trim(),i=e.model??ry,c=e.fetchImpl??globalThis.fetch,d=e.transport,f=d?"synlexa-cloud":"gemini-api",p=Ov(e.enableWebSearch!==!1),b=z=>{const O=d3(e.prompt,e.workspace);if(e.onFallbackAction)for(const H of O.actions)e.onFallbackAction(H);const V=z?`[${d?"Synlexa Cloud":"Gemini API"} unavailable: ${z} — using local deterministic Copilot]
685
+ `:"",P=O.reply.actionTaken?[{name:O.reply.command??"copilot",args:{},ok:!0,summary:O.reply.actionTaken,result:null,permissionStatus:"auto"}]:[],$=P.map((H,Z)=>({round:Z+1,phase:"tool",title:`${H.name} · ok`,detail:H.summary,toolName:String(H.name),ok:!0}));return{id:n,role:"assistant",mode:"local-deterministic-fallback",model:"deterministic-copilot",providerLabel:"Local Deterministic Copilot",text:`${V}${O.reply.text}`,citations:O.reply.citations,thinkingTrace:O.reply.actionTaken?[`Matched local deterministic command: ${O.reply.actionTaken}`]:[],stepTrace:$,executedTools:P,timestampUtc:r,error:z}};if(!s&&!d||typeof c!="function")return b();const x=[];for(const z of e.history.slice(-8))x.push({role:z.role==="user"?"user":"model",parts:[{text:z.text}]});x.push({role:"user",parts:[{text:`[LIVE WORKSPACE STATE]
686
+ ${Tv(e.workspace)}
687
+
688
+ [USER REQUEST]
689
+ ${e.prompt}`}]});const g=[],_=[],y=[],S=Math.max(1,e.maxToolRounds??10),k=d?d.endpoint:yI(i),E=d?{"Content-Type":"application/json",...d.headers}:{"Content-Type":"application/json","x-goog-api-key":s},T={inputTokens:0,outputTokens:0},j=Date.now();let q=!0;try{for(let z=0;z<S;z++){const O=d?"Synlexa Cloud":"Gemini BYOK",{step:V,startedAtMs:P}=Mv(_,z+1,O,e.onProgress),$=async he=>{const W=await c(k,{method:"POST",headers:E,body:JSON.stringify({...d?{model:i}:{},systemInstruction:{parts:[{text:Ev}]},contents:x,tools:[{functionDeclarations:p}],generationConfig:{temperature:.2,...he?{thinkingConfig:{includeThoughts:!0}}:{}}})}),me=await W.json().catch(()=>({}))??{};return{response:W,payload:me}};let{response:H,payload:Z}=await $(q);if(!H.ok&&H.status===400&&q&&/thinkingConfig|includeThoughts|thinking/i.test(Z.error?.message??"")&&(q=!1,{response:H,payload:Z}=await $(!1)),T.inputTokens+=Z.usageMetadata?.promptTokenCount??0,T.outputTokens+=(Z.usageMetadata?.candidatesTokenCount??0)+(Z.usageMetadata?.thoughtsTokenCount??0),!H.ok||Z.error){Wc(_,V);const he=Z.error?.message??`HTTP ${H.status}`;return b(he)}const G=Math.max(1,Date.now()-P);Wc(_,V);const K=Z.candidates?.[0]?.content?.parts??[],we=K.filter(he=>he.thought&&typeof he.text=="string"&&he.text.trim().length>0).map(he=>he.text.trim()),Se=K.filter(he=>he.functionCall),Q=K.filter(he=>!he.thought).map(he=>he.text).filter(he=>typeof he=="string"&&he.trim().length>0);if(Rv({stepTrace:_,thinkingTrace:y,round:z+1,thoughts:we,preToolRationale:Se.length>0?Q.join(`
690
+ `).trim():void 0,roundDurationMs:G}),Se.length===0){Ds(e.onProgress,_);const he=Q.join(`
691
+ `).trim()||"Completed requested tools. Check the workspace panels for updated deterministic metrics.",me=/research[- ]use[- ]only|\(ruo\)/i.test(he)?he:`${he}
692
+
693
+ _${Cn}_`,I=[];return e.workspace.comparison&&I.push(`resultId:${e.workspace.comparison.resultId}`),{id:n,role:"assistant",mode:f,model:i,providerLabel:d?`Synlexa Cloud (${i})`:`Gemini BYOK (${i})`,text:me,thinkingTrace:y,stepTrace:_,executedTools:g,citations:I,timestampUtc:r,durationMs:Math.max(1,Date.now()-j),usage:T}}Ds(e.onProgress,_),x.push({role:"model",parts:K});const F=[];for(const he of Se){const W=he.functionCall,me=W.name,I=W.args??{},J=await zv({round:z+1,executeTool:e.executeTool,requestToolPermission:e.requestToolPermission,sessionApprovedCategories:e.sessionApprovedCategories,permissionPolicies:e.permissionPolicies,onProgress:e.onProgress,stepTrace:_,executedTools:g},me,I);F.push({functionResponse:{name:me,response:{result:J.data}}})}x.push({role:"user",parts:F})}return{id:n,role:"assistant",mode:f,model:i,providerLabel:d?`Synlexa Cloud (${i})`:`Gemini BYOK (${i})`,text:`Executed ${g.length} tool step(s). ${Cn}`,thinkingTrace:y,stepTrace:_,executedTools:g,timestampUtc:r,durationMs:Math.max(1,Date.now()-j),usage:T}}catch(z){return b(z instanceof Error?z.message:String(z))}}const Pv="synlexa.studio.usage.v1",_I=120,Ep=new Set;function vI(e){return Ep.add(e),()=>Ep.delete(e)}function iy(){try{const e=localStorage.getItem(Pv),r=e?JSON.parse(e):[];return Array.isArray(r)?r:[]}catch{return[]}}function qc(e){const r=new Date().toISOString().slice(0,10),n=iy();let s=n.find(d=>d.date===r&&d.provider===e.provider&&d.model===e.model);s||(s={date:r,provider:e.provider,model:e.model,requests:0,inputTokens:0,outputTokens:0,toolCalls:0,errors:0},n.push(s)),s.requests+=1,s.inputTokens+=e.inputTokens??0,s.outputTokens+=e.outputTokens??0,s.toolCalls+=e.toolCalls??0,e.error&&(s.errors+=1);const i=new Date(Date.now()-_I*864e5).toISOString().slice(0,10),c=n.filter(d=>d.date>=i);try{localStorage.setItem(Pv,JSON.stringify(c))}catch{}for(const d of Ep)d()}function wI(){try{localStorage.removeItem(Pv)}catch{}for(const e of Ep)e()}function SI(e,r){const n=new Date(Date.now()-r*864e5).toISOString().slice(0,10),s=e.filter(f=>f.date>=n),i=new Map;for(const f of s){const p=`${f.provider}::${f.model}`,b=i.get(p)??{requests:0,inputTokens:0,outputTokens:0,errors:0,toolCalls:0};b.requests+=f.requests,b.inputTokens+=f.inputTokens,b.outputTokens+=f.outputTokens,b.errors+=f.errors,b.toolCalls+=f.toolCalls,i.set(p,b)}const c=s.reduce((f,p)=>({requests:f.requests+p.requests,inputTokens:f.inputTokens+p.inputTokens,outputTokens:f.outputTokens+p.outputTokens,toolCalls:f.toolCalls+p.toolCalls,errors:f.errors+p.errors}),{requests:0,inputTokens:0,outputTokens:0,toolCalls:0,errors:0}),d=[];for(let f=r-1;f>=0;f--){const p=new Date(Date.now()-f*864e5).toISOString().slice(0,10),b=s.filter(x=>x.date===p);d.push({date:p,tokens:b.reduce((x,g)=>x+g.inputTokens+g.outputTokens,0),requests:b.reduce((x,g)=>x+g.requests,0)})}return{totals:c,byProvider:Array.from(i.entries()),days:d}}function kI(){try{const e=import.meta?.env?.VITE_SYNLEXA_CLOUD_URL?.trim();if(e)return e.replace(/\/+$/,"")}catch{}return"https://synlexa.com"}const $v=kI(),CI=`${$v}/auth/studio-connect`,Iv="synlexa-studio://auth/callback",v3="synlexa-studio",NI=`${$v}/api/studio/token`,AI=`${$v}/api/studio/assistant`,Dv="synlexa.studio.auth.pending",n0="synlexa.studio.auth.session",Mp="synlexa.studio.auth.token",jI="studio-auth-callback",w3=600*1e3,yx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",TI=/^[A-Za-z0-9\-._~]{43,128}$/,nA=2048;class Nc extends Error{code;constructor(r,n){super(n),this.name="StudioAuthError",this.code=r}}function EI(){const e=new Map;return{getItem:r=>e.has(r)?e.get(r):null,setItem:(r,n)=>{e.set(r,String(n))},removeItem:r=>{e.delete(r)}}}function oy(e){try{const n=globalThis[e];if(n&&typeof n.getItem=="function"&&typeof n.setItem=="function")return n}catch{}return null}let _x=null;function S3(){return _x||(_x=EI()),_x}function s0(){const e=[oy("sessionStorage"),oy("localStorage")].filter(r=>r!==null);return e.length===0?S3():{getItem(r){for(const n of e)try{const s=n.getItem(r);if(s!==null)return s}catch{}return null},setItem(r,n){for(const s of e)try{s.setItem(r,n)}catch{}},removeItem(r){for(const n of e)try{n.removeItem(r)}catch{}}}}function wh(){return oy("localStorage")??S3()}function k3(){const e=globalThis.crypto;if(!e||typeof e.getRandomValues!="function")throw new Error("Web Crypto (crypto.getRandomValues) is unavailable in this runtime.");return e}const jr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function C3(e){let r="",n=0;for(;n+2<e.length;n+=3){const i=e[n]<<16|e[n+1]<<8|e[n+2];r+=jr[i>>18&63]+jr[i>>12&63]+jr[i>>6&63]+jr[i&63]}const s=e.length-n;if(s===1){const i=e[n]<<16;r+=jr[i>>18&63]+jr[i>>12&63]}else if(s===2){const i=e[n]<<16|e[n+1]<<8;r+=jr[i>>18&63]+jr[i>>12&63]+jr[i>>6&63]}return r}function MI(e=64){if(!Number.isInteger(e)||e<43||e>128)throw new RangeError("PKCE code_verifier length must be an integer between 43 and 128.");const r=k3(),n=256-256%yx.length;let s="";for(;s.length<e;){const i=r.getRandomValues(new Uint8Array(e*2));for(let c=0;c<i.length&&s.length<e;c++)i[c]<n&&(s+=yx[i[c]%yx.length])}return s}function RI(){return C3(k3().getRandomValues(new Uint8Array(32)))}async function N3(e){return C3(await QA(new TextEncoder().encode(e)))}function sA(e,r){let n=e.length^r.length;const s=Math.max(e.length,r.length);for(let i=0;i<s;i++)n|=(e.charCodeAt(i)||0)^(r.charCodeAt(i)||0);return n===0}function zI(e){return e.replace(/\/+$/,"")}function A3(e){return`${zI(e)}/?studio_auth=callback`}function OI(e){const r=new URL(CI);return r.searchParams.set("mode",e.mode),r.searchParams.set("client",v3),r.searchParams.set("redirect_uri",Iv),r.searchParams.set("web_redirect_uri",A3(e.webOrigin)),r.searchParams.set("code_challenge",e.codeChallenge),r.searchParams.set("code_challenge_method","S256"),r.searchParams.set("state",e.state),e.platform&&r.searchParams.set("platform",e.platform),r.toString()}async function PI(e,r={}){if(e!=="signin"&&e!=="signup")throw new Nc("INVALID_CALLBACK","Unsupported Studio auth mode.");const n=r.storage??s0(),s=r.now??(()=>new Date),i=globalThis.location?.origin,c=r.webOrigin??(i&&i!=="null"?i:"http://localhost:5173"),d=MI(),f=await N3(d),p=RI(),b={mode:e,state:p,codeVerifier:d,codeChallenge:f,redirectUri:Iv,webRedirectUri:A3(c),createdAtUtc:s().toISOString()};return n.setItem(Dv,JSON.stringify(b)),{url:OI({mode:e,state:p,codeChallenge:f,webOrigin:c,platform:r.platform}),pending:b}}function $I(e=s0()){let r=null;try{r=e.getItem(Dv)}catch{return null}if(!r)return null;try{const n=JSON.parse(r);if((n.mode==="signin"||n.mode==="signup")&&typeof n.state=="string"&&typeof n.codeVerifier=="string"&&typeof n.codeChallenge=="string"&&typeof n.redirectUri=="string"&&typeof n.webRedirectUri=="string"&&typeof n.createdAtUtc=="string")return n}catch{}return null}function up(e=s0()){try{e.removeItem(Dv)}catch{}}function tr(e){return{ok:!1,reason:"INVALID_CALLBACK",message:e}}function aA(e,r){const n=e.get("error");if(n){const f=e.get("error_description")??void 0;return{ok:!1,reason:"PROVIDER_ERROR",message:f?`${n}: ${f}`:n,error:n,errorDescription:f}}const s=e.get("code"),i=e.get("state");if(!s||!i)return tr("Callback is missing the required code and/or state parameter.");if(s.length>nA||i.length>nA)return tr("Callback parameters exceed the maximum allowed length.");const c=e.get("email"),d={ok:!0,code:s,state:i,source:r};return c&&(d.email=c),d}function II(e){if(typeof e!="string")return tr("Callback URI must be a string.");const r=e.trim();if(!r)return tr("Callback URI is empty.");if(r.length>8192)return tr("Callback URI is too long.");const n=r.toLowerCase();if(n.startsWith("synlexa-studio:")){const i=Iv;if(!n.startsWith(i))return tr("Deep link must target synlexa-studio://auth/callback.");const c=r.slice(i.length);if(c!==""&&c[0]!=="?"&&c[0]!=="#")return tr("Deep link must target synlexa-studio://auth/callback.");const d=c.startsWith("?")?c.slice(1).split("#")[0]:"";return aA(new URLSearchParams(d),"deep-link")}let s;try{s=new URL(r)}catch{return tr("Callback URI is not a valid URL.")}return s.protocol!=="http:"&&s.protocol!=="https:"?tr(`Unsupported callback scheme "${s.protocol}".`):s.searchParams.get("studio_auth")!=="callback"?tr("Web callback must include studio_auth=callback."):aA(s.searchParams,"web")}function j3(e){try{const r=new URL(e);if(r.searchParams.get("studio_auth")==="callback")return r.toString()}catch{}return null}async function DI(e){const r=globalThis.fetch;if(typeof r!="function")throw new Error("fetch is unavailable");const n=typeof AbortController=="function"?new AbortController:null,s=n?setTimeout(()=>n.abort(),1e4):null;try{const i=await r(NI,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:e.code,code_verifier:e.codeVerifier,redirect_uri:e.redirectUri,client_id:e.clientId}),signal:n?.signal});if(!i.ok)throw new Error(`Token endpoint responded with HTTP ${i.status}`);const c=await i.json();if(!c||typeof c!="object"||Array.isArray(c))throw new Error("Token endpoint returned non-object JSON");const d=c;if(typeof d.error=="string"&&d.error)throw new Error(`Token endpoint error: ${d.error}`);const f=p=>typeof p=="string"&&p?p:void 0;return{accessToken:f(d.access_token)??f(d.accessToken),email:f(d.email),displayName:f(d.display_name)??f(d.displayName)}}finally{s&&clearTimeout(s)}}async function qI(e,r={}){const n=r.storage??s0(),s=r.now??(()=>new Date),i=II(e);if(!i.ok)throw new Nc(i.reason,i.message);const c=$I(n);if(!c)throw new Nc("NO_PENDING",'No pending Studio sign-in was found in this app/browser profile. Start again from "Continue on synlexa.com".');if(!sA(i.state,c.state))throw new Nc("STATE_MISMATCH","Callback state does not match the pending handshake.");const d=Date.parse(c.createdAtUtc),f=s().getTime()-d;if(!Number.isFinite(d)||f<-6e4||f>w3)throw up(n),new Nc("EXPIRED","The pending Studio sign-in expired (10 minute limit). Please start again.");const p=TI.test(c.codeVerifier)?await N3(c.codeVerifier):"";if(!p||!sA(p,c.codeChallenge))throw up(n),new Nc("PKCE_MISMATCH","Stored PKCE verifier does not match its code challenge.");const b=r.exchange??DI;let x=null;try{x=await b({code:i.code,codeVerifier:c.codeVerifier,redirectUri:i.source==="deep-link"?c.redirectUri:c.webRedirectUri,clientId:v3})}catch{x=null}const g=x!==null,_={mode:c.mode,email:x?.email??i.email??null,displayName:x?.displayName??null,serverVerified:g,verification:g?"server-token-exchange":"local-pkce-only",establishedAtUtc:s().toISOString(),callbackSource:i.source};return up(n),LI(_,r.sessionStore),BI(x?.accessToken??null,r.sessionStore),_}function LI(e,r=wh()){const n={mode:e.mode,email:e.email,displayName:e.displayName,serverVerified:e.serverVerified,verification:e.verification,establishedAtUtc:e.establishedAtUtc,callbackSource:e.callbackSource};try{r.setItem(n0,JSON.stringify(n))}catch{}}function rA(e=wh()){let r=null;try{r=e.getItem(n0)}catch{return null}if(!r)return null;try{const n=JSON.parse(r),s=i=>i===null||typeof i=="string";if((n.mode==="signin"||n.mode==="signup")&&s(n.email)&&s(n.displayName)&&typeof n.serverVerified=="boolean"&&(n.verification==="server-token-exchange"||n.verification==="local-pkce-only")&&n.serverVerified===(n.verification==="server-token-exchange")&&typeof n.establishedAtUtc=="string"&&(n.callbackSource==="deep-link"||n.callbackSource==="web"))return{mode:n.mode,email:n.email??null,displayName:n.displayName??null,serverVerified:n.serverVerified,verification:n.verification,establishedAtUtc:n.establishedAtUtc,callbackSource:n.callbackSource}}catch{}return null}function UI(e=wh()){try{e.removeItem(n0),e.removeItem(Mp)}catch{}}function BI(e,r=wh()){try{e&&/^[A-Za-z0-9._~+/=-]{16,512}$/.test(e)?r.setItem(Mp,e):r.removeItem(Mp)}catch{}}function GI(e=wh()){try{const r=e.getItem(Mp);return r&&/^[A-Za-z0-9._~+/=-]{16,512}$/.test(r)?r:null}catch{return null}}function qv(){const e=globalThis.__TAURI__;return e&&typeof e=="object"?e:null}function HI(e){const r=qv()?.event?.listen;if(typeof r!="function")return()=>{};let n=!1,s=null;return r(jI,i=>{!n&&typeof i.payload=="string"&&e(i.payload)}).then(i=>{n?i():s=i}).catch(()=>{}),()=>{n=!0,s&&(s(),s=null)}}async function FI(e){const r=qv()?.opener?.openUrl;if(typeof r=="function")try{return await r(e),!0}catch{}const n=globalThis.open;return typeof n=="function"?(n(e,"_blank","noopener,noreferrer"),!0):!1}function VI(){return qv()!==null}const T3="synlexa-studio-signin",Lv="synlexa.studio.auth.popup_active",ly="synlexa.studio.auth.callback_relay",E3="synlexa-studio-auth",M3="synlexa-studio-auth-callback";function cy(){try{window.localStorage?.removeItem(Lv)}catch{}}function KI(e){if(typeof window>"u"||typeof window.open!="function")return null;const r=480,n=720,s=Math.max(0,Math.round(window.screenX+(window.outerWidth-r)/2)),i=Math.max(0,Math.round(window.screenY+(window.outerHeight-n)/2)),c=window.open(e,T3,`popup=yes,width=${r},height=${n},left=${s},top=${i}`);if(c)try{window.localStorage?.setItem(Lv,String(Date.now()))}catch{}return c}function YI(e){if(typeof window>"u")return!1;const r=j3(e);if(!r)return!1;const n=window.opener;let s=!1;try{const p=window.localStorage?.getItem(Lv);if(p){const b=Number(p);s=Number.isFinite(b)&&Date.now()-b<=w3}}catch{s=!1}const i=window.outerWidth>0&&window.outerWidth<=620&&window.outerHeight>0&&window.outerHeight<=860;if(!(window.name===T3||!!n||s||i))return!1;cy();const d={type:M3,href:r,ts:Date.now()};let f=!1;try{if(typeof BroadcastChannel=="function"){const p=new BroadcastChannel(E3);p.postMessage(d),p.close(),f=!0}}catch{}try{window.localStorage&&(window.localStorage.setItem(ly,JSON.stringify(d)),f=!0)}catch{}try{n&&!n.closed&&(n.postMessage(d,window.location.origin),f=!0)}catch{}return f}function WI(e){if(typeof window>"u")return()=>{};let r="";const n=d=>{if(!d||typeof d!="object")return;const f=d;f.type!==M3||typeof f.href!="string"||f.href===r||(r=f.href,e(f.href))},s=d=>{d.origin===window.location.origin&&n(d.data)},i=d=>{if(!(d.key!==ly||!d.newValue))try{n(JSON.parse(d.newValue)),window.localStorage?.removeItem(ly)}catch{}};window.addEventListener("message",s),window.addEventListener("storage",i);let c=null;try{typeof BroadcastChannel=="function"&&(c=new BroadcastChannel(E3),c.onmessage=d=>n(d.data))}catch{c=null}return()=>{window.removeEventListener("message",s),window.removeEventListener("storage",i),c?.close()}}const XI={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Uv=["synlexa","anthropic","gemini","openai"],es={synlexa:{label:"Synlexa Cloud",keyHint:"",keyUrl:"https://synlexa.com",models:eA.map(({id:e,label:r,note:n})=>({id:e,label:r,note:n}))},anthropic:{label:"Anthropic Claude",keyHint:"sk-ant-…",keyUrl:"https://console.anthropic.com/settings/keys",models:[{id:"claude-opus-5-5",label:"Claude Opus 5.5",note:"Most capable · deep multi-step analysis"},{id:"claude-sonnet-5-5",label:"Claude Sonnet 5.5",note:"Balanced speed and capability"},{id:"claude-haiku-5-5",label:"Claude Haiku 5.5",note:"Fastest · lowest cost"}]},gemini:{label:"Google Gemini",keyHint:"AIza… or AQ.…",keyUrl:"https://aistudio.google.com/apikey",models:eA.map(({id:e,label:r,note:n})=>({id:e,label:r,note:n}))},openai:{label:"OpenAI / Codex",keyHint:"sk-…",keyUrl:"https://platform.openai.com/api-keys",models:[{id:"gpt-4.1",label:"GPT-4.1",note:"Strong reasoning & MCP tool orchestration"},{id:"o4-mini",label:"o4-mini",note:"Fast STEM & scientific reasoning"},{id:"codex-mini-latest",label:"Codex Mini",note:"Low-latency agentic workflow execution"}]}},Ud="synlexa.studio.ai.provider",R3="synlexa.studio.ai.routingPreference",z3="synlexa.studio.ai.webSearch",O3="synlexa.studio.anthropic.model",P3="synlexa.studio.openai.model",$3="synlexa.studio.cloud.model";function I3(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function QI(){try{const e=XI?.VITE_GEMINI_API_KEY;return typeof e=="string"?e.trim():""}catch{return""}}function Xc(e){const n=["anthropic","gemini","openai"].filter(d=>!!(e[d]?.apiKey??"").trim()),s=n.length>0,i=!!(e.synlexa?.apiKey??"").trim(),c=e.routingPreference??"byok-first";return e.provider!=="synlexa"&&(e[e.provider]?.apiKey??"").trim()?{provider:e.provider,isByok:!0,hasByok:s,hasCloudToken:i,overriddenFromCloud:!1}:c==="byok-first"&&s?{provider:n[0],isByok:!0,hasByok:s,hasCloudToken:i,overriddenFromCloud:e.provider==="synlexa"}:{provider:e.provider,isByok:e.provider!=="synlexa"&&!!(e[e.provider]?.apiKey??"").trim(),hasByok:s,hasCloudToken:i,overriddenFromCloud:!1}}function Ac(){const e=I3(),r=e?.getItem(Ud),s=e?.getItem(R3)==="manual"?"manual":"byok-first",i=Uv.find(k=>k===r)??null,c=e?.getItem(z3)!=="false",d=e?.getItem(_3)?.trim()??"",f={apiKey:xx("gemini")||QI(),model:d&&!/^gemini-[12]\./.test(d)?d:ry},p={apiKey:xx("anthropic"),model:e?.getItem(O3)||es.anthropic.models[0].id},b={apiKey:xx("openai"),model:e?.getItem(P3)||es.openai.models[0].id},x=e?.getItem($3),g={apiKey:GI()??"",model:es.synlexa.models.some(k=>k.id===x)?x:ry},y={provider:i??(p.apiKey?"anthropic":f.apiKey?"gemini":b.apiKey?"openai":"synlexa"),routingPreference:s,enableWebSearch:c,synlexa:g,gemini:f,anthropic:p,openai:b},S=Xc(y);return{...y,provider:S.provider}}function JI(e){const r=I3();if(r){e.routingPreference&&r.setItem(R3,e.routingPreference),e.provider?r.setItem(Ud,e.provider):e.anthropic?.apiKey?.trim()?r.setItem(Ud,"anthropic"):e.gemini?.apiKey?.trim()?r.setItem(Ud,"gemini"):e.openai?.apiKey?.trim()&&r.setItem(Ud,"openai"),e.enableWebSearch!==void 0&&r.setItem(z3,e.enableWebSearch?"true":"false");const n=(s,i)=>{if(i===void 0)return;const c=i.trim();c?r.setItem(s,c):r.removeItem(s)};n(_3,e.gemini?.model),n(O3,e.anthropic?.model),n(P3,e.openai?.model),n($3,e.synlexa?.model)}return e.gemini?.apiKey!==void 0&&cp("gemini",e.gemini.apiKey),e.anthropic?.apiKey!==void 0&&cp("anthropic",e.anthropic.apiKey),e.openai?.apiKey!==void 0&&cp("openai",e.openai.apiKey),Ac()}function ZI(e){return e?e.length<=10?"••••":`${e.slice(0,6)}••••${e.slice(-4)}`:""}function Bv(e){const r={};for(const[n,s]of Object.entries(e.parameters.properties)){const i={type:s.type.toLowerCase(),description:s.description};s.enum&&(i.enum=s.enum),s.items&&(i.items={type:s.items.type.toLowerCase()}),r[n]=i}return{type:"object",properties:r,required:e.parameters.required??[]}}Tp.map(e=>({name:e.name,description:e.description,input_schema:Bv(e)}));function eD(e){return Ov(e).map(r=>({name:r.name,description:r.description,input_schema:Bv(r)}))}function tD(e){return Ov(e).map(r=>({type:"function",function:{name:r.name,description:r.description,parameters:Bv(r)}}))}function Qd(e,r,n,s){const i=d3(e.prompt,e.workspace);if(e.onFallbackAction)for(const f of i.actions)e.onFallbackAction(f);const c=i.reply.actionTaken?[{name:i.reply.command??"copilot",args:{},ok:!0,summary:i.reply.actionTaken,result:null,permissionStatus:"auto"}]:[],d=c.map((f,p)=>({round:p+1,phase:"tool",title:`${f.name} · ok`,detail:f.summary,toolName:String(f.name),ok:!0}));return{id:r,role:"assistant",mode:"local-deterministic-fallback",model:"deterministic-copilot",providerLabel:"Local Deterministic Copilot",text:`${s?`AI provider unavailable (${s}). Answered with the built-in deterministic assistant.
694
+
695
+ `:""}${i.reply.text}`,citations:i.reply.citations,thinkingTrace:i.reply.actionTaken?[`Matched local deterministic command: ${i.reply.actionTaken}`]:[],stepTrace:d,executedTools:c,timestampUtc:n,error:s}}function nD(e){return e instanceof aa.AuthenticationError?"invalid Anthropic API key":e instanceof aa.PermissionDeniedError?"this key cannot use the selected model":e instanceof aa.RateLimitError?"rate limited — try again shortly":e instanceof aa.BadRequestError?`request rejected: ${e.message}`:e instanceof aa.APIConnectionError?"network error reaching api.anthropic.com":e instanceof aa.APIError?`Anthropic API error ${e.status??""}`.trim():e instanceof Error?e.message:String(e)}async function sD(e){const r=new Date().toISOString(),n=`agent-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,s=new aa({apiKey:e.apiKey,dangerouslyAllowBrowser:!0,maxRetries:2,...e.fetchImpl?{fetch:e.fetchImpl}:{}}),i=[];for(const S of e.history.slice(-8)){if(!S.text.trim())continue;const k=S.role==="user"?"user":"assistant";i.length===0&&k==="assistant"||i.push({role:k,content:S.text})}i.push({role:"user",content:`[LIVE WORKSPACE STATE]
696
+ ${Tv(e.workspace)}
697
+
698
+ [USER REQUEST]
699
+ ${e.prompt}`});const c=[],d=[],f=[],p={inputTokens:0,outputTokens:0},b=Math.max(1,e.maxToolRounds??10),x=e.model==="claude-opus-5-5"||e.model==="claude-sonnet-5-5",g=eD(e.enableWebSearch!==!1),_=Date.now();let y=!0;try{for(let S=0;S<b;S++){const{step:k,startedAtMs:E}=Mv(d,S+1,"Anthropic BYOK",e.onProgress),T=async $=>s.beta.messages.create({model:e.model,max_tokens:16e3,system:Ev,tools:g,messages:i,...$?{thinking:{type:"adaptive",display:"summarized"}}:{},...x?{betas:["server-side-fallback-2026-07-01"],fallbacks:"default"}:{}});let j;try{j=await T(y)}catch($){if($ instanceof aa.BadRequestError&&y&&/thinking/i.test($.message))y=!1,j=await T(!1);else throw Wc(d,k),$}const q=Math.max(1,Date.now()-E);if(Wc(d,k),p.inputTokens+=j.usage.input_tokens??0,p.outputTokens+=j.usage.output_tokens??0,j.stop_reason==="refusal")return{id:n,role:"assistant",mode:"anthropic-api",model:j.model,providerLabel:`Anthropic BYOK (${j.model})`,text:"The model declined this request. Try rephrasing it as a research-use computational question.",thinkingTrace:f,stepTrace:d,executedTools:c,timestampUtc:r,durationMs:Math.max(1,Date.now()-_),usage:p};const z=j.content.filter($=>$.type==="thinking"&&typeof $.thinking=="string").map($=>$.thinking.trim()).filter(Boolean),O=j.content.filter($=>$.type==="tool_use"),V=j.content.filter($=>$.type==="text").map($=>$.text).join(`
700
+ `).trim();if(Rv({stepTrace:d,thinkingTrace:f,round:S+1,thoughts:z,preToolRationale:j.stop_reason==="tool_use"&&O.length>0?V:void 0,roundDurationMs:q,thoughtTitle:"Claude reasoning"}),j.stop_reason!=="tool_use"||O.length===0){if(j.stop_reason==="pause_turn"){i.push({role:"assistant",content:j.content});continue}Ds(e.onProgress,d);const $=V||"Done. Check the workspace tabs for updated results.",H=/research[- ]use[- ]only|\(ruo\)/i.test($);return{id:n,role:"assistant",mode:"anthropic-api",model:j.model,providerLabel:`Anthropic BYOK (${j.model})`,text:H?$:`${$}
701
+
702
+ _${Cn}_`,thinkingTrace:f,stepTrace:d,executedTools:c,citations:e.workspace.comparison?[`resultId:${e.workspace.comparison.resultId}`]:[],timestampUtc:r,durationMs:Math.max(1,Date.now()-_),usage:p}}Ds(e.onProgress,d),i.push({role:"assistant",content:j.content});const P=[];for(const $ of O){const H=$.input&&typeof $.input=="object"?$.input:{},Z=await zv({round:S+1,executeTool:e.executeTool,requestToolPermission:e.requestToolPermission,sessionApprovedCategories:e.sessionApprovedCategories,permissionPolicies:e.permissionPolicies,onProgress:e.onProgress,stepTrace:d,executedTools:c},$.name,H);P.push({type:"tool_result",tool_use_id:$.id,content:JSON.stringify({summary:Z.summary,data:Z.data}).slice(0,6e4),is_error:!Z.ok})}i.push({role:"user",content:P})}return{id:n,role:"assistant",mode:"anthropic-api",model:e.model,providerLabel:`Anthropic BYOK (${e.model})`,text:`Ran ${c.length} tool step(s). ${Cn}`,thinkingTrace:f,stepTrace:d,executedTools:c,timestampUtc:r,durationMs:Math.max(1,Date.now()-_),usage:p}}catch(S){const k=nD(S);return qc({provider:"anthropic",model:e.model,...p,error:!0}),Qd(e,n,r,k)}}async function aD(e){const r=new Date().toISOString(),n=`agent-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,s=e.fetchImpl??globalThis.fetch;if(typeof s!="function")return Qd(e,n,r,"fetch unavailable");const i=[{role:"system",content:Ev}];for(const y of e.history.slice(-8))y.text.trim()&&i.push({role:y.role==="user"?"user":"assistant",content:y.text});i.push({role:"user",content:`[LIVE WORKSPACE STATE]
703
+ ${Tv(e.workspace)}
704
+
705
+ [USER REQUEST]
706
+ ${e.prompt}`});const c=[],d=[],f=[],p={inputTokens:0,outputTokens:0},b=Math.max(1,e.maxToolRounds??10),x=tD(e.enableWebSearch!==!1),g=Date.now(),_=!/^(o\d|codex)/i.test(e.model);try{for(let y=0;y<b;y++){const{step:S,startedAtMs:k}=Mv(d,y+1,"OpenAI BYOK",e.onProgress),E=await s("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`},body:JSON.stringify({model:e.model,messages:i,tools:x,..._?{temperature:.2}:{}})}),T=await E.json().catch(()=>({}))??{};if(p.inputTokens+=T.usage?.prompt_tokens??0,p.outputTokens+=T.usage?.completion_tokens??0,!E.ok||T.error){Wc(d,S);const V=T.error?.message??`OpenAI HTTP ${E.status}`;return qc({provider:"openai",model:e.model,...p,error:!0}),Qd(e,n,r,V)}const j=Math.max(1,Date.now()-k);Wc(d,S);const q=T.choices?.[0]?.message,z=q?.reasoning_content?.trim()||q?.reasoning?.trim(),O=q?.tool_calls??[];if(Rv({stepTrace:d,thinkingTrace:f,round:y+1,thoughts:z?[z]:[],preToolRationale:O.length>0?q?.content?.trim():void 0,roundDurationMs:j,thoughtTitle:"Reasoning"}),O.length===0){Ds(e.onProgress,d);const V=(q?.content??"").trim()||"Completed requested analysis.",P=/research[- ]use[- ]only|\(ruo\)/i.test(V);return{id:n,role:"assistant",mode:"openai-api",model:T.model??e.model,providerLabel:`OpenAI BYOK (${T.model??e.model})`,text:P?V:`${V}
707
+
708
+ _${Cn}_`,thinkingTrace:f,stepTrace:d,executedTools:c,citations:e.workspace.comparison?[`resultId:${e.workspace.comparison.resultId}`]:[],timestampUtc:r,durationMs:Math.max(1,Date.now()-g),usage:p}}Ds(e.onProgress,d),i.push({role:"assistant",content:q?.content??null,tool_calls:O});for(const V of O){let P={};try{P=JSON.parse(V.function.arguments||"{}")}catch{P={}}const $=await zv({round:y+1,executeTool:e.executeTool,requestToolPermission:e.requestToolPermission,sessionApprovedCategories:e.sessionApprovedCategories,permissionPolicies:e.permissionPolicies,onProgress:e.onProgress,stepTrace:d,executedTools:c},V.function.name,P);i.push({role:"tool",tool_call_id:V.id,content:JSON.stringify({summary:$.summary,data:$.data}).slice(0,6e4)})}}return{id:n,role:"assistant",mode:"openai-api",model:e.model,providerLabel:`OpenAI BYOK (${e.model})`,text:`Ran ${c.length} tool step(s). ${Cn}`,thinkingTrace:f,stepTrace:d,executedTools:c,timestampUtc:r,durationMs:Math.max(1,Date.now()-g),usage:p}}catch(y){const S=y instanceof Error?y.message:String(y);return qc({provider:"openai",model:e.model,...p,error:!0}),Qd(e,n,r,S)}}async function rD(e){const{config:r}=e,s=Xc(r).provider,i=r[s]??{apiKey:"",model:""},c=e.enableWebSearch??r.enableWebSearch??!0;if(!i.apiKey){const f=new Date().toISOString(),p=Qd(e,`agent-${Date.now()}`,f);return qc({provider:"local",model:"deterministic-copilot",toolCalls:p.executedTools?.length??0}),p}let d;return s==="anthropic"?d=await sD({...e,enableWebSearch:c,apiKey:i.apiKey,model:i.model}):s==="openai"?d=await aD({...e,enableWebSearch:c,apiKey:i.apiKey,model:i.model}):s==="synlexa"?d=await tA({...e,enableWebSearch:c,model:i.model,transport:{endpoint:AI,headers:{Authorization:`Bearer ${i.apiKey}`}}}):d=await tA({...e,enableWebSearch:c,apiKey:i.apiKey,model:i.model}),d.mode!=="local-deterministic-fallback"?qc({provider:s,model:d.model??i.model,inputTokens:d.usage?.inputTokens,outputTokens:d.usage?.outputTokens,toolCalls:d.executedTools?.length??0}):s!=="anthropic"&&s!=="openai"&&qc({provider:s,model:i.model,error:!0}),d}const D3="synlexa.studio.computeNodes.v1",q3="synlexa.studio.activeComputeNode.v1",Gv="compute-node:";let sn=[],Fr=null,jc=[];const uy=new Set;function tl(){for(const e of uy)e()}function L3(e){return uy.add(e),()=>uy.delete(e)}function Di(){return{nodes:[...sn],activeNodeId:Fr,activeNode:sn.find(e=>e.id===Fr)??null,jobs:[...jc]}}function U3(e){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function iD(e){const r=U3();if(!r)return sn;try{const n=r.getItem(D3);if(n){const i=JSON.parse(n);Array.isArray(i)&&(sn=i.map(c=>({...c,online:!1})))}const s=r.getItem(q3);s&&(Fr=s)}catch{}return tl(),[...sn]}function mh(e){const r=U3();if(r)try{r.setItem(D3,JSON.stringify(sn)),Fr&&r.setItem(q3,Fr)}catch{}}function oD(e){const r=e.toLowerCase();return r.includes("trycloudflare.com")||r.includes("ngrok")||r.includes("colab")?"colab":r.includes("127.0.0.1")||r.includes("localhost")?"local":"remote"}function lD(e){const r=e.trim();if(!r)throw new Error("Pairing URI or endpoint is empty.");let n=r;if(n.startsWith("synlexa-node://")&&(n=n.slice(15)),!/^https?:\/\//i.test(n))throw new Error("Endpoint must begin with synlexa-node://, http://, or https://");let s;try{s=new URL(n)}catch{throw new Error("Malformed compute node URL.")}const i=s.hash?s.hash.slice(1).trim():"";s.hash="";const c=s.toString().replace(/\/+$/,"");return{endpoint:c,token:i,kind:oD(c)}}async function cD(e,r){const n=lD(e.pairingOrEndpoint),s=(e.token??n.token).trim(),i=e.kind??n.kind,c=sn.find(b=>b.endpoint===n.endpoint),d=c?.id??`node-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,f=i==="colab"?"Google Colab GPU":i==="local"?"Local Compute Daemon":"Remote GPU Node",p={id:d,label:e.label?.trim()||c?.label||f,kind:i,endpoint:n.endpoint,createdAtUtc:c?.createdAtUtc??new Date().toISOString(),lastCheckedUtc:c?.lastCheckedUtc??null,online:c?.online??!1,lastError:null,capabilities:c?.capabilities??null};return s&&await p3(`${Gv}${d}`,s),sn=c?sn.map(b=>b.id===d?p:b):[p,...sn],Fr=d,mh(),tl(),p}async function uD(e,r){await p3(`${Gv}${e}`,""),sn=sn.filter(n=>n.id!==e),Fr===e&&(Fr=sn[0]?.id??null),mh(),tl()}function dD(e,r){Fr=e,mh(),tl()}function Sh(e){return uI(`${Gv}${e}`)}async function iA(e,r=fetch,n){const s=sn.find(d=>d.id===e);if(!s)throw new Error(`Unknown compute node: ${e}`);const i=Sh(e),c=new Date().toISOString();try{const d=await r(`${s.endpoint}/v1/health`);if(!d.ok)throw new Error(`Health check HTTP ${d.status}`);const f=await r(`${s.endpoint}/v1/capabilities`,{headers:i?{"X-Synlexa-Compute-Token":i}:{}});if(!f.ok)throw new Error(f.status===401?"Compute token rejected (401). Re-paste pairing string.":`Capabilities check HTTP ${f.status}`);const p=await f.json();if(!p.ok||!p.data)throw new Error(p.error||"Malformed capabilities payload.");const b={...s,online:!0,lastCheckedUtc:c,lastError:null,capabilities:p.data};return sn=sn.map(x=>x.id===e?b:x),mh(n),tl(),b}catch(d){const f={...s,online:!1,lastCheckedUtc:c,lastError:d instanceof Error?d.message:String(d)};return sn=sn.map(p=>p.id===e?f:p),mh(),tl(),f}}function Hv(e,r){const n={...e,nodeId:r},s=jc.findIndex(i=>i.job_id===n.job_id);s>=0?jc=jc.map((i,c)=>c===s?n:i):jc=[n,...jc].slice(0,50),tl()}async function dy(e,r,n,s=fetch){const i=sn.find(p=>p.id===e);if(!i)throw new Error("No compute node selected.");const c=Sh(e);if(!c)throw new Error("Missing compute node token in encrypted vault.");const d=await s(`${i.endpoint}/v1/jobs`,{method:"POST",headers:{"Content-Type":"application/json","X-Synlexa-Compute-Token":c},body:JSON.stringify({toolId:r,params:n})}),f=await d.json();if(!d.ok||!f.ok||!f.job)throw new Error(f.error||`Job submission failed (HTTP ${d.status})`);return Hv(f.job,e),f.job}async function hD(e,r,n=fetch){const s=sn.find(f=>f.id===e);if(!s)throw new Error("Unknown compute node.");const i=Sh(e),c=await n(`${s.endpoint}/v1/jobs/${encodeURIComponent(r)}`,{headers:i?{"X-Synlexa-Compute-Token":i}:{}}),d=await c.json();if(!c.ok||!d.ok||!d.job)throw new Error(d.error||`Job status failed (HTTP ${c.status})`);return Hv(d.job,e),d.job}async function mD(e,r,n=fetch){const s=sn.find(f=>f.id===e);if(!s)throw new Error("Unknown compute node.");const i=Sh(e),c=await n(`${s.endpoint}/v1/jobs/${encodeURIComponent(r)}/cancel`,{method:"POST",headers:i?{"X-Synlexa-Compute-Token":i}:{}}),d=await c.json();if(!c.ok||!d.ok||!d.job)throw new Error(d.error||`Cancel failed (HTTP ${c.status})`);return Hv(d.job,e),d.job}async function hy(e,r,n){const c=fetch;for(let d=0;d<300;d++){const f=await hD(e,r,c);if(f.status==="completed"||f.status==="failed"||f.status==="cancelled")return f;await new Promise(p=>setTimeout(p,1200))}throw new Error("Timed out waiting for compute job completion.")}async function fD(e,r,n,s=fetch){const i=sn.find(b=>b.id===e);if(!i)throw new Error("Unknown compute node.");const c=Sh(e),d=await s(`${i.endpoint}/v1/jobs/${encodeURIComponent(r)}/artifacts/${encodeURIComponent(n.name)}`,{headers:c?{"X-Synlexa-Compute-Token":c}:{}});if(!d.ok)throw new Error(`Artifact download failed (HTTP ${d.status})`);const f=await d.text(),p=await Jc(f);if(n.sha256&&p!==n.sha256)throw new Error(`Artifact SHA-256 mismatch for ${n.name}: expected ${n.sha256}, got ${p}`);return f}function oA(e,r){if(!e)return null;const n=e.refDisplayAtoms?.ligands??[],s=n.find(c=>c.atoms.length>=4&&c.resName.toUpperCase()!=="HOH")??n.find(c=>c.atoms.length>0);if(s&&s.atoms.length>0){let c=1/0,d=-1/0,f=1/0,p=-1/0,b=1/0,x=-1/0;for(const _ of s.atoms){const[y,S,k]=_.xyz;y<c&&(c=y),y>d&&(d=y),S<f&&(f=S),S>p&&(p=S),k<b&&(b=k),k>x&&(x=k)}const g=10;return{center:[Number(((c+d)/2).toFixed(2)),Number(((f+p)/2).toFixed(2)),Number(((b+x)/2).toFixed(2))],size:[Number(Math.max(18,Math.min(36,d-c+g)).toFixed(1)),Number(Math.max(18,Math.min(36,p-f+g)).toFixed(1)),Number(Math.max(18,Math.min(36,x-b+g)).toFixed(1))],sourceLabel:`Ligand ${s.resName} ${s.chainId}:${s.seqId}`}}const i=e.refDisplayAtoms?.residues??[];if(r!==null){const c=i.find(d=>d.seqId===r);if(c)return{center:[Number(c.ca[0].toFixed(2)),Number(c.ca[1].toFixed(2)),Number(c.ca[2].toFixed(2))],size:[22,22,22],sourceLabel:`Residue ${c.resName3}${c.seqId}`}}if(i.length>0){let c=0,d=0,f=0;for(const b of i)c+=b.ca[0],d+=b.ca[1],f+=b.ca[2];const p=i.length;return{center:[Number((c/p).toFixed(2)),Number((d/p).toFixed(2)),Number((f/p).toFixed(2))],size:[26,26,26],sourceLabel:"Polymer centroid"}}return null}const B3="synlexa.studio.plugins.v1",Fv=[{schemaVersion:"1.0.0",id:"org.synlexa.molstar",name:"Mol* 3D Viewer",version:"5.13.1",category:"Molecular visualization",tier:"tier1-wasm",license:"MIT",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,description:"Browser-native WebGL 3D macromolecular viewer for cartoon, surface, ligand, and docking box inspection.",homepage:"https://github.com/molstar/molstar"},{schemaVersion:"1.0.0",id:"org.synlexa.rdkit-wasm",name:"RDKit Engine (WASM + Python 3D)",version:"2026.9.2",category:"Molecular modeling",tier:"tier1-wasm",license:"BSD-3-Clause",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,computeAdapterId:"rdkit_3d",installHint:"Built-in WASM in browser; optional `pip install rdkit` on Compute Node for 3D ETKDGv3",description:"Canonical SMILES, InChIKey, Morgan fingerprints, PAINS/Brenk alerts, 2D SVG, and ETKDGv3 conformers.",homepage:"https://github.com/rdkit/rdkit"},{schemaVersion:"1.0.0",id:"org.synlexa.openmm",name:"OpenMM Molecular Dynamics",version:"8.1",category:"Molecular dynamics",tier:"tier2-compute",license:"MIT / LGPL",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,computeAdapterId:"openmm_md",installHint:"conda install -c conda-forge openmm pdbfixer",description:"GPU-accelerated programmable MD (CUDA, OpenCL, Apple Metal, CPU) and energy minimization.",homepage:"https://github.com/openmm/openmm",mcpTools:[{name:"run_openmm_relaxation",description:"Run energy minimization / short MD relaxation on a PDB structure via connected Compute Node.",computeToolId:"openmm_md",inputSchema:{type:"object",properties:{steps:{type:"integer",description:"MD integration steps (0 for minimization only)."},temperatureK:{type:"number",description:"Simulation temperature in Kelvin (default 300)."}},required:[]}}]},{schemaVersion:"1.0.0",id:"org.synlexa.autodock-vina",name:"AutoDock Vina / Smina",version:"1.2.5",category:"Molecular docking",tier:"tier2-compute",license:"Apache-2.0",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,computeAdapterId:"vina_docking",installHint:"pip install vina meeko rdkit",description:"Classical protein-ligand docking and binding affinity pose prediction inside a defined 3D box.",homepage:"https://github.com/forlilab/AutoDock-Vina",mcpTools:[{name:"run_autodock_vina",description:"Dock the active SMILES ligand into the active reference protein on the connected Compute Node.",computeToolId:"vina_docking",inputSchema:{type:"object",properties:{ligandSmiles:{type:"string",description:"SMILES string of ligand to dock."},exhaustiveness:{type:"integer",description:"Search exhaustiveness (default 8)."}},required:["ligandSmiles"]}}]},{schemaVersion:"1.0.0",id:"org.synlexa.rfdiffusion",name:"RFdiffusion + ProteinMPNN",version:"1.1",category:"Protein design",tier:"tier2-compute",license:"BSD / MIT (check weights)",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,requiresGpu:!0,computeAdapterId:"rfdiffusion_design",installHint:"Install RFdiffusion + ProteinMPNN on Colab/Docker GPU Compute Node",description:"Generative de novo protein backbone scaffolds and binder design paired with inverse folding.",homepage:"https://github.com/RosettaCommons/RFdiffusion"},{schemaVersion:"1.0.0",id:"org.synlexa.gromacs",name:"GROMACS HPC MD",version:"2024",category:"Molecular dynamics",tier:"tier2-compute",license:"LGPL-2.1+ (external CLI)",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,computeAdapterId:"gromacs_md",installHint:"conda install -c conda-forge gromacs # external user-installed CLI",description:"High-throughput protein and membrane molecular dynamics executed via external `gmx` subprocess.",homepage:"https://github.com/gromacs/gromacs"},{schemaVersion:"1.0.0",id:"org.synlexa.boltz2",name:"Boltz-2 Structure & Complex AI",version:"2.0",category:"Protein structure prediction",tier:"tier2-compute",license:"MIT (code & weights)",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,requiresGpu:!0,computeAdapterId:"boltz_predict",installHint:"pip install boltz",description:"MIT-licensed biomolecular structure & protein-ligand complex prediction with confidence metrics.",homepage:"https://github.com/jwohlwend/boltz",mcpTools:[{name:"run_boltz2_prediction",description:"Predict a protein or protein-ligand complex structure using Boltz-2 on a connected GPU node.",computeToolId:"boltz_predict",inputSchema:{type:"object",properties:{sequence:{type:"string",description:"Amino acid sequence for chain A."},ligandSmiles:{type:"string",description:"Optional co-folded ligand SMILES."}},required:["sequence"]}}]},{schemaVersion:"1.0.0",id:"org.synlexa.pyscf",name:"PySCF Quantum Chemistry",version:"2.6",category:"Quantum chemistry",tier:"tier2-compute",license:"Apache-2.0",commercialSafe:!0,ruoRequired:!0,topPick:!0,builtin:!0,computeAdapterId:"pyscf_qm",installHint:"pip install pyscf",description:"DFT/HF electronic structure, HOMO-LUMO frontier energies, and dipole analysis for small ligands.",homepage:"https://github.com/pyscf/pyscf"},{schemaVersion:"1.0.0",id:"org.synlexa.gemmi-core",name:"Synlexa Bio-Core (Rust/Wasm)",version:"0.4.0",category:"Structural bioinformatics",tier:"tier0-core",license:"Apache-2.0",commercialSafe:!0,ruoRequired:!0,builtin:!0,description:"Deterministic PDB/mmCIF parsing, Kabsch float64 superposition, Ramachandran, peptide & CRISPR engine."},{schemaVersion:"1.0.0",id:"org.synlexa.chemprop",name:"Chemprop & DeepChem ML",version:"2.0",category:"Cheminformatics ML",tier:"tier2-compute",license:"MIT",commercialSafe:!0,ruoRequired:!0,builtin:!0,computeAdapterId:"ml_property",installHint:"pip install chemprop deepchem",description:"Message-passing neural network ADMET & molecular property inference on GPU/CPU nodes."},{schemaVersion:"1.0.0",id:"org.synlexa.workflows",name:"Nextflow & Snakemake Runner",version:"1.0",category:"Scientific workflow orchestration",tier:"tier2-compute",license:"Apache-2.0 / MIT",commercialSafe:!0,ruoRequired:!0,builtin:!0,computeAdapterId:"workflow_runner",installHint:"pip install snakemake # or install Nextflow CLI",description:"Export visual DAG pipelines as reproducible Nextflow/Snakemake scripts or execute on Compute Nodes."},{schemaVersion:"1.0.0",id:"org.synlexa.genomics-bio",name:"Biopython / HTSlib / SeqAn3",version:"1.83",category:"Genomics",tier:"tier2-compute",license:"BSD-3 / MIT",commercialSafe:!0,ruoRequired:!0,builtin:!0,installHint:"pip install biopython && conda install -c bioconda samtools",description:"Sequence, BAM/VCF/CRAM indexing and genomic alignment utilities."},{schemaVersion:"1.0.0",id:"org.synlexa.chembl-opentargets",name:"ChEMBL & Open Targets Connectors",version:"1.0",category:"Public databases",tier:"database",license:"CC-BY-SA-3.0 / Apache-2.0",commercialSafe:!0,ruoRequired:!0,builtin:!0,description:"Query ChEMBL bioactive molecules/IC50s and Open Targets target-disease evidence with provenance."},{schemaVersion:"1.0.0",id:"org.synlexa.openbabel-external",name:"Open Babel (User-Installed External)",version:"3.1",category:"Molecular modeling",tier:"tier2-compute",license:"GPL-2.0-external",commercialSafe:!1,ruoRequired:!0,builtin:!0,installHint:"External GPL-2.0 user binary only (never bundled): conda install -c conda-forge openbabel",description:"Optional external format converter when already installed by the user on a Compute Node."}],pD=Fv.filter(e=>e.commercialSafe).map(e=>e.id);let Hi=new Set(pD),nl=[];const my=new Set;function a0(){for(const e of my)e()}function gD(e){return my.add(e),()=>my.delete(e)}function G3(e){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function bD(e){const r=G3();if(r){try{const n=r.getItem(B3);if(!n)return;const s=JSON.parse(n);Array.isArray(s.enabledIds)&&(Hi=new Set(s.enabledIds)),Array.isArray(s.customPlugins)&&(nl=s.customPlugins)}catch{}a0()}}function Vv(e){const r=G3();if(r)try{const n={enabledIds:Array.from(Hi),customPlugins:nl};r.setItem(B3,JSON.stringify(n))}catch{}}function Jd(){return[...Fv,...nl].map(e=>({...e,enabled:Hi.has(e.id)}))}function H3(e,r,n){const s=r??!Hi.has(e);return s?Hi.add(e):Hi.delete(e),Vv(),a0(),s}function xD(e){if(!e||typeof e!="object")throw new Error("Plugin manifest must be a JSON object.");const r=e;if(r.schemaVersion!=="1.0.0")throw new Error('Plugin manifest schemaVersion must be "1.0.0".');const n=String(r.id??"").trim();if(!/^[a-z0-9][a-z0-9.-]{2,64}$/.test(n))throw new Error("Invalid plugin id (must be reverse-DNS lowercase, e.g. org.lab.my-tool).");const s=String(r.name??"").trim(),i=String(r.version??"").trim(),c=String(r.license??"").trim(),d=String(r.description??"").trim();if(!s||!i||!c||!d)throw new Error("Plugin manifest requires name, version, license, and description.");if(r.ruoRequired!==!0)throw new Error('All Synlexa Studio plugins must declare "ruoRequired": true.');if(r.homepage&&!/^https?:\/\//i.test(String(r.homepage)))throw new Error("Plugin homepage must use http:// or https://");return{schemaVersion:"1.0.0",id:n,name:s,version:i,category:r.category||"Drug discovery workflows",tier:r.tier||"tier2-compute",license:c,commercialSafe:!!r.commercialSafe,ruoRequired:!0,description:d,homepage:r.homepage?String(r.homepage):void 0,computeAdapterId:r.computeAdapterId?String(r.computeAdapterId):void 0,requiresGpu:!!r.requiresGpu,installHint:r.installHint?String(r.installHint):void 0,mcpTools:Array.isArray(r.mcpTools)?r.mcpTools:void 0,builtin:!1}}function yD(e,r){const n=typeof e=="string"?JSON.parse(e):e,s=xD(n);if(Fv.some(i=>i.id===s.id))throw new Error(`Cannot overwrite built-in plugin "${s.id}".`);return nl=[...nl.filter(i=>i.id!==s.id),s],Hi.add(s.id),Vv(),a0(),s}function _D(e,r){nl=nl.filter(n=>n.id!==e),Hi.delete(e),Vv(),a0()}const F3="synlexa.studio.projects.v1",V3="synlexa.studio.activeProjectId.v1";let Kt=[],Bs=null;const fy=new Set;function kh(){for(const e of fy)e()}function vD(e){return fy.add(e),()=>fy.delete(e)}function K3(e){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Ch(e){const r=K3();if(r)try{r.setItem(F3,JSON.stringify(Kt)),Bs&&r.setItem(V3,Bs)}catch{}}function wD(e){const r=K3();if(r)try{const n=r.getItem(F3);if(n){const i=JSON.parse(n);Array.isArray(i)&&(Kt=i)}const s=r.getItem(V3);s&&Kt.some(i=>i.id===s)&&(Bs=s)}catch{}if(Kt.length===0){const n=Kv();Kt=[n],Bs=n.id,Ch()}else Bs||(Bs=Kt[0].id);return kh(),[...Kt]}function Kv(){const e=new Date().toISOString();return{id:"proj-default",name:"Carbonic Anhydrase II Workspace",description:"Default RUO workspace for structure comparison, ligand design, peptide mutations, and CRISPR edits.",template:"structure-compare",createdAtUtc:e,updatedAtUtc:e,structures:[],molecules:[{id:"mol-azm",name:"Acetazolamide (AZM)",smiles:"CC(=O)Nc1nnc(S(N)(=O)=O)s1",note:"Reference 3HS4 inhibitor",addedAtUtc:e}],peptides:[],crisprs:[],notes:""}}function dp(){if(Kt.length===0){const r=Kv();Kt=[r],Bs=r.id}const e=Kt.find(r=>r.id===Bs)??Kt[0]??null;return{projects:[...Kt],activeProject:e}}function SD(e,r){const n=new Date().toISOString(),s=e.name.trim()||`Project ${Kt.length+1}`,i={id:`proj-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,name:s,description:e.description?.trim()||"Multi-molecule & structural biology RUO research project.",template:e.template??"blank",createdAtUtc:n,updatedAtUtc:n,structures:[],molecules:[],peptides:[],crisprs:[],notes:""};return Kt=[i,...Kt],Bs=i.id,Ch(),kh(),i}function vx(e,r){const n=Kt.find(s=>s.id===e)??null;return n?(Bs=n.id,Ch(),kh(),n):null}function kD(e,r){Kt=Kt.filter(n=>n.id!==e),Kt.length===0&&(Kt=[Kv()]),(Bs===e||!Kt.some(n=>n.id===Bs))&&(Bs=Kt[0].id),Ch(),kh()}function Nh(e,r){const s=dp().activeProject,i={...e(s),updatedAtUtc:new Date().toISOString()};return Kt=Kt.map(c=>c.id===s.id?i:c),Ch(),kh(),i}function wx(e,r){const n={...e,id:`str-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,addedAtUtc:new Date().toISOString()};return Nh(s=>{const i=s.structures.filter(c=>!(c.label===n.label&&c.role===n.role));return{...s,structures:[n,...i].slice(0,24)}}),n}function Sx(e,r){const n={...e,id:`mol-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,addedAtUtc:new Date().toISOString()};return Nh(s=>{const i=s.molecules.filter(c=>c.smiles!==n.smiles||c.name!==n.name);return{...s,molecules:[n,...i].slice(0,40)}}),n}function lA(e,r){const n={...e,id:`pep-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,addedAtUtc:new Date().toISOString()};return Nh(s=>({...s,peptides:[n,...s.peptides].slice(0,25)})),n}function cA(e,r){const n={...e,id:`cr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,addedAtUtc:new Date().toISOString()};return Nh(s=>({...s,crisprs:[n,...s.crisprs].slice(0,25)})),n}function CD(e,r,n){Nh(s=>e==="structure"?{...s,structures:s.structures.filter(i=>i.id!==r)}:e==="molecule"?{...s,molecules:s.molecules.filter(i=>i.id!==r)}:e==="peptide"?{...s,peptides:s.peptides.filter(i=>i.id!==r)}:{...s,crisprs:s.crisprs.filter(i=>i.id!==r)})}function ND(e,r){const n=e.replace(/\r\n?/g,`
709
+ `).split(`
710
+ `),s=e.trimStart().startsWith("data_")||e.includes("_atom_site."),i=r.replace(/\.(cif|mmcif|pdb|ent)$/i,""),c=new Map,d=new Map;if(s){const p=[];let b=!1,x=1;for(let g=0;g<n.length;g++){const _=n[g].trim();if(_==="loop_"){p.length=0,b=!1;continue}if(_.startsWith("_atom_site.")){p.push(_.slice(11)),b=!0;continue}if(!b||p.length===0)continue;if(!_||_.startsWith("#")||_.startsWith("_")||_==="loop_"){_==="loop_"&&(p.length=0,b=!1);continue}const y=_.match(/(?:'[^']*'|"[^"]*"|\S+)/g);if(!y||y.length<p.length)continue;const S=G=>{const K=p.indexOf(G);return K>=0?y[K].replace(/^['"]|['"]$/g,""):""},k=S("group_PDB")||"ATOM",E=(S("auth_atom_id")||S("label_atom_id")||"CA").slice(0,4),T=(S("auth_comp_id")||S("label_comp_id")||"UNK").slice(0,3);if(T==="HOH"||T==="WAT")continue;const j=(S("auth_asym_id")||S("label_asym_id")||"A").slice(0,1),q=Number.parseInt(S("auth_seq_id")||S("label_seq_id")||"1",10)||1,z=Number.parseFloat(S("Cartn_x")||"0")||0,O=Number.parseFloat(S("Cartn_y")||"0")||0,V=Number.parseFloat(S("Cartn_z")||"0")||0,P=Number.parseFloat(S("occupancy")||"1")||1,$=Number.parseFloat(S("B_iso_or_equiv")||"0")||0,H=(S("type_symbol")||"C").slice(0,2),Z=`${k.padEnd(6," ")}${String(x++%1e5).padStart(5," ")} ${E.padEnd(4," ")} ${T.padStart(3," ")} ${j}${String(q%1e4).padStart(4," ")} ${z.toFixed(3).padStart(8," ")}${O.toFixed(3).padStart(8," ")}${V.toFixed(3).padStart(8," ")}${P.toFixed(2).padStart(6," ")}${$.toFixed(2).padStart(6," ")} ${H.padStart(2," ")}`;if(k==="HETATM"){const G=`${T}_${j}`,K=d.get(G)??[];K.push(Z),d.set(G,K)}else{const G=c.get(j)??[];G.push(Z),c.set(j,G)}}}else for(const p of n)if(p.startsWith("ATOM ")){const b=(p.slice(21,22).trim()||"A").toUpperCase(),x=c.get(b)??[];x.push(p),c.set(b,x)}else if(p.startsWith("HETATM")){const b=p.slice(17,20).trim().toUpperCase();if(b==="HOH"||b==="WAT")continue;const x=(p.slice(21,22).trim()||"A").toUpperCase(),g=`${b}_${x}`,_=d.get(g)??[];_.push(p),d.set(g,_)}const f=[];for(const[p,b]of c.entries())f.push({label:`${i}_chain_${p}.pdb`,kind:"chain",chainId:p,pdbContent:`${b.join(`
711
+ `)}
712
+ TER
713
+ END
714
+ `,atomCount:b.length});for(const[p,b]of d.entries()){const x=p.split("_").pop()??"A";f.push({label:`${i}_ligand_${p}.pdb`,kind:"ligand",chainId:x,pdbContent:`${b.join(`
715
+ `)}
716
+ END
717
+ `,atomCount:b.length})}return f}const AD=[{id:"PAINS-rhodanine",family:"PAINS",label:"Rhodanine / ene-rhodanine motif",smarts:"O=C1NC(=S)SC1"},{id:"PAINS-catechol",family:"PAINS",label:"Catechol redox motif",smarts:"Oc1c(O)cccc1"},{id:"PAINS-quinone",family:"PAINS",label:"Para/ortho-quinone redox motif",smarts:"O=C1C=CC(=O)C=C1"},{id:"PAINS-ene-one",family:"PAINS",label:"Michael acceptor (alpha,beta-unsaturated carbonyl)",smarts:"[#6]=[#6]-[C](=O)-[#6,#7,#8]"},{id:"PAINS-azo",family:"PAINS",label:"Azo / diazo chromophore",smarts:"[#6]-N=N-[#6]"},{id:"Brenk-nitro",family:"Brenk",label:"Nitro group (potential mutagenic/redox alert)",smarts:"[N+](=O)[O-]"},{id:"Brenk-aldehyde",family:"Brenk",label:"Reactive aldehyde",smarts:"[CX3H1](=O)[#6]"},{id:"Brenk-epoxide",family:"Brenk",label:"Strained epoxide / oxirane",smarts:"C1OC1"},{id:"Brenk-sulfonyl-halide",family:"Brenk",label:"Sulfonyl halide (covalent modifier)",smarts:"S(=O)(=O)[F,Cl,Br,I]"},{id:"Brenk-acyl-halide",family:"Brenk",label:"Acyl halide",smarts:"C(=O)[F,Cl,Br,I]"},{id:"Brenk-azide",family:"Brenk",label:"Azide group",smarts:"[N-]=[N+]=[N-]"},{id:"Brenk-hydrazine",family:"Brenk",label:"Hydrazine / hydrazide motif",smarts:"[NX3][NX3]"},{id:"Brenk-thiol",family:"Brenk",label:"Free thiol",smarts:"[SX2H1]"}],Rp=new Uint8Array(256);for(let e=0;e<256;e++){let r=e,n=0;for(;r;)n+=r&1,r>>>=1;Rp[e]=n}function jD(e,r){const n=Math.min(e.length,r.length);let s=0,i=0;for(let c=0;c<n;c++)s+=Rp[e[c]&r[c]],i+=Rp[e[c]|r[c]];return i===0?0:s/i}function TD(e){let r=0;for(let n=0;n<e.length;n++)r+=Rp[e[n]];return r}function ED(e,r,n){const s=e.get_mol(r);if(!s||!s.is_valid())throw s?.delete(),new Error("RDKit could not parse molecule input.");try{return n(s)}finally{s.delete()}}function Y3(e){return e.replace(/fill:#FFFFFF;/gi,"fill:transparent;").replace(/stroke:#000000;/gi,"stroke:#cbd5e1;").replace(/fill:#000000;/gi,"fill:#e2e8f0;")}function W3(e,r){const n=new Set,s=new Set;try{const i=e.get_substruct_matches(r)||"[]",c=JSON.parse(i),d=Array.isArray(c)?c:[c];for(const f of d){if(Array.isArray(f.atoms))for(const p of f.atoms)n.add(p);if(Array.isArray(f.bonds))for(const p of f.bonds)s.add(p)}}catch{const i=JSON.parse(e.get_substruct_match(r)||"{}");if(Array.isArray(i.atoms))for(const c of i.atoms)n.add(c);if(Array.isArray(i.bonds))for(const c of i.bonds)s.add(c)}return{atoms:Array.from(n),bonds:Array.from(s)}}function MD(e,r,n){const s=r.trim();if(!s)throw new Error("Molecule input is empty.");const i=n?.width??340,c=n?.height??220;return ED(e,s,d=>{const f=d.get_smiles(),p=d.get_inchi(),b=p?e.get_inchikey_for_inchi(p):"",x=JSON.parse(d.get_descriptors());let g="";const _=d.copy();if(_)try{_.set_new_coords(!0),g=_.get_molblock()}finally{_.delete()}let y=[],S=[];if(n?.highlightSmarts?.trim()){const Se=e.get_qmol(n.highlightSmarts.trim());if(Se&&Se.is_valid())try{const Q=W3(d,Se);y=Q.atoms,S=Q.bonds}finally{Se.delete()}else Se?.delete()}const k=y.length>0?d.get_svg_with_highlights(JSON.stringify({width:i,height:c,atoms:y,bonds:S,highlightColour:[.22,.74,.97,.45]})):d.get_svg(i,c),E=[];for(const Se of AD){const Q=e.get_qmol(Se.smarts);if(!Q||!Q.is_valid()){Q?.delete();continue}try{const F=d.get_substruct_match(Q),he=JSON.parse(F||"{}");Array.isArray(he.atoms)&&he.atoms.length>0&&E.push({id:Se.id,family:Se.family,label:Se.label,smarts:Se.smarts,matchedAtoms:he.atoms})}finally{Q.delete()}}const T=d.get_morgan_fp_as_uint8array(JSON.stringify({radius:2,nBits:2048})),j=TD(T),q=Number(x.amw??0),z=Number(x.CrippenClogP??0),O=Number(x.lipinskiHBD??x.NumHBD??0),V=Number(x.lipinskiHBA??x.NumHBA??0),P=Number(x.tpsa??0),$=Number(x.NumRotatableBonds??0),H=Number(x.NumHeavyAtoms??0),Z=Number(x.CrippenMR??0);let G=0;q>500&&G++,z>5&&G++,O>5&&G++,V>10&&G++;const K=$<=10&&P<=140,we=q>=160&&q<=480&&z>=-.4&&z<=5.6&&Z>=40&&Z<=130&&H>=20&&H<=70;return{engine:"rdkit-wasm",rdkitVersion:e.version(),canonicalSmiles:f,inchi:p,inchiKey:b,molblock2d:g,svg:Y3(k),descriptors:{exactMass:Number(x.exactmw??0),molecularWeight:q,tpsa:P,crippenLogP:z,hbd:Number(x.NumHBD??0),hba:Number(x.NumHBA??0),rotatableBonds:$,heavyAtoms:H,totalAtoms:Number(x.NumAtoms??0),heteroatoms:Number(x.NumHeteroatoms??0),rings:Number(x.NumRings??0),aromaticRings:Number(x.NumAromaticRings??0),aliphaticRings:Number(x.NumAliphaticRings??0),fractionCsp3:Number(x.FractionCSP3??0),stereoCenters:Number(x.NumAtomStereoCenters??0),labuteAsa:Number(x.labuteASA??0),lipinskiHbd:O,lipinskiHba:V},rules:{lipinskiViolations:G,veberCompliant:K,ghoseCompliant:we},alerts:E,morganFpPopcount:j}})}function RD(e,r,n){const s=r.trim();if(!s)return[];const i=e.get_qmol(s),c=e.get_mol(s);if((!i||!i.is_valid())&&(!c||!c.is_valid()))throw i?.delete(),c?.delete(),new Error("Query must be a valid SMILES or SMARTS pattern.");const d=c&&c.is_valid()?c.get_morgan_fp_as_uint8array(JSON.stringify({radius:2,nBits:2048})):null,f=[];try{for(const p of n){const b=e.get_mol(p.smiles);if(!b||!b.is_valid()){b?.delete();continue}try{let x=[],g=[];if(i&&i.is_valid()){const k=W3(b,i);x=k.atoms,g=k.bonds}const _=b.get_morgan_fp_as_uint8array(JSON.stringify({radius:2,nBits:2048})),y=d?jD(d,_):x.length>0?1:0,S=Y3(x.length>0?b.get_svg_with_highlights(JSON.stringify({width:180,height:110,atoms:x,bonds:g,highlightColour:[.22,.74,.97,.45]})):b.get_svg(180,110));f.push({id:p.id,name:p.name,smiles:b.get_smiles(),substructureMatch:x.length>0,tanimoto:y,svg:S})}finally{b.delete()}}}finally{i?.delete(),c?.delete()}return f.sort((p,b)=>p.substructureMatch!==b.substructureMatch?p.substructureMatch?-1:1:b.tanimoto-p.tanimoto)}class Yv{worker=null;directModule=null;nextId=1;latestByChannel=new Map;pending=new Map;static fromModule(r){const n=new Yv;return n.directModule=r,n}ensureWorker(){if(this.worker)return this.worker;if(typeof Worker>"u")throw new Error("Web Worker is unavailable; use RdkitClient.fromModule() in Node tests.");const r=new Worker(new URL("/assets/rdkit.worker-BvevbBxc.js",import.meta.url),{type:"module"});return r.onmessage=n=>{const{id:s,cancelled:i,ok:c,data:d,error:f}=n.data,p=this.pending.get(s);p&&(this.pending.delete(s),i?p.reject(new Error("Cancelled stale RDKit request.")):c?p.resolve(d):p.reject(new Error(f||"RDKit WASM error")))},r.onerror=n=>{for(const[,s]of this.pending)s.reject(new Error(n.message||"RDKit worker failure"));this.pending.clear()},this.worker=r,r}cancelChannel(r){const n=this.nextId++;this.latestByChannel.set(r,n),this.worker?.postMessage({type:"cancel",channel:r,minId:n})}async run(r,n,s){if(this.directModule){if(n==="analyze"){const p=s;return MD(this.directModule,p.input,p)}const f=s;return RD(this.directModule,f.query,f.candidates)}const i=this.nextId++;this.latestByChannel.set(r,i);const c=this.ensureWorker(),d=await new Promise((f,p)=>{this.pending.set(i,{resolve:b=>f(b),reject:p}),c.postMessage({type:"run",id:i,channel:r,op:n,payload:s})});if((this.latestByChannel.get(r)??0)>i)throw new Error("Cancelled stale RDKit request.");return d}analyzeMolecule(r,n){return this.run("analyze","analyze",{input:r,...n})}searchLibrary(r,n){return this.run("search","search",{query:r,candidates:n})}dispose(){this.worker?.terminate(),this.worker=null,this.pending.clear()}}let kx=null;function Fo(){return kx||(kx=new Yv),kx}const Zn={load_structures:{kind:"load_structures",label:"Workspace Inputs",tier:"tier0-wasm",toolName:"synlexa-bio-core",inputPort:"files",outputPort:"Structure + SMILES",defaultParams:{useActiveWorkspace:!0}},kabsch_compare:{kind:"kabsch_compare",label:"Kabsch 3D Superpose",tier:"tier0-wasm",toolName:"synlexa_bio_core.wasm",inputPort:"Ref + Mob CIF/PDB",outputPort:"ComparisonResultV1",defaultParams:{}},rdkit_prep:{kind:"rdkit_prep",label:"RDKit Prep & PAINS",tier:"tier1-wasm",toolName:"@rdkit/rdkit WASM",inputPort:"SMILES / MOL",outputPort:"Canonical Ligand + Alerts",defaultParams:{}},vina_docking:{kind:"vina_docking",label:"AutoDock Vina Docking",tier:"tier2-gpu",toolName:"AutoDock Vina (Apache-2.0)",computeAdapterId:"vina_docking",inputPort:"Receptor + Ligand",outputPort:"Docked Poses (.pdbqt)",defaultParams:{exhaustiveness:8,numModes:9}},openmm_md:{kind:"openmm_md",label:"OpenMM Relaxation / MD",tier:"tier2-gpu",toolName:"OpenMM (MIT/LGPL)",computeAdapterId:"openmm_md",inputPort:"PDB Complex",outputPort:"Minimized PDB + Trajectory",defaultParams:{steps:1e3,temperatureK:300}},boltz_predict:{kind:"boltz_predict",label:"Boltz-2 Complex AI",tier:"tier2-gpu",toolName:"Boltz-2 (MIT)",computeAdapterId:"boltz_predict",inputPort:"Sequence + Ligand",outputPort:"Predicted CIF + pLDDT",defaultParams:{useMsaServer:!0}},rfdiffusion_design:{kind:"rfdiffusion_design",label:"RFdiffusion + ProteinMPNN",tier:"tier2-gpu",toolName:"RFdiffusion (BSD/MIT)",computeAdapterId:"rfdiffusion_design",inputPort:"Target PDB + Hotspots",outputPort:"Designed Backbones (.pdb)",defaultParams:{contigs:"[A1-60/0 50-70]",numDesigns:2}},pyscf_qm:{kind:"pyscf_qm",label:"PySCF DFT Orbitals",tier:"tier2-gpu",toolName:"PySCF (Apache-2.0)",computeAdapterId:"pyscf_qm",inputPort:"Ligand SMILES / XYZ",outputPort:"HOMO/LUMO & Dipole",defaultParams:{functional:"B3LYP",basis:"sto-3g"}},export_report:{kind:"export_report",label:"RUO Provenance Report",tier:"tier0-wasm",toolName:"reportGenerator",inputPort:"Verified Metrics",outputPort:"HTML + JSON Manifest",defaultParams:{format:"json"}}},Rc="Research-Use-Only (RUO). Computational estimates only; not for diagnostic or clinical decisions.",Zd=[{schemaVersion:"1.0.0",id:"tpl-hit-to-lead",name:"Hit-to-Lead Docking + OpenMM MD",ruoNotice:Rc,nodes:[{id:"n1",kind:"load_structures",x:30,y:110,params:{useActiveWorkspace:!0}},{id:"n2",kind:"rdkit_prep",x:255,y:40,params:{}},{id:"n3",kind:"kabsch_compare",x:255,y:185,params:{}},{id:"n4",kind:"vina_docking",x:485,y:110,params:{exhaustiveness:8,numModes:9}},{id:"n5",kind:"openmm_md",x:715,y:110,params:{steps:1e3,temperatureK:300}},{id:"n6",kind:"export_report",x:945,y:110,params:{format:"json"}}],edges:[{id:"e1",from:"n1",to:"n2"},{id:"e2",from:"n1",to:"n3"},{id:"e3",from:"n2",to:"n4"},{id:"e4",from:"n3",to:"n4"},{id:"e5",from:"n4",to:"n5"},{id:"e6",from:"n5",to:"n6"}]},{schemaVersion:"1.0.0",id:"tpl-binder-design",name:"De Novo Binder: RFdiffusion → Boltz-2",ruoNotice:Rc,nodes:[{id:"n1",kind:"load_structures",x:40,y:110,params:{useActiveWorkspace:!0}},{id:"n2",kind:"rfdiffusion_design",x:290,y:110,params:{contigs:"[A1-60/0 50-70]",numDesigns:2}},{id:"n3",kind:"boltz_predict",x:550,y:110,params:{useMsaServer:!0}},{id:"n4",kind:"export_report",x:810,y:110,params:{format:"json"}}],edges:[{id:"e1",from:"n1",to:"n2"},{id:"e2",from:"n2",to:"n3"},{id:"e3",from:"n3",to:"n4"}]},{schemaVersion:"1.0.0",id:"tpl-quantum-ligand",name:"Quantum Ligand Audit: RDKit → PySCF",ruoNotice:Rc,nodes:[{id:"n1",kind:"load_structures",x:40,y:110,params:{useActiveWorkspace:!0}},{id:"n2",kind:"rdkit_prep",x:290,y:110,params:{}},{id:"n3",kind:"pyscf_qm",x:550,y:110,params:{functional:"B3LYP",basis:"sto-3g"}},{id:"n4",kind:"export_report",x:810,y:110,params:{format:"json"}}],edges:[{id:"e1",from:"n1",to:"n2"},{id:"e2",from:"n2",to:"n3"},{id:"e3",from:"n3",to:"n4"}]},{schemaVersion:"1.0.0",id:"tpl-structure-audit",name:"Offline Structure Audit (Wasm Only)",ruoNotice:Rc,nodes:[{id:"n1",kind:"load_structures",x:40,y:110,params:{useActiveWorkspace:!0}},{id:"n2",kind:"kabsch_compare",x:300,y:110,params:{}},{id:"n3",kind:"rdkit_prep",x:560,y:110,params:{}},{id:"n4",kind:"export_report",x:820,y:110,params:{format:"json"}}],edges:[{id:"e1",from:"n1",to:"n2"},{id:"e2",from:"n2",to:"n3"},{id:"e3",from:"n3",to:"n4"}]}];function fh(e){const r=new Map,n=new Map,s=new Map;for(const d of e.nodes)r.set(d.id,d),n.set(d.id,0),s.set(d.id,[]);for(const d of e.edges){if(!r.has(d.from)||!r.has(d.to))throw new Error(`Edge ${d.id} references unknown node.`);if(d.from===d.to)throw new Error(`Self-loop detected on node ${d.from}.`);s.get(d.from).push(d.to),n.set(d.to,(n.get(d.to)??0)+1)}const i=[];for(const[d,f]of n.entries())f===0&&i.push(d);const c=[];for(;i.length>0;){const d=i.shift();c.push(r.get(d));for(const f of s.get(d)??[]){const p=(n.get(f)??0)-1;n.set(f,p),p===0&&i.push(f)}}if(c.length!==e.nodes.length)throw new Error("Workflow graph contains a cycle; DAG execution requires acyclic edges.");return c}function X3(e){const r=fh(e),n=r.map((i,c)=>{const d=Zn[i.kind];return`process ${`${i.kind}_${c+1}`.toUpperCase()} {
718
+ tag "${d.label}"
719
+ input:
720
+ val prev_meta
721
+ output:
722
+ path "${i.id}_output.json"
723
+ script:
724
+ """
725
+ echo '{"node":"${i.id}","kind":"${i.kind}","tool":"${d.toolName}","ruo":true}' > ${i.id}_output.json
726
+ """
727
+ }`}),s=r.map((i,c)=>{const d=`${i.kind}_${c+1}`.toUpperCase();return c===0?` ch_0 = ${d}(Channel.of("init"))`:` ch_${c} = ${d}(ch_${c-1})`});return`#!/usr/bin/env nextflow
728
+ // Synlexa Studio Exported Pipeline: ${e.name}
729
+ // ${Rc}
730
+ nextflow.enable.dsl=2
731
+
732
+ ${n.join(`
733
+
734
+ `)}
735
+
736
+ workflow {
737
+ ${s.join(`
738
+ `)}
739
+ }
740
+ `}function Q3(e){const r=fh(e),n=r.length>0?`${r[r.length-1].id}_output.json`:"pipeline_done.json",s=r.map((i,c)=>{const d=Zn[i.kind],f=c===0?"":`
741
+ input:
742
+ "${r[c-1].id}_output.json"`;return`rule step_${c+1}_${i.kind}:${f}
743
+ output:
744
+ "${i.id}_output.json"
745
+ message:
746
+ "Running ${d.label} (${d.toolName})"
747
+ shell:
748
+ """echo '{{"node": "${i.id}", "kind": "${i.kind}", "ruo": true}}' > {output}"""`});return`# Synlexa Studio Exported Snakefile: ${e.name}
749
+ # ${Rc}
750
+
751
+ rule all:
752
+ input:
753
+ "${n}"
754
+
755
+ ${s.join(`
756
+
757
+ `)}
758
+ `}const zD="2024-11-05",py={name:"synlexa-studio-mcp",version:"0.4.4",description:"Deterministic computational biology, structural superposition, CRISPR, SMILES, and scientific web MCP server (RUO)."},eh=[],gy=new Set;function J3(){for(const e of gy)e()}function uA(){return[...eh]}function OD(){eh.length=0,J3()}function PD(e){return gy.add(e),()=>gy.delete(e)}function Z3(e){eh.unshift(e),eh.length>100&&(eh.length=100),J3()}function $D(e){const r={};for(const[n,s]of Object.entries(e.parameters.properties)){const i={type:s.type.toLowerCase(),description:s.description};s.enum&&(i.enum=s.enum),s.items&&(i.items={type:s.items.type.toLowerCase()}),r[n]=i}return{type:"object",properties:r,required:e.parameters.required??[]}}const Lc=Tp.map(e=>({name:e.name,description:e.description,inputSchema:$D(e)}));function by(){const e=[];for(const r of Jd())if(!(r.builtin||!r.enabled||!r.mcpTools))for(const n of r.mcpTools)e.push({name:n.name,description:`[Plugin: ${r.name}] ${n.description}`,inputSchema:n.inputSchema});return[...Lc,...e]}const Bd=[{uri:"synlexa://workspace/summary",name:"Live Workspace Summary",description:"Overview of loaded structures, RMSD, coverage, active-site contacts, and workbench state.",mimeType:"application/json"},{uri:"synlexa://workspace/comparison",name:"Kabsch Superposition Result",description:"Full ComparisonResultV1 metrics, 4x4 rigid transform matrix, and top deviating residues.",mimeType:"application/json"},{uri:"synlexa://workspace/peptide",name:"Peptide Engineering State",description:"Wild-type vs engineered biophysical descriptors, pH titration delta, and 5.0 Å 3D contacts.",mimeType:"application/json"},{uri:"synlexa://workspace/crispr",name:"CRISPR & Coding Transcript Analysis",description:"Codon translation consequence and SpCas9/SaCas9/Cas12a PAM site scan.",mimeType:"application/json"},{uri:"synlexa://workspace/chemistry",name:"Ligands & SMILES Descriptors",description:"Formula, molecular weight, TPSA, cLogP, Lipinski/Veber metrics, and 2D layout.",mimeType:"application/json"},{uri:"synlexa://workspace/ramachandran",name:"Ramachandran Geometry & Contacts",description:"Backbone (φ, ψ) angles, secondary structure fractions, and Cα–Cα contact pairs.",mimeType:"application/json"},{uri:"synlexa://library/catalog",name:"Local Molecule Library Catalog",description:"Structures, ligands, and sequences saved in IndexedDB with SHA-256 provenance.",mimeType:"application/json"},{uri:"synlexa://vault/status",name:"Encrypted BYOK Vault Status",description:"Non-secret metadata and backend status for local state.vscdb key storage.",mimeType:"application/json"}],dA=[{name:"structural-deviation-audit",description:"Audit Kabsch RMSD, coverage denominators, PAE uncertainty, and top deviating residues (RUO).",arguments:[{name:"focus_chain",description:"Chain ID to examine (e.g. A)",required:!1}]},{name:"active-site-mutation-scan",description:"Evaluate a point mutation in the active site along with 5.0 Å local 3D contacts.",arguments:[{name:"mutation",description:"Mutation notation such as H94A",required:!0}]},{name:"crispr-codon-pam-plan",description:"Inspect coding codon edit consequence and enumerate SpCas9/Cas12a PAM windows.",arguments:[{name:"transcript",description:"RefSeq transcript ID (e.g. NM_000067.3)",required:!0}]},{name:"literature-evidence-check",description:"Query Europe PMC and ClinicalTrials.gov via search_scientific_web with verified PMIDs/NCTs.",arguments:[{name:"topic",description:"Biomarker, protein, or ligand query",required:!0}]}];function Ii(e,r,n="all",s=10){const i=Math.max(1,Math.min(50,s)),c=f=>n==="all"||n===f,d={ruoNotice:"For research and development use. Not for diagnostic or treatment decisions.",capturedAtUtc:new Date().toISOString()};return c("comparison")&&(d.structures={refLabel:e.refLabel,refChain:e.refChain,refSha256:e.comparison?.reference.sha256??e.refInspect?.sha256??null,refConfidenceKind:e.comparison?.reference.confidenceKind??e.refInspect?.confidenceKind??null,mobLabel:e.mobLabel,mobChain:e.mobChain,mobSha256:e.comparison?.mobile.sha256??e.mobInspect?.sha256??null,mobConfidenceKind:e.comparison?.mobile.confidenceKind??e.mobInspect?.confidenceKind??null,comparison:e.comparison?{resultId:e.comparison.resultId,metrics:e.comparison.metrics,topDeviatingResidues:[...e.comparison.matchedResidues].sort((f,p)=>p.distanceAngstrom-f.distanceAngstrom).slice(0,i),ligands:e.comparison.refDisplayAtoms?.ligands.map(f=>({resName:f.resName,chainId:f.chainId,seqId:f.seqId,atomCount:f.atoms.length}))}:null}),c("contacts")&&(d.activeSiteContacts=(e.comparison?.refContacts??[]).slice(0,i)),c("peptide")&&(d.peptide=e.peptide?{appliedMutations:e.peptide.appliedMutations,wildType:e.peptide.wildType,engineered:e.peptide.engineered,deltas:e.peptide.deltas,local3dContacts:e.peptide.local3dContacts.slice(0,i)}:null),c("crispr")&&(d.crispr=e.crispr?{transcriptId:e.crispr.transcriptId,geneSymbol:e.crispr.geneSymbol,cdsLengthBp:e.crispr.cdsLengthBp,targetCodon:e.crispr.targetCodon,pamSitesCount:e.crispr.pamSites.length,topPamSites:e.crispr.pamSites.slice(0,i)}:null),c("chemistry")&&(d.chemistry=e.smiles?{name:e.smiles.name,smiles:e.smiles.smiles,formula:e.smiles.formula,molecularWeight:e.smiles.molecularWeight,exactMass:e.smiles.exactMass,tpsa:e.smiles.tpsa,crippenLogP:e.smiles.crippenLogP,hbd:e.smiles.hbd,hba:e.smiles.hba,rotatableBonds:e.smiles.rotatableBonds,ringCount:e.smiles.ringCount,lipinskiViolations:e.smiles.lipinskiViolations,veberCompliant:e.smiles.veberCompliant}:null),c("ramachandran")&&(d.ramachandran=e.ramachandran?{chainId:e.ramachandran.chainId,residueCount:e.ramachandran.residueCount,secondaryCounts:e.ramachandran.secondaryCounts,regionCounts:e.ramachandran.regionCounts,contactPairsCount:e.ramachandran.contactPairs.length,outliers:e.ramachandran.residues.filter(f=>f.region==="outlier").slice(0,i)}:null),c("library")&&(d.library=r.slice(0,i).map(f=>({id:f.id,kind:f.kind,name:f.name,format:f.format,sha256:f.sha256,sizeBytes:f.sizeBytes,source:f.source}))),d}function ID(e,r,n){let s;switch(e){case"synlexa://workspace/summary":s=Ii(r,n,"all",10);break;case"synlexa://workspace/comparison":s=Ii(r,n,"comparison",25);break;case"synlexa://workspace/peptide":s=Ii(r,n,"peptide",20);break;case"synlexa://workspace/crispr":s=Ii(r,n,"crispr",20);break;case"synlexa://workspace/chemistry":s=Ii(r,n,"chemistry",20);break;case"synlexa://workspace/ramachandran":s=Ii(r,n,"ramachandran",25);break;case"synlexa://library/catalog":s=Ii(r,n,"library",50);break;case"synlexa://vault/status":s=Zo();break;default:throw new Error(`Unknown MCP resource URI: ${e}`)}return{contents:[{uri:e,mimeType:"application/json",text:JSON.stringify(s,null,2)}]}}async function eE(e,r,n,s="internal-ai-agent"){const i=typeof performance<"u"?performance.now():Date.now();let c;try{c=await e.executeTool(r,n)}catch(f){const p=f instanceof Error?f.message:String(f);c={ok:!1,summary:p,data:{error:p}}}const d=typeof performance<"u"?performance.now():Date.now();return Z3({id:`mcp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestampUtc:new Date().toISOString(),caller:s,method:"tools/call",target:r,ok:c.ok,durationMs:Math.max(0,Math.round(d-i)),summary:c.summary,requestPayload:n,responsePreview:c.data}),c}async function hA(e,r,n="mcp-playground"){const s=e.id??null,i=typeof performance<"u"?performance.now():Date.now(),c=e.params??{};try{switch(e.method){case"initialize":return{jsonrpc:"2.0",id:s,result:{protocolVersion:zD,serverInfo:py,capabilities:{tools:{listChanged:!1},resources:{subscribe:!1,listChanged:!1},prompts:{listChanged:!1}}}};case"ping":return{jsonrpc:"2.0",id:s,result:{}};case"tools/list":return{jsonrpc:"2.0",id:s,result:{tools:by()}};case"tools/call":{const d=String(c.name??""),f=c.arguments&&typeof c.arguments=="object"?c.arguments:{};if(!by().some(b=>b.name===d))return{jsonrpc:"2.0",id:s,error:{code:-32601,message:`Unknown MCP tool: ${d}`}};const p=await eE(r,d,f,n);return{jsonrpc:"2.0",id:s,result:{isError:!p.ok,content:[{type:"text",text:JSON.stringify({summary:p.summary,data:p.data},null,2)}]}}}case"resources/list":return{jsonrpc:"2.0",id:s,result:{resources:Bd}};case"resources/read":{const d=String(c.uri??""),f=ID(d,r.workspace,r.libraryItems),p=typeof performance<"u"?performance.now():Date.now();return Z3({id:`mcp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,timestampUtc:new Date().toISOString(),caller:n,method:"resources/read",target:d,ok:!0,durationMs:Math.max(0,Math.round(p-i)),summary:`Read resource ${d}`,requestPayload:c}),{jsonrpc:"2.0",id:s,result:f}}case"prompts/list":return{jsonrpc:"2.0",id:s,result:{prompts:dA}};case"prompts/get":{const d=String(c.name??""),f=dA.find(b=>b.name===d);if(!f)return{jsonrpc:"2.0",id:s,error:{code:-32602,message:`Unknown MCP prompt: ${d}`}};const p=c.arguments&&typeof c.arguments=="object"?c.arguments:{};return{jsonrpc:"2.0",id:s,result:{description:f.description,messages:[{role:"user",content:{type:"text",text:`[Synlexa Studio RUO MCP Prompt: ${f.name}] Arguments: ${JSON.stringify(p)}. Inspect synlexa://workspace/summary first, use deterministic Studio MCP tools, and cite verified provenance only.`}}]}}}default:return{jsonrpc:"2.0",id:s,error:{code:-32601,message:`Method not found: ${e.method}`}}}}catch(d){return{jsonrpc:"2.0",id:s,error:{code:-32e3,message:d instanceof Error?d.message:String(d)}}}}function DD(e=4179){return{claudeDesktopJson:JSON.stringify({mcpServers:{"synlexa-studio":{command:"synlexa-studio",args:["mcp","--stdio"]}}},null,2),claudeCodeCmd:"claude mcp add synlexa-studio -- synlexa-studio mcp --stdio",codexCliCmd:"codex mcp add synlexa-studio -- synlexa-studio mcp --stdio",codexConfigToml:`[mcp_servers.synlexa_studio]
759
+ command = "synlexa-studio"
760
+ args = ["mcp", "--stdio"]`,httpEndpointJson:JSON.stringify({mcpServers:{"synlexa-studio-http":{url:`http://127.0.0.1:${e}/mcp`,transport:"http"}}},null,2)}}const mA=[{source:"pinned-reference",sourceType:"pinned_fixture_citation",identifier:"PDB:3HS4",pmid:null,pmcid:null,doi:"10.2210/pdb3HS4/pdb",nctId:null,title:"Crystal structure of human carbonic anhydrase II complexed with acetazolamide (1.10 Å, PDB 3HS4)",authorsOrSponsor:"Sjoblom et al.",journalOrStatus:"RCSB Protein Data Bank (CC0-1.0)",yearOrPhase:"2009 / rev 2025-09-25",snippet:"Bundled SHA-256 verified reference structure 3HS4.cif in Synlexa Studio local fixtures.",sourceUrl:"https://www.rcsb.org/structure/3HS4",extractionMethod:"pinned-manifest-record"},{source:"pinned-reference",sourceType:"pinned_fixture_citation",identifier:"AF-P00918-F1",pmid:null,pmcid:null,doi:null,nctId:null,title:"AlphaFold Protein Structure Database prediction for Human Carbonic Anhydrase 2 (UniProt P00918, v6)",authorsOrSponsor:"Jumper et al. / Varadi et al. (EMBL-EBI / Google DeepMind)",journalOrStatus:"AlphaFold DB v6 (CC-BY-4.0)",yearOrPhase:"2025-08-01",snippet:"Bundled SHA-256 verified model AF-P00918-F1-model_v6.cif and 260x260 PAE JSON.",sourceUrl:"https://alphafold.ebi.ac.uk/entry/P00918",extractionMethod:"pinned-manifest-record"}];function In(e){if(typeof e!="string")return null;const r=e.trim();return r.length>0?r:null}function tE(e,r=320){if(!e)return null;const n=e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim();return n.length<=r?n:`${n.slice(0,r-1)}…`}async function qD(e,r,n,s,i){const c=`https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=${encodeURIComponent(e)}&format=json&resultType=core&pageSize=${r}`,d=await n(c,{signal:i});if(!d.ok)throw new Error(`Europe PMC returned HTTP ${d.status}`);const f=await d.json();return(Array.isArray(f?.resultList?.result)?f.resultList.result:[]).map(b=>{const x=In(b.pmid),g=In(b.pmcid),_=In(b.doi),y=In(b.id)??x??g??_??"epmc-record",S=In(b.source)??"MED",k=S==="PPR",E=x?`https://pubmed.ncbi.nlm.nih.gov/${encodeURIComponent(x)}/`:g?`https://europepmc.org/article/PMC/${encodeURIComponent(g)}`:_?`https://doi.org/${_}`:`https://europepmc.org/article/${encodeURIComponent(S)}/${encodeURIComponent(y)}`;return{source:"europepmc",sourceType:k?"preprint":"peer_reviewed_literature",identifier:x?`PMID:${x}`:g?`PMCID:${g}`:_?`DOI:${_}`:y,pmid:x,pmcid:g,doi:_,nctId:null,title:In(b.title)??"Untitled Europe PMC record",authorsOrSponsor:In(b.authorString),journalOrStatus:In(b.journalTitle)??In(b.bookOrReportDetails?.toString?.()),yearOrPhase:In(b.pubYear),snippet:tE(In(b.abstractText)),sourceUrl:E,retrievedAtUtc:s,extractionMethod:"europepmc-rest-api"}})}async function LD(e,r,n,s,i){const c=`https://clinicaltrials.gov/api/v2/studies?query.term=${encodeURIComponent(e)}&pageSize=${r}`,d=await n(c,{signal:i});if(!d.ok)throw new Error(`ClinicalTrials.gov returned HTTP ${d.status}`);const f=await d.json();return(Array.isArray(f?.studies)?f.studies:[]).map(b=>{const x=b.protocolSection?.identificationModule,g=b.protocolSection?.statusModule,_=b.protocolSection?.designModule,y=b.protocolSection?.descriptionModule,S=In(x?.nctId)??"NCT_UNKNOWN",k=Array.isArray(_?.phases)&&_.phases.length>0?_.phases.join(", "):null,E=Array.isArray(b.protocolSection?.conditionsModule?.conditions)?b.protocolSection.conditionsModule.conditions.slice(0,3).join(", "):null;return{source:"clinicaltrials",sourceType:"trial_registry",identifier:S,pmid:null,pmcid:null,doi:null,nctId:S,title:In(x?.briefTitle)??`ClinicalTrials.gov study ${S}`,authorsOrSponsor:In(x?.organization?.fullName),journalOrStatus:In(g?.overallStatus),yearOrPhase:[k,In(g?.startDateStruct?.date)].filter(Boolean).join(" · ")||null,snippet:tE(In(y?.briefSummary)??E),sourceUrl:`https://clinicaltrials.gov/study/${encodeURIComponent(S)}`,retrievedAtUtc:s,extractionMethod:"clinicaltrials-gov-apiv2"}})}async function UD(e,r={}){const n=e.trim(),s=r.scope??"all",i=Math.max(1,Math.min(8,r.limit??5)),c=new Date().toISOString(),d=[];if(!n)throw new Error("Web search query must not be empty.");const f=r.fetchImpl??globalThis.fetch;if(!!r.offline||typeof navigator<"u"&&navigator.onLine===!1||typeof f!="function"){const g=n.toLowerCase().split(/\s+/).filter(Boolean),_=mA.filter(y=>{const S=`${y.identifier} ${y.title} ${y.snippet??""}`.toLowerCase();return g.some(k=>S.includes(k))}).map(y=>({...y,retrievedAtUtc:c}));return{query:n,scope:s,origin:"offline-fallback",retrievedAtUtc:c,hits:_,warnings:["Offline mode or unavailable network: returned pinned local citations only."]}}const b=[],x=[];if((s==="all"||s==="literature")&&x.push(qD(n,i,f,c,r.signal).then(g=>{b.push(...g)}).catch(g=>{d.push(g instanceof Error?g.message:String(g))})),(s==="all"||s==="trials")&&x.push(LD(n,Math.min(4,i),f,c,r.signal).then(g=>{b.push(...g)}).catch(g=>{d.push(g instanceof Error?g.message:String(g))})),await Promise.all(x),b.length===0&&d.length>0){const g=n.toLowerCase().split(/\s+/).filter(Boolean),_=mA.filter(y=>{const S=`${y.identifier} ${y.title} ${y.snippet??""}`.toLowerCase();return g.some(k=>S.includes(k))}).map(y=>({...y,retrievedAtUtc:c}));return{query:n,scope:s,origin:"offline-fallback",retrievedAtUtc:c,hits:_,warnings:d}}return{query:n,scope:s,origin:"live-network",retrievedAtUtc:c,hits:b,warnings:d}}const zc={uiScale:1,guidedMode:!0,restoreTabs:!0,autoSaveImports:!0,confirmDeletes:!0,loadDemoOnStart:!0,viewer:{defaultStyle:"ribbon",defaultColorMode:"identity",defaultLayout:"overlay",embedPngInReports:!0}},nE=.85,sE=1.35,aE=.05,rE="synlexa.studio.settings.v2",xy=new Set;function Wv(e){return Number.isFinite(e)?Math.round(Math.min(sE,Math.max(nE,e))*100)/100:1}function BD(){try{const e=localStorage.getItem(rE);if(!e)return zc;const r=JSON.parse(e);return{...zc,...r,uiScale:Wv(r.uiScale??1),viewer:{...zc.viewer,...r.viewer??{}}}}catch{return zc}}let th=typeof localStorage<"u"?BD():zc;function Xv(){return th}function Qv(e){const r=typeof e=="function"?e(th):{...th,...e};r.uiScale=Wv(r.uiScale),th=r;try{localStorage.setItem(rE,JSON.stringify(r))}catch{}Jv(r.uiScale);for(const n of xy)n(r);return r}function GD(){return Qv(zc)}function Jv(e){typeof document>"u"||(document.documentElement.style.fontSize=`${16*Wv(e)}px`)}function Cx(e){const r=Xv();Qv({uiScale:e===0?1:r.uiScale+e*aE})}function Zv(){const[e,r]=C.useState(th);C.useEffect(()=>(xy.add(r),()=>{xy.delete(r)}),[]);const n=C.useCallback(Qv,[]);return[e,n]}const HD="synlexa_studio_library",zp="items",Ah=new Map,yy=new Set;function jh(){for(const e of yy)e()}function r0(e){return yy.add(e),()=>yy.delete(e)}let Wf=null;function Th(){return Wf||(Wf=new Promise(e=>{if(typeof indexedDB>"u")return e(null);try{const r=indexedDB.open(HD,1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(zp)||n.createObjectStore(zp,{keyPath:"id"}).createIndex("sha256","sha256",{unique:!1})},r.onsuccess=()=>e(r.result),r.onerror=()=>e(null)}catch{e(null)}}),Wf)}function Eh(e,r,n){return new Promise((s,i)=>{const c=e.transaction(zp,r),d=n(c.objectStore(zp));d.onsuccess=()=>s(d.result),d.onerror=()=>i(d.error)})}function iE(){const e=new Uint8Array(8);return globalThis.crypto?.getRandomValues?.(e),`lib_${Date.now().toString(36)}_${Array.from(e,r=>r.toString(16).padStart(2,"0")).join("")}`}async function nu(){const e=await Th();return(e?await Eh(e,"readonly",n=>n.getAll()):Array.from(Ah.values())).sort((n,s)=>n.favorite!==s.favorite?n.favorite?-1:1:(s.lastOpenedAtUtc??s.updatedAtUtc).localeCompare(n.lastOpenedAtUtc??n.updatedAtUtc))}async function oE(e){const r=await Th();return r?await Eh(r,"readonly",n=>n.get(e))??null:Ah.get(e)??null}async function e1(e){const r=await Th();r?await Eh(r,"readwrite",n=>n.put(e)):Ah.set(e.id,e)}async function t1(e){const r=await Jc(e.content),n=(await nu()).find(c=>c.sha256===r&&c.kind===e.kind);if(n)return{item:n,duplicate:!0};const s=new Date().toISOString(),i={...e,id:iE(),sha256:r,sizeBytes:new TextEncoder().encode(e.content).byteLength,tags:e.tags??[],notes:e.notes??"",favorite:e.favorite??!1,createdAtUtc:s,updatedAtUtc:s,lastOpenedAtUtc:null};return await e1(i),jh(),{item:i,duplicate:!1}}async function n1(e,r){const n=await oE(e);if(!n)return null;const s={...n,...r};return r.content!==void 0&&r.content!==n.content&&(s.sha256=await Jc(r.content),s.sizeBytes=new TextEncoder().encode(r.content).byteLength,s.source={...n.source,origin:"manual"}),r.lastOpenedAtUtc===void 0&&(s.updatedAtUtc=new Date().toISOString()),await e1(s),jh(),s}async function FD(e){const r=await oE(e);if(!r)return null;const n=new Date().toISOString(),s={...r,id:iE(),name:`${r.name} (copy)`,favorite:!1,createdAtUtc:n,updatedAtUtc:n,lastOpenedAtUtc:null};return await e1(s),jh(),s}async function VD(e){const r=await Th();for(const n of e)r?await Eh(r,"readwrite",s=>s.delete(n)):Ah.delete(n);jh()}async function KD(){const e=await Th();e?await Eh(e,"readwrite",r=>r.clear()):Ah.clear(),jh()}async function lE(e,r){const n=await nu();return{format:"synlexa.library.v1",exportedAtUtc:new Date().toISOString(),disclaimer:e,items:r?n.filter(s=>r.includes(s.id)):n}}async function YD(e){const r=JSON.parse(e);if(r.format!=="synlexa.library.v1"||!Array.isArray(r.items))throw new Error('Not a Synlexa library export (expected format "synlexa.library.v1").');let n=0;for(const s of r.items){if(!s||typeof s.content!="string"||typeof s.name!="string")continue;const{duplicate:i}=await t1({kind:s.kind,name:s.name,format:s.format,content:s.content,paeJson:s.paeJson??null,tags:s.tags,notes:s.notes,favorite:s.favorite,source:s.source});i||n++}return n}function Uc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function WD(e){const r=e.toLowerCase();return/\.(cif|mmcif)$/.test(r)?{kind:"structure",format:"cif"}:/\.(pdb|ent)$/.test(r)?{kind:"structure",format:"pdb"}:/\.smi$/.test(r)?{kind:"compound",format:"smiles"}:/\.(fasta|fa|faa)$/.test(r)?{kind:"sequence",format:"fasta"}:null}class kn extends Error{code;constructor(r,n){super(n),this.name="BundleValidationError",this.code=r}}const XD=new TextEncoder;async function hp(e){return Jc(XD.encode(e))}function QD(e){if(typeof e!="string"||e.length===0)throw new kn("ERR_BUNDLE_PATH_TRAVERSAL","Bundle file path must be a non-empty relative string.");if(e.includes("\0")||e.includes("\\"))throw new kn("ERR_BUNDLE_PATH_TRAVERSAL",`Invalid path characters in "${e}".`);if(/%2e|%2f|%5c/i.test(e))throw new kn("ERR_BUNDLE_PATH_TRAVERSAL",`Encoded traversal characters are not allowed in "${e}".`);if(e.startsWith("/")||/^[A-Za-z]:/.test(e))throw new kn("ERR_BUNDLE_PATH_TRAVERSAL",`Absolute paths are prohibited in bundle: "${e}".`);const r=e.split("/");for(const n of r){if(n===""||n==="."||n==="..")throw new kn("ERR_BUNDLE_PATH_TRAVERSAL",`Path traversal or empty segment rejected: "${e}".`);if(!/^[A-Za-z0-9._-]+$/.test(n))throw new kn("ERR_BUNDLE_PATH_TRAVERSAL",`Unsupported characters in path segment "${n}".`)}return e}async function JD(e){const[r,n]=await Promise.all([hp(e.refContent),hp(e.mobContent)]),s=[{path:"structures/reference.cif",role:"reference",label:e.refLabel,sha256:r,content:e.refContent},{path:"structures/mobile.cif",role:"mobile",label:e.mobLabel,sha256:n,content:e.mobContent}];return e.paeJson&&e.paeJson.trim().length>0&&s.push({path:"pae/predicted_aligned_error.json",role:"pae",label:"PAE Matrix",sha256:await hp(e.paeJson),content:e.paeJson}),{schemaVersion:"1.0.0",bundleFormat:"synlexa-studio-bundle-v1",ruoNotice:Cn,exportedAtUtc:new Date().toISOString(),files:s,state:e.state,comparisonResult:e.comparisonResult}}async function ZD(e){let r;try{r=JSON.parse(e)}catch(c){throw new kn("ERR_BUNDLE_PARSE",`Invalid bundle JSON: ${c instanceof Error?c.message:String(c)}`)}if(!r||typeof r!="object")throw new kn("ERR_BUNDLE_SCHEMA","Bundle root must be an object.");const n=r;if(n.bundleFormat!=="synlexa-studio-bundle-v1"||n.schemaVersion!=="1.0.0")throw new kn("ERR_BUNDLE_SCHEMA","Unsupported bundleFormat or schemaVersion (expected synlexa-studio-bundle-v1 / 1.0.0).");if(!Array.isArray(n.files)||n.files.length===0)throw new kn("ERR_BUNDLE_SCHEMA","Bundle must contain a non-empty files array.");if(!n.state||typeof n.state!="object")throw new kn("ERR_BUNDLE_SCHEMA","Bundle missing workspace state.");const s=new Set,i=new Map;for(const c of n.files){if(!c||typeof c!="object")throw new kn("ERR_BUNDLE_SCHEMA","Invalid file entry in bundle.");const d=QD(c.path);if(s.has(d))throw new kn("ERR_BUNDLE_DUPLICATE_PATH",`Duplicate bundle file path "${d}".`);if(s.add(d),typeof c.content!="string"||typeof c.sha256!="string")throw new kn("ERR_BUNDLE_SCHEMA",`File "${d}" missing string content or sha256.`);if(!/^[a-fA-F0-9]{64}$/.test(c.sha256))throw new kn("ERR_BUNDLE_HASH_MISMATCH",`Invalid SHA-256 format on "${d}".`);const f=await hp(c.content);if(f!==c.sha256.toLowerCase())throw new kn("ERR_BUNDLE_HASH_MISMATCH",`SHA-256 mismatch on "${d}": expected ${c.sha256}, computed ${f}.`);(c.role==="reference"||c.role==="mobile")&&i.set(c.role,f)}if(n.comparisonResult){const c=i.get("reference"),d=i.get("mobile");if(c&&n.comparisonResult.reference?.sha256&&n.comparisonResult.reference.sha256.toLowerCase()!==c)throw new kn("ERR_BUNDLE_HASH_MISMATCH","Bundled comparisonResult.reference.sha256 does not match reference file digest.");if(d&&n.comparisonResult.mobile?.sha256&&n.comparisonResult.mobile.sha256.toLowerCase()!==d)throw new kn("ERR_BUNDLE_HASH_MISMATCH","Bundled comparisonResult.mobile.sha256 does not match mobile file digest.")}return n}const eq="synlexa_studio_db",Yi="run_history",s1="synlexa.studio.runHistory.v1",a1=25;function r1(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise(e=>{try{const r=indexedDB.open(eq,1);r.onupgradeneeded=()=>{const n=r.result;n.objectStoreNames.contains(Yi)||n.createObjectStore(Yi,{keyPath:"id"})},r.onsuccess=()=>e(r.result),r.onerror=()=>e(null)}catch{e(null)}})}function Xf(){if(typeof localStorage>"u")return[];try{const e=localStorage.getItem(s1);if(!e)return[];const r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}}function tq(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(s1,JSON.stringify(e.slice(0,a1)))}catch{}}async function cE(){const e=await r1();return e?new Promise(r=>{try{const i=e.transaction(Yi,"readonly").objectStore(Yi).getAll();i.onsuccess=()=>{const c=i.result??[];c.sort((d,f)=>f.createdAtUtc.localeCompare(d.createdAtUtc)),e.close(),r(c.length>0?c.slice(0,a1):Xf())},i.onerror=()=>{e.close(),r(Xf())}}catch{e.close(),r(Xf())}}):Xf()}async function nq(e){const r=await cE(),n=[e,...r.filter(i=>i.id!==e.id)].slice(0,a1);tq(n);const s=await r1();return s&&await new Promise(i=>{try{const c=s.transaction(Yi,"readwrite");c.objectStore(Yi).put(e),c.oncomplete=()=>{s.close(),i()},c.onerror=()=>{s.close(),i()}}catch{s.close(),i()}}),n}async function uE(){typeof localStorage<"u"&&localStorage.removeItem(s1);const e=await r1();e&&await new Promise(r=>{try{const n=e.transaction(Yi,"readwrite");n.objectStore(Yi).clear(),n.oncomplete=()=>{e.close(),r()},n.onerror=()=>{e.close(),r()}}catch{e.close(),r()}})}const dE=[{id:"ca2-azm",kind:"protein-pair",title:"Carbonic Anhydrase II",subtitle:"3HS4 vs AF-P00918 + Acetazolamide",blurb:"Compare a 1.1 Å crystal structure with its AlphaFold prediction, inspect the Zn²⁺ active site, and profile the co-crystallised sulfonamide ligand.",tags:["Enzyme","Zn²⁺ pocket","Ligand","PAE"],reference:{fileName:"3HS4.cif",chainId:"A",label:"3HS4.cif"},mobile:{fileName:"AF-P00918-F1-model_v6.cif",chainId:"A",label:"AF-P00918-F1-model_v6.cif"},paeFileName:"AF-P00918-F1-predicted_aligned_error_v6.json",focusSeqId:94,peptideMutations:["H94A"],crispr:{transcriptId:"NM_000067.3",targetCodonIndex:94,baseEditOffset:0,newBase:"G",nuclease:"SpCas9",note:"CA2 codon 94 (His94, a Zn²⁺-coordinating residue in the pinned structure)."},smilesPresetId:"azm",openTab:"sequence"},{id:"ubiquitin",kind:"protein-pair",title:"Human Ubiquitin",subtitle:"1UBQ vs AF-P0CG48 (Polyubiquitin-C)",blurb:"Compare a 76-aa monomer crystal structure (1UBQ) against the 685-aa 9-repeat polyubiquitin-C AlphaFold precursor (AF-P0CG48), and inspect its β-grasp Ramachandran angles.",tags:["β-grasp","Repeat precursor","Ramachandran"],reference:{fileName:"1UBQ.cif",chainId:"A",label:"1UBQ.cif"},mobile:{fileName:"AF-P0CG48-F1-model_v6.cif",chainId:"A",label:"AF-P0CG48-F1-model_v6.cif"},focusSeqId:48,openTab:"ramachandran"},{id:"hbb-e6v",kind:"protein-pair",title:"Hemoglobin β",subtitle:"1A3N chain B vs AF-P68871 + HBB E6V edit",blurb:"Select the β subunit from a four-chain assembly, then explore the classic E6V nucleotide change (HGVS c.20A>T, p.Glu7Val with the initiator Met counted) in the CRISPR studio.",tags:["Multi-chain","CRISPR","Missense"],reference:{fileName:"1A3N.cif",chainId:"B",label:"1A3N.cif"},mobile:{fileName:"AF-P68871-F1-model_v6.cif",chainId:"A",label:"AF-P68871-F1-model_v6.cif"},focusSeqId:6,peptideMutations:["E7V"],crispr:{transcriptId:"NM_000518.5",targetCodonIndex:7,baseEditOffset:1,newBase:"T",nuclease:"SpCas9",note:'Legacy "E6V" (mature-protein numbering) = CDS codon 7, c.20A>T (GAG → GTG).'},openTab:"crispr"},{id:"lysozyme",kind:"protein-pair",title:"Human Lysozyme C",subtitle:"1LZ1 vs AF-P61626",blurb:"A mixed α/β enzyme. The prediction includes the signal peptide, so coverage shows how sequence-aware mapping handles extra residues.",tags:["α/β enzyme","Coverage","Signal peptide"],reference:{fileName:"1LZ1.cif",chainId:"A",label:"1LZ1.cif"},mobile:{fileName:"AF-P61626-F1-model_v6.cif",chainId:"A",label:"AF-P61626-F1-model_v6.cif"},focusSeqId:35,openTab:"sequence"},{id:"chem-panel",kind:"chemistry-panel",title:"Small-Molecule Chemistry Panel",subtitle:"Imatinib · Acetazolamide · Aspirin · Caffeine",blurb:"Parse SMILES deterministically, depict 2D graphs, and read TPSA, cLogP, H-bond counts, and rule-of-five flags with plain-English badges.",tags:["SMILES","TPSA","cLogP","Lipinski"],smilesPresetId:"imatinib",smilesPanelIds:["imatinib","azm","aspirin","caffeine"],openTab:"chemistry"}];function sq(e){return dE.find(r=>r.id===e)}function aq(e){return e.split(/[,\s;]+/).map(r=>r.trim().toUpperCase()).filter(r=>/^[ACDEFGHIKLMNPQRSTVWY]\d+[ACDEFGHIKLMNPQRSTVWY]$/.test(r))}function rq(e,r){switch(r.type){case"set_sequence":{const n=r.sequence.toUpperCase().replace(/[^ACDEFGHIKLMNPQRSTVWY]/g,"");return{...e,sequence:n,sliceStart:1,sliceEnd:Math.max(1,n.length)}}case"set_mutations_input":return{...e,mutationsInput:r.raw,mutations:aq(r.raw)};case"add_mutation":{const n=r.notation.trim().toUpperCase();if(!/^[ACDEFGHIKLMNPQRSTVWY]\d+[ACDEFGHIKLMNPQRSTVWY]$/.test(n)||e.mutations.includes(n))return e;const s=[...e.mutations,n];return{...e,mutations:s,mutationsInput:s.join(", ")}}case"remove_mutation":{const n=e.mutations.filter(s=>s!==r.notation);return{...e,mutations:n,mutationsInput:n.join(", ")}}case"set_slice":{const n=Math.max(1,e.sequence.length),s=Math.max(1,Math.min(n,Math.floor(r.start))),i=Math.max(s,Math.min(n,Math.floor(r.end)));return{...e,sliceStart:s,sliceEnd:i}}case"focus_residue":return{...e,focusSeqId:r.seqId};default:return e}}function iq(e,r){switch(r.type){case"select_transcript":return{...e,transcriptId:r.transcriptId,useCustomDna:!1,targetCodonIndex:Math.max(1,e.targetCodonIndex)};case"set_custom_dna":return{...e,customDna:r.dna.toUpperCase().replace(/[^ACGT]/g,""),useCustomDna:!0};case"toggle_custom_dna":return{...e,useCustomDna:r.enabled};case"set_target_codon":return{...e,targetCodonIndex:Math.max(1,Math.floor(r.codonIndex))};case"set_base_edit":return{...e,baseEditOffset:r.offset,newBase:r.newBase};case"set_nuclease":return{...e,nuclease:r.nuclease};default:return e}}const Xo=[{id:"azm",name:"Acetazolamide (AZM · 3HS4 ligand)",smiles:"CC(=O)Nc1nnc(S(N)(=O)=O)s1",note:"Co-crystallized carbonic anhydrase II inhibitor in PDB 3HS4"},{id:"dorzolamide",name:"Dorzolamide",smiles:"CCN[C@H]1C[C@@H](C)S(=O)(=O)c2sc(S(N)(=O)=O)cc12",note:"Thienothiopyran sulfonamide scaffold"},{id:"bsa",name:"Benzene sulfonamide",smiles:"NS(=O)(=O)c1ccccc1",note:"Minimal arylsulfonamide zinc-binding headgroup"},{id:"aspirin",name:"Aspirin",smiles:"CC(=O)Oc1ccccc1C(=O)O",note:"Reference small-molecule carboxylate ester"},{id:"caffeine",name:"Caffeine",smiles:"Cn1cnc2c1c(=O)n(C)c(=O)n2C",note:"Purine xanthine benchmark"},{id:"imatinib",name:"Imatinib",smiles:"CC1=C(C=C(C=C1)NC(=O)C2=CC=C(C=C2)CN3CCN(CC3)C)NC4=NC=CC(=N4)C5=CN=CC=C5",note:"Phenylaminopyrimidine kinase-inhibitor scaffold (PubChem CID 5291)"}];function oq(e,r){switch(r.type){case"select_preset":{const n=Xo.find(s=>s.id===r.presetId);return n?{selectedPresetId:n.id,name:n.name,smiles:n.smiles}:e}case"set_custom_smiles":return{selectedPresetId:"custom",name:r.name?.trim()||"Custom SMILES",smiles:r.smiles.trim()};default:return e}}const lq=["home","viewer","results","sequence","ramachandran","peptide","crispr","chemistry","workflow","compute","plugins","assistant","mcp","library"],Op=new Set(["viewer"]),mp={groups:[{tabs:["home","viewer"],active:"home"},{tabs:["assistant","results","sequence","mcp"],active:"assistant"}],focused:0,split:.62};function Id(e,r){return e.groups.findIndex(n=>n.tabs.includes(r))}function Gd(e){let r=e.groups.filter(n=>n.tabs.length>0);return r.length===0&&(r=[{tabs:["home","viewer"],active:"home"}]),r=r.map(n=>({tabs:n.tabs,active:n.active&&n.tabs.includes(n.active)?n.active:n.tabs[n.tabs.length-1]??null})),r.some(n=>n.tabs.includes("viewer"))||(r[0]={...r[0],tabs:[...r[0].tabs,"viewer"]}),{groups:r.slice(0,2),focused:Math.min(e.focused,r.length-1),split:Math.min(.8,Math.max(.2,e.split))}}function _y(e,r){switch(r.type){case"open":{const n=Id(e,r.tab);if(n>=0&&!r.toSide){const c=e.groups.map((d,f)=>f===n?{...d,active:r.tab}:d);return{...e,groups:c,focused:n}}if(r.toSide){const c=n>=0?n:e.focused,d=e.groups.length===1?1:1-c;return _y(e,{type:"move",tab:r.tab,toGroup:d})}const s=e.focused,i=e.groups.map((c,d)=>d===s?{tabs:[...c.tabs,r.tab],active:r.tab}:c);return{...e,groups:i}}case"activate":{const n=Id(e,r.tab);if(n<0)return _y(e,{type:"open",tab:r.tab});const s=e.groups.map((i,c)=>c===n?{...i,active:r.tab}:i);return{...e,groups:s,focused:n}}case"close":{if(Op.has(r.tab))return e;const n=Id(e,r.tab);if(n<0)return e;const s=e.groups.map((i,c)=>{if(c!==n)return i;const d=i.tabs.indexOf(r.tab),f=i.tabs.filter(b=>b!==r.tab),p=i.active===r.tab?f[Math.min(d,f.length-1)]??null:i.active;return{tabs:f,active:p}});return Gd({...e,groups:s})}case"close_others":{const n=Id(e,r.tab);if(n<0)return e;const s=e.groups.map((i,c)=>c===n?{tabs:i.tabs.filter(d=>d===r.tab||Op.has(d)),active:r.tab}:i);return Gd({...e,groups:s})}case"move":{const n=Id(e,r.tab);let s=e.groups.map(p=>({...p,tabs:[...p.tabs]}));if(r.toGroup>=s.length&&s.push({tabs:[],active:null}),n>=0){const p=s[n],b=p.tabs.indexOf(r.tab);p.tabs.splice(b,1),p.active===r.tab&&(p.active=p.tabs[Math.min(b,p.tabs.length-1)]??null)}const i=s[r.toGroup],c=r.index===void 0?i.tabs.length:Math.max(0,Math.min(r.index,i.tabs.length));i.tabs.splice(c,0,r.tab),i.active=r.tab;const d=n>=0&&s[n].tabs.length===0;s=s.filter(p=>p.tabs.length>0);const f=d&&n<r.toGroup?r.toGroup-1:r.toGroup;return Gd({...e,groups:s,focused:f})}case"focus_group":return{...e,focused:Math.min(r.group,e.groups.length-1)};case"set_split":return{...e,split:Math.min(.8,Math.max(.2,r.split))};case"merge_split":{if(e.groups.length<2)return e;const n=e.groups[e.focused]??e.groups[0],s=Array.from(new Set(e.groups.flatMap(i=>i.tabs)));return Gd({...e,groups:[{tabs:s,active:n.active??s[0]??null}],focused:0})}case"reset":return mp}}const hE="synlexa.studio.layout.v1";function cq(e){if(!e)return mp;try{const r=localStorage.getItem(hE);if(!r)return mp;const n=JSON.parse(r),s=new Set(lq),i=(n.groups??[]).map(c=>({tabs:Array.from(new Set((c.tabs??[]).filter(f=>s.has(f)))),active:c.active&&s.has(c.active)?c.active:null})).slice(0,2);return i.length===2&&(i[1].tabs=i[1].tabs.filter(c=>!i[0].tabs.includes(c))),Gd({groups:i,focused:n.focused??0,split:n.split??.6})}catch{return mp}}function uq(e){try{localStorage.setItem(hE,JSON.stringify(e))}catch{}}function dq(e){if(typeof document>"u")return()=>{};const r=d=>{(d.ctrlKey||d.metaKey)&&d.preventDefault()},n=d=>d.preventDefault(),s=d=>{d.touches.length>1&&d.preventDefault()},i=d=>{!(d.metaKey||d.ctrlKey)||d.altKey||(d.key==="="||d.key==="+"?(d.preventDefault(),e?.(1)):d.key==="-"||d.key==="_"?(d.preventDefault(),e?.(-1)):d.key==="0"&&(d.preventDefault(),e?.(0)))},c={passive:!1};return window.addEventListener("wheel",r,c),document.addEventListener("gesturestart",n,c),document.addEventListener("gesturechange",n,c),document.addEventListener("gestureend",n,c),document.addEventListener("touchmove",s,c),window.addEventListener("keydown",i),()=>{window.removeEventListener("wheel",r),document.removeEventListener("gesturestart",n),document.removeEventListener("gesturechange",n),document.removeEventListener("gestureend",n),document.removeEventListener("touchmove",s),window.removeEventListener("keydown",i)}}var hq=$A();function Ie(...e){return e.filter(Boolean).join(" ")}const mq={primary:"bg-sky-500 text-slate-950 hover:bg-sky-400 font-semibold shadow-sm shadow-sky-950/40",secondary:"border border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08] hover:border-white/20",ghost:"text-slate-300 hover:bg-white/[0.06] hover:text-white",danger:"border border-rose-500/30 bg-rose-500/10 text-rose-200 hover:bg-rose-500/20"},fq={sm:"h-7 px-2.5 text-xs gap-1.5 rounded-md",md:"h-9 px-3.5 text-sm gap-2 rounded-lg"};function Oe({variant:e="secondary",size:r="md",className:n,icon:s,children:i,...c}){return o.jsxs("button",{type:"button",...c,className:Ie("inline-flex shrink-0 items-center justify-center whitespace-nowrap transition-colors outline-none focus-visible:ring-2 focus-visible:ring-sky-400/60 disabled:pointer-events-none disabled:opacity-40",mq[e],fq[r],n),children:[s,i]})}function sl({label:e,active:r,className:n,children:s,...i}){return o.jsx("button",{type:"button","aria-label":e,title:e,...i,className:Ie("inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors outline-none focus-visible:ring-2 focus-visible:ring-sky-400/60 disabled:opacity-40",r?"bg-sky-500/15 text-sky-300":"text-slate-400 hover:bg-white/[0.07] hover:text-slate-100",n),children:s})}function Dn({className:e,...r}){return o.jsx("input",{...r,className:Ie("h-9 w-full rounded-lg border border-white/10 bg-black/30 px-3 text-sm text-slate-100 placeholder-slate-500 outline-none transition focus:border-sky-400/70 focus:ring-2 focus:ring-sky-400/20",e)})}function Pp({className:e,...r}){return o.jsx("textarea",{...r,className:Ie("w-full rounded-lg border border-white/10 bg-black/30 px-3 py-2 text-sm text-slate-100 placeholder-slate-500 outline-none transition focus:border-sky-400/70 focus:ring-2 focus:ring-sky-400/20",e)})}function Na({className:e,children:r,...n}){return o.jsx("select",{...n,className:Ie("h-9 w-full rounded-lg border border-white/10 bg-[#121722] px-2.5 text-sm text-slate-100 outline-none focus:border-sky-400/70",e),children:r})}function $r({checked:e,onChange:r,label:n}){return o.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:()=>r(!e),className:Ie("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors outline-none focus-visible:ring-2 focus-visible:ring-sky-400/60",e?"bg-sky-500":"bg-slate-700"),children:o.jsx("span",{className:Ie("inline-block h-4 w-4 rounded-full bg-white shadow transition-transform",e?"translate-x-[1.125rem]":"translate-x-0.5")})})}function It({tone:e="neutral",children:r,className:n}){const s={neutral:"bg-white/[0.06] text-slate-300 border-white/10",accent:"bg-sky-500/10 text-sky-300 border-sky-500/25",good:"bg-emerald-500/10 text-emerald-300 border-emerald-500/25",warn:"bg-amber-500/10 text-amber-300 border-amber-500/25",bad:"bg-rose-500/10 text-rose-300 border-rose-500/25"};return o.jsx("span",{className:Ie("inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[0.6875rem] font-medium leading-none",s[e],n),children:r})}function Rr({children:e}){return o.jsx("kbd",{className:"rounded border border-white/15 bg-white/[0.04] px-1.5 py-0.5 font-mono text-[0.6875rem] text-slate-400",children:e})}function yt({title:e,description:r,actions:n,children:s,className:i}){return o.jsxs("section",{className:Ie("rounded-xl border border-white/[0.08] bg-white/[0.02]",i),children:[(e||n)&&o.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-white/[0.06] px-4 py-3",children:[o.jsxs("div",{className:"min-w-0",children:[e&&o.jsx("h3",{className:"text-sm font-semibold text-slate-100",children:e}),r&&o.jsx("p",{className:"mt-0.5 text-xs text-slate-400",children:r})]}),n&&o.jsx("div",{className:"flex shrink-0 items-center gap-2",children:n})]}),s&&o.jsx("div",{className:"p-4",children:s})]})}function Qt({label:e,hint:r,children:n}){return o.jsxs("div",{className:"flex flex-col gap-2 py-3 @xl:flex-row @xl:items-center @xl:justify-between @xl:gap-6",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm text-slate-200",children:e}),r&&o.jsx("div",{className:"mt-0.5 text-xs text-slate-500",children:r})]}),o.jsx("div",{className:"min-w-0 @xl:max-w-[60%] @xl:shrink-0",children:n})]})}function mE({icon:e,title:r,description:n,action:s}){return o.jsxs("div",{className:"flex h-full min-h-40 flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e&&o.jsx("div",{className:"mb-1 text-slate-500",children:e}),o.jsx("div",{className:"text-sm font-medium text-slate-200",children:r}),n&&o.jsx("div",{className:"max-w-sm text-xs leading-relaxed text-slate-400",children:n}),s&&o.jsx("div",{className:"mt-3",children:s})]})}function fE({open:e,onClose:r,title:n,children:s,footer:i,width:c="max-w-lg"}){return C.useEffect(()=>{if(!e)return;const d=f=>{f.key==="Escape"&&r()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e,r]),e?o.jsx("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onMouseDown:d=>{d.target===d.currentTarget&&r()},children:o.jsxs("div",{className:Ie("w-full overflow-hidden rounded-2xl border border-white/10 bg-[#121722] shadow-2xl",c),children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.06] px-5 py-3.5",children:[o.jsx("h2",{className:"text-base font-semibold text-slate-100",children:n}),o.jsx(sl,{label:"Close",onClick:r,children:o.jsx(Xi,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"max-h-[70vh] overflow-y-auto px-5 py-4",children:s}),i&&o.jsx("div",{className:"flex justify-end gap-2 border-t border-white/[0.06] px-5 py-3",children:i})]})}):null}const pE=C.createContext({toast:()=>{},confirm:async()=>!0});function cl(){return C.useContext(pE)}function pq({children:e}){const[r,n]=C.useState([]),[s,i]=C.useState(null),c=C.useRef(1),d=C.useCallback((x,g="info",_)=>{const y=c.current++;n(S=>[...S.slice(-3),{id:y,tone:g,message:x,action:_}]),setTimeout(()=>n(S=>S.filter(k=>k.id!==y)),g==="error"?7e3:4e3)},[]),f=C.useCallback(x=>new Promise(g=>i({...x,resolve:g})),[]),p=x=>{s?.resolve(x),i(null)},b={info:o.jsx(zy,{className:"h-4 w-4 text-sky-300"}),success:o.jsx(Gs,{className:"h-4 w-4 text-emerald-300"}),warn:o.jsx(Gc,{className:"h-4 w-4 text-amber-300"}),error:o.jsx(Bc,{className:"h-4 w-4 text-rose-300"})};return o.jsxs(pE.Provider,{value:{toast:d,confirm:f},children:[e,o.jsx("div",{className:"pointer-events-none fixed right-4 bottom-10 z-[90] flex w-80 flex-col gap-2",children:r.map(x=>o.jsxs("div",{className:"pointer-events-auto flex items-start gap-2.5 rounded-xl border border-white/10 bg-[#161c28]/95 px-3.5 py-3 text-sm text-slate-200 shadow-xl backdrop-blur",children:[o.jsx("span",{className:"mt-0.5 shrink-0",children:b[x.tone]}),o.jsx("div",{className:"min-w-0 flex-1 leading-snug",children:x.message}),x.action&&o.jsx("button",{type:"button",onClick:()=>{x.action.run(),n(g=>g.filter(_=>_.id!==x.id))},className:"shrink-0 text-xs font-semibold text-sky-300 hover:text-sky-200",children:x.action.label})]},x.id))}),o.jsx(fE,{open:!!s,onClose:()=>p(!1),title:s?.title??"",width:"max-w-md",footer:o.jsxs(o.Fragment,{children:[o.jsx(Oe,{variant:"ghost",onClick:()=>p(!1),children:"Cancel"}),o.jsx(Oe,{variant:s?.danger?"danger":"primary",onClick:()=>p(!0),autoFocus:!0,children:s?.confirmLabel??"Confirm"})]}),children:o.jsx("div",{className:"text-sm leading-relaxed text-slate-300",children:s?.message})})]})}function i1({trigger:e,items:r,align:n="right"}){const[s,i]=C.useState(!1),[c,d]=C.useState(null),f=C.useRef(null),p=C.useRef(null);return C.useLayoutEffect(()=>{if(!s){d(null);return}const b=()=>{const x=f.current?.getBoundingClientRect(),g=p.current;if(!x||!g)return;const _=8,y=g.offsetWidth,S=n==="right"?x.right-y:x.left,k=Math.min(Math.max(_,S),window.innerWidth-y-_),E=x.bottom+4;d({top:E,left:k,maxHeight:Math.max(160,window.innerHeight-E-_)})};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[s,n]),C.useEffect(()=>{if(!s)return;const b=g=>{const _=g.target;f.current?.contains(_)||p.current?.contains(_)||i(!1)},x=g=>g.key==="Escape"&&i(!1);return window.addEventListener("mousedown",b),window.addEventListener("keydown",x),()=>{window.removeEventListener("mousedown",b),window.removeEventListener("keydown",x)}},[s]),o.jsxs("div",{ref:f,className:"relative",children:[e(s,()=>i(b=>!b)),s&&hq.createPortal(o.jsx("div",{ref:p,style:c?{position:"fixed",top:c.top,left:c.left,maxHeight:Math.min(c.maxHeight,480)}:{position:"fixed",top:0,left:0,visibility:"hidden"},className:"z-[90] max-w-[calc(100vw-1rem)] min-w-52 overflow-y-auto rounded-xl border border-white/10 bg-[#161c28] py-1 shadow-2xl",children:r.map((b,x)=>b==="divider"?o.jsx("div",{className:"my-1 h-px bg-white/[0.06]"},`d${x}`):"heading"in b?o.jsx("div",{className:"px-3 pt-2.5 pb-1 text-[0.6875rem] font-semibold tracking-wide text-slate-500 uppercase",children:b.heading},`h${x}`):o.jsxs("button",{type:"button",disabled:b.disabled,onClick:()=>{i(!1),b.onSelect()},className:Ie("flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm transition-colors disabled:opacity-40",b.danger?"text-rose-300 hover:bg-rose-500/10":"text-slate-200 hover:bg-white/[0.06]",b.selected&&"bg-white/[0.05]"),children:[b.icon&&o.jsx("span",{className:"shrink-0 text-slate-400",children:b.icon}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"block",children:b.label}),b.description&&o.jsx("span",{className:"block truncate text-xs text-slate-500",children:b.description})]}),b.hint&&o.jsx("span",{className:"text-xs text-slate-500",children:b.hint})]},b.key??b.label))}),document.body)]})}const gq=new Set(["\\","`","*","_","{","}","[","]","(",")","#","+","-",".","!","|",">","~"]);function Nx(e){const r=e.trim().replace(/^<|>$/g,"");if(!r)return null;try{const n=new URL(r);return n.protocol==="http:"||n.protocol==="https:"?n.href:null}catch{return null}}function $p(e){let r=e.trim();r.startsWith("|")&&(r=r.slice(1)),r.endsWith("|")&&!r.endsWith("\\|")&&(r=r.slice(0,-1));const n=[];let s="",i=0,c=0;for(;i<r.length;){const d=r[i];if(d==="\\"&&i+1<r.length&&r[i+1]==="|"){s+="|",i+=2;continue}if(d==="`"){let f=0;for(;i+f<r.length&&r[i+f]==="`";)f++;c===0?c=f:c===f&&(c=0),s+=r.slice(i,i+f),i+=f;continue}if(d==="|"&&c===0){n.push(s.trim()),s="",i++;continue}s+=d,i++}return n.push(s.trim()),n}function gE(e,r){if(!e.includes("|")&&r<=1)return null;const n=e.trim();if(!n)return null;const s=$p(n);if(s.length===0||s.length<r&&r>1&&s.length===1)return null;const i=[];for(const c of s){if(!/^:?-{1,}:?$/.test(c))return null;const d=c.startsWith(":"),f=c.endsWith(":");d&&f?i.push("center"):f?i.push("right"):d?i.push("left"):i.push(null)}return i}function fp(e){const r=e.match(/^(\s*)([-*+•])\s+(.*)$/);if(r){const s=r[3],i=s.match(/^\[([ xX])\]\s+(.*)$/);return{indent:r[1].replace(/\t/g," ").length,ordered:!1,start:1,text:i?i[2]:s,...i?{checked:i[1].toLowerCase()==="x"}:{}}}const n=e.match(/^(\s*)(\d{1,9})[.)]\s+(.*)$/);if(n){const s=n[3],i=s.match(/^\[([ xX])\]\s+(.*)$/);return{indent:n[1].replace(/\t/g," ").length,ordered:!0,start:Number.parseInt(n[2],10)||1,text:i?i[2]:s,...i?{checked:i[1].toLowerCase()==="x"}:{}}}return null}function vy(e){return/^\s*([-*_])(?:\s*\1){2,}\s*$/.test(e)}function wy(e){const r=e.match(/^\s*(#{1,6})\s+(.+?)(?:\s+#+)?\s*$/);return r?{level:r[1].length,text:r[2].trim()}:null}function Sy(e){const r=e.match(/^\s*(`{3,}|~{3,})(.*)$/);if(!r)return null;const n=r[1],s=r[2].trim();return n[0]==="`"&&s.includes("`")?null:{char:n[0],len:n.length,lang:s.split(/\s+/)[0]??""}}function fA(e,r){const n=e[r];if(!n.trim()||Sy(n)||wy(n)||vy(n)||/^\s*>\s?/.test(n)||fp(n))return!0;if(r+1<e.length&&n.includes("|")){const s=$p(n);if(gE(e[r+1],s.length))return!0}return!1}function bE(e,r=0,n=e[0]?.indent??0){const s=e[r],i={type:"list",ordered:s.ordered,start:s.start,items:[]};let c=r;for(;c<e.length;){const d=e[c];if(d.indent<n||d.indent===n&&d.ordered!==i.ordered)break;if(d.indent>n){if(i.items.length===0){const p={lines:d.lines,checked:d.checked,children:[]};i.items.push(p),c++;continue}const f=bE(e,c,d.indent);i.items[i.items.length-1].children.push(f.list),c=f.nextIdx;continue}i.items.push({lines:d.lines,checked:d.checked,children:[]}),c++}return{list:i,nextIdx:c}}function xE(e){const n=e.replace(/\r\n?/g,`
761
+ `).split(`
762
+ `),s=[];let i=0;for(;i<n.length;){const c=n[i];if(!c.trim()){i++;continue}const d=Sy(c);if(d){const x=[],g=new RegExp(`^\\s*${d.char}{${d.len},}\\s*$`);for(i++;i<n.length&&!g.test(n[i]);)x.push(n[i]),i++;i<n.length&&g.test(n[i])&&i++,s.push({type:"code",lang:d.lang,code:x.join(`
763
+ `)});continue}if(i+1<n.length&&c.includes("|")){const x=$p(c),g=gE(n[i+1],x.length);if(g){const _=Math.max(x.length,g.length),y=Array.from({length:_},(E,T)=>x[T]??""),S=Array.from({length:_},(E,T)=>g[T]??null),k=[];for(i+=2;i<n.length;){const E=n[i];if(!E.trim()||!E.includes("|")||Sy(E)||wy(E)||vy(E)||/^\s*>\s?/.test(E))break;const T=$p(E);k.push(Array.from({length:_},(j,q)=>T[q]??"")),i++}s.push({type:"table",headers:y,alignments:S,rows:k});continue}}const f=wy(c);if(f){s.push({type:"heading",level:f.level,text:f.text}),i++;continue}if(vy(c)){s.push({type:"hr"}),i++;continue}if(/^\s*>\s?/.test(c)){const x=[];for(;i<n.length&&/^\s*>\s?/.test(n[i]);)x.push(n[i].replace(/^\s*>\s?/,"")),i++;s.push({type:"blockquote",blocks:xE(x.join(`
764
+ `))});continue}if(fp(c)){const x=[];for(;i<n.length;){const _=n[i];if(!_.trim()){let S=i+1;for(;S<n.length&&!n[S].trim();)S++;if(S<n.length&&fp(n[S])){i=S;continue}break}const y=fp(_);if(y){x.push({indent:y.indent,ordered:y.ordered,start:y.start,lines:[y.text],checked:y.checked}),i++;continue}if(fA(n,i))break;if(x.length>0){x[x.length-1].lines.push(_.trim()),i++;continue}break}let g=0;for(;g<x.length;){const _=bE(x,g,x[g].indent);s.push(_.list),g=_.nextIdx}continue}const b=[c];for(i++;i<n.length&&!fA(n,i);)b.push(n[i]),i++;s.push({type:"paragraph",lines:b})}return s}function Dd(e,r,n,s){let i=r;for(;i<=e.length-n.length;){if(e[i]==="\\"&&i+1<e.length){i+=2;continue}if(e[i]==="`"){let c=0;for(;i+c<e.length&&e[i+c]==="`";)c++;const d=e.indexOf("`".repeat(c),i+c);if(d!==-1){i=d+c;continue}}if(e.startsWith(n,i)){if(n.length===1&&e[i+1]===n[0]){i+=2;continue}const c=e[i-1]??"";if(!/\s/.test(c))if(s){const d=e[i+n.length]??"";if(!d||!/[a-zA-Z0-9]/.test(d))return i}else return i}i++}return-1}function bq(e,r){let n=0,s=r;for(;s<e.length;){if(e[s]==="\\"&&s+1<e.length){s+=2;continue}if(e[s]==="`"){let i=0;for(;s+i<e.length&&e[s+i]==="`";)i++;const c=e.indexOf("`".repeat(i),s+i);if(c!==-1){s=c+i;continue}}if(e[s]==="[")n++;else if(e[s]==="]"&&(n--,n===0))return s;s++}return-1}function xq(e,r){let n=0,s=r;for(;s<e.length;){if(e[s]==="\\"&&s+1<e.length){s+=2;continue}if(e[s]==="(")n++;else if(e[s]===")"){if(n--,n===0)return s}else if(/\s/.test(e[s])&&n===1)return e.indexOf(")",s);s++}return-1}function yq(e){let r=e;for(;r.length>0;){const n=r[r.length-1];if(n==="."||n===","||n===";"||n===":"||n==="!"||n==="?"){r=r.slice(0,-1);continue}if(n===")"||n==="]"){const s=n===")"?"(":"[",i=(r.match(new RegExp(`\\${s}`,"g"))??[]).length;if((r.match(new RegExp(`\\${n}`,"g"))??[]).length>i){r=r.slice(0,-1);continue}}break}return r}function Sa(e,r=!1,n="in"){const s=[];let i="",c=0,d=0;const f=()=>{i&&(s.push(i),i="")},p="inline-flex items-baseline gap-0.5 break-all font-medium text-sky-300 underline decoration-sky-400/35 underline-offset-2 transition-colors hover:text-sky-200 hover:decoration-sky-300",b=r?"rounded border border-white/[0.06] bg-white/[0.08] px-1 py-px font-mono text-[0.8125em] text-sky-200":"rounded-md border border-white/[0.07] bg-white/[0.07] px-1.5 py-px font-mono text-[0.8125em] text-sky-200";for(;c<e.length;){const x=e[c];if(x==="\\"&&c+1<e.length&&gq.has(e[c+1])){i+=e[c+1],c+=2;continue}if(x==="`"){let g=0;for(;c+g<e.length&&e[c+g]==="`";)g++;const _="`".repeat(g);let y=c+g,S=-1;for(;y<e.length;){const k=e.indexOf(_,y);if(k===-1)break;const E=k===0||e[k-1]!=="`",T=k+g>=e.length||e[k+g]!=="`";if(E&&T){S=k;break}y=k+1}if(S!==-1){let k=e.slice(c+g,S);k.length>=2&&k.startsWith(" ")&&k.endsWith(" ")&&k.trim().length>0&&(k=k.slice(1,-1)),f(),s.push(o.jsx("code",{className:b,children:k},`${n}-c-${d++}`)),c=S+g;continue}i+=_,c+=g;continue}if(x==="["){const g=bq(e,c);if(g!==-1&&e[g+1]==="("){const _=xq(e,g+1);if(_!==-1){const y=e.slice(c+1,g),k=e.slice(g+2,_).trim().split(/\s+/)[0]??"",E=Nx(k);if(E){f(),s.push(o.jsxs("a",{href:E,target:"_blank",rel:"noopener noreferrer",className:p,children:[o.jsx("span",{children:Sa(y,r,`${n}-l-${d}`)}),o.jsx(Kd,{className:"inline h-3 w-3 shrink-0 self-center opacity-70"})]},`${n}-a-${d++}`)),c=_+1;continue}}}}if(x==="<"){const g=e.slice(c).match(/^<(https?:\/\/[^\s<>]+)>/i);if(g){const _=Nx(g[1]);if(_){f(),s.push(o.jsxs("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:p,children:[o.jsx("span",{children:g[1]}),o.jsx(Kd,{className:"inline h-3 w-3 shrink-0 self-center opacity-70"})]},`${n}-au-${d++}`)),c+=g[0].length;continue}}}if((x==="h"||x==="H")&&(c===0||/[\s(|[\-:;,>]/.test(e[c-1]))&&/^https?:\/\/[^\s<>"'`]+/i.test(e.slice(c))){const g=e.slice(c).match(/^https?:\/\/[^\s<>"'`]+/i),_=yq(g[0]),y=Nx(_);if(y){f(),s.push(o.jsxs("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:p,children:[o.jsx("span",{children:_}),o.jsx(Kd,{className:"inline h-3 w-3 shrink-0 self-center opacity-70"})]},`${n}-u-${d++}`)),c+=_.length;continue}}if(e.startsWith("**",c)&&c+2<e.length&&!/\s/.test(e[c+2])){const g=Dd(e,c+2,"**",!1);if(g!==-1){f(),s.push(o.jsx("strong",{className:"font-semibold text-slate-100",children:Sa(e.slice(c+2,g),r,`${n}-bi-${d}`)},`${n}-b-${d++}`)),c=g+2;continue}}if(e.startsWith("__",c)&&(c===0||!/[a-zA-Z0-9]/.test(e[c-1]))&&c+2<e.length&&!/\s/.test(e[c+2])){const g=Dd(e,c+2,"__",!0);if(g!==-1){f(),s.push(o.jsx("strong",{className:"font-semibold text-slate-100",children:Sa(e.slice(c+2,g),r,`${n}-bbi-${d}`)},`${n}-bb-${d++}`)),c=g+2;continue}}if(e.startsWith("~~",c)&&c+2<e.length&&!/\s/.test(e[c+2])){const g=Dd(e,c+2,"~~",!1);if(g!==-1){f(),s.push(o.jsx("del",{className:"text-slate-400 line-through",children:Sa(e.slice(c+2,g),r,`${n}-si-${d}`)},`${n}-s-${d++}`)),c=g+2;continue}}if(x==="*"&&e[c+1]!=="*"&&c+1<e.length&&!/\s/.test(e[c+1])){const g=Dd(e,c+1,"*",!1);if(g!==-1){f(),s.push(o.jsx("em",{className:"italic text-slate-300",children:Sa(e.slice(c+1,g),r,`${n}-emi-${d}`)},`${n}-em-${d++}`)),c=g+1;continue}}if(x==="_"&&e[c+1]!=="_"&&(c===0||!/[a-zA-Z0-9]/.test(e[c-1]))&&c+1<e.length&&!/\s/.test(e[c+1])){const g=Dd(e,c+1,"_",!0);if(g!==-1){f(),s.push(o.jsx("em",{className:"italic text-slate-400",children:Sa(e.slice(c+1,g),r,`${n}-emui-${d}`)},`${n}-emu-${d++}`)),c=g+1;continue}}i+=x,c++}return f(),s}function _q({lang:e,code:r,compact:n}){const[s,i]=C.useState(!1),c=()=>{try{navigator.clipboard?.writeText(r),i(!0),window.setTimeout(()=>i(!1),1600)}catch{}};return o.jsxs("div",{className:"my-2 overflow-hidden rounded-xl border border-white/[0.09] bg-[#06090f]",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.06] bg-white/[0.03] px-3 py-1.5",children:[o.jsx("span",{className:"font-mono text-[0.6875rem] font-medium tracking-wide text-slate-400 lowercase",children:e||"code"}),o.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.6875rem] text-slate-400 transition-colors hover:bg-white/[0.07] hover:text-slate-200",title:"Copy code",children:[s?o.jsx(Fi,{className:"h-3 w-3 text-emerald-400"}):o.jsx(Lr,{className:"h-3 w-3"}),o.jsx("span",{children:s?"Copied":"Copy"})]})]}),o.jsx("pre",{className:Ie("overflow-x-auto px-3.5 py-2.5 font-mono leading-relaxed text-slate-200",n?"text-[0.75rem]":"text-[0.8125rem]"),children:o.jsx("code",{children:r})})]})}function yE(e,r,n){const s=e.ordered?"ol":"ul";return o.jsx(s,{start:e.ordered&&e.start!==1?e.start:void 0,className:Ie("my-1.5 space-y-1.5 pl-5",e.ordered?"list-decimal marker:font-mono marker:text-[0.82em] marker:font-medium marker:text-sky-300/80":"list-disc marker:text-slate-500"),children:e.items.map((i,c)=>o.jsxs("li",{className:"leading-relaxed text-slate-200",children:[o.jsxs("div",{className:Ie(i.checked!==void 0&&"flex items-start gap-2"),children:[i.checked!==void 0&&o.jsx("span",{"aria-hidden":!0,className:Ie("mt-1 inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border text-[0.625rem]",i.checked?"border-emerald-400/50 bg-emerald-500/20 text-emerald-300":"border-white/20 bg-white/[0.03] text-transparent"),children:"✓"}),o.jsx("div",{className:"min-w-0 flex-1",children:i.lines.map((d,f)=>o.jsxs(C.Fragment,{children:[f>0&&o.jsx("br",{}),Sa(d,r,`${n}-li-${c}-${f}`)]},f))})]}),i.children.map((d,f)=>o.jsx(C.Fragment,{children:yE(d,r,`${n}-sub-${c}-${f}`)},`${n}-sub-${c}-${f}`))]},`${n}-li-${c}`))})}function _E(e,r,n="blk"){const s={1:r?"mt-2.5 mb-1 border-b border-white/[0.08] pb-1 text-sm font-semibold text-slate-50 first:mt-0":"mt-4 mb-1.5 border-b border-white/[0.08] pb-1.5 text-base font-semibold tracking-tight text-slate-50 first:mt-0",2:r?"mt-2.5 mb-1 text-[0.84375rem] font-semibold text-slate-100 first:mt-0":"mt-3.5 mb-1.5 text-[0.9375rem] font-semibold tracking-tight text-slate-100 first:mt-0",3:r?"mt-2 mb-0.5 text-[0.8125rem] font-semibold text-sky-200/95 first:mt-0":"mt-3 mb-1 text-sm font-semibold text-slate-100 first:mt-0",4:r?"mt-2 mb-0.5 text-xs font-semibold text-sky-200/90 first:mt-0":"mt-2.5 mb-1 text-[0.84375rem] font-semibold text-sky-200/95 first:mt-0",5:"mt-2 mb-0.5 text-xs font-semibold tracking-wide text-slate-300 uppercase first:mt-0",6:"mt-2 mb-0.5 text-[0.6875rem] font-semibold tracking-wider text-slate-400 uppercase first:mt-0"};return e.map((i,c)=>{const d=`${n}-${c}`;switch(i.type){case"heading":{const f=`h${i.level}`;return o.jsx(f,{className:s[i.level],children:Sa(i.text,r,d)},d)}case"hr":return o.jsx("hr",{className:"my-3 border-t border-white/[0.08]"},d);case"code":return o.jsx(_q,{lang:i.lang,code:i.code,compact:r},d);case"table":return o.jsx("div",{className:"my-2.5 overflow-x-auto rounded-xl border border-white/[0.09] bg-black/25",children:o.jsxs("table",{className:Ie("w-full border-collapse text-left",r?"text-[0.75rem]":"text-[0.8125rem]"),children:[o.jsx("thead",{className:"border-b border-white/[0.09] bg-white/[0.04] text-slate-100",children:o.jsx("tr",{children:i.headers.map((f,p)=>{const b=i.alignments[p];return o.jsx("th",{className:Ie("px-3 py-2 font-semibold whitespace-nowrap",b==="center"&&"text-center",b==="right"&&"text-right"),children:Sa(f,r,`${d}-th-${p}`)},p)})})}),o.jsx("tbody",{className:"divide-y divide-white/[0.05] text-slate-200",children:i.rows.map((f,p)=>o.jsx("tr",{className:"transition-colors hover:bg-white/[0.025]",children:f.map((b,x)=>{const g=i.alignments[x];return o.jsx("td",{className:Ie("px-3 py-2 align-top leading-snug",g==="center"&&"text-center",g==="right"&&"text-right"),children:Sa(b,r,`${d}-td-${p}-${x}`)},x)})},p))})]})},d);case"blockquote":return o.jsx("blockquote",{className:"my-2 space-y-1.5 rounded-r-lg border-l-2 border-sky-400/50 bg-sky-500/[0.04] py-2 pr-3 pl-3.5 text-slate-300",children:_E(i.blocks,r,`${d}-bq`)},d);case"list":return o.jsx(C.Fragment,{children:yE(i,r,d)},d);case"paragraph":return o.jsx("p",{className:"leading-relaxed text-slate-200",children:i.lines.map((f,p)=>o.jsxs(C.Fragment,{children:[p>0&&o.jsx("br",{}),Sa(f,r,`${d}-p-${p}`)]},p))},d)}})}function vq(e){return e.replace(/```[\s\S]*?```/g," [code] ").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^[-*•>]\s+/gm,"").replace(/[`*_~]/g,"").replace(/\s+/g," ").trim()}function vE({text:e,compact:r=!1,className:n}){const s=xE(e);return o.jsx("div",{className:Ie("min-w-0 break-words",r?"space-y-1.5 text-[0.8125rem] leading-relaxed":"space-y-2.5 text-sm leading-relaxed",n),children:_E(s,r)})}function pA(e){return!Number.isFinite(e)||e<=0?"":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function wq({args:e}){const[r,n]=C.useState(!1),s=Object.entries(e);if(s.length===0)return null;const i=d=>typeof d=="string"||typeof d=="number"||typeof d=="boolean"||d===null,c=s.length<=4&&s.every(([,d])=>i(d));return!c||r?o.jsxs("div",{className:"mt-1.5",children:[c&&o.jsx("button",{type:"button",onClick:()=>n(!1),className:"mb-1 text-[0.625rem] font-medium text-slate-400 hover:text-slate-200",children:"Compact view"}),o.jsx("pre",{className:"overflow-x-auto rounded-lg border border-white/[0.06] bg-black/40 px-2.5 py-1.5 font-mono text-[0.6875rem] leading-snug text-slate-400",children:JSON.stringify(e,null,2)})]}):o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[s.map(([d,f])=>{const p=typeof f=="string"?f:JSON.stringify(f),b=p.length>56?`${p.slice(0,53)}…`:p;return o.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-md border border-white/[0.07] bg-white/[0.03] px-1.5 py-0.5 font-mono text-[0.6875rem]",title:`${d}: ${p}`,children:[o.jsxs("span",{className:"text-slate-500",children:[d,":"]}),o.jsx("span",{className:"truncate text-sky-200/90",children:b})]},d)}),o.jsx("button",{type:"button",onClick:()=>n(!0),className:"text-[0.625rem] text-slate-500 hover:text-slate-300",children:"JSON"})]})}function gA({thinkingTrace:e,stepTrace:r,executedTools:n,defaultOpen:s=!1,running:i=!1,durationMs:c,compact:d=!1}){const[f,p]=C.useState(s),[b,x]=C.useState(0);C.useEffect(()=>{if(!i){x(0);return}const H=Date.now(),Z=window.setInterval(()=>{x(Date.now()-H)},120);return()=>window.clearInterval(Z)},[i]);const g=C.useMemo(()=>r&&r.length>0?r:[...(e??[]).map((H,Z)=>({round:Z+1,phase:"thinking",title:`Model reasoning (round ${Z+1})`,detail:H,status:"done"})),...(n??[]).map((H,Z)=>({round:Z+1,phase:H.ok?"tool":"error",title:`${String(H.name)} · ${H.ok?"ok":"failed"}`,detail:H.summary,toolName:String(H.name),args:H.args,durationMs:H.durationMs,ok:H.ok,status:H.ok?"done":"error"}))],[r,e,n]);if(g.length===0&&!i)return null;const _=g.filter(H=>H.phase==="thinking"&&!!H.detail&&H.status!=="running"),y=g.filter(H=>H.phase==="tool"||H.phase==="error"),S=n?.length??y.length,k=Math.max(e?.length??0,_.length),E=[...g].reverse().find(H=>H.status==="running"),T=E?E.phase==="tool"?`Running ${E.toolName??"tool"}…`:E.phase==="permission"?"Waiting for permission…":"Reasoning…":"Reasoning…",j=i?b:c??g.reduce((H,Z)=>H+(typeof Z.durationMs=="number"&&Z.durationMs>0?Z.durationMs:0),0),q=pA(j),z=_.find(H=>!!H.detail?.trim())?.detail??e?.[0],O=z?vq(z):"",V=(n&&n.length>0?n.map(H=>({name:String(H.name),ok:H.ok})):y.map(H=>({name:H.toolName??H.title.split(" · ")[0],ok:H.ok!==!1}))).slice(0,3),P=Math.max(0,S-V.length),$=i?"Live thinking & tool trace":S>0?"Thinking & tool process":"Thought process";return o.jsxs("div",{className:Ie("overflow-hidden rounded-xl border text-xs transition-colors",i?"border-sky-500/30 bg-gradient-to-b from-sky-500/[0.07] to-black/30":"border-white/[0.08] bg-black/25"),children:[o.jsxs("button",{type:"button",onClick:()=>p(H=>!H),"aria-expanded":f,className:"flex w-full flex-col gap-1 px-3 py-2 text-left transition-colors hover:bg-white/[0.03]",children:[o.jsxs("div",{className:"flex w-full items-center gap-2",children:[f?o.jsx(ph,{className:"h-3.5 w-3.5 shrink-0 text-slate-400"}):o.jsx(Ty,{className:"h-3.5 w-3.5 shrink-0 text-slate-400"}),i?o.jsx(qs,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-sky-300"}):o.jsx(Tb,{className:"h-3.5 w-3.5 shrink-0 text-sky-300"}),o.jsx("span",{className:"font-medium text-slate-200",children:$}),i&&o.jsx("span",{className:"rounded-full border border-sky-400/25 bg-sky-500/15 px-2 py-0.5 text-[0.625rem] font-medium text-sky-200",children:T}),o.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 text-[0.6875rem] text-slate-400 tabular-nums",children:[q&&o.jsxs("span",{className:"inline-flex items-center gap-1 text-slate-400",children:[o.jsx(zx,{className:"h-2.5 w-2.5 text-slate-500"}),q]}),k>0&&o.jsxs("span",{children:[k," thought",k===1?"":"s"]}),S>0&&o.jsxs("span",{children:[S," tool",S===1?"":"s"]})]})]}),!f&&!i&&(O||V.length>0)&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-5.5",children:[O&&o.jsx("span",{className:"line-clamp-1 max-w-full text-[0.71875rem] text-slate-400",children:O}),V.length>0&&o.jsxs("span",{className:"flex flex-wrap items-center gap-1",children:[V.map((H,Z)=>o.jsxs("span",{className:Ie("inline-flex items-center gap-1 rounded border px-1.5 py-px font-mono text-[0.625rem]",H.ok?"border-emerald-500/20 bg-emerald-500/[0.07] text-emerald-300/90":"border-rose-500/25 bg-rose-500/[0.08] text-rose-300"),children:[H.ok?o.jsx(Gs,{className:"h-2.5 w-2.5"}):o.jsx(Bc,{className:"h-2.5 w-2.5"}),H.name]},`${H.name}-${Z}`)),P>0&&o.jsxs("span",{className:"text-[0.625rem] text-slate-500",children:["+",P," more"]})]})]})]}),f&&o.jsx("div",{className:Ie("border-t border-white/[0.06]",d?"px-2.5 py-2":"px-3.5 py-2.5"),children:g.length===0&&i?o.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-slate-400",children:[o.jsx(Tb,{className:"h-3.5 w-3.5 animate-pulse text-sky-300"}),o.jsx("span",{children:"Planning next MCP steps…"})]}):o.jsx("div",{className:"relative space-y-2.5 pl-5 before:absolute before:top-2 before:bottom-2 before:left-[0.5rem] before:w-px before:bg-white/[0.08]",children:g.map((H,Z)=>{const G=H.status==="running",K=typeof H.durationMs=="number"&&H.durationMs>0?pA(H.durationMs):"",we=H.phase==="thinking",Se=H.phase==="permission",Q=H.phase==="error"||H.ok===!1;return o.jsxs("div",{className:"relative",children:[o.jsx("span",{className:Ie("absolute top-1 -left-5 flex h-4 w-4 items-center justify-center rounded-full border",G?"border-sky-400/50 bg-[#0d1522] text-sky-300":we?"border-sky-400/30 bg-sky-500/15 text-sky-300":Se?H.ok===!0?"border-emerald-400/30 bg-emerald-500/15 text-emerald-300":H.ok===!1?"border-rose-400/35 bg-rose-500/15 text-rose-400":"border-amber-400/40 bg-amber-500/15 text-amber-300":Q?"border-rose-400/35 bg-rose-500/15 text-rose-400":"border-emerald-400/30 bg-emerald-500/15 text-emerald-300"),children:G?o.jsx(qs,{className:"h-2.5 w-2.5 animate-spin"}):we?o.jsx(Tb,{className:"h-2.5 w-2.5"}):Se?o.jsx(YA,{className:"h-2.5 w-2.5"}):Q?o.jsx(Bc,{className:"h-2.5 w-2.5"}):o.jsx(Py,{className:"h-2.5 w-2.5"})}),o.jsxs("div",{className:Ie("rounded-lg border px-2.5 py-2",G?"border-sky-500/25 bg-sky-500/[0.04]":we?"border-white/[0.06] bg-white/[0.02]":Q?"border-rose-500/20 bg-rose-500/[0.04]":"border-white/[0.06] bg-white/[0.02]"),children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[H.toolName?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"font-mono text-[0.71875rem] font-semibold text-sky-200",children:H.toolName}),o.jsx("span",{className:Ie("rounded px-1.5 py-px text-[0.625rem] font-medium",G?"bg-sky-500/15 text-sky-300":Q?"bg-rose-500/15 text-rose-300":"bg-emerald-500/15 text-emerald-300"),children:G?"running":Q?"failed":"ok"})]}):o.jsx("span",{className:"text-[0.71875rem] font-medium text-slate-200",children:H.title}),K&&o.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[0.625rem] text-slate-500 tabular-nums",children:[o.jsx(zx,{className:"h-2.5 w-2.5"}),K]})]}),H.args&&Object.keys(H.args).length>0&&o.jsx(wq,{args:H.args}),H.detail&&o.jsx("div",{className:"mt-1.5 text-slate-300",children:we&&!G?o.jsx(vE,{text:H.detail,compact:!0,className:"text-[0.75rem] text-slate-300/95"}):o.jsx("p",{className:Ie("text-[0.75rem] leading-snug whitespace-pre-wrap",G?"animate-pulse text-sky-200/80":"text-slate-400"),children:H.detail})})]})]},`${H.round}-${H.phase}-${Z}`)})})})]})}const Sq=["Explain the comparison metrics","Which residues deviate most?","Show active-site contacts","Ramachandran outliers","mutate H94A","crispr codon 94"],kq=["Create a new project, split 3HS4 chains/ligands, and open the 3D viewer","Design an aspirin analog in RDKit, score MW/cLogP/TPSA, and add to project","Search Europe PMC for 3HS4 carbonic anhydrase II acetazolamide","Run superposition, apply H94A peptide mutation, and export an RUO report"];function Cq({text:e}){const[r,n]=C.useState(!1),s=()=>{try{navigator.clipboard?.writeText(e),n(!0),window.setTimeout(()=>n(!1),1600)}catch{}};return o.jsxs("button",{type:"button",onClick:s,className:"ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[0.6875rem] text-slate-500 transition-colors hover:bg-white/[0.06] hover:text-slate-200",title:"Copy response markdown",children:[r?o.jsx(Fi,{className:"h-3 w-3 text-emerald-400"}):o.jsx(Lr,{className:"h-3 w-3"}),o.jsx("span",{children:r?"Copied":"Copy"})]})}function Nq({messages:e,busy:r,config:n,liveSteps:s=[],pendingPermission:i,onResolvePermission:c,onSelectProvider:d,onToggleWebSearch:f,onSend:p,onClear:b,onOpenKeySettings:x,onOpenMcpServer:g}){const[_,y]=C.useState(""),S=C.useRef(null),k=C.useRef(null),E=Xc(n),T=es[E.provider],j=n[E.provider]??{apiKey:"",model:""},q=T.models.find($=>$.id===j.model)?.label??j.model,z=!!j.apiKey,O=n.enableWebSearch!==!1;C.useEffect(()=>{S.current?.scrollTo({top:S.current.scrollHeight,behavior:"smooth"})},[e.length,r,s.length,i?.id]),C.useEffect(()=>{const $=k.current;$&&($.style.height="auto",$.style.height=`${Math.min(180,$.scrollHeight)}px`)},[_]);const V=($=_)=>{const H=$.trim();!H||r||(p(H),y(""))},P=e.filter($=>$.role==="user").length;return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col",children:[o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between gap-2 border-b border-white/[0.06] px-4",children:[o.jsx(i1,{align:"left",trigger:($,H)=>o.jsxs("button",{type:"button",onClick:H,className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-sm hover:bg-white/[0.05]",children:[o.jsx(qr,{className:"h-4 w-4 text-sky-300"}),o.jsx("span",{className:"font-medium text-slate-100",children:z?q:"Local Copilot"}),z&&o.jsx(It,{tone:E.isByok?"good":"accent",className:"hidden @md:inline-flex",children:E.isByok?"BYOK · state.vscdb":"Synlexa Cloud"}),o.jsx(ph,{className:Ie("h-3.5 w-3.5 text-slate-500 transition-transform",$&&"rotate-180")})]}),items:[...Uv.flatMap(($,H)=>{const Z=!!n[$]?.apiKey,G={heading:es[$].label},K=H>0?["divider"]:[];return Z?[...K,G,...es[$].models.map(we=>{const Se=E.provider===$&&j.model===we.id;return{key:`${$}:${we.id}`,label:we.label,description:we.note,selected:Se,hint:Se?"✓":void 0,onSelect:()=>d($,we.id)}})]:[...K,G,{key:`${$}:setup`,label:$==="synlexa"?"Sign in to use Synlexa Cloud…":"Add your BYOK key (state.vscdb)…",icon:o.jsx(tp,{className:"h-4 w-4"}),onSelect:x}]}),"divider",{label:"AI routing, permissions & vault…",icon:o.jsx(tp,{className:"h-4 w-4"}),onSelect:x}]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[f&&o.jsxs("button",{type:"button",onClick:()=>f(!O),title:"Allow AI agent to query Europe PMC & ClinicalTrials.gov via MCP",className:Ie("inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs transition-colors",O?"border-emerald-500/40 bg-emerald-500/10 text-emerald-300":"border-white/10 bg-white/[0.03] text-slate-400 hover:text-slate-200"),children:[o.jsx(Ry,{className:"h-3.5 w-3.5"}),o.jsxs("span",{className:"hidden @lg:inline",children:["Web ",O?"ON":"OFF"]})]}),g&&o.jsxs("button",{type:"button",onClick:g,title:`Open In-App MCP Server (${Lc.length} tools)`,className:"inline-flex items-center gap-1 rounded-md border border-sky-500/30 bg-sky-500/10 px-2 py-1 text-xs text-sky-300 hover:bg-sky-500/20",children:[o.jsx(rl,{className:"h-3.5 w-3.5"}),o.jsxs("span",{className:"hidden @lg:inline",children:["MCP (",Lc.length,")"]})]}),P>0&&o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(KA,{className:"h-3.5 w-3.5"}),onClick:b,disabled:r,children:"New chat"})]})]}),o.jsx("div",{ref:S,className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-3xl space-y-5 px-5 py-5",children:[P===0&&o.jsxs("div",{className:"pt-4 pb-2",children:[o.jsxs("h2",{className:"text-lg font-semibold text-slate-100",children:["Autonomous AI Copilot (",Lc.length," MCP tools)"]}),o.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Inspects loaded 3D structures, designs molecules in RDKit, creates projects, splits chains/ligands, stages binding, runs GPU pipelines, controls the Studio UI, and shows its step-by-step thinking trace."}),!z&&o.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 rounded-xl border border-white/10 bg-white/[0.02] p-3.5",children:[o.jsx(tp,{className:"h-4 w-4 shrink-0 text-amber-300"}),o.jsxs("div",{className:"min-w-0 flex-1 text-sm text-slate-300",children:["Add your own Anthropic, Gemini, or OpenAI/Codex BYOK key in ",o.jsx("code",{className:"text-sky-300",children:"state.vscdb"})," (prioritized over Synlexa Cloud), or sign in to synlexa.com. Until then, the built-in deterministic Copilot handles workspace commands."]}),o.jsx(Oe,{size:"sm",variant:"primary",onClick:x,children:"Set up AI"})]}),o.jsx("div",{className:"mt-5 grid gap-2 @xl:grid-cols-2",children:(z?kq:Sq).map($=>o.jsx("button",{type:"button",onClick:()=>V($),disabled:r,className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3.5 py-3 text-left text-sm text-slate-300 transition-colors hover:border-sky-400/40 hover:bg-sky-400/[0.04] hover:text-slate-100",children:$},$))})]}),e.map(($,H)=>$.role==="assistant"&&H===0&&P===0?null:$.role==="user"?o.jsx("div",{className:"flex justify-end",children:o.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md bg-sky-500/15 px-4 py-2.5 text-sm whitespace-pre-wrap text-slate-100",children:$.text})},$.id):o.jsxs("div",{className:"flex gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-white/[0.05] text-sky-300",children:o.jsx(qr,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0 flex-1 space-y-2.5",children:[o.jsx(gA,{thinkingTrace:$.thinkingTrace,stepTrace:$.stepTrace,executedTools:$.executedTools,durationMs:$.durationMs,defaultOpen:!1}),o.jsx("div",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] px-4 py-3",children:o.jsx(vE,{text:$.text})}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[0.6875rem] text-slate-500",children:[$.mode==="local-deterministic-fallback"?o.jsx(It,{children:"Built-in assistant"}):o.jsx(It,{tone:$.mode==="synlexa-cloud"?"accent":"good",children:$.providerLabel??($.mode==="synlexa-cloud"?`Synlexa Cloud · ${$.model}`:`BYOK · ${$.model}`)}),$.usage&&($.usage.inputTokens>0||$.usage.outputTokens>0)&&o.jsxs("span",{className:"tabular-nums",children:[$.usage.inputTokens.toLocaleString()," in · ",$.usage.outputTokens.toLocaleString()," out"]}),typeof $.durationMs=="number"&&$.durationMs>0&&o.jsxs("span",{className:"tabular-nums",children:["· ",$.durationMs<1e3?`${$.durationMs}ms`:`${($.durationMs/1e3).toFixed(1)}s`]}),$.error&&o.jsx(It,{tone:"warn",children:$.error}),o.jsx("span",{children:"Model output is provisional · RUO"}),o.jsx(Cq,{text:$.text})]})]})]},$.id)),r&&o.jsxs("div",{className:"flex gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-white/[0.05]",children:o.jsx(qs,{className:"h-4 w-4 animate-spin text-sky-300"})}),o.jsx("div",{className:"min-w-0 flex-1 space-y-2",children:o.jsx(gA,{stepTrace:s,defaultOpen:!0,running:!0})})]}),i&&o.jsx("div",{className:"rounded-xl border border-amber-400/40 bg-amber-500/[0.08] p-4 shadow-lg",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(YA,{className:"mt-0.5 h-5 w-5 shrink-0 text-amber-300"}),o.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"text-sm font-semibold text-amber-100",children:i.title}),o.jsx(It,{tone:"warn",children:i.category})]}),o.jsx("p",{className:"text-xs leading-relaxed text-slate-200",children:i.detail}),Object.keys(i.args).length>0&&o.jsx("pre",{className:"overflow-x-auto rounded-lg bg-black/35 px-2.5 py-1.5 font-mono text-[0.7rem] text-slate-300",children:JSON.stringify(i.args,null,2)}),o.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[o.jsx(Oe,{size:"sm",variant:"primary",onClick:()=>c?.("allow_once"),children:"Allow once"}),o.jsx(Oe,{size:"sm",variant:"secondary",onClick:()=>c?.("allow_session"),children:"Always allow this session"}),o.jsx(Oe,{size:"sm",variant:"danger",onClick:()=>c?.("deny"),children:"Deny"})]})]})]})})]})}),o.jsxs("div",{className:"shrink-0 border-t border-white/[0.06] p-3",children:[o.jsxs("div",{className:"mx-auto flex max-w-3xl items-end gap-2 rounded-2xl border border-white/10 bg-black/30 p-2 focus-within:border-sky-400/50",children:[o.jsx("textarea",{ref:k,rows:1,value:_,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&!$.nativeEvent.isComposing&&($.preventDefault(),V())},placeholder:"Ask the agent to inspect, design molecules, split chains, test docking, open tabs, or search literature…",className:"max-h-44 min-h-9 flex-1 resize-none bg-transparent px-2 py-1.5 text-sm text-slate-100 placeholder-slate-500 outline-none"}),o.jsx("button",{type:"button",onClick:()=>V(),disabled:!_.trim()||r,"aria-label":"Send",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-sky-500 text-slate-950 transition hover:bg-sky-400 disabled:bg-white/[0.08] disabled:text-slate-500",children:o.jsx(cR,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"mx-auto mt-1.5 flex max-w-3xl items-center justify-between px-1 text-[0.6875rem] text-slate-500",children:o.jsx(C.Fragment,{children:"Enter to send · Shift+Enter for a new line · Keys encrypted in state.vscdb · Research use only"})})]})]})}const rr=(e,r)=>Number.isFinite(e)?e.toFixed(r):"n/a";function Aq(e){const r=`${rr(e,3)} Å`;return e<1?{metric:"Cα RMSD",value:r,tone:"excellent",label:"High Structural Agreement",explanation:"Backbones overlay almost perfectly after superposition — the two models share the same fold at near-atomic detail.",rule:"RMSD < 1.0 Å"}:e<2?{metric:"Cα RMSD",value:r,tone:"good",label:"Close Structural Agreement",explanation:"Same overall fold with small local differences (loops, termini, or side-chain driven shifts).",rule:"1.0 ≤ RMSD < 2.0 Å"}:e<3?{metric:"Cα RMSD",value:r,tone:"moderate",label:"Partial Agreement",explanation:"Core fold is likely similar, but some regions deviate noticeably. Inspect the Δd track.",rule:"2.0 ≤ RMSD < 3.0 Å"}:{metric:"Cα RMSD",value:r,tone:"caution",label:"Low Agreement",explanation:"Large deviations — check chain selection, domain motion, or sequence mapping before interpreting.",rule:"RMSD ≥ 3.0 Å"}}function wE(e){const r=rr(e,1);return e>90?{metric:"Mean pLDDT",value:r,tone:"excellent",label:"Very High Confidence",explanation:"The predictor is very confident in local backbone and many side-chain positions.",rule:"pLDDT > 90"}:e>70?{metric:"Mean pLDDT",value:r,tone:"good",label:"Confident",explanation:"Backbone placement is generally reliable; side chains may vary.",rule:"70 < pLDDT ≤ 90"}:e>50?{metric:"Mean pLDDT",value:r,tone:"moderate",label:"Low Confidence",explanation:"Treat these regions with caution — they may be flexible or poorly constrained.",rule:"50 < pLDDT ≤ 70"}:{metric:"Mean pLDDT",value:r,tone:"caution",label:"Very Low Confidence",explanation:"Likely disordered or unreliable in isolation; do not interpret fine structure here.",rule:"pLDDT ≤ 50"}}function jq(e,r,n){const s=`${r}/${n} (${rr(e*100,1)}%)`;return e>=.9?{metric:"Coverage",value:s,tone:"excellent",label:"Near-Complete Coverage",explanation:"Almost every residue was matched, so the RMSD summarises nearly the whole chain.",rule:"coverage ≥ 90%"}:e>=.6?{metric:"Coverage",value:s,tone:"good",label:"Good Coverage",explanation:"Most residues were matched; unmatched parts are often termini, tags, or signal peptides.",rule:"60% ≤ coverage < 90%"}:e>=.3?{metric:"Coverage",value:s,tone:"moderate",label:"Partial Coverage",explanation:"Only part of the chain was compared — RMSD describes that subset only.",rule:"30% ≤ coverage < 60%"}:{metric:"Coverage",value:s,tone:"caution",label:"Sparse Coverage",explanation:"Few residues matched. The comparison may cover a single domain of a larger protein.",rule:"coverage < 30%"}}function Tq(e){const r=`${rr(e,1)} Å`;return e<5?{metric:"Mean PAE",value:r,tone:"excellent",label:"Confident Relative Placement",explanation:"Domains and residues are predicted to sit in well-defined positions relative to each other.",rule:"mean PAE < 5 Å"}:e<10?{metric:"Mean PAE",value:r,tone:"good",label:"Moderate Relative Placement",explanation:"Overall arrangement is plausible, with some uncertainty between distant regions.",rule:"5 ≤ mean PAE < 10 Å"}:{metric:"Mean PAE",value:r,tone:"caution",label:"Uncertain Relative Placement",explanation:"Relative domain positions are uncertain — avoid reading inter-domain geometry.",rule:"mean PAE ≥ 10 Å"}}function bA(e){const r=`${rr(e,1)} Ų`;return e<=140?{metric:"TPSA",value:r,tone:e<=90?"excellent":"good",label:"Good Permeability (heuristic)",explanation:"Polar surface area is within the common Veber guideline associated with passive membrane permeability in computational screens.",rule:"TPSA ≤ 140 Ų"}:{metric:"TPSA",value:r,tone:"caution",label:"High Polarity",explanation:"Large polar surface area; passive permeability is usually lower for such compounds.",rule:"TPSA > 140 Ų"}}function xA(e){const r=rr(e,2);return e<0?{metric:"cLogP",value:r,tone:"info",label:"Hydrophilic",explanation:"Prefers water over octanol — typically very soluble but less membrane-partitioning.",rule:"cLogP < 0"}:e<=5?{metric:"cLogP",value:r,tone:"good",label:"Balanced Lipophilicity",explanation:"Within the Lipinski rule-of-five lipophilicity limit (≤ 5).",rule:"0 ≤ cLogP ≤ 5"}:{metric:"cLogP",value:r,tone:"caution",label:"Highly Lipophilic",explanation:"Above the rule-of-five limit; often associated with low aqueous solubility.",rule:"cLogP > 5"}}function Eq(e){return{metric:"Lipinski",value:`${e} violation${e===1?"":"s"}`,tone:e===0?"excellent":e===1?"good":"caution",label:e===0?"Rule-of-Five Compliant":e===1?"One Rule Exceeded":"Multiple Rules Exceeded",explanation:e<=1?"Descriptor profile sits inside the classic rule-of-five heuristic for small molecules.":"Outside the classic rule-of-five heuristic (many natural products and biologics are too).",rule:"MW ≤ 500, cLogP ≤ 5, HBD ≤ 5, HBA ≤ 10"}}function yA(e,r){const n=`pI ${rr(e,2)}`,s=r>.5?"positive":r<-.5?"negative":"near-neutral";return{metric:"Isoelectric point",value:n,tone:"info",label:e>7.4?"Basic (pI > 7.4)":e<7.4?"Acidic (pI < 7.4)":"Neutral pI",explanation:`At pH 7.4 the sequence carries a ${s} net charge (${r>=0?"+":""}${rr(r,2)}), estimated by Henderson–Hasselbalch.`,rule:"compare pI with pH 7.4"}}function _A(e){return{metric:"GRAVY",value:rr(e,3),tone:"info",label:e>0?"Net Hydrophobic":"Net Hydrophilic",explanation:e>0?"Average Kyte–Doolittle hydropathy is positive — the sequence leans hydrophobic.":"Average Kyte–Doolittle hydropathy is negative — typical of soluble, globular proteins.",rule:"GRAVY > 0 hydrophobic"}}function Mq(e){const r=e>=40&&e<=60;return{metric:"Guide GC%",value:`${rr(e,0)}%`,tone:r?"good":"moderate",label:r?"Typical GC Range":"Atypical GC",explanation:r?"Protospacer GC content is within the 40–60% range commonly preferred in guide design heuristics.":"GC content is outside the commonly preferred 40–60% window; consider nearby PAM sites.",rule:"40% ≤ GC ≤ 60%"}}function Rq(e){let r=0,n=0;for(const s of e)typeof s=="number"&&Number.isFinite(s)&&(r+=s,n+=1);return n>0?r/n:null}function zq(e){if(!e)return null;try{const r=JSON.parse(e),s=(Array.isArray(r)?r[0]:r)?.predicted_aligned_error;if(!Array.isArray(s))return null;let i=0,c=0;for(const d of s)if(Array.isArray(d))for(const f of d)typeof f=="number"&&Number.isFinite(f)&&(i+=f,c+=1);return c>0?i/c:null}catch{return null}}const Oq={excellent:"border-emerald-400/40 bg-emerald-400/10 text-emerald-200",good:"border-sky-400/40 bg-sky-400/10 text-sky-200",moderate:"border-amber-400/40 bg-amber-400/10 text-amber-200",caution:"border-rose-400/40 bg-rose-400/10 text-rose-200",info:"border-slate-500/40 bg-slate-500/10 text-slate-200"};function Ca({insight:e,compact:r=!1}){const n=Oq[e.tone];return r?o.jsx("span",{title:`${e.label} (${e.rule}): ${e.explanation}`,className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[0.6875rem] font-medium ${n}`,children:o.jsx("span",{children:e.label})}):o.jsxs("div",{className:"rounded-lg border border-slate-800/90 bg-slate-950/75 p-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-[0.75rem] text-slate-400",children:e.metric}),o.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[0.6875rem] font-medium ${n}`,children:e.label})]}),o.jsxs("div",{className:"mt-1 flex items-baseline justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-sm font-bold text-slate-100",children:e.value}),o.jsx("span",{className:"font-mono text-[0.6875rem] text-slate-500",children:e.rule})]}),o.jsx("p",{className:"mt-1 text-[0.75rem] leading-relaxed text-slate-400",children:e.explanation})]})}const Pq=new Set(["C","N","O","S","P","F","Cl","Br"]);function nh(){return{atoms:[],bonds:[],nextId:1}}function $q(e){const r=e.trim();return Pq.has(r)?r:"C"}function Qf(e,r="SynlexaSketch"){const n=e.atoms.length,s=e.bonds.length,i=new Map;e.atoms.forEach((b,x)=>i.set(b.id,x+1));const c=1.5/48;let d=0,f=0;for(const b of e.atoms)d+=b.x,f+=b.y;n>0&&(d/=n,f/=n);const p=[r.slice(0,80)," Synlexa2D 2D","",`${String(n).padStart(3," ")}${String(s).padStart(3," ")} 0 0 0 0 0 0 0 0999 V2000`];for(const b of e.atoms){const x=((b.x-d)*c).toFixed(4).padStart(10," "),g=(-(b.y-f)*c).toFixed(4).padStart(10," "),_=" 0.0000",y=b.element.padEnd(3," ");p.push(`${x}${g}${_} ${y} 0 0 0 0 0 0 0 0 0 0 0 0`)}for(const b of e.bonds){const x=i.get(b.from),g=i.get(b.to);!x||!g||p.push(`${String(x).padStart(3," ")}${String(g).padStart(3," ")}${String(b.order).padStart(3," ")} 0 0 0 0`)}return p.push("M END"),p.join(`
765
+ `)}function Ax(e,r=480,n=300){const s=e.replace(/\r\n?/g,`
766
+ `).split(`
767
+ `);if(s.length<4)return nh();const i=s[3],c=Number.parseInt(i.slice(0,3).trim(),10),d=Number.parseInt(i.slice(3,6).trim(),10);if(!Number.isFinite(c)||!Number.isFinite(d)||c<=0||s.length<4+c+d)return nh();const f=[];for(let q=0;q<c;q++){const z=s[4+q],O=Number.parseFloat(z.slice(0,10).trim()),V=Number.parseFloat(z.slice(10,20).trim()),P=$q(z.slice(31,34).trim());if(!Number.isFinite(O)||!Number.isFinite(V))return nh();f.push({x:O,y:V,element:P})}let p=1/0,b=-1/0,x=1/0,g=-1/0;for(const q of f)q.x<p&&(p=q.x),q.x>b&&(b=q.x),q.y<x&&(x=q.y),q.y>g&&(g=q.y);const _=Math.max(.001,b-p),y=Math.max(.001,g-x),S=Math.min(34,Math.min((r-96)/_,(n-80)/y)),k=(p+b)/2,E=(x+g)/2,T=f.map((q,z)=>({id:z+1,element:q.element,x:r/2+(q.x-k)*S,y:n/2-(q.y-E)*S})),j=[];for(let q=0;q<d;q++){const z=s[4+c+q],O=Number.parseInt(z.slice(0,3).trim(),10),V=Number.parseInt(z.slice(3,6).trim(),10),P=Number.parseInt(z.slice(6,9).trim(),10),$=P===2?2:P===3?3:1;O>=1&&O<=c&&V>=1&&V<=c&&O!==V&&j.push({from:O,to:V,order:$})}return{atoms:T,bonds:j,nextId:c+1}}function vA(e,r,n,s,i=42){let c=e.nextId;const d=[],f=[];if(r==="sulfonamide"){const p=c++,b=c++,x=c++,g=c++;d.push({id:p,element:"S",x:n,y:s},{id:b,element:"O",x:n,y:s-44},{id:x,element:"O",x:n,y:s+44},{id:g,element:"N",x:n+44,y:s}),f.push({from:p,to:b,order:2},{from:p,to:x,order:2},{from:p,to:g,order:1})}else if(r==="carboxyl"){const p=c++,b=c++,x=c++;d.push({id:p,element:"C",x:n,y:s},{id:b,element:"O",x:n,y:s-44},{id:x,element:"O",x:n+40,y:s+22}),f.push({from:p,to:b,order:2},{from:p,to:x,order:1})}else if(r==="amide"){const p=c++,b=c++,x=c++;d.push({id:p,element:"C",x:n,y:s},{id:b,element:"O",x:n,y:s-44},{id:x,element:"N",x:n+40,y:s+22}),f.push({from:p,to:b,order:2},{from:p,to:x,order:1})}else{const p=r==="cyclopentane"||r==="thiophene"?5:6,b=[];for(let x=0;x<p;x++){const g=Math.PI*2*x/p-Math.PI/2,_=r==="pyridine"&&x===0?"N":r==="thiophene"&&x===0?"S":"C",y=c++;b.push(y),d.push({id:y,element:_,x:n+Math.cos(g)*i,y:s+Math.sin(g)*i})}for(let x=0;x<p;x++){const g=b[x],_=b[(x+1)%p];let y=1;r==="benzene"||r==="pyridine"?y=x%2===0?2:1:r==="thiophene"&&(y=x===1||x===3?2:1),f.push({from:g,to:_,order:y})}}return{atoms:[...e.atoms,...d],bonds:[...e.bonds,...f],nextId:c}}const Iq=["C","N","O","S","P","F","Cl","Br"],wA={C:"#cbd5e1",N:"#60a5fa",O:"#f87171",S:"#facc15",P:"#fb923c",F:"#34d399",Cl:"#34d399",Br:"#fb7185"},Dq=[{id:"benzene",label:"Benzene",tip:"Stamp a 6-membered aromatic benzene ring"},{id:"pyridine",label:"Pyridine",tip:"Stamp an N-heteroaromatic pyridine ring"},{id:"thiophene",label:"Thiophene",tip:"Stamp a 5-membered S-aromatic ring"},{id:"cyclohexane",label:"Cyclohexane",tip:"Stamp a saturated 6-membered ring"},{id:"cyclopentane",label:"Cyclopentane",tip:"Stamp a saturated 5-membered ring"},{id:"sulfonamide",label:"-SO₂NH₂",tip:"Stamp a zinc-binding sulfonamide group"},{id:"carboxyl",label:"-COOH",tip:"Stamp a carboxylic acid group"},{id:"amide",label:"-CONH₂",tip:"Stamp a primary amide group"}];function qq({initialMolblock:e,activeSmiles:r,activeName:n,onCommitMolblock:s}){const i=C.useRef(null),c=C.useMemo(()=>e?Ax(e):vA(nh(),"benzene",240,150),[]),[d,f]=C.useState([c]),[p,b]=C.useState(0),[x,g]=C.useState(e??null),[_,y]=C.useState(!1),S=d[p]??c,[k,E]=C.useState("C"),[T,j]=C.useState(1),[q,z]=C.useState("draw"),[O,V]=C.useState(null),[P,$]=C.useState(null);C.useEffect(()=>{if(!(!e||e===x)&&!_){const le=Ax(e);f([le]),b(0),g(e)}},[e,x,_]);const H=C.useMemo(()=>{const le=new Map;for(const D of S.atoms)le.set(D.id,D);return le},[S.atoms]),Z=(le,D=!0)=>{const pe=[...d.slice(0,p+1),le].slice(-30);f(pe),b(pe.length-1),y(!0),D&&le.atoms.length>0&&s(Qf(le))},G=p>0,K=p<d.length-1,we=()=>{if(!G)return;const le=p-1;b(le);const D=d[le];D&&D.atoms.length>0&&s(Qf(D))},Se=()=>{if(!K)return;const le=p+1;b(le);const D=d[le];D&&D.atoms.length>0&&s(Qf(D))},Q=()=>{if(!e)return;const le=Ax(e);f([le]),b(0),g(e),y(!1)},F=le=>{const D=i.current?.getBoundingClientRect();return!D||D.width===0||D.height===0?{x:240,y:150}:{x:(le.clientX-D.left)/D.width*480,y:(le.clientY-D.top)/D.height*300}},he=(le,D,ae=18)=>{let pe=null,Ae=ae;for(const Ne of S.atoms){const Re=Math.hypot(Ne.x-le,Ne.y-D);Re<Ae&&(pe=Ne,Ae=Re)}return pe},W=(le,D,ae=11)=>{for(let pe=0;pe<S.bonds.length;pe++){const Ae=S.bonds[pe],Ne=H.get(Ae.from),Re=H.get(Ae.to);if(!Ne||!Re)continue;const $e=Re.x-Ne.x,Ce=Re.y-Ne.y,Ue=$e*$e+Ce*Ce;if(Ue===0)continue;const be=Math.max(.1,Math.min(.9,((le-Ne.x)*$e+(D-Ne.y)*Ce)/Ue)),bt=Ne.x+be*$e,Ot=Ne.y+be*Ce;if(Math.hypot(le-bt,D-Ot)<=ae)return pe}return-1},me=le=>{const D=F(le);if(q!=="draw"&&q!=="erase"){const Ne=he(D.x,D.y,20),Re=Ne?Ne.x:D.x,$e=Ne?Ne.y:D.y,Ce=vA(S,q,Re,$e);Z(Ce),z("draw");return}const ae=he(D.x,D.y);if(q==="erase"){if(ae){Z({...S,atoms:S.atoms.filter(Re=>Re.id!==ae.id),bonds:S.bonds.filter(Re=>Re.from!==ae.id&&Re.to!==ae.id)});return}const Ne=W(D.x,D.y);Ne>=0&&Z({...S,bonds:S.bonds.filter((Re,$e)=>$e!==Ne)});return}if(ae){V(ae),$(D);return}const pe=W(D.x,D.y);if(pe>=0){const Ne=S.bonds.map((Re,$e)=>$e===pe?{...Re,order:Re.order%3+1}:Re);Z({...S,bonds:Ne});return}const Ae=S.nextId;Z({atoms:[...S.atoms,{id:Ae,element:k,x:D.x,y:D.y}],bonds:S.bonds,nextId:Ae+1})},I=le=>{O&&$(F(le))},J=le=>{if(!O)return;const D=F(le),ae=Math.hypot(D.x-O.x,D.y-O.y),pe=he(D.x,D.y);if(ae<10)O.element!==k&&Z({...S,atoms:S.atoms.map(Ae=>Ae.id===O.id?{...Ae,element:k}:Ae)});else if(pe&&pe.id!==O.id){const Ae=S.bonds.findIndex(Ne=>Ne.from===O.id&&Ne.to===pe.id||Ne.to===O.id&&Ne.from===pe.id);Ae>=0?Z({...S,bonds:S.bonds.map((Ne,Re)=>Re===Ae?{...Ne,order:Ne.order%3+1}:Ne)}):Z({...S,bonds:[...S.bonds,{from:O.id,to:pe.id,order:T}]})}else{const Ae=Math.atan2(D.y-O.y,D.x-O.x),Ne=Math.round(Ae/(Math.PI/6))*(Math.PI/6),Re=Math.max(20,Math.min(460,O.x+Math.cos(Ne)*48)),$e=Math.max(20,Math.min(280,O.y+Math.sin(Ne)*48)),Ce=S.nextId;Z({atoms:[...S.atoms,{id:Ce,element:k,x:Re,y:$e}],bonds:[...S.bonds,{from:O.id,to:Ce,order:T}],nextId:Ce+1})}V(null),$(null)},ge=!!(e&&e!==x&&_);return o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[Iq.map(le=>o.jsx("button",{type:"button",title:`Select element ${le} (click an atom to replace, or drag to sprout)`,onClick:()=>{E(le),z("draw")},className:`rounded-md border px-2 py-1 font-mono text-xs font-semibold transition ${q==="draw"&&k===le?"border-sky-400/60 bg-sky-500/20":"border-white/10 bg-slate-900/80 hover:border-white/25"}`,style:{color:wA[le]},children:le},le)),o.jsx("span",{className:"mx-1 h-4 w-px bg-white/10"}),[1,2,3].map(le=>o.jsx("button",{type:"button",title:`Draw ${le===1?"single":le===2?"double":"triple"} bond (or click existing bond to cycle)`,onClick:()=>{j(le),z("draw")},className:`rounded-md border px-2 py-1 font-mono text-xs transition ${q==="draw"&&T===le?"border-emerald-400/60 bg-emerald-500/20 text-emerald-200":"border-white/10 bg-slate-900/80 text-slate-400 hover:border-white/25 hover:text-slate-200"}`,children:le===1?"Single":le===2?"Double":"Triple"},le))]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[o.jsx("button",{type:"button",onClick:we,disabled:!G,title:"Undo last stroke",className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900/80 px-2 py-1 text-xs text-slate-300 hover:border-white/25 disabled:opacity-35",children:o.jsx(tz,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:Se,disabled:!K,title:"Redo stroke",className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900/80 px-2 py-1 text-xs text-slate-300 hover:border-white/25 disabled:opacity-35",children:o.jsx(P6,{className:"h-3.5 w-3.5"})}),o.jsxs("button",{type:"button",onClick:()=>z(q==="erase"?"draw":"erase"),className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs transition ${q==="erase"?"border-rose-400/60 bg-rose-500/20 text-rose-200":"border-white/10 bg-slate-900/80 text-slate-300 hover:border-white/25"}`,children:[o.jsx(VR,{className:"h-3.5 w-3.5"})," Erase"]}),e&&o.jsxs("button",{type:"button",onClick:Q,className:`flex items-center gap-1 rounded-md border px-2 py-1 text-xs transition ${ge?"border-amber-400/50 bg-amber-500/15 text-amber-200 hover:bg-amber-500/25":"border-white/10 bg-slate-900/80 text-slate-300 hover:border-white/25"}`,title:"Import the active analyzed molecule into the sketcher canvas",children:[o.jsx(KA,{className:"h-3.5 w-3.5"})," Load Active"]}),o.jsxs("button",{type:"button",onClick:()=>{Z(nh(),!1)},className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900/80 px-2 py-1 text-xs text-slate-400 hover:border-rose-500/40 hover:text-rose-200",children:[o.jsx(Wi,{className:"h-3.5 w-3.5"})," Clear"]}),S.atoms.length>0&&o.jsxs("button",{type:"button",onClick:()=>s(Qf(S)),className:"flex items-center gap-1 rounded-md border border-emerald-400/40 bg-emerald-500/15 px-2.5 py-1 text-xs font-medium text-emerald-200 hover:bg-emerald-500/25",title:"Re-analyze this 2D sketch in RDKit WASM",children:[o.jsx(Fi,{className:"h-3.5 w-3.5"})," Apply Sketch"]})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs("span",{className:"flex items-center gap-1 text-[0.6875rem] font-medium text-slate-400",children:[o.jsx(u6,{className:"h-3.5 w-3.5 text-violet-300"})," Stamps:"]}),Dq.map(le=>o.jsx("button",{type:"button",title:le.tip,onClick:()=>z(q===le.id?"draw":le.id),className:`rounded-md border px-2 py-0.5 text-[0.75rem] transition ${q===le.id?"border-violet-400/60 bg-violet-500/20 text-violet-200":"border-white/10 bg-slate-950/70 text-slate-300 hover:border-white/25 hover:text-white"}`,children:le.label},le.id))]}),o.jsxs("div",{className:"relative overflow-hidden rounded-lg border border-white/[0.08] bg-[#070b12]",children:[o.jsxs("svg",{ref:i,viewBox:"0 0 480 300",className:"aspect-[16/10] w-full max-h-[380px] min-h-[220px] touch-none select-none cursor-crosshair",onPointerDown:me,onPointerMove:I,onPointerUp:J,children:[o.jsx("defs",{children:o.jsx("pattern",{id:"synlexa-sketch-grid",width:"24",height:"24",patternUnits:"userSpaceOnUse",children:o.jsx("path",{d:"M 24 0 L 0 0 0 24",fill:"none",stroke:"rgba(148,163,184,0.06)",strokeWidth:"1"})})}),o.jsx("rect",{width:"480",height:"300",fill:"url(#synlexa-sketch-grid)"}),O&&P&&o.jsx("line",{x1:O.x,y1:O.y,x2:P.x,y2:P.y,stroke:"#38bdf8",strokeWidth:2,strokeDasharray:"4 4"}),S.bonds.map((le,D)=>{const ae=H.get(le.from),pe=H.get(le.to);if(!ae||!pe)return null;const Ae=pe.x-ae.x,Ne=pe.y-ae.y,Re=Math.hypot(Ae,Ne)||1,$e=-Ne/Re*3.5,Ce=Ae/Re*3.5;return le.order===2?o.jsxs("g",{stroke:"#94a3b8",strokeWidth:2.2,strokeLinecap:"round",children:[o.jsx("line",{x1:ae.x+$e,y1:ae.y+Ce,x2:pe.x+$e,y2:pe.y+Ce}),o.jsx("line",{x1:ae.x-$e,y1:ae.y-Ce,x2:pe.x-$e,y2:pe.y-Ce})]},D):le.order===3?o.jsxs("g",{stroke:"#94a3b8",strokeWidth:2,strokeLinecap:"round",children:[o.jsx("line",{x1:ae.x,y1:ae.y,x2:pe.x,y2:pe.y}),o.jsx("line",{x1:ae.x+$e*1.4,y1:ae.y+Ce*1.4,x2:pe.x+$e*1.4,y2:pe.y+Ce*1.4}),o.jsx("line",{x1:ae.x-$e*1.4,y1:ae.y-Ce*1.4,x2:pe.x-$e*1.4,y2:pe.y-Ce*1.4})]},D):o.jsx("line",{x1:ae.x,y1:ae.y,x2:pe.x,y2:pe.y,stroke:"#94a3b8",strokeWidth:2.3,strokeLinecap:"round"},D)}),S.atoms.map(le=>o.jsxs("g",{children:[o.jsx("circle",{cx:le.x,cy:le.y,r:le.element==="C"?5.5:10,fill:le.element==="C"?"#1e293b":"#070b12",stroke:O?.id===le.id?"#38bdf8":"rgba(148,163,184,0.35)",strokeWidth:1.2}),le.element!=="C"&&o.jsx("text",{x:le.x,y:le.y+4,textAnchor:"middle",fill:wA[le.element],fontSize:"12",fontWeight:"700",fontFamily:"ui-monospace, monospace",children:le.element})]},le.id))]}),S.atoms.length===0&&o.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center text-xs text-slate-500",children:"Click anywhere to place an atom, or select a Stamp above and click on the grid."})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-[0.6875rem] text-slate-400",children:[o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(ia,{className:"h-3.5 w-3.5 text-sky-400"}),o.jsx("span",{children:q==="erase"?"Erase mode: click any atom or bond to remove it":q!=="draw"?`Stamp mode (${q}): click canvas to place group`:"Drag from an atom to sprout a 30°-snapped bond · Click a bond to cycle 1/2/3 · Click atom to swap element"})]}),o.jsxs("span",{className:"font-mono text-slate-300",children:[S.atoms.length," atoms · ",S.bonds.length," bonds",r?` · ${n?`${n}: `:""}${r.slice(0,36)}${r.length>36?"…":""}`:""]})]})]})}function ir({bridge:e,title:r,subtitle:n,icon:s,guideOpen:i,onToggleGuide:c,actions:d}){const f=!!(e&&(e.hasRef||e.hasMob));return o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-[#0c111b] px-3 py-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-2.5",children:[o.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-sky-400/25 bg-sky-500/10 text-sky-300",children:s}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-semibold text-slate-100",children:r}),e?.activeProjectName&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-1.5 py-0.5 text-[0.6875rem] text-slate-300",children:[o.jsx(My,{className:"h-3 w-3 text-sky-300"}),o.jsx("span",{className:"max-w-44 truncate",children:e.activeProjectName})]})]}),n&&o.jsx("p",{className:"mt-0.5 text-xs text-slate-400",children:n})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[d,o.jsxs("button",{type:"button",onClick:c,"aria-expanded":i,className:Ie("inline-flex items-center gap-1 rounded-lg border px-2 py-1 text-xs font-medium transition-colors",i?"border-sky-400/50 bg-sky-500/15 text-sky-200":"border-white/10 bg-white/[0.03] text-slate-300 hover:border-white/20 hover:text-white"),children:[o.jsx(CR,{className:"h-3.5 w-3.5 text-sky-300"}),o.jsx("span",{children:"Guide"})]})]})]}),e&&o.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2 text-[0.6875rem]",children:f?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md border border-white/[0.07] bg-black/25 px-2 py-0.5 text-slate-300",children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400"}),o.jsx("span",{className:"text-slate-500",children:"3D:"}),e.hasRef&&o.jsxs("span",{className:"font-mono text-sky-300",children:[e.refLabel," (",e.refChain||"?",")"]}),e.hasRef&&e.hasMob&&o.jsx("span",{className:"text-slate-600",children:"vs"}),e.hasMob&&o.jsxs("span",{className:"font-mono text-emerald-300",children:[e.mobLabel," (",e.mobChain||"?",")"]})]}),e.focusedSeqId!==null&&o.jsxs("button",{type:"button",onClick:()=>e.focusIn3D(e.focusedSeqId,{centerCamera:!0,openViewer:"none"}),title:"Center 3D camera on this residue",className:"inline-flex items-center gap-1 rounded-md border border-amber-400/35 bg-amber-500/10 px-2 py-0.5 font-mono text-amber-200 hover:bg-amber-500/20",children:[o.jsx(Ur,{className:"h-3 w-3"}),o.jsxs("span",{children:["Focus #",e.focusedSeqId]})]}),e.activeHighlight&&e.activeHighlight.seqIds.length>0&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-pink-400/35 bg-pink-500/10 px-2 py-0.5 text-pink-200",children:[o.jsxs("span",{children:["3D Highlight: ",e.activeHighlight.seqIds.length," res (",e.activeHighlight.source,")"]}),o.jsx("button",{type:"button",onClick:e.clearHighlights3D,title:"Clear 3D highlights",className:"rounded p-0.5 hover:bg-white/10",children:o.jsx(Xi,{className:"h-2.5 w-2.5"})})]}),o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[o.jsxs("button",{type:"button",onClick:()=>e.openTab("viewer",!1),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/30 bg-sky-500/10 px-2 py-0.5 font-medium text-sky-200 hover:bg-sky-500/20",title:"Switch to 3D Viewer tab",children:[o.jsx(_s,{className:"h-3 w-3"}),o.jsx("span",{children:"Open 3D"})]}),o.jsxs("button",{type:"button",onClick:()=>e.openTab("viewer",!0),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-0.5 text-slate-300 hover:border-sky-400/40 hover:text-sky-200",title:"Open 3D Viewer side-by-side next to this tool",children:[o.jsx(Ey,{className:"h-3 w-3"}),o.jsx("span",{children:"Split 3D"})]})]})]}):o.jsxs("div",{className:"flex w-full flex-wrap items-center justify-between gap-2 text-slate-400",children:[o.jsx("span",{children:"No 3D protein structure loaded yet — load one to enable 3D pocket & residue synchronization."}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("button",{type:"button",onClick:e.loadExample,className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2 py-0.5 font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Br,{className:"h-3 w-3"})," Load CA II Example"]}),o.jsxs("button",{type:"button",onClick:e.openDatabases,className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-0.5 text-slate-200 hover:bg-white/[0.08]",children:[o.jsx(Vi,{className:"h-3 w-3"})," Public Databases"]})]})]})})]})}function Qi({open:e,title:r,summary:n,steps:s,connectionTip:i,glossary:c}){const[d,f]=C.useState(!1);return e?o.jsxs("div",{className:"rounded-xl border border-sky-400/25 bg-sky-500/[0.05] p-3 text-xs",children:[o.jsx("div",{className:"font-semibold text-sky-200",children:r}),o.jsx("p",{className:"mt-1 leading-relaxed text-slate-300",children:n}),o.jsxs("div",{className:"mt-2.5 grid gap-2 @2xl:grid-cols-2",children:[o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/25 p-2.5",children:[o.jsx("div",{className:"text-[0.6875rem] font-semibold tracking-wide text-slate-400 uppercase",children:"What to do"}),o.jsx("ol",{className:"mt-1.5 list-inside list-decimal space-y-1 text-slate-300",children:s.map((p,b)=>o.jsx("li",{className:"leading-relaxed",children:p},b))})]}),o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/25 p-2.5",children:[o.jsx("div",{className:"text-[0.6875rem] font-semibold tracking-wide text-emerald-300 uppercase",children:"3D Project Connection"}),o.jsx("p",{className:"mt-1.5 leading-relaxed text-slate-300",children:i})]})]}),c&&c.length>0&&o.jsxs("div",{className:"mt-2 border-t border-white/[0.06] pt-2",children:[o.jsxs("button",{type:"button",onClick:()=>f(p=>!p),className:"inline-flex items-center gap-1 text-[0.6875rem] font-medium text-sky-300 hover:text-sky-200",children:[d?o.jsx(ph,{className:"h-3 w-3"}):o.jsx(Ty,{className:"h-3 w-3"}),"Metric & Parameter Definitions (",c.length,")"]}),d&&o.jsx("div",{className:"mt-2 grid gap-1.5 @xl:grid-cols-2",children:c.map(p=>o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/25 px-2.5 py-1.5",children:[o.jsx("div",{className:"font-mono text-[0.6875rem] font-semibold text-slate-200",children:p.term}),o.jsx("div",{className:"mt-0.5 text-[0.6875rem] leading-relaxed text-slate-400",children:p.desc})]},p.term))})]})]}):null}function bs({label:e,value:r,hint:n,tooltip:s,accent:i="text-slate-100"}){return o.jsxs("div",{title:s??(n?`${e}: ${n}`:e),className:"min-w-0 rounded-lg border border-white/[0.07] bg-black/25 px-2.5 py-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-slate-400",children:e}),o.jsx("div",{className:Ie("mt-0.5 truncate font-mono text-sm font-semibold tabular-nums",i),children:r}),n&&o.jsx("div",{className:"mt-0.5 truncate text-[0.625rem] text-slate-500",children:n})]})}const Lq=[{label:"Sulfonamide",smarts:"S(=O)(=O)N"},{label:"Benzene",smarts:"c1ccccc1"},{label:"Amide",smarts:"C(=O)N"},{label:"Carboxyl",smarts:"C(=O)[OH]"},{label:"Halogen",smarts:"[F,Cl,Br,I]"},{label:"Heterocycle",smarts:"[n,o,s]"}],Uq=[{label:"Sulfonamide",query:"S(=O)(=O)N"},{label:"Aryl Ring",query:"c1ccccc1"},{label:"Amide",query:"C(=O)N"},{label:"Carbonyl",query:"C=O"},{label:"Acetazolamide-like",query:"CC(=O)Nc1nnc(S(N)(=O)=O)s1"}];function Bq({state:e,dispatch:r,result:n,comparison:s,error:i,onFocusResidue:c,onStageForCompute:d,libraryCompounds:f=[],simpleMode:p=!1,bridge:b}){const[x,g]=C.useState(e.smiles),[_,y]=C.useState(e.name),[S,k]=C.useState("analyze"),[E,T]=C.useState(!1),[j,q]=C.useState(""),[z,O]=C.useState(null),[V,P]=C.useState(!1),[$,H]=C.useState(null),[Z,G]=C.useState(null),[K,we]=C.useState(null),[Se,Q]=C.useState([]),[F,he]=C.useState("S(=O)(=O)N"),[W,me]=C.useState([]),[I,J]=C.useState(!1),[ge,le]=C.useState(4.5),[D,ae]=C.useState("ALL"),[pe,Ae]=C.useState("grouped");C.useEffect(()=>{g(e.smiles),y(e.name)},[e.smiles,e.name]),C.useEffect(()=>{if(typeof Worker>"u"||!e.smiles.trim())return;let re=!0;return P(!0),H(null),Fo().analyzeMolecule(e.smiles,{highlightSmarts:j||void 0}).then(ve=>{re&&O(ve)}).catch(ve=>{re&&H(ve instanceof Error?ve.message:String(ve))}).finally(()=>{re&&P(!1)}),()=>{re=!1}},[e.smiles,j]),C.useEffect(()=>{if(typeof Worker>"u"||!e.smiles.trim())return;let re=!0;const ve=[...Xo.map(Fe=>({id:Fe.id,name:Fe.name.split(" (")[0],smiles:Fe.smiles})),...(b?.projectMolecules??[]).map(Fe=>({id:Fe.id,name:Fe.name,smiles:Fe.smiles}))],Qe=Array.from(new Map(ve.map(Fe=>[Fe.smiles,Fe])).values());return Fo().searchLibrary(e.smiles,Qe).then(Fe=>{re&&Q(Fe.slice(0,5))}).catch(()=>{re&&Q([])}),()=>{re=!1}},[e.smiles,b?.projectMolecules]);const Ne=(re,ve)=>{navigator.clipboard?.writeText(ve),G(re),setTimeout(()=>G(null),1500)},Re=re=>{we(re),setTimeout(()=>we(null),2e3)},$e=()=>{x.trim()&&r({type:"set_custom_smiles",smiles:x.trim(),name:_.trim()||"Custom SMILES"})},Ce=re=>{typeof Worker>"u"||Fo().analyzeMolecule(re,{highlightSmarts:j||void 0}).then(ve=>{O(ve),g(ve.canonicalSmiles),y("2D Sketch Molecule"),r({type:"set_custom_smiles",smiles:ve.canonicalSmiles,name:"2D Sketch Molecule"})}).catch(()=>{})},Ue=async re=>{const ve=(re??F).trim();if(!(typeof Worker>"u"||!ve)){J(!0),H(null);try{const Qe=[...Xo.map(We=>({id:We.id,name:We.name,smiles:We.smiles})),...(b?.projectMolecules??[]).map(We=>({id:We.id,name:We.name,smiles:We.smiles})),...f],Fe=Array.from(new Map(Qe.map(We=>[We.smiles,We])).values()),Fn=await Fo().searchLibrary(ve,Fe);me(Fn)}catch(Qe){H(Qe instanceof Error?Qe.message:String(Qe))}finally{J(!1)}}},be=(re,ve,Qe)=>{const Fe=new Blob([ve],{type:Qe}),Fn=URL.createObjectURL(Fe),We=document.createElement("a");We.href=Fn,We.download=re,We.click(),setTimeout(()=>URL.revokeObjectURL(Fn),1e3)},bt=(e.name||"ligand").replace(/[^a-zA-Z0-9._-]+/g,"_"),Ot=s?.refContacts??[],St=C.useMemo(()=>Array.from(new Set(Ot.map(re=>re.ligandResName))),[Ot]),Ke=C.useMemo(()=>[...Ot].filter(re=>re.distanceAngstrom<=ge).filter(re=>D==="ALL"||re.ligandResName===D).sort((re,ve)=>{const Qe=Fn=>Fn==="AZM"?0:Fn==="ZN"?1:2,Fe=Qe(re.ligandResName)-Qe(ve.ligandResName);return Fe!==0?Fe:re.distanceAngstrom-ve.distanceAngstrom}),[Ot,ge,D]),et=C.useMemo(()=>{const re=new Map;for(const ve of Ke){const Qe=re.get(ve.proteinSeqId);Qe?(Qe.count+=1,Qe.ligands.add(ve.ligandResName),ve.distanceAngstrom<Qe.minDist&&(Qe.minDist=ve.distanceAngstrom,Qe.closestPair=`${ve.ligandResName} ${ve.ligandAtom} ↔ ${ve.proteinAtom}`)):re.set(ve.proteinSeqId,{seqId:ve.proteinSeqId,resName3:ve.proteinResName3,minDist:ve.distanceAngstrom,count:1,ligands:new Set([ve.ligandResName]),closestPair:`${ve.ligandResName} ${ve.ligandAtom} ↔ ${ve.proteinAtom}`})}return Array.from(re.values()).sort((ve,Qe)=>ve.minDist-Qe.minDist)},[Ke]),ue=re=>{c(re),b?.focusIn3D(re,{centerCamera:!0,style:"pocket"})},He=()=>{if(!b||et.length===0)return;const re=et.map(ve=>ve.seqId);b.highlightIn3D(re,`Pocket ≤${ge.toFixed(1)} Å`,{focusSeqId:et[0]?.seqId,style:"pocket"})},Pe=z?.canonicalSmiles??e.smiles,ut=C.useMemo(()=>new Set(et.map(re=>re.seqId)),[et]),Je=b?.coCrystalLigands??[];return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:b,title:"Ligands, 2D Sketcher & Binding Prep",subtitle:"Inspect SMILES, compute deterministic RDKit descriptors & PAINS alerts, sketch analogs, and inspect 3D receptor pockets.",icon:o.jsx(ia,{className:"h-4 w-4"}),guideOpen:E,onToggleGuide:()=>T(re=>!re),actions:z&&o.jsxs("span",{className:"rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 font-mono text-[0.6875rem] text-emerald-300",children:["RDKit ",z.rdkitVersion," WASM"]})}),o.jsx(Qi,{open:E,title:"How Ligands & 2D Sketcher Works",summary:"Design or load small-molecule ligands using SMILES or the interactive 2D SVG canvas. All physicochemical properties, Lipinski/Veber/Ghose heuristics, and PAINS/Brenk alerts run locally in your browser via Rust + RDKit WebAssembly (RUO).",steps:["Pick a preset scaffold, a molecule from your Active Project, or paste any SMILES string and click Analyze.","Switch to 2D Sketcher to draw bonds/rings visually or edit an existing scaffold; changes auto-update descriptors.","Use Highlight SMARTS chips to visually locate functional groups (e.g. sulfonamide zinc-binders) and Substructure Search to screen your project + library."],connectionTip:"When a 3D receptor complex (like 3HS4 with AZM & Zn²⁺) is loaded in the main 3D project, the 3D Binding Pocket panel lists every protein contact residue. Click any residue or 'Highlight Pocket in 3D' to focus the 3D camera directly on the active site, or send your ligand + pocket box straight to AutoDock Vina / PySCF.",glossary:[{term:"SMILES",desc:"Text notation describing a molecule’s atoms, bonds, rings, and stereochemistry."},{term:"SMARTS",desc:"Substructure pattern language (e.g. S(=O)(=O)N for sulfonamide) used for highlighting and screening."},{term:"TPSA (Ų)",desc:"Topological Polar Surface Area. Values ≤ 140 Ų are generally favored for passive membrane permeation."},{term:"cLogP",desc:"Wildman-Crippen octanol-water partition coefficient estimating lipophilicity (Rule of 5 ≤ 5)."},{term:"Fsp³",desc:"Fraction of sp³ hybridized carbons (0–1); higher values indicate greater 3D saturation rather than flat aromaticity."},{term:"PAINS / Brenk",desc:"Empirical substructure filters flagging potentially reactive, promiscuous, or assay-interfering motifs."}]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border border-white/[0.08] bg-[#0b1018] p-2",children:[o.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:[["analyze","Analyze & Depict",o.jsx(ia,{className:"h-3.5 w-3.5"},"a")],["sketch","2D Sketcher",o.jsx(Ox,{className:"h-3.5 w-3.5"},"s")],["search","Substructure & Similarity",o.jsx(Gr,{className:"h-3.5 w-3.5"},"q")]].map(([re,ve,Qe])=>o.jsxs("button",{type:"button",onClick:()=>k(re),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-medium transition ${S===re?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-white/[0.03] text-slate-300 hover:border-white/20 hover:text-white"}`,children:[Qe,ve]},re))}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[K&&o.jsx("span",{className:"rounded-md bg-emerald-500/15 px-2 py-1 text-[0.6875rem] font-medium text-emerald-300",children:K}),b&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",onClick:()=>{b.saveMoleculeToProject({name:_.trim()||e.name,smiles:Pe,molblock2d:z?.molblock2d,note:z?`MW ${z.descriptors.molecularWeight.toFixed(1)} · cLogP ${z.descriptors.crippenLogP.toFixed(2)}`:void 0}),Re("Saved to Project")},title:"Save active ligand into the active project's asset list",className:"flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1.5 text-xs text-slate-200 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(Qc,{className:"h-3.5 w-3.5 text-sky-300"})," Save to Project"]}),o.jsxs("button",{type:"button",onClick:()=>{b.saveMoleculeToLibrary({name:_.trim()||e.name,smiles:Pe}),Re("Saved to Library")},title:"Save active ligand to persistent local device library",className:"flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1.5 text-xs text-slate-200 hover:border-emerald-400/40 hover:text-emerald-200",children:[o.jsx(qA,{className:"h-3.5 w-3.5 text-emerald-300"})," Library"]})]}),d&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",title:"Stage this ligand + active 3D pocket box for AutoDock Vina on a GPU/compute node",onClick:()=>d("vina",{name:e.name,smiles:Pe,molblock2d:z?.molblock2d}),className:"flex items-center gap-1 rounded-lg border border-cyan-500/40 bg-cyan-500/15 px-2.5 py-1.5 text-xs font-medium text-cyan-200 hover:bg-cyan-500/25",children:[o.jsx(Br,{className:"h-3.5 w-3.5"})," Dock (Vina)"]}),o.jsxs("button",{type:"button",title:"Stage this ligand for PySCF DFT frontier orbital calculation on a compute node",onClick:()=>d("pyscf",{name:e.name,smiles:Pe,molblock2d:z?.molblock2d}),className:"flex items-center gap-1 rounded-lg border border-violet-500/40 bg-violet-500/15 px-2.5 py-1.5 text-xs font-medium text-violet-200 hover:bg-violet-500/25",children:[o.jsx(al,{className:"h-3.5 w-3.5"})," Quantum (PySCF)"]})]})]})]}),o.jsxs("div",{className:"space-y-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsxs("div",{className:"grid grid-cols-1 gap-2 @xl:grid-cols-[12rem_1fr_auto]",children:[o.jsx("input",{value:_,onChange:re=>y(re.target.value),placeholder:"Ligand name…","aria-label":"Ligand name",className:"h-9 rounded-lg border border-white/10 bg-slate-950 px-2.5 text-xs font-medium text-slate-100 outline-none focus:border-cyan-500"}),o.jsxs("div",{className:"flex min-w-0 items-center gap-1 rounded-lg border border-white/10 bg-slate-950 px-2.5 focus-within:border-cyan-500",children:[o.jsx("span",{className:"shrink-0 font-mono text-[0.6875rem] text-slate-500",children:"SMILES"}),o.jsx("input",{value:x,onChange:re=>g(re.target.value),onKeyDown:re=>{re.key==="Enter"&&$e()},placeholder:"Paste SMILES string (e.g. CC(=O)Nc1nnc(S(N)(=O)=O)s1)…","aria-label":"SMILES input",className:"h-9 min-w-0 flex-1 bg-transparent font-mono text-xs text-slate-100 outline-none"}),x&&o.jsx("button",{type:"button",onClick:()=>Ne("smiles",x),title:"Copy SMILES",className:"rounded p-1 text-slate-400 hover:bg-white/[0.07] hover:text-slate-100",children:Z==="smiles"?o.jsx(Fi,{className:"h-3.5 w-3.5 text-emerald-400"}):o.jsx(Lr,{className:"h-3.5 w-3.5"})})]}),o.jsxs("button",{type:"button",onClick:$e,className:"flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-emerald-500/40 bg-emerald-500/15 px-3.5 text-xs font-semibold text-emerald-200 hover:bg-emerald-500/25",children:[o.jsx(qp,{className:"h-3.5 w-3.5"})," Analyze"]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] font-medium text-slate-400",children:"Presets:"}),Xo.map(re=>o.jsx("button",{type:"button",title:`${re.note} — ${re.smiles}`,onClick:()=>{r({type:"select_preset",presetId:re.id}),g(re.smiles),y(re.name)},className:`rounded-md border px-2 py-0.5 text-[0.75rem] transition ${e.selectedPresetId===re.id?"border-cyan-500/50 bg-cyan-500/20 text-cyan-200":"border-white/10 bg-slate-900/70 text-slate-300 hover:border-white/25"}`,children:re.name.split(" (")[0]},re.id)),b&&b.projectMolecules.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mx-1 h-3.5 w-px bg-white/10"}),o.jsx("span",{className:"text-[0.6875rem] font-medium text-violet-300",children:"Project:"}),b.projectMolecules.slice(0,6).map(re=>o.jsx("button",{type:"button",title:`Load project molecule: ${re.smiles}`,onClick:()=>{r({type:"set_custom_smiles",smiles:re.smiles,name:re.name}),g(re.smiles),y(re.name)},className:`rounded-md border px-2 py-0.5 text-[0.75rem] transition ${e.smiles===re.smiles?"border-violet-400/50 bg-violet-500/20 text-violet-200":"border-violet-500/25 bg-violet-500/5 text-violet-200/80 hover:border-violet-400/40"}`,children:re.name.split(" (")[0]},re.id))]}),Je.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"mx-1 h-3.5 w-px bg-white/10"}),o.jsx("span",{className:"text-[0.6875rem] font-medium text-emerald-300",children:"3D Co-Crystal:"}),Je.map(re=>o.jsxs("button",{type:"button",title:`Focus 3D active pocket around ${re.resName} (${re.atomCount} atoms)`,onClick:()=>{ae(re.resName),re.resName.toUpperCase()==="AZM"&&r({type:"select_preset",presetId:"azm"}),b?.setStyle3D("pocket"),et[0]&&b?.focusIn3D(et[0].seqId,{centerCamera:!0,style:"pocket"})},className:"inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[0.75rem] text-emerald-200 hover:bg-emerald-500/20",children:[o.jsx(Ur,{className:"h-3 w-3"}),re.resName," (",re.atomCount,"a)"]},`${re.chainId}-${re.seqId}-${re.resName}`))]})]})]}),S==="sketch"&&o.jsx(qq,{initialMolblock:z?.molblock2d,activeSmiles:Pe,activeName:e.name,onCommitMolblock:Ce}),S==="search"&&o.jsxs("div",{className:"space-y-3 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2",children:o.jsxs("div",{children:[o.jsx("div",{className:"font-semibold text-slate-200",children:"RDKit Substructure & Similarity Search"}),o.jsx("div",{className:"text-[0.6875rem] text-slate-400",children:"Screens built-in presets, active project molecules, and your local library using SMARTS pattern matching & Morgan fingerprint Tanimoto similarity (Tc)."})]})}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("input",{value:F,onChange:re=>he(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Ue()},placeholder:"SMARTS or SMILES query (e.g. S(=O)(=O)N, c1ccccc1)…",className:"min-w-0 flex-1 rounded-lg border border-white/10 bg-slate-950 px-3 py-2 font-mono text-xs text-slate-100 outline-none focus:border-sky-500"}),o.jsxs("button",{type:"button",onClick:()=>void Ue(),disabled:I,className:"flex items-center gap-1.5 rounded-lg border border-sky-500/40 bg-sky-500/15 px-3.5 py-2 text-xs font-medium text-sky-200 hover:bg-sky-500/25 disabled:opacity-50",children:[o.jsx(Gr,{className:"h-3.5 w-3.5"}),I?"Searching…":"Search Molecules"]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-500",children:"Quick SMARTS:"}),Uq.map(re=>o.jsx("button",{type:"button",onClick:()=>{he(re.query),Ue(re.query)},className:"rounded-md border border-white/10 bg-slate-900/80 px-2 py-0.5 text-[0.6875rem] text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:re.label},re.label))]}),W.length>0&&o.jsx("div",{className:"grid grid-cols-1 gap-2.5 @lg:grid-cols-2 @3xl:grid-cols-3",children:W.map(re=>o.jsxs("button",{type:"button",onClick:()=>{r({type:"set_custom_smiles",smiles:re.smiles,name:re.name}),q(F),k("analyze")},className:"flex flex-col items-start rounded-xl border border-white/[0.08] bg-[#070b12] p-2.5 text-left transition hover:border-sky-500/50",children:[o.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[o.jsx("span",{className:"truncate font-medium text-slate-200",children:re.name}),o.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[0.6875rem] ${re.substructureMatch?"bg-emerald-500/20 text-emerald-300":"bg-slate-800 text-slate-400"}`,children:re.substructureMatch?"SMARTS Match":`Tc ${re.tanimoto.toFixed(2)}`})]}),re.svg&&o.jsx("div",{className:"mt-1.5 flex w-full justify-center",dangerouslySetInnerHTML:{__html:re.svg}})]},re.id))})]}),(i||$)&&o.jsx("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/10 px-3 py-2 font-mono text-xs text-rose-200",children:i??$}),n&&o.jsxs("div",{className:"grid grid-cols-1 gap-3 @4xl:grid-cols-2 @6xl:grid-cols-12",children:[o.jsxs("div",{className:"flex flex-col justify-between gap-2.5 rounded-xl border border-white/[0.08] bg-[#070b12] p-3 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-[0.75rem] font-semibold text-sky-300",children:"2D STRUCTURE DEPICTION"}),o.jsx("div",{className:"flex items-center gap-1",children:o.jsxs("button",{type:"button",onClick:()=>k("sketch"),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-0.5 text-[0.6875rem] text-slate-200 hover:border-sky-400/40",children:[o.jsx(Ox,{className:"h-3 w-3"})," Edit Sketch"]})})]}),o.jsx("div",{className:"flex min-h-44 w-full items-center justify-center rounded-lg border border-white/[0.05] bg-[#0a0f18] p-2",children:z?.svg?o.jsx("div",{className:"flex w-full items-center justify-center [&>svg]:max-h-52 [&>svg]:w-full",dangerouslySetInnerHTML:{__html:z.svg}}):o.jsx(Gq,{layout:n.layout2d})}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 font-mono text-[0.75rem] text-slate-300",children:[o.jsx("span",{className:"truncate font-semibold",children:n.name}),o.jsxs("span",{className:"text-slate-400",children:[n.heavyAtomCount," heavy · ",n.ringCount," rings",z?` · ${z.descriptors.aromaticRings} arom`:"",V?" · updating…":""]})]}),z&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-500",children:"SMARTS highlight:"}),Lq.map(re=>o.jsx("button",{type:"button",onClick:()=>q(j===re.smarts?"":re.smarts),className:`rounded border px-1.5 py-0.5 text-[0.6875rem] transition ${j===re.smarts?"border-sky-400/60 bg-sky-500/20 text-sky-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:re.label},re.label))]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2 text-[0.6875rem]",children:[o.jsx("input",{value:j,onChange:re=>q(re.target.value),placeholder:"Custom SMARTS highlight (e.g. S(=O)(=O)N)",className:"min-w-0 flex-1 rounded-md border border-white/10 bg-slate-950 px-2 py-1 font-mono text-slate-200 outline-none focus:border-sky-500"}),j&&o.jsx("button",{type:"button",onClick:()=>q(""),className:"rounded-md border border-white/10 bg-slate-900 px-2 py-1 text-slate-400 hover:text-white",children:"Clear"}),o.jsxs("button",{type:"button",onClick:()=>be(`${bt}.mol`,z.molblock2d,"chemical/x-mdl-molfile"),className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900 px-2 py-1 text-slate-300 hover:border-white/25",children:[o.jsx(sr,{className:"h-3 w-3"})," .MOL"]}),o.jsxs("button",{type:"button",onClick:()=>be(`${bt}.svg`,z.svg,"image/svg+xml"),className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900 px-2 py-1 text-slate-300 hover:border-white/25",children:[o.jsx(sr,{className:"h-3 w-3"})," .SVG"]})]})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsx("span",{className:"font-semibold text-cyan-300",children:"COMPUTATIONAL DESCRIPTORS"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:`flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[0.6875rem] ${n.veberCompliant?"border-emerald-500/30 bg-emerald-500/10 text-emerald-300":"border-amber-500/30 bg-amber-500/10 text-amber-300"}`,children:[o.jsx(Gs,{className:"h-3 w-3"}),n.veberCompliant?"Veber OK":"Veber Warn"]}),z&&o.jsxs("span",{className:`rounded-md border px-1.5 py-0.5 text-[0.6875rem] ${z.rules.ghoseCompliant?"border-emerald-500/30 bg-emerald-500/10 text-emerald-300":"border-amber-500/30 bg-amber-500/10 text-amber-300"}`,children:["Ghose ",z.rules.ghoseCompliant?"Pass":"Warn"]})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 @md:grid-cols-3",children:[o.jsx(bs,{label:"Formula",value:n.formula,tooltip:"Molecular formula"}),o.jsx(bs,{label:"MW",value:`${n.molecularWeight.toFixed(2)} Da`,hint:n.molecularWeight<=500?"≤ 500 Ro5":"> 500 Da",accent:n.molecularWeight<=500?"text-slate-100":"text-amber-300"}),o.jsx(bs,{label:"Exact Mass",value:`${n.exactMass.toFixed(4)} Da`}),o.jsx(bs,{label:"TPSA",value:`${n.tpsa.toFixed(1)} Ų`,hint:n.tpsa<=140?"≤ 140 Veber":"> 140 polar",accent:n.tpsa<=140?"text-emerald-300":"text-amber-300"}),o.jsx(bs,{label:"cLogP",value:n.crippenLogP.toFixed(2),hint:n.crippenLogP<=5?"Crippen ≤ 5":"Lipophilic > 5",accent:n.crippenLogP<=5?"text-slate-100":"text-amber-300"}),o.jsx(bs,{label:"HBD / HBA",value:`${n.hbd} / ${n.hba}`,hint:"Donors / Acceptors"}),o.jsx(bs,{label:"Rot. Bonds",value:String(n.rotatableBonds),hint:n.rotatableBonds<=10?"≤ 10 Veber":"Flexible > 10"}),o.jsx(bs,{label:"Lipinski Viol.",value:String(n.lipinskiViolations),hint:"Rule-of-5 checks",accent:n.lipinskiViolations<=1?"text-emerald-300":"text-amber-300"}),z&&o.jsx(bs,{label:"Fsp³ / Stereo",value:`${z.descriptors.fractionCsp3.toFixed(2)} / ${z.descriptors.stereoCenters}`,hint:"3D saturation / centers"})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx(Ca,{insight:bA(n.tpsa),compact:!0}),o.jsx(Ca,{insight:xA(n.crippenLogP),compact:!0}),o.jsx(Ca,{insight:Eq(n.lipinskiViolations),compact:!0})]}),o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/25 px-2.5 py-2 text-[0.6875rem] leading-relaxed text-slate-300",children:[bA(n.tpsa).explanation," ",p?"":xA(n.crippenLogP).explanation]}),z&&o.jsxs("div",{className:"space-y-2 border-t border-white/[0.06] pt-2 font-mono text-[0.6875rem]",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2 text-slate-400",children:[o.jsxs("span",{className:"min-w-0 truncate",children:["InChIKey: ",o.jsx("span",{className:"text-slate-200",children:z.inchiKey||"—"})]}),z.inchiKey&&o.jsx("button",{type:"button",onClick:()=>Ne("inchikey",z.inchiKey),className:"shrink-0 rounded p-1 text-slate-400 hover:bg-white/10 hover:text-slate-100",title:"Copy InChIKey",children:Z==="inchikey"?o.jsx(Fi,{className:"h-3 w-3 text-emerald-400"}):o.jsx(Lr,{className:"h-3 w-3"})})]}),z.alerts.length===0?o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-emerald-500/20 bg-emerald-500/8 px-2.5 py-1.5 text-emerald-300",children:[o.jsx(Ki,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{children:"0 PAINS / Brenk structural alerts detected"})]}):o.jsx("div",{className:"space-y-1 rounded-lg border border-amber-500/30 bg-amber-500/10 p-2 text-amber-200",children:z.alerts.map(re=>o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Gc,{className:"h-3.5 w-3.5 shrink-0"}),o.jsxs("span",{children:["[",re.family,"] ",re.label]})]},re.id))}),Se.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"font-sans text-[0.6875rem] font-medium text-slate-400",children:"Morgan Fingerprint Similarity (Tanimoto)"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:Se.slice(0,4).map(re=>o.jsxs("button",{type:"button",onClick:()=>r({type:"set_custom_smiles",smiles:re.smiles,name:re.name}),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-black/30 px-2 py-0.5 text-[0.6875rem] text-slate-300 hover:border-sky-400/40",children:[o.jsx("span",{className:"truncate max-w-28",children:re.name}),o.jsxs("span",{className:"text-sky-300",children:["Tc ",re.tanimoto.toFixed(2)]})]},re.id))})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @4xl:col-span-2 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"font-mono text-[0.75rem] font-semibold text-violet-300",children:["3D RECEPTOR POCKET CONTACTS (≤ ",ge.toFixed(1)," Å)"]}),o.jsx("div",{className:"text-[0.6875rem] text-slate-400",children:s?`Active 3D structure: ${s.reference.label} (${et.length} residues · ${Ke.length} atom pairs)`:"Contacts around co-crystallized ligands in the active 3D structure."})]}),et.length>0&&b&&o.jsxs("button",{type:"button",onClick:He,className:"inline-flex items-center gap-1 rounded-lg border border-violet-400/40 bg-violet-500/15 px-2.5 py-1 text-[0.6875rem] font-medium text-violet-200 hover:bg-violet-500/25",children:[o.jsx(_s,{className:"h-3 w-3"})," Highlight Pocket in 3D"]})]}),Ot.length===0?o.jsxs("div",{className:"flex flex-1 flex-col items-start justify-center gap-2 rounded-lg border border-white/[0.06] bg-black/20 p-3 text-slate-400",children:[o.jsx("p",{children:"No co-crystallized 3D ligand contacts found in the active reference structure."}),b&&!b.hasRef&&o.jsxs("button",{type:"button",onClick:b.loadExample,className:"inline-flex items-center gap-1 rounded-lg border border-sky-400/40 bg-sky-500/15 px-2.5 py-1 text-xs font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Br,{className:"h-3.5 w-3.5"})," Load 3HS4 (AZM + Zn²⁺ Pocket)"]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-white/[0.06] bg-black/25 p-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>ae("ALL"),className:`rounded px-2 py-0.5 font-mono text-[0.6875rem] ${D==="ALL"?"bg-sky-500/20 text-sky-200":"text-slate-400 hover:text-slate-200"}`,children:"All"}),St.map(re=>o.jsx("button",{type:"button",onClick:()=>ae(re),className:`rounded px-2 py-0.5 font-mono text-[0.6875rem] ${D===re?"bg-violet-500/25 text-violet-200":"text-slate-400 hover:text-slate-200"}`,children:re},re))]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("label",{className:"flex items-center gap-1.5 font-mono text-[0.6875rem] text-slate-400",children:[o.jsxs("span",{children:["≤",ge.toFixed(1),"Å"]}),o.jsx("input",{type:"range",min:2.5,max:4.5,step:.1,value:ge,onChange:re=>le(Number(re.target.value)),className:"w-20 accent-sky-400"})]}),o.jsxs("div",{className:"flex rounded border border-white/10 bg-slate-950 p-0.5 text-[0.6875rem]",children:[o.jsx("button",{type:"button",onClick:()=>Ae("grouped"),className:`rounded px-1.5 py-0.5 ${pe==="grouped"?"bg-white/10 text-white":"text-slate-400"}`,children:"Residues"}),o.jsx("button",{type:"button",onClick:()=>Ae("atoms"),className:`rounded px-1.5 py-0.5 ${pe==="atoms"?"bg-white/10 text-white":"text-slate-400"}`,children:"Atoms"})]})]})]}),o.jsx("div",{className:"max-h-60 space-y-1.5 overflow-y-auto pr-0.5 font-mono text-[0.75rem]",children:pe==="grouped"?et.map(re=>{const ve=b?.focusedSeqId===re.seqId;return o.jsxs("button",{type:"button",onClick:()=>ue(re.seqId),className:`flex w-full items-center justify-between gap-2 rounded-lg border px-2.5 py-1.5 text-left transition ${ve?"border-amber-400/60 bg-amber-500/10":"border-white/[0.07] bg-black/30 hover:border-cyan-400/50"}`,children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"font-semibold text-sky-300",children:[re.resName3," ",re.seqId]}),o.jsxs("span",{className:"text-[0.6875rem] text-slate-400",children:["(",Array.from(re.ligands).join("+"),")"]})]}),o.jsxs("div",{className:"truncate text-[0.6875rem] text-slate-500",children:[re.closestPair," · ",re.count," pair",re.count===1?"":"s"]})]}),o.jsxs("span",{className:"shrink-0 font-semibold text-emerald-300",children:[re.minDist.toFixed(2)," Å"]})]},re.seqId)}):Ke.slice(0,80).map((re,ve)=>o.jsxs("button",{type:"button",onClick:()=>ue(re.proteinSeqId),className:"flex w-full items-center justify-between gap-2 rounded-lg border border-white/[0.07] bg-black/30 px-2.5 py-1 text-left hover:border-cyan-400/50",children:[o.jsxs("span",{className:"min-w-0 truncate",children:[o.jsx("span",{className:"text-violet-300",children:re.ligandResName})," ",o.jsx("span",{className:"text-slate-400",children:re.ligandAtom})," ↔"," ",o.jsxs("span",{className:"text-sky-300",children:[re.proteinResName3,re.proteinSeqId]})," ",o.jsx("span",{className:"text-slate-400",children:re.proteinAtom})]}),o.jsxs("span",{className:"shrink-0 text-emerald-300",children:[re.distanceAngstrom.toFixed(2)," Å"]})]},`${re.ligandSeqId}-${re.ligandAtom}-${re.proteinSeqId}-${re.proteinAtom}-${ve}`))})]}),b?.dockingBox&&o.jsxs("div",{className:"mt-auto flex flex-wrap items-center justify-between gap-2 rounded-lg border border-cyan-500/20 bg-cyan-500/[0.05] px-2.5 py-2 text-[0.6875rem]",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"font-medium text-cyan-200",children:["3D Vina Search Box (",b.dockingBox.sourceLabel,")"]}),o.jsxs("div",{className:"truncate font-mono text-slate-400",children:["Center [",b.dockingBox.center.join(", "),"] · Size ",b.dockingBox.size.join("×")," Å"]})]}),d&&o.jsx("button",{type:"button",onClick:()=>d("vina",{name:e.name,smiles:Pe,molblock2d:z?.molblock2d}),className:"shrink-0 rounded-md border border-cyan-400/40 bg-cyan-500/20 px-2 py-1 font-medium text-cyan-100 hover:bg-cyan-500/30",children:"Dock Here →"})]}),ut.size>0&&o.jsx("div",{className:"text-[0.6875rem] text-slate-500",children:"Tip: Click any residue above to focus the 3D camera directly on that pocket sidechain."})]})]})]})}function Gq({layout:e}){const r=C.useMemo(()=>{if(e.atoms.length===0)return"0 0 100 100";let i=1/0,c=-1/0,d=1/0,f=-1/0;for(const g of e.atoms)g.x<i&&(i=g.x),g.x>c&&(c=g.x),g.y<d&&(d=g.y),g.y>f&&(f=g.y);const p=1.4,b=Math.max(2,c-i+p*2),x=Math.max(2,f-d+p*2);return`${i-p} ${d-p} ${b} ${x}`},[e]),n=C.useMemo(()=>{const i=new Map;for(const c of e.atoms)i.set(c.id,c);return i},[e.atoms]),s=i=>{switch(i.toUpperCase()){case"N":return"#60a5fa";case"O":return"#f87171";case"S":return"#facc15";case"P":return"#fb923c";case"F":case"CL":return"#34d399";case"ZN":return"#c084fc";default:return"#cbd5e1"}};return o.jsxs("svg",{viewBox:r,className:"h-44 w-full max-w-[300px]",children:[e.bonds.map((i,c)=>{const d=n.get(i.from),f=n.get(i.to);if(!d||!f)return null;const p=f.x-d.x,b=f.y-d.y,x=Math.hypot(p,b)||1,g=-b/x*.1,_=p/x*.1;return i.order===2?o.jsxs("g",{stroke:"#94a3b8",strokeWidth:.08,strokeLinecap:"round",children:[o.jsx("line",{x1:d.x+g,y1:d.y+_,x2:f.x+g,y2:f.y+_}),o.jsx("line",{x1:d.x-g,y1:d.y-_,x2:f.x-g,y2:f.y-_})]},c):i.order===3?o.jsxs("g",{stroke:"#94a3b8",strokeWidth:.075,strokeLinecap:"round",children:[o.jsx("line",{x1:d.x,y1:d.y,x2:f.x,y2:f.y}),o.jsx("line",{x1:d.x+g*1.4,y1:d.y+_*1.4,x2:f.x+g*1.4,y2:f.y+_*1.4}),o.jsx("line",{x1:d.x-g*1.4,y1:d.y-_*1.4,x2:f.x-g*1.4,y2:f.y-_*1.4})]},c):i.order===4?o.jsxs("g",{stroke:"#67e8f9",strokeWidth:.08,strokeLinecap:"round",children:[o.jsx("line",{x1:d.x,y1:d.y,x2:f.x,y2:f.y}),o.jsx("line",{x1:d.x+g*1.1,y1:d.y+_*1.1,x2:f.x+g*1.1,y2:f.y+_*1.1,strokeDasharray:"0.18 0.14"})]},c):o.jsx("line",{x1:d.x,y1:d.y,x2:f.x,y2:f.y,stroke:"#94a3b8",strokeWidth:.09,strokeLinecap:"round"},c)}),e.atoms.map(i=>i.element==="C"&&i.charge===0?null:o.jsxs("g",{children:[o.jsx("circle",{cx:i.x,cy:i.y,r:.38,fill:"#070b12"}),o.jsxs("text",{x:i.x,y:i.y+.18,textAnchor:"middle",fill:s(i.element),fontSize:.55,fontWeight:"700",fontFamily:"ui-monospace, monospace",children:[i.element,i.charge>0?"+":i.charge<0?"-":""]})]},i.id))]})}function Hq({open:e,onClose:r,commands:n}){const[s,i]=C.useState(""),[c,d]=C.useState(0);C.useEffect(()=>{e&&(i(""),d(0))},[e]);const f=C.useMemo(()=>{const p=s.trim().toLowerCase();return p?n.filter(b=>b.label.toLowerCase().includes(p)||b.category.toLowerCase().includes(p)):n},[n,s]);return C.useEffect(()=>{d(0)},[s]),e?o.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/70 pt-20 backdrop-blur-xs",onClick:r,children:o.jsxs("div",{className:"w-full max-w-xl overflow-hidden rounded-lg border border-slate-700 bg-[#0d131f] shadow-2xl",onClick:p=>p.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-slate-800 px-3 py-2.5",children:[o.jsx(Gr,{className:"h-4 w-4 text-cyan-400"}),o.jsx("input",{autoFocus:!0,value:s,onChange:p=>i(p.target.value),onKeyDown:p=>{p.key==="Escape"?r():p.key==="ArrowDown"?(p.preventDefault(),d(b=>Math.min(f.length-1,b+1))):p.key==="ArrowUp"?(p.preventDefault(),d(b=>Math.max(0,b-1))):p.key==="Enter"&&f[c]&&(p.preventDefault(),f[c].run(),r())},placeholder:"Type a command (e.g. 'Zn2+', 'pLDDT', 'H94A', 'AZM', 'HTML report')…",className:"w-full bg-transparent text-xs text-slate-100 placeholder-slate-500 outline-none"}),o.jsx("kbd",{className:"rounded border border-slate-700 px-1.5 py-0.5 font-mono text-[0.75rem] text-slate-400",children:"ESC"})]}),o.jsx("div",{className:"max-h-72 overflow-y-auto py-1",children:f.length===0?o.jsx("div",{className:"px-4 py-6 text-center text-xs text-slate-500",children:"No matching commands."}):f.map((p,b)=>o.jsxs("button",{type:"button",onClick:()=>{p.run(),r()},className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs transition ${b===c?"bg-cyan-500/15 text-cyan-100":"text-slate-300 hover:bg-slate-800/70"}`,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"rounded bg-slate-800 px-1.5 py-0.5 font-mono text-[0.75rem] text-slate-400",children:p.category}),o.jsx("span",{children:p.label})]}),o.jsxs("div",{className:"flex items-center gap-2 font-mono text-[0.75rem] text-slate-500",children:[p.shortcut&&o.jsx("span",{children:p.shortcut}),b===c&&o.jsx(IR,{className:"h-3 w-3 text-cyan-400"})]})]},p.id))}),o.jsxs("div",{className:"flex items-center justify-between border-t border-slate-800 bg-slate-950/60 px-3 py-1.5 text-[0.75rem] text-slate-500",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(RR,{className:"h-3 w-3"})," Synlexa Studio Command Palette"]}),o.jsx("span",{children:"Research Use Only (RUO)"})]})]})}):null}const jx={vina_docking:{label:"AutoDock Vina",desc:"Rigid-receptor / flexible-ligand docking inside the 3D pocket box.",inputNote:"Uses your active Ligand SMILES + active 3D Receptor + 3D Pocket Box."},openmm_md:{label:"OpenMM MD",desc:"GPU-accelerated energy minimization and molecular dynamics relaxation.",inputNote:"Uses the active 3D Receptor PDB/mmCIF structure."},boltz_predict:{label:"Boltz-2 AI",desc:"MIT-licensed biomolecular folding and protein-ligand complex prediction.",inputNote:"Uses the protein sequence + optional co-folded Ligand SMILES."},rfdiffusion_design:{label:"RFdiffusion",desc:"Generative de novo backbone design against a target 3D protein surface.",inputNote:"Uses the active 3D Receptor structure + contig specification."},pyscf_qm:{label:"PySCF DFT",desc:"Quantum chemical DFT electronic structure (HOMO/LUMO gap, dipole).",inputNote:"Uses the active Ligand SMILES + chosen functional & basis set."}};function Fq({activeSmiles:e,activeSmilesName:r,activeRefPdbOrCif:n,activeRefLabel:s,pocketBox:i,stagedComputeTarget:c,onImportArtifactToViewer:d,bridge:f}){const[p,b]=C.useState(()=>Di()),[x,g]=C.useState(""),[_,y]=C.useState(""),[S,k]=C.useState(null),[E,T]=C.useState(null),[j,q]=C.useState(!1),[z,O]=C.useState(!1),[V,P]=C.useState("vina_docking"),[$,H]=C.useState(e),[Z,G]=C.useState("MSHHWGYGKHNGPEHWHKDFPIAKGERQSPVDIDTHTAKYDPSLKPLSVSYDQATSLRIL"),[K,we]=C.useState("1000"),[Se,Q]=C.useState("8"),[F,he]=C.useState("[A1-60/0 50-70]"),[W,me]=C.useState("B3LYP"),[I,J]=C.useState("sto-3g"),[ge,le]=C.useState(!1),[D,ae]=C.useState(null);C.useEffect(()=>(b(Di()),L3(()=>b(Di()))),[]),C.useEffect(()=>{H(e)},[e]),C.useEffect(()=>{c&&P(c.tool==="pyscf"?"pyscf_qm":"vina_docking")},[c]);const pe=p.activeNode,Ae=async()=>{k(null);try{const be=await cD({pairingOrEndpoint:x,label:_||void 0});g(""),y(""),T(be.id),await iA(be.id)}catch(be){k(be instanceof Error?be.message:String(be))}finally{T(null)}},Ne=async be=>{T(be),k(null);try{await iA(be)}finally{T(null)}},Re=async()=>{if(!pe){ae("Pair and select an online GPU/compute node first (see steps above).");return}le(!0),ae(null);try{let be={};V==="vina_docking"?be={ligandSmiles:$,receptorPdb:n,center:i?.center??[0,0,0],size:i?.size??[22,22,22],exhaustiveness:Number.parseInt(Se,10)||8,numModes:9}:V==="openmm_md"?be={pdbContent:n,steps:Number.parseInt(K,10)||1e3,temperatureK:300}:V==="boltz_predict"?be={sequences:[{id:"A",sequence:Z.trim()},...$.trim()?[{id:"B",smiles:$.trim()}]:[]],useMsaServer:!0}:V==="pyscf_qm"?be={smiles:$,functional:W,basis:I}:V==="rfdiffusion_design"&&(be={targetPdb:n,contigs:F.trim()||"[A1-60/0 50-70]",numDesigns:2});const bt=await dy(pe.id,V,be);hy(pe.id,bt.job_id)}catch(be){ae(be instanceof Error?be.message:String(be))}finally{le(!1)}},$e=async(be,bt)=>{if(!be.nodeId)return;const Ot=await fD(be.nodeId,be.job_id,bt),St=bt.format==="cif"?"mmcif":bt.format==="pdbqt"?"pdbqt":bt.format==="sdf"?"sdf":bt.format==="mol"?"mol":"pdb";d({label:`${be.tool_id}:${bt.name}`,content:Ot,format:St})},Ce="cd services/compute-worker && python3 -m synlexa_compute.server --port 4180 --tunnel",Ue=jx[V];return o.jsx("div",{className:"@container h-full min-h-0 overflow-y-auto p-3 text-xs @xl:p-4",children:o.jsxs("div",{className:"mx-auto max-w-6xl space-y-3.5",children:[o.jsx(ir,{bridge:f,title:"External GPU & Compute Nodes (Tier-2 Bridge)",subtitle:"Pair Google Colab (T4/L4/A100), local CUDA/Apple Metal workstations, or HPC servers to run heavy docking, MD, folding & DFT.",icon:o.jsx(rl,{className:"h-4 w-4"}),guideOpen:z,onToggleGuide:()=>O(be=>!be),actions:o.jsx(It,{tone:"warn",children:"Tokens sealed in AES-256-GCM state.vscdb"})}),o.jsx(Qi,{open:z,title:"How to Connect a GPU / Compute Node in 3 Steps",summary:"Lightweight analysis runs instantly in browser Wasm. For heavy GPU/CPU engines (AutoDock Vina, OpenMM, Boltz-2, RFdiffusion, PySCF), pair an external worker running on your computer or free Google Colab.",steps:["Start the worker locally using the command below OR open services/compute-worker/colab/synlexa_colab_gpu.ipynb in Google Colab.","Copy the printed synlexa-node://...#<token> pairing URL and paste it into Pair & Probe.","Select a workload below (pre-filled with your active 3D protein, pocket box & SMILES) and click Dispatch to Node. Completed poses/structures load directly into the Mol* 3D Viewer!"],connectionTip:"Docked poses (.pdbqt/.sdf), relaxed trajectories (.pdb), and predicted complexes (.cif) can be loaded straight into the main 3D Viewer as overlays using 'Load <artifact>' on completed jobs."}),o.jsxs(yt,{className:"space-y-3 p-3.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("span",{className:"flex items-center gap-1.5 font-semibold text-slate-200",children:[o.jsx(TR,{className:"h-4 w-4 text-sky-400"}),"Pair Colab, Local, or Remote GPU Node"]}),o.jsxs("button",{type:"button",onClick:()=>{navigator.clipboard?.writeText(Ce),q(!0),setTimeout(()=>q(!1),1500)},className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-900 px-2.5 py-1 font-mono text-[0.6875rem] text-slate-300 hover:border-sky-500/50",children:[o.jsx(Lr,{className:"h-3 w-3"}),j?"Copied start command!":"Copy local worker command"]})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-2 @2xl:grid-cols-[12rem_1fr_auto]",children:[o.jsx(Dn,{value:_,onChange:be=>y(be.target.value),placeholder:"Node label (e.g. Colab T4)"}),o.jsx(Dn,{value:x,onChange:be=>g(be.target.value),placeholder:"Paste synlexa-node://https://xxxx.trycloudflare.com#<token> or http://127.0.0.1:4180#<token>",className:"font-mono"}),o.jsx(Oe,{variant:"primary",size:"sm",icon:o.jsx(gh,{className:"h-3.5 w-3.5"}),onClick:()=>void Ae(),children:"Pair & Probe"})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-[0.6875rem] text-slate-400",children:[o.jsx(WA,{className:"h-3.5 w-3.5 shrink-0 text-slate-500"}),o.jsxs("span",{children:["Colab notebook: ",o.jsx("code",{className:"text-sky-300",children:"services/compute-worker/colab/synlexa_colab_gpu.ipynb"})]}),o.jsx("span",{children:"·"}),o.jsxs("span",{className:"break-all",children:["Local: ",o.jsx("code",{className:"text-slate-300",children:Ce})]})]}),S&&o.jsx("div",{className:"rounded-lg border border-rose-500/40 bg-rose-500/10 px-2.5 py-1.5 text-rose-200",children:S})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-4 @4xl:grid-cols-12",children:[o.jsxs("div",{className:"space-y-2 @4xl:col-span-5",children:[o.jsxs("div",{className:"text-xs font-semibold tracking-wide text-slate-400 uppercase",children:["Registered Nodes (",p.nodes.length,")"]}),p.nodes.length===0?o.jsxs(yt,{className:"p-4 text-slate-400 leading-relaxed",children:["No external nodes paired yet. Start ",o.jsx("code",{className:"text-slate-200",children:"synlexa-compute"})," locally or in Google Colab and paste its ",o.jsx("code",{className:"text-sky-300",children:"synlexa-node://"})," pairing string above."]}):p.nodes.map(be=>{const bt=be.id===pe?.id,Ot=be.capabilities?.gpus?.[0];return o.jsxs("div",{onClick:()=>dD(be.id),className:Ie("cursor-pointer rounded-xl border p-3 transition",bt?"border-sky-500/60 bg-sky-500/[0.06]":"border-white/[0.07] bg-white/[0.02] hover:border-white/20"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o.jsx("span",{className:Ie("h-2 w-2 shrink-0 rounded-full",be.online?"bg-emerald-400":"bg-slate-600")}),o.jsx("span",{className:"truncate font-semibold text-slate-100",children:be.label}),o.jsx(It,{tone:be.kind==="colab"?"accent":"neutral",children:be.kind})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("button",{type:"button",onClick:St=>{St.stopPropagation(),Ne(be.id)},className:"rounded p-1 text-slate-400 hover:bg-white/[0.06] hover:text-slate-200",title:"Re-probe node",children:o.jsx(gp,{className:Ie("h-3.5 w-3.5",E===be.id&&"animate-spin")})}),o.jsx("button",{type:"button",onClick:St=>{St.stopPropagation(),uD(be.id)},className:"rounded p-1 text-slate-500 hover:bg-white/[0.06] hover:text-rose-300",title:"Remove node",children:o.jsx(Wi,{className:"h-3.5 w-3.5"})})]})]}),o.jsx("div",{className:"mt-1 truncate font-mono text-[0.6875rem] text-slate-400",children:be.endpoint}),be.capabilities?o.jsxs("div",{className:"mt-2 flex flex-wrap gap-2 text-[0.6875rem] text-slate-300",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(al,{className:"h-3 w-3 text-emerald-400"}),Ot?`${Ot.name}${Ot.vram_mb?` (${(Ot.vram_mb/1024).toFixed(1)} GB)`:""}`:`${be.capabilities.cpu_cores} CPU cores`]}),o.jsx("span",{children:"·"}),o.jsxs("span",{children:[be.capabilities.tools.filter(St=>St.installed).length," tools ready"]})]}):be.lastError?o.jsx("div",{className:"mt-1.5 text-[0.6875rem] text-amber-300",children:be.lastError}):null]},be.id)})]}),o.jsxs("div",{className:"space-y-3 @4xl:col-span-7",children:[o.jsxs(yt,{className:"p-3.5",children:[o.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[o.jsx("span",{className:"font-semibold text-slate-200",children:"Run GPU / HPC Workload"}),o.jsxs("span",{className:"font-mono text-[0.6875rem] text-slate-400",children:["Target: ",pe?`${pe.label} (${pe.online?"online":"offline"})`:"No node selected"]})]}),o.jsx("div",{className:"flex flex-wrap gap-1.5 pb-2.5",children:Object.keys(jx).map(be=>o.jsx("button",{type:"button",onClick:()=>P(be),className:Ie("rounded-lg border px-2.5 py-1 text-xs font-medium transition",V===be?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-slate-900 text-slate-300 hover:border-white/25"),children:jx[be].label},be))}),o.jsxs("div",{className:"mb-2.5 rounded-lg border border-sky-500/20 bg-sky-500/[0.04] px-2.5 py-2 text-[0.6875rem]",children:[o.jsx("div",{className:"font-medium text-sky-200",children:Ue.desc}),o.jsx("div",{className:"mt-0.5 text-slate-400",children:Ue.inputNote})]}),o.jsxs("div",{className:"space-y-2.5 rounded-lg border border-white/[0.06] bg-[#070b12] p-3",children:[(V==="vina_docking"||V==="pyscf_qm"||V==="boltz_predict")&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1 text-[0.6875rem] text-slate-400",children:[o.jsxs("span",{children:["Ligand SMILES (",r,")"]}),f&&f.projectMolecules.length>0&&o.jsxs("select",{"aria-label":"Pick ligand from active project",value:"",onChange:be=>{be.target.value&&H(be.target.value)},className:"rounded border border-white/10 bg-slate-900 px-1.5 py-0.5 text-[0.6875rem] text-slate-200",children:[o.jsx("option",{value:"",children:"Load from Project…"}),f.projectMolecules.map(be=>o.jsx("option",{value:be.smiles,children:be.name},be.id))]})]}),o.jsx(Dn,{value:$,onChange:be=>H(be.target.value),className:"font-mono"})]}),V==="vina_docking"&&o.jsxs("div",{className:"grid grid-cols-1 gap-2 @lg:grid-cols-2",children:[o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-slate-950/70 px-2.5 py-2 text-[0.6875rem]",children:[o.jsx("div",{className:"text-slate-400",children:"Receptor & Pocket Box"}),o.jsx("div",{className:"mt-0.5 font-semibold text-slate-200",children:s||"None loaded"}),o.jsx("div",{className:"mt-0.5 font-mono text-slate-400",children:i?`${i.sourceLabel} · [${i.center.join(", ")}] (${i.size.join("×")} Å)`:"Default [0, 0, 0]"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Exhaustiveness (search depth)"}),o.jsx(Dn,{value:Se,onChange:be=>Q(be.target.value),className:"font-mono"})]})]}),V==="openmm_md"&&o.jsxs("div",{className:"grid grid-cols-1 gap-2 @lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Receptor Structure"}),o.jsx("div",{className:"rounded-lg border border-white/10 bg-slate-950 px-2.5 py-2 text-slate-200",children:s||"None loaded"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"MD Steps (2 fs/step)"}),o.jsx(Dn,{value:K,onChange:be=>we(be.target.value),className:"font-mono"})]})]}),V==="boltz_predict"&&o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Protein Sequence (Chain A)"}),o.jsx("textarea",{rows:3,value:Z,onChange:be=>G(be.target.value),className:"w-full rounded-lg border border-white/10 bg-[#0d1119] p-2 font-mono text-xs text-slate-100 outline-none focus:border-sky-400/60"})]}),V==="rfdiffusion_design"&&o.jsxs("div",{className:"grid grid-cols-1 gap-2 @lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Target Receptor Structure"}),o.jsx("div",{className:"rounded-lg border border-white/10 bg-slate-950 px-2.5 py-2 text-slate-200",children:s||"None loaded"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Contigs Specification"}),o.jsx(Dn,{value:F,onChange:be=>he(be.target.value),className:"font-mono"})]})]}),V==="pyscf_qm"&&o.jsxs("div",{className:"grid grid-cols-1 gap-2 @lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"DFT Functional"}),o.jsx(Dn,{value:W,onChange:be=>me(be.target.value),className:"font-mono"})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-1 text-[0.6875rem] text-slate-400",children:"Basis Set"}),o.jsx(Dn,{value:I,onChange:be=>J(be.target.value),className:"font-mono"})]})]}),D&&o.jsx("div",{className:"rounded-lg border border-rose-500/40 bg-rose-500/10 px-2.5 py-1.5 text-rose-200",children:D}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-1",children:[o.jsxs("span",{className:"flex items-center gap-1 text-[0.6875rem] text-slate-500",children:[o.jsx(Ki,{className:"h-3.5 w-3.5 text-amber-400/80"}),"RUO provenance & SHA-256 verified on return"]}),o.jsxs("div",{className:"flex items-center gap-2",children:[f&&o.jsxs("button",{type:"button",onClick:()=>f.openTab("viewer",!0),className:"inline-flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1.5 text-xs text-slate-300 hover:border-sky-400/40",children:[o.jsx(_s,{className:"h-3.5 w-3.5"})," Inspect Pocket in 3D"]}),o.jsx(Oe,{variant:"primary",size:"sm",disabled:ge||!pe?.online,icon:o.jsx(qp,{className:"h-3.5 w-3.5"}),onClick:()=>void Re(),children:ge?"Submitting…":pe?.online?"Dispatch to Node":"Pair Online Node First"})]})]})]})]}),pe?.capabilities&&o.jsxs(yt,{className:"p-3.5",children:[o.jsxs("div",{className:"mb-2 text-xs font-semibold text-slate-200",children:["Detected Engines on ",pe.label]}),o.jsx("div",{className:"grid grid-cols-1 gap-1.5 @xl:grid-cols-2",children:pe.capabilities.tools.map(be=>o.jsxs("div",{className:"flex items-start justify-between gap-2 rounded-lg border border-white/[0.06] bg-[#070b12] px-2.5 py-2",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-slate-200",children:[be.installed?o.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0 text-emerald-400"}):o.jsx(Bc,{className:"h-3.5 w-3.5 shrink-0 text-slate-600"}),o.jsx("span",{className:"truncate",children:be.name})]}),o.jsx("div",{className:"mt-0.5 truncate font-mono text-[0.6875rem] text-slate-500",children:be.installed?be.version??"installed":be.install_hint})]}),o.jsx(It,{tone:be.commercial_safe?"neutral":"warn",children:be.license})]},be.id))})]})]})]}),o.jsxs(yt,{className:"p-3.5",children:[o.jsxs("div",{className:"mb-2 flex items-center gap-2 font-semibold text-slate-200",children:[o.jsx(Qo,{className:"h-4 w-4 text-sky-400"}),"Remote Compute Job Queue (",p.jobs.length,")"]}),p.jobs.length===0?o.jsx("p",{className:"text-slate-500",children:"Dispatched GPU/HPC jobs appear here with live logs and verified artifacts that load into the 3D Viewer."}):o.jsx("div",{className:"space-y-2",children:p.jobs.map(be=>o.jsxs("div",{className:"rounded-lg border border-white/[0.07] bg-[#070b12] p-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"font-mono font-semibold text-slate-100",children:be.tool_id}),o.jsx("span",{className:"font-mono text-[0.6875rem] text-slate-500",children:be.job_id}),o.jsxs(It,{tone:be.status==="completed"?"good":be.status==="failed"?"bad":be.status==="running"?"accent":"warn",children:[be.status," · ",Math.round(be.progress*100),"%"]})]}),be.status==="running"&&be.nodeId&&o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>void mD(be.nodeId,be.job_id),children:"Cancel"})]}),be.error_message&&o.jsxs("div",{className:"mt-1.5 rounded border border-amber-500/30 bg-amber-500/10 px-2 py-1 font-mono text-[0.6875rem] text-amber-200",children:[be.error_code,": ",be.error_message]}),Object.keys(be.metrics).length>0&&o.jsx("pre",{className:"mt-2 max-h-28 overflow-auto rounded bg-slate-950 p-2 font-mono text-[0.6875rem] text-emerald-300",children:JSON.stringify(be.metrics,null,2)}),be.artifacts.length>0&&o.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:be.artifacts.map(bt=>o.jsxs("button",{type:"button",onClick:()=>void $e(be,bt),className:"flex items-center gap-1 rounded border border-sky-500/40 bg-sky-500/15 px-2 py-1 font-mono text-[0.6875rem] text-sky-200 hover:bg-sky-500/25",children:[o.jsx(LA,{className:"h-3 w-3"})," Load ",bt.name," into 3D (",bt.sha256.slice(0,8),")"]},bt.name))})]},be.job_id))})]})]})})}const Vq=[{id:"NM_000067.3",label:"CA2 (NM_000067.3 · P00918 260aa)",matchesProteinHint:"CA2 / 3HS4 / P00918"},{id:"NM_000546.6",label:"TP53 (NM_000546.6 · GRCh38 MANE)",matchesProteinHint:"Tumor suppressor p53"},{id:"NM_000518.5",label:"HBB (NM_000518.5 · GRCh38 MANE)",matchesProteinHint:"Hemoglobin β / 1A3N / P68871"}],Kq={"NM_000067.3":"ATGTCCCATCACTGGGGGTACGGCAAACACAACGGACCTGAGCACTGGCATAAGGACTTCCCCATTGCCAAGGGAGAGCGCCAGTCCCCTGTTGACATCGACACTCATACAGCCAAGTATGACCCTTCCCTGAAGCCCCTGTCTGTTTCCTATGATCAAGCAACTTCCCTGAGGATCCTCAACAATGGTCATGCTTTCAACGTGGAGTTTGATGACTCTCAGGACAAAGCAGTGCTCAAGGGAGGACCCCTGGATGGCACTTACAGATTGATTCAGTTTCACTTTCACTGGGGTTCACTTGATGGACAAGGTTCAGAGCATACTGTGGATAAAAAGAAATATGCTGCAGAACTTCACTTGGTTCACTGGAACACCAAATATGGGGATTTTGGGAAAGCTGTGCAGCAACCTGATGGACTGGCCGTTCTAGGTATTTTTTTGAAGGTTGGCAGCGCTAAACCGGGCCTTCAGAAAGTTGTTGATGTGCTGGATTCCATTAAAACAAAGGGCAAGAGTGCTGACTTCACTAACTTCGATCCTCGTGGCCTCCTTCCTGAATCCCTGGATTACTGGACCTACCCAGGCTCACTGACCACCCCTCCTCTTCTGGAATGTGTGACCTGGATTGTGCTCAAGGAACCCATCAGCGTCAGCAGCGAGCAGGTGTTGAAATTCCGTAAACTTAACTTCAATGGGGAGGGTGAACCCGAAGAACTGATGGTGGACAACTGGCGCCCAGCTCAGCCACTGAAGAACAGGCAAATCAAAGCTTCCTTCAAA","NM_000518.5":"ATGGTGCATCTGACTCCTGAGGAGAAGTCTGCCGTTACTGCCCTGTGGGGCAAGGTGAACGTGGATGAAGTTGGTGGTGAGGCCCTGGGCAGGCTGCTGGTGGTCTACCCTTGGACCCAGAGGTTCTTTGAGTCCTTTGGGGATCTGTCCACTCCTGATGCTGTTATGGGCAACCCTAAGGTGAAGGCTCATGGCAAGAAAGTGCTCGGTGCCTTTAGTGATGGCCTGGCTCACCTGGACAACCTCAAGGGCACCTTTGCCACACTGAGTGAGCTGCACTGTGACAAGCTGCACGTGGATCCTGAGAACTTCAGGCTCCTGGGCAACGTGCTGGTCTGTGTGCTGGCCCATCACTTTGGCAAAGAATTCACCCCACCAGTGCAGGCTGCCTATCAGAAAGTGGTGGCTGGTGTGGCTAATGCCCTGGCCCACAAGTATCAC","NM_000546.6":"ATGGAGGAGCCGCAGTCAGATCCTAGCGTCGAGCCCCCTCTGAGTCAGGAAACATTTTCAGACCTATGGAAACTACTTCCTGAAAACAACGTTCTGTCCCCCTTGCCGTCCCAAGCAATGGATGATTTGATGCTGTCCCCGGACGATATTGAACAATGGTTCACTGAAGACCCAGGTCCAGATGAAGCTCCCAGAATGCCAGAGGCTGCTCCCCCCGTGGCCCCTGCACCAGCAGCTCCTACACCGGCGGCCCCTGCACCAGCCCCCTCCTGGCCCCTGTCATCTTCTGTCCCTTCCCAGAAAACCTACCAGGGCAGCTACGGTTTCCGTCTGGGCTTCTTGCATTCTGGGACAGCCAAGTCTGTGACTTGCACGTACTCCCCTGCCCTCAACAAGATGTTTTGCCAACTGGCCAAGACCTGCCCTGTGCAGCTGTGGGTTGATTCCACACCCCCGCCCGGCACCCGCGTCCGCGCCATGGCCATCTACAAGCAGTCACAGCACATGACGGAGGTTGTGAGGCGCTGCCCCCACCATGAGCGCTGCTCAGATAGCGATGGTCTGGCCCCTCCTCAGCATCTTATCCGAGTGGAAGGAAATTTGCGTGTGGAGTATTTGGATGACAGAAACACTTTTCGACATAGTGTGGTGGTGCCCTATGAGCCGCCTGAGGTTGGCTCTGACTGTACCACCATCCACTACAACTACATGTGTAACAGTTCCTGCATGGGCGGCATGAACCGGAGGCCCATCCTCACCATCATCACACTGGAAGACTCCAGTGGTAATCTACTGGGACGGAACAGCTTTGAGGTGCGTGTTTGTGCCTGTCCTGGGAGAGACCGGCGCACAGAGGAAGAGAATCTCCGCAAGAAAGGGGAGCCTCACCACGAGCTGCCCCCAGGGAGCACTAAGCGAGCACTGCCCAACAACACCAGCTCCTCTCCCCAGCCAAAGAAGAAACCACTGGATGGAGAATATTTCACCCTTCAGATCCGTGGGCGTGAGCGCTTCGAGATGTTCCGAGAGCTGAATGAGGCCTTGGAACTCAAGGATGCCCAGGCTGGGAAGGAGCCAGGGGGGAGCAGGGCTCACTCCAGCCACCTGAAGTCCAAAAAGGGTCAGTCTACCTCCCGCCATAAAAAACTCATGTTCAAGACAGAAGGGCCTGACTCAGAC"};function Yq({state:e,dispatch:r,result:n,error:s,onFocusResidue:i,simpleMode:c=!1,bridge:d}){const[f,p]=C.useState(!1),[b,x]=C.useState("all"),[g,_]=C.useState(null),[y,S]=C.useState(null),k=C.useMemo(()=>{const O=n?.codingDna??(e.useCustomDna?e.customDna:Kq[n?.transcriptId??e.transcriptId]??"");if(!O)return[];const V=Math.floor(O.length/3),P=Math.max(1,Math.min(V,e.targetCodonIndex)),$=Math.max(1,P-7),H=Math.min(V,P+7),Z=[];for(let G=$;G<=H;G++)Z.push({index1:G,triplet:O.slice((G-1)*3,G*3)});return Z},[n?.codingDna,n?.transcriptId,e.targetCodonIndex,e.useCustomDna,e.customDna,e.transcriptId]),E=C.useMemo(()=>{const O=n?.pamSites??[];return b==="near"?O.filter(V=>Math.abs(V.distanceToTargetCodonBp)<=30):b==="optimal"?O.filter(V=>!V.hasPolyT&&V.gcPercent>=40&&V.gcPercent<=60):O},[n?.pamSites,b]),T=n?.targetCodon.consequence==="nonsense"?"border-rose-500/50 bg-rose-500/15 text-rose-200":n?.targetCodon.consequence==="missense"?"border-amber-500/50 bg-amber-500/15 text-amber-200":n?.targetCodon.consequence==="synonymous"?"border-emerald-500/50 bg-emerald-500/15 text-emerald-200":"border-slate-700 bg-slate-900 text-slate-300",j=(O,V)=>{navigator.clipboard?.writeText(V),_(O),setTimeout(()=>_(null),1500)},q=(O,V=!1)=>{r({type:"set_target_codon",codonIndex:O}),i(O),V&&d?.focusIn3D(O,{centerCamera:!0})},z=!!d&&!!n&&n.targetCodon.consequence==="missense"&&n.targetCodon.wtAa!=="*"&&n.targetCodon.editedAa!=="*";return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:d,title:"Gene & CRISPR Base-Editing Workbench",subtitle:"Simulate single-nucleotide codon edits, scan SpCas9/SaCas9/Cas12a PAM windows, and bridge DNA edits to 3D residues.",icon:o.jsx(Fs,{className:"h-4 w-4"}),guideOpen:f,onToggleGuide:()=>p(O=>!O),actions:d&&n&&o.jsxs("button",{type:"button",onClick:()=>{d.saveCrisprToProject({name:`${n.geneSymbol} codon ${e.targetCodonIndex} (${n.targetCodon.wtCodon}→${n.targetCodon.editedCodon})`,transcriptId:e.transcriptId,targetCodonIndex:e.targetCodonIndex,baseEditOffset:e.baseEditOffset,newBase:e.newBase,nuclease:e.nuclease}),S("Saved!"),setTimeout(()=>S(null),1600)},className:"inline-flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1 text-xs font-medium text-slate-200 hover:border-sky-400/40",children:[o.jsx(Qc,{className:"h-3.5 w-3.5 text-sky-300"}),o.jsx("span",{children:y??"Save Edit"})]})}),o.jsx(Qi,{open:f,title:"How Gene & CRISPR Base Editing Works",summary:"Select a GRCh38/MANE transcript or paste your own coding DNA (CDS), choose a target codon position, and test single-base edits (+1, +2, or +3 within the triplet) while scanning nearby nuclease PAM sites.",steps:["Select CA2 (matches 3HS4), HBB (matches 1A3N), TP53, or Custom Coding DNA.","Pick a Codon # (or click a residue in the 3D Viewer to jump directly to its codon) and test a nucleotide change at Edit Pos +1/+2/+3.","Browse PAM & Guide hits below — click any row to focus its cut-site codon in the 3D protein structure or copy its protospacer."],connectionTip:"Codon indices map directly onto the 3D protein residue numbering for matched transcripts (CA2 ↔ 3HS4, HBB ↔ 1A3N). When a base edit creates a missense substitution, click 'Test in Peptide' to evaluate its biophysical impact.",glossary:[{term:"SpCas9 / SaCas9 / Cas12a",desc:"Different CRISPR nucleases recognize different PAM motifs: 5′-NGG-3′, 5′-NNGRRT-3′, and 5′-TTTV-3′ respectively."},{term:"ΔCodon (bp)",desc:"Distance in base pairs from the predicted double-strand/nick cut site to the target codon."},{term:"GC% (40–60%)",desc:"Balanced spacer GC content is generally preferred for gRNA stability and specificity."},{term:"Poly-T (TTTT)",desc:"Four consecutive T’s act as a premature RNA Pol III terminator for U6-driven sgRNA expression."}]}),o.jsxs("div",{className:"space-y-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("select",{value:e.useCustomDna?"CUSTOM":e.transcriptId,onChange:O=>{O.target.value==="CUSTOM"?r({type:"toggle_custom_dna",enabled:!0}):r({type:"select_transcript",transcriptId:O.target.value})},"aria-label":"Transcript selector",className:"h-8 rounded-lg border border-white/10 bg-slate-950 px-2.5 font-mono text-xs text-slate-200 outline-none focus:border-cyan-500",children:[Vq.map(O=>o.jsx("option",{value:O.id,children:O.label},O.id)),o.jsx("option",{value:"CUSTOM",children:"Custom Coding DNA (CDS)…"})]}),o.jsxs("label",{className:"flex h-8 items-center gap-1.5 rounded-lg border border-white/10 bg-slate-950/70 px-2.5 font-mono text-xs text-slate-300",children:[o.jsx("span",{className:"text-slate-400",children:"Codon #"}),o.jsx("input",{type:"number",min:1,max:n?.proteinLengthAa??500,value:e.targetCodonIndex,onChange:O=>{const V=Number(O.target.value)||1;q(V,!1)},className:"w-16 rounded border border-white/10 bg-slate-900 px-1.5 py-0.5 text-slate-100 outline-none focus:border-cyan-500"})]}),o.jsxs("select",{value:e.nuclease,onChange:O=>r({type:"set_nuclease",nuclease:O.target.value}),"aria-label":"Nuclease selector",className:"h-8 rounded-lg border border-white/10 bg-slate-950 px-2.5 font-mono text-xs text-emerald-300 outline-none focus:border-emerald-500",children:[o.jsx("option",{value:"SpCas9",children:"SpCas9 (NGG)"}),o.jsx("option",{value:"SaCas9",children:"SaCas9 (NNGRRT)"}),o.jsx("option",{value:"Cas12a",children:"Cas12a (TTTV)"})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs",children:[o.jsx("span",{className:"text-slate-400",children:"Edit Pos:"}),[0,1,2].map(O=>o.jsxs("button",{type:"button",title:`Edit codon nucleotide ${O+1}`,onClick:()=>r({type:"set_base_edit",offset:O,newBase:e.newBase}),className:`rounded-md border px-2 py-1 ${e.baseEditOffset===O?"border-cyan-500/50 bg-cyan-500/20 text-cyan-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:["+",O+1]},O)),o.jsx("span",{className:"text-slate-500",children:"→"}),["A","C","G","T"].map(O=>o.jsx("button",{type:"button",title:`Substitute base with ${O}`,onClick:()=>r({type:"set_base_edit",offset:e.baseEditOffset,newBase:O}),className:`rounded-md border px-2 py-1 font-bold ${e.newBase===O?"border-amber-500/50 bg-amber-500/25 text-amber-200":"border-white/10 bg-slate-900 text-slate-300 hover:border-white/25"}`,children:O},O))]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2 text-[0.6875rem]",children:[o.jsx("span",{className:"text-slate-500",children:"Examples:"}),o.jsx("button",{type:"button",onClick:()=>{r({type:"select_transcript",transcriptId:"NM_000067.3"}),r({type:"set_target_codon",codonIndex:94}),r({type:"set_base_edit",offset:0,newBase:"G"}),i(94)},className:"rounded-md border border-white/10 bg-slate-900/80 px-2 py-0.5 text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:"CA2 Codon 94 (Zn²⁺ His)"}),o.jsx("button",{type:"button",onClick:()=>{r({type:"select_transcript",transcriptId:"NM_000518.5"}),r({type:"set_target_codon",codonIndex:7}),r({type:"set_base_edit",offset:1,newBase:"T"}),i(7)},className:"rounded-md border border-white/10 bg-slate-900/80 px-2 py-0.5 text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:"HBB Codon 7 (c.20A>T · Glu→Val)"}),o.jsx("button",{type:"button",onClick:()=>{r({type:"select_transcript",transcriptId:"NM_000546.6"}),r({type:"set_target_codon",codonIndex:175}),r({type:"set_base_edit",offset:1,newBase:"A"}),i(175)},className:"rounded-md border border-white/10 bg-slate-900/80 px-2 py-0.5 text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:"TP53 Codon 175 (Arg→His)"})]})]}),e.useCustomDna&&o.jsx("textarea",{value:e.customDna,onChange:O=>r({type:"set_custom_dna",dna:O.target.value}),rows:3,placeholder:"Paste coding DNA sequence (5'->3' ATG...)",className:"w-full rounded-xl border border-white/10 bg-slate-950 p-2.5 font-mono text-xs text-slate-200 outline-none focus:border-cyan-500"}),s&&o.jsx("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/10 px-3 py-2 font-mono text-xs text-rose-200",children:s}),n&&o.jsxs("div",{className:"grid grid-cols-1 gap-3 @4xl:grid-cols-12",children:[o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @4xl:col-span-5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsxs("span",{className:"font-semibold text-cyan-300",children:[n.geneSymbol," · ",n.assembly," · ",n.cdsLengthBp," bp"]}),o.jsx("span",{className:`rounded-md border px-2 py-0.5 text-[0.6875rem] uppercase ${T}`,children:n.targetCodon.consequence})]}),o.jsxs("div",{className:"rounded-lg border border-white/[0.07] bg-black/30 p-2.5 font-mono text-xs",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("span",{className:"text-slate-400",children:["Codon ",n.targetCodon.codonIndex1," (bp ",n.targetCodon.dnaStartBp1,"–",n.targetCodon.dnaStartBp1+2,")"]}),o.jsxs("span",{className:"font-semibold",children:[o.jsxs("span",{className:"text-sky-300",children:[n.targetCodon.wtCodon," (",n.targetCodon.wtAa,")"]}),o.jsx("span",{className:"mx-1.5 text-slate-500",children:"→"}),o.jsxs("span",{className:"text-amber-300",children:[n.targetCodon.editedCodon," (",n.targetCodon.editedAa,")"]})]})]}),o.jsx("div",{className:"mt-2 font-sans text-xs leading-relaxed text-slate-300",children:n.targetCodon.consequence==="missense"?`Changes amino acid ${n.targetCodon.wtAa} to ${n.targetCodon.editedAa} (missense substitution).`:n.targetCodon.consequence==="synonymous"?`Silent nucleotide change — encodes the same amino acid (${n.targetCodon.wtAa}).`:n.targetCodon.consequence==="nonsense"?`Introduces a premature stop codon (*) at position ${n.targetCodon.codonIndex1}.`:"Select a different nucleotide at +1 / +2 / +3 to simulate a codon change."}),n.pamSites.length>0&&o.jsx("div",{className:"mt-2 font-sans",children:o.jsx(Ca,{insight:Mq(n.pamSites[0].gcPercent),compact:!0})})]}),k.length>0&&o.jsxs("div",{className:"space-y-1",children:[o.jsx("div",{className:"text-[0.6875rem] text-slate-400",children:"Click any codon to focus & sync 3D:"}),o.jsx("div",{className:"flex flex-wrap gap-1",children:k.map(O=>{const V=O.index1===e.targetCodonIndex;return o.jsxs("button",{type:"button",onClick:()=>q(O.index1,!0),className:`rounded-md border px-2 py-1 font-mono text-xs transition ${V?"border-amber-400 bg-amber-500/20 text-amber-200":"border-white/10 bg-black/30 text-slate-300 hover:border-cyan-500/40"}`,children:[o.jsx("div",{className:"text-[0.625rem] text-slate-500",children:O.index1}),o.jsx("div",{children:O.triplet})]},O.index1)})})]}),d&&o.jsxs("div",{className:"mt-auto flex flex-wrap gap-1.5 border-t border-white/[0.06] pt-2",children:[o.jsxs("button",{type:"button",onClick:()=>d.focusIn3D(n.targetCodon.codonIndex1,{centerCamera:!0,openViewer:"activate"}),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2.5 py-1 text-[0.6875rem] font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Ur,{className:"h-3 w-3"})," Focus Res #",n.targetCodon.codonIndex1," in 3D"]}),z&&o.jsxs("button",{type:"button",onClick:()=>d.sendMutationToPeptide(`${n.targetCodon.wtAa}${n.targetCodon.codonIndex1}${n.targetCodon.editedAa}`,n.targetCodon.codonIndex1),className:"inline-flex items-center gap-1 rounded-md border border-emerald-400/40 bg-emerald-500/15 px-2.5 py-1 text-[0.6875rem] font-medium text-emerald-200 hover:bg-emerald-500/25",children:[o.jsx(ar,{className:"h-3 w-3"})," Test ",n.targetCodon.wtAa,n.targetCodon.codonIndex1,n.targetCodon.editedAa," in Peptide"]})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @4xl:col-span-7",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsxs("span",{className:"font-semibold text-emerald-300",children:[e.nuclease," PAM & GUIDE SCANNER (",E.length,"/",n.pamSites.length,")"]}),o.jsx("div",{className:"flex flex-wrap gap-1 font-sans text-[0.6875rem]",children:[["all","All"],["near","Near Target (≤30bp)"],["optimal","Optimal GC & No TTTT"]].map(([O,V])=>o.jsx("button",{type:"button",onClick:()=>x(O),className:`rounded-md border px-2 py-0.5 transition ${b===O?"border-emerald-400/50 bg-emerald-500/20 text-emerald-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:V},O))})]}),o.jsx("div",{className:"max-h-72 overflow-auto rounded-lg border border-white/[0.06] bg-black/25",children:o.jsxs("table",{className:"w-full min-w-[520px] font-mono text-[0.75rem]",children:[o.jsx("thead",{className:"sticky top-0 bg-[#0d131d]",children:o.jsxs("tr",{className:"border-b border-white/10 text-slate-400",children:[o.jsx("th",{className:"px-2 py-1.5 text-left",children:"Strand"}),o.jsx("th",{className:"px-2 py-1.5 text-left",children:"Protospacer (5'→3')"}),o.jsx("th",{className:"px-2 py-1.5 text-left",children:"PAM"}),o.jsx("th",{className:"px-2 py-1.5 text-right",children:"Cut bp"}),o.jsx("th",{className:"px-2 py-1.5 text-right",children:"ΔCodon"}),o.jsx("th",{className:"px-2 py-1.5 text-right",children:"GC%"}),o.jsx("th",{className:"px-2 py-1.5 text-right",children:"Poly-T"}),o.jsx("th",{className:"px-2 py-1.5 text-right",children:"Copy"})]})}),o.jsxs("tbody",{className:"divide-y divide-white/[0.05] text-slate-200",children:[E.slice(0,30).map((O,V)=>{const P=Math.max(1,Math.ceil(O.cutBp1/3)),$=`${O.cutBp1}-${O.strand}-${V}`;return o.jsxs("tr",{onClick:()=>q(P,!0),title:`Click to jump to cut codon #${P} and focus in 3D`,className:"cursor-pointer transition hover:bg-sky-500/10",children:[o.jsx("td",{className:"px-2 py-1.5 text-cyan-300",children:O.strand}),o.jsx("td",{className:"px-2 py-1.5",children:O.protospacer}),o.jsx("td",{className:"px-2 py-1.5 text-amber-300",children:O.pam}),o.jsx("td",{className:"px-2 py-1.5 text-right",children:O.cutBp1}),o.jsxs("td",{className:"px-2 py-1.5 text-right",children:[O.distanceToTargetCodonBp>=0?"+":"",O.distanceToTargetCodonBp," bp"]}),o.jsxs("td",{className:"px-2 py-1.5 text-right",children:[O.gcPercent.toFixed(0),"%"]}),o.jsx("td",{className:"px-2 py-1.5 text-right",children:O.hasPolyT?o.jsx("span",{className:"text-rose-400",children:"TTTT"}):o.jsx("span",{className:"text-emerald-400",children:"ok"})}),o.jsx("td",{className:"px-2 py-1.5 text-right",children:o.jsx("button",{type:"button",onClick:H=>{H.stopPropagation(),j($,`${O.protospacer}${O.pam}`)},title:"Copy protospacer + PAM",className:"rounded p-1 text-slate-400 hover:bg-white/10 hover:text-white",children:g===$?o.jsx(Fi,{className:"h-3 w-3 text-emerald-400"}):o.jsx(Lr,{className:"h-3 w-3"})})})]},$)}),E.length===0&&o.jsx("tr",{children:o.jsx("td",{colSpan:8,className:"px-3 py-6 text-center font-sans text-xs text-slate-500",children:"No PAM sites match the current filter. Switch to “All” or try another nuclease."})})]})]})}),o.jsx("div",{className:"text-[0.6875rem] text-slate-500",children:"RUO Computational Guide Window · Click any row to focus the corresponding cut-site codon in the 3D protein structure."})]})]})]})}const Tx=[{id:"rcsb",label:"RCSB PDB",hint:"Experimental mmCIF structures (CC0-1.0)",examples:["carbonic anhydrase","ubiquitin","1A3N","1LZ1"]},{id:"alphafold",label:"AlphaFold DB",hint:"Predicted structures + PAE matrices (CC-BY-4.0)",examples:["P00918","P0CG48","P68871","P61626"]},{id:"uniprot",label:"UniProtKB",hint:"Protein accessions & annotations (CC-BY-4.0)",examples:["carbonic anhydrase","ubiquitin","P68871","lysozyme"]},{id:"pubchem",label:"PubChem",hint:"Small-molecule SMILES & properties (Public domain)",examples:["imatinib","acetazolamide","aspirin","caffeine"]},{id:"chembl",label:"ChEMBL",hint:"Bioactive ligands & clinical candidates (CC-BY-SA-3.0)",examples:["acetazolamide","imatinib","dorzolamide"]},{id:"opentargets",label:"Open Targets",hint:"Human target-disease associations (Apache-2.0)",examples:["CA2","TPO","TSHR","TP53"]}];function Wq({source:e}){return e==="rcsb"?o.jsx(qi,{className:"h-3.5 w-3.5"}):e==="alphafold"?o.jsx(ia,{className:"h-3.5 w-3.5"}):e==="uniprot"?o.jsx(Fs,{className:"h-3.5 w-3.5"}):o.jsx(Br,{className:"h-3.5 w-3.5"})}function Ex({origin:e}){return e==="live-network"?o.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-emerald-500/40 bg-emerald-500/10 px-1.5 py-0.5 font-mono text-[0.75rem] font-semibold tracking-wider text-emerald-300",children:[o.jsx(Ry,{className:"h-2.5 w-2.5"}),"LIVE"]}):o.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-amber-500/40 bg-amber-500/10 px-1.5 py-0.5 font-mono text-[0.75rem] font-semibold tracking-wider text-amber-300",children:[o.jsx(GA,{className:"h-2.5 w-2.5"}),"PINNED CACHE"]})}function Xq({open:e,onClose:r,onImportStructure:n,onImportCompound:s,defaultSource:i="rcsb"}){const[c,d]=C.useState(i),[f,p]=C.useState(""),[b,x]=C.useState(()=>typeof navigator<"u"&&navigator.onLine===!1),[g,_]=C.useState(!1),[y,S]=C.useState(null),[k,E]=C.useState(null),[T,j]=C.useState(null),[q,z]=C.useState({}),[O,V]=C.useState(null),P=C.useRef(null);C.useEffect(()=>{e?(d(i),E(null)):P.current?.abort()},[e,i]),C.useEffect(()=>{if(!e)return;const Q=F=>{F.key==="Escape"&&r()};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[e,r]);const $=C.useCallback(async Q=>{P.current?.abort();const F=new AbortController;P.current=F,_(!0),E(null);try{const he=await Tz(Q,{signal:F.signal});F.signal.aborted||S(he)}catch(he){F.signal.aborted||E(he instanceof Error?he.message:String(he))}finally{F.signal.aborted||_(!1)}},[]);C.useEffect(()=>{e&&b&&$(c)},[e,b,c,$]);const H=C.useCallback(async(Q,F)=>{const he=F.trim();if(!he){b?await $(Q):E(`Enter a search query or click an example chip for ${$x[Q]}.`);return}P.current?.abort();const W=new AbortController;P.current=W,_(!0),E(null);try{const me=await Iy(Q,he,{offline:b,signal:W.signal});W.signal.aborted||(S(me),z({}))}catch(me){W.signal.aborted||E(me instanceof Error?me.message:String(me))}finally{W.signal.aborted||_(!1)}},[b,$]),Z=Q=>{P.current?.abort(),d(Q),E(null),z({}),b||S(null)},G=async(Q,F)=>{const he=`${Q.source}:${Q.id}:${F}`;j(he),E(null);try{const W=await uj(Q,{offline:b});await n(W,F),V({kind:"structure",label:W.label,roleLabel:F==="reference"?"Reference Structure":"Mobile Structure",sha256:W.sha256,paeSha256:W.paeSha256,retrievedAtUtc:W.retrievedAtUtc,origin:W.origin,sourceUrl:W.sourceUrl,license:W.license,warnings:W.warnings})}catch(W){E(W instanceof Error?W.message:String(W))}finally{j(null)}},K=async Q=>{const F=`af-lookup:${Q.id}`;j(F),E(null);try{const he=await Pz(Q.id,{offline:b});he.records.length===0?E(`No AlphaFold DB prediction found for UniProt accession ${Q.id}.`):z(W=>({...W,[Q.id]:he.records}))}catch(he){E(he instanceof Error?he.message:String(he))}finally{j(null)}},we=Q=>{E(null);try{const F=dj(Q);s(F),V({kind:"compound",label:F.name,roleLabel:F.cid!==null?`PubChem CID ${F.cid}`:"Small Molecule",sha256:null,paeSha256:null,retrievedAtUtc:F.retrievedAtUtc,origin:F.origin,sourceUrl:F.sourceUrl,license:F.license,warnings:[]})}catch(F){E(F instanceof Error?F.message:String(F))}};if(!e)return null;const Se=Tx.find(Q=>Q.id===c)??Tx[0];return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/75 p-4 backdrop-blur-xs",onClick:r,role:"dialog","aria-modal":"true","aria-label":"Public Database Explorer",children:o.jsxs("div",{className:"flex max-h-[88vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-slate-800 bg-[#0b1019] text-slate-100 shadow-2xl",onClick:Q=>Q.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-slate-800 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md border border-cyan-500/40 bg-cyan-500/10 text-cyan-300",children:o.jsx(Vi,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold tracking-wide text-slate-100",children:"Public Database Explorer"}),o.jsx("p",{className:"text-[0.8125rem] text-slate-400",children:"Direct browser fetch with SHA-256 provenance & pinned local fixture fallback"})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>x(Q=>!Q),"aria-pressed":b,className:`inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 font-mono text-[0.8125rem] transition-colors ${b?"border-amber-500/50 bg-amber-500/10 text-amber-300 hover:bg-amber-500/20":"border-slate-700 bg-slate-900/80 text-slate-300 hover:border-cyan-500/40 hover:text-cyan-200"}`,title:"Toggle between live public API requests and pinned local cache (/fixtures/)",children:b?o.jsxs(o.Fragment,{children:[o.jsx(GA,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"Offline: Pinned Cache"})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ry,{className:"h-3.5 w-3.5 text-cyan-400"}),o.jsx("span",{children:"Network: Live API"})]})}),o.jsx("button",{type:"button",onClick:r,"aria-label":"Close database explorer",className:"rounded-md border border-slate-800 bg-slate-900/80 p-1.5 text-slate-400 transition-colors hover:border-slate-700 hover:text-slate-100",children:o.jsx(Xi,{className:"h-4 w-4"})})]})]}),o.jsx("div",{className:"grid grid-cols-2 gap-1.5 border-b border-slate-800 bg-[#090d15] px-4 py-2 sm:grid-cols-4",children:Tx.map(Q=>{const F=Q.id===c;return o.jsxs("button",{type:"button",onClick:()=>Z(Q.id),className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-left transition-colors ${F?"border-cyan-500/60 bg-cyan-500/10 text-cyan-200":"border-slate-800/90 bg-slate-900/50 text-slate-400 hover:border-slate-700 hover:text-slate-200"}`,children:[o.jsx("span",{className:F?"text-cyan-400":"text-slate-500",children:o.jsx(Wq,{source:Q.id})}),o.jsx("span",{className:"text-xs font-medium",children:Q.label})]},Q.id)})}),o.jsxs("div",{className:"border-b border-slate-800 bg-[#0d131f]/70 px-4 py-3",children:[o.jsxs("form",{className:"flex items-center gap-2",onSubmit:Q=>{Q.preventDefault(),H(c,f)},children:[o.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-lg border border-slate-700/80 bg-[#0b1019] px-3 py-2 focus-within:border-cyan-500/60",children:[o.jsx(Gr,{className:"h-4 w-4 shrink-0 text-cyan-400"}),o.jsx("input",{autoFocus:!0,value:f,onChange:Q=>p(Q.target.value),placeholder:`Search ${Se.label} (${Se.examples.slice(0,2).join(", ")})…`,className:"w-full bg-transparent text-xs text-slate-100 placeholder-slate-500 outline-none"})]}),o.jsxs("button",{type:"submit",disabled:g,className:"inline-flex items-center gap-1.5 rounded-lg border border-cyan-500/50 bg-cyan-500/15 px-3.5 py-2 text-xs font-medium text-cyan-200 transition-colors hover:bg-cyan-500/25 disabled:opacity-50",children:[g?o.jsx(qs,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(Gr,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"Search"})]}),o.jsx("button",{type:"button",onClick:()=>void $(c),disabled:g,className:"hidden rounded-lg border border-slate-700 bg-slate-900 px-2.5 py-2 text-[0.8125rem] text-slate-300 transition-colors hover:border-slate-600 hover:text-slate-100 sm:inline-flex",title:"Browse curated local pinned fixtures for this source",children:"Pinned Fixtures"})]}),o.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[0.75rem] font-medium uppercase tracking-wider text-slate-500",children:"Examples:"}),Se.examples.map(Q=>o.jsx("button",{type:"button",onClick:()=>{p(Q),H(c,Q)},className:"rounded-full border border-slate-700/80 bg-slate-900/70 px-2.5 py-0.5 font-mono text-[0.75rem] text-slate-300 transition-colors hover:border-cyan-500/50 hover:text-cyan-200",children:Q},Q))]}),o.jsx("span",{className:"text-[0.75rem] text-slate-500",children:Se.hint})]})]}),o.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3",children:[O&&o.jsxs("div",{className:"rounded-lg border border-emerald-500/40 bg-emerald-500/10 px-3 py-2.5 text-xs",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 font-medium text-emerald-200",children:[o.jsx(Gs,{className:"h-4 w-4 shrink-0 text-emerald-400"}),o.jsxs("span",{children:["Imported ",O.label," (",O.roleLabel,")"]})]}),o.jsx(Ex,{origin:O.origin})]}),o.jsxs("div",{className:"mt-2 grid gap-1.5 font-mono text-[0.75rem] text-slate-300 sm:grid-cols-2",children:[O.sha256&&o.jsxs("div",{className:"flex items-center gap-1.5 break-all",children:[o.jsx(ck,{className:"h-3 w-3 shrink-0 text-emerald-400"}),o.jsxs("span",{children:[o.jsx("strong",{className:"text-slate-400",children:"SHA-256:"})," ",O.sha256]})]}),O.paeSha256&&o.jsxs("div",{className:"flex items-center gap-1.5 break-all",children:[o.jsx(ck,{className:"h-3 w-3 shrink-0 text-cyan-400"}),o.jsxs("span",{children:[o.jsx("strong",{className:"text-slate-400",children:"PAE SHA-256:"})," ",O.paeSha256]})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(zx,{className:"h-3 w-3 shrink-0 text-slate-400"}),o.jsxs("span",{children:[o.jsx("strong",{className:"text-slate-400",children:"Retrieved UTC:"})," ",O.retrievedAtUtc]})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Ki,{className:"h-3 w-3 shrink-0 text-slate-400"}),o.jsxs("span",{children:[o.jsx("strong",{className:"text-slate-400",children:"License:"})," ",O.license]})]})]}),O.warnings.length>0&&o.jsx("p",{className:"mt-1.5 text-[0.8125rem] text-amber-300",children:O.warnings.join(" ")})]}),y?.warning&&o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:[o.jsx(Gc,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-400"}),o.jsx("span",{children:y.warning})]}),k&&o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-xs text-rose-200",children:[o.jsx(Gc,{className:"mt-0.5 h-4 w-4 shrink-0 text-rose-400"}),o.jsx("span",{children:k})]}),!g&&!y&&o.jsxs("div",{className:"rounded-lg border border-slate-800/80 bg-slate-900/30 px-4 py-8 text-center",children:[o.jsxs("p",{className:"text-xs text-slate-300",children:["Search ",Se.label," above or choose an example chip to fetch verified records."]}),o.jsx("p",{className:"mt-1 text-[0.8125rem] text-slate-500",children:"Rate-limited or offline requests automatically fall back to the pinned local fixture cache with explicit provenance badges."})]}),!g&&y&&y.records.length===0&&o.jsxs("div",{className:"rounded-lg border border-slate-800/80 bg-slate-900/30 px-4 py-8 text-center text-xs text-slate-400",children:["No records returned from ",$x[c]," for “",f,"”."]}),y&&y.records.map(Q=>{const F=q[Q.id],he=T===`${Q.source}:${Q.id}:reference`,W=T===`${Q.source}:${Q.id}:mobile`,me=T===`af-lookup:${Q.id}`;return o.jsxs("div",{className:"rounded-lg border border-slate-800 bg-[#0e1522]/90 p-3 transition-colors hover:border-slate-700",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"rounded border border-cyan-500/40 bg-cyan-500/10 px-1.5 py-0.5 font-mono text-[0.8125rem] font-semibold text-cyan-300",children:Q.id}),o.jsx(Ex,{origin:Q.origin}),o.jsx("span",{className:"rounded border border-slate-700 bg-slate-900 px-1.5 py-0.5 font-mono text-[0.75rem] text-slate-300",children:Q.license}),Q.uniprotAccession&&Q.source!=="uniprot"&&o.jsxs("span",{className:"font-mono text-[0.75rem] text-slate-400",children:["UniProt ",Q.uniprotAccession]})]}),o.jsx("h3",{className:"mt-1.5 text-xs font-medium text-slate-100",children:Q.title}),Q.subtitle&&o.jsx("p",{className:"mt-0.5 text-[0.8125rem] text-slate-400",children:Q.subtitle}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[0.75rem] text-slate-400",children:[Q.organism&&o.jsxs("span",{children:["Organism: ",Q.organism]}),Q.length!==null&&Q.length!==void 0&&o.jsxs("span",{children:["Length: ",Q.length," aa"]}),Q.formula&&o.jsxs("span",{children:["Formula: ",Q.formula]}),Q.molecularWeight!==null&&Q.molecularWeight!==void 0&&o.jsxs("span",{children:["MW: ",Q.molecularWeight.toFixed(2)," g/mol"]}),o.jsxs("span",{children:["UTC: ",Q.retrievedAtUtc]}),o.jsxs("a",{href:Q.sourceUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-cyan-400 hover:text-cyan-300 hover:underline",children:[o.jsx("span",{className:"max-w-[260px] truncate",children:Q.sourceUrl}),o.jsx(Kd,{className:"h-2.5 w-2.5 shrink-0"})]})]}),Q.smiles&&o.jsxs("div",{className:"mt-1.5 truncate rounded border border-slate-800 bg-[#090d15] px-2 py-1 font-mono text-[0.75rem] text-slate-300",children:["SMILES: ",Q.smiles]})]}),o.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5",children:[(Q.source==="rcsb"||Q.source==="alphafold")&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",disabled:T!==null,onClick:()=>void G(Q,"reference"),className:"inline-flex items-center gap-1.5 rounded-md border border-cyan-500/40 bg-cyan-500/10 px-2.5 py-1.5 text-[0.8125rem] font-medium text-cyan-200 transition-colors hover:bg-cyan-500/20 disabled:opacity-50",children:[he&&o.jsx(qs,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{children:"Import as Reference"})]}),o.jsxs("button",{type:"button",disabled:T!==null,onClick:()=>void G(Q,"mobile"),className:"inline-flex items-center gap-1.5 rounded-md border border-slate-700 bg-slate-800/90 px-2.5 py-1.5 text-[0.8125rem] font-medium text-slate-200 transition-colors hover:border-cyan-500/40 hover:text-cyan-200 disabled:opacity-50",children:[W&&o.jsx(qs,{className:"h-3 w-3 animate-spin"}),o.jsx("span",{children:"Import as Mobile"})]})]}),Q.source==="uniprot"&&o.jsxs("button",{type:"button",disabled:T!==null,onClick:()=>void K(Q),className:"inline-flex items-center gap-1.5 rounded-md border border-cyan-500/40 bg-cyan-500/10 px-2.5 py-1.5 text-[0.8125rem] font-medium text-cyan-200 transition-colors hover:bg-cyan-500/20 disabled:opacity-50",children:[me?o.jsx(qs,{className:"h-3 w-3 animate-spin"}):o.jsx(ia,{className:"h-3 w-3"}),o.jsx("span",{children:"Fetch AlphaFold model"})]}),(Q.source==="pubchem"||Q.source==="chembl")&&o.jsxs("button",{type:"button",disabled:!Q.smiles||T!==null,onClick:()=>we(Q),title:Q.smiles?"Load SMILES into Chemistry Workbench":"SMILES unavailable in offline CID-only fallback",className:"inline-flex items-center gap-1.5 rounded-md border border-cyan-500/40 bg-cyan-500/10 px-2.5 py-1.5 text-[0.8125rem] font-medium text-cyan-200 transition-colors hover:bg-cyan-500/20 disabled:cursor-not-allowed disabled:opacity-40",children:[o.jsx(Br,{className:"h-3 w-3"}),o.jsx("span",{children:"Analyze SMILES"})]}),Q.source==="opentargets"&&o.jsxs("button",{type:"button",onClick:()=>{d("uniprot"),p(Q.title)},className:"inline-flex items-center gap-1.5 rounded-md border border-cyan-500/40 bg-cyan-500/10 px-2.5 py-1.5 text-[0.8125rem] font-medium text-cyan-200 transition-colors hover:bg-cyan-500/20",children:[o.jsx(Fs,{className:"h-3 w-3"}),o.jsx("span",{children:"Lookup UniProt"})]})]})]}),F&&F.length>0&&o.jsx("div",{className:"mt-2.5 space-y-2 border-t border-slate-800/80 pt-2.5",children:F.map(I=>o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-cyan-500/25 bg-cyan-500/5 px-2.5 py-2",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("span",{className:"font-mono text-[0.8125rem] font-semibold text-cyan-300",children:I.id}),o.jsx(Ex,{origin:I.origin}),I.dataRevision&&o.jsx("span",{className:"font-mono text-[0.75rem] text-slate-400",children:I.dataRevision})]}),o.jsx("p",{className:"mt-0.5 truncate text-[0.8125rem] text-slate-300",children:I.title})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.jsx("button",{type:"button",disabled:T!==null,onClick:()=>void G(I,"reference"),className:"rounded border border-cyan-500/40 bg-cyan-500/10 px-2 py-1 text-[0.8125rem] font-medium text-cyan-200 hover:bg-cyan-500/20 disabled:opacity-50",children:"Import as Reference"}),o.jsx("button",{type:"button",disabled:T!==null,onClick:()=>void G(I,"mobile"),className:"rounded border border-slate-700 bg-slate-800 px-2 py-1 text-[0.8125rem] font-medium text-slate-200 hover:border-cyan-500/40 hover:text-cyan-200 disabled:opacity-50",children:"Import as Mobile"})]})]},`${I.id}-${I.origin}`))})]},`${Q.source}-${Q.id}-${Q.origin}`)})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-slate-800 bg-[#090d15] px-4 py-2 text-[0.75rem] text-slate-400",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Ki,{className:"h-3.5 w-3.5 shrink-0 text-amber-400"}),o.jsxs("span",{children:[o.jsx("strong",{className:"text-amber-300",children:"RESEARCH USE ONLY (RUO):"})," External records carry verbatim source URLs, licenses, UTC timestamps, and SHA-256 digests. Not for clinical diagnosis or treatment."]})]}),o.jsx("button",{type:"button",onClick:r,className:"rounded border border-slate-700 bg-slate-900 px-2.5 py-1 text-[0.8125rem] text-slate-300 hover:border-slate-600 hover:text-slate-100",children:"Close"})]})]})})}const Qq={structure:o.jsx(_s,{className:"h-4 w-4 text-sky-300"}),compound:o.jsx(ia,{className:"h-4 w-4 text-violet-300"}),sequence:o.jsx(Fs,{className:"h-4 w-4 text-emerald-300"})};function Jq({activeStarterId:e,runHistory:r,projects:n=[],activeProject:s,onCreateProject:i,onSwitchProject:c,onDeleteProject:d,onOpenTutorial:f,onImportFile:p,onSearchDatabases:b,onOpenLibrary:x,onOpenAssistant:g,onOpenChemistry:_,onOpenPeptide:y,onOpenCrispr:S,onOpenWorkflows:k,onOpenComputeNodes:E,onOpenPlugins:T,onLaunchStarter:j,onOpenLibraryItem:q}){const[z,O]=C.useState([]),[V,P]=C.useState(!1),[$,H]=C.useState(""),[Z,G]=C.useState(""),[K,we]=C.useState("ligand-docking");C.useEffect(()=>{const F=()=>nu().then(he=>O(he.slice(0,6)));return F(),r0(()=>void F())},[]);const Se=()=>{i&&(i({name:$.trim()||`Project ${n.length+1}`,description:Z.trim()||void 0,template:K}),H(""),G(""),P(!1))},Q=[{label:"Import files",desc:"mmCIF, PDB, SMILES, FASTA, or project bundle",icon:o.jsx(Oc,{className:"h-5 w-5"}),run:p,kbd:"⌘O"},{label:"Public databases",desc:"RCSB PDB, AlphaFold DB, UniProt, PubChem",icon:o.jsx(Vi,{className:"h-5 w-5"}),run:b,kbd:"⌘⇧F"},{label:_?"Design & 2D Sketcher":"Open your library",desc:_?"Draw molecules, compute RDKit & PAINS checks":"Everything you have saved on this device",icon:_?o.jsx(ia,{className:"h-5 w-5"}):o.jsx(sh,{className:"h-5 w-5"}),run:_??x},{label:"AI Copilot (MCP)",desc:"Autonomous reasoning trace, project & UI control",icon:o.jsx(qr,{className:"h-5 w-5"}),run:g}];return o.jsx("div",{className:"@container h-full overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8 @3xl:px-8 @3xl:py-10",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-slate-100",children:"Welcome to Synlexa Studio"}),o.jsx("p",{className:"mt-1.5 max-w-2xl text-sm text-slate-400",children:"All-in-one computational biology & chemistry workbench: create multi-molecule projects, split chains, design inhibitors in RDKit, test docking/MD on Colab GPUs, and run peptide & CRISPR edits."})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f&&o.jsx(Oe,{size:"sm",variant:"secondary",icon:o.jsx(jy,{className:"h-4 w-4 text-emerald-400"}),onClick:f,children:"Interactive Tutorial"}),i&&o.jsx(Oe,{size:"sm",variant:"primary",icon:o.jsx(Qc,{className:"h-4 w-4"}),onClick:()=>P(F=>!F),children:"New Project"})]})]}),V&&i&&o.jsxs("div",{className:"mt-5 rounded-2xl border border-sky-400/35 bg-sky-500/[0.06] p-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-semibold text-slate-100",children:"Create New RUO Project"}),o.jsx("button",{type:"button",onClick:()=>P(!1),className:"text-xs text-slate-400 hover:text-white",children:"Cancel"})]}),o.jsxs("div",{className:"mt-3 grid gap-3 @lg:grid-cols-3",children:[o.jsx(Dn,{value:$,onChange:F=>H(F.target.value),placeholder:"Project name (e.g. CA-II Sulfonamide Series)"}),o.jsx(Dn,{value:Z,onChange:F=>G(F.target.value),placeholder:"Short research objective (optional)"}),o.jsxs(Na,{value:K,onChange:F=>we(F.target.value),children:[o.jsx("option",{value:"ligand-docking",children:"Ligand Design & Binding (Vina + RDKit)"}),o.jsx("option",{value:"structure-compare",children:"3D Structure Comparison & Splitting"}),o.jsx("option",{value:"peptide-crispr",children:"Peptide Mutation & CRISPR Editing"}),o.jsx("option",{value:"blank",children:"Blank Workspace"})]})]}),o.jsx("div",{className:"mt-3 flex justify-end gap-2",children:o.jsx(Oe,{size:"sm",variant:"primary",onClick:Se,children:"Create & Open Workspace"})})]}),n.length>0&&s&&c&&o.jsxs("section",{className:"mt-6 rounded-2xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold tracking-wide text-slate-300 uppercase",children:[o.jsx(My,{className:"h-4 w-4 text-sky-300"}),"Your Projects (",n.length,")"]}),o.jsxs("span",{className:"text-xs text-slate-400",children:["Active: ",o.jsx("strong",{className:"text-slate-100",children:s.name})]})]}),o.jsx("div",{className:"mt-3 grid gap-2.5 @lg:grid-cols-3",children:n.map(F=>{const he=F.id===s.id,W=`${F.structures.length} struct · ${F.molecules.length} mol · ${F.peptides.length+F.crisprs.length} edits`;return o.jsxs("div",{className:Ie("flex items-start justify-between gap-2 rounded-xl border p-3 transition-colors",he?"border-sky-400/50 bg-sky-500/[0.08]":"border-white/[0.07] bg-black/20 hover:border-white/20"),children:[o.jsxs("button",{type:"button",onClick:()=>c(F.id),className:"min-w-0 flex-1 text-left",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"truncate text-sm font-medium text-slate-100",children:F.name}),he&&o.jsx(It,{tone:"accent",children:"Active"})]}),o.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs text-slate-400",children:F.description}),o.jsx("div",{className:"mt-1.5 text-[0.6875rem] text-slate-500",children:W})]}),n.length>1&&d&&o.jsx("button",{type:"button",onClick:()=>d(F.id),title:"Delete project",className:"rounded p-1 text-slate-500 hover:bg-white/[0.06] hover:text-rose-400",children:o.jsx(Wi,{className:"h-3.5 w-3.5"})})]},F.id)})})]}),o.jsx("div",{className:"mt-6 grid gap-3 @lg:grid-cols-2 @4xl:grid-cols-4",children:Q.map(F=>o.jsxs("button",{type:"button",onClick:F.run,className:"group flex flex-col items-start rounded-2xl border border-white/[0.08] bg-white/[0.02] p-4 text-left transition-colors hover:border-sky-400/40 hover:bg-sky-400/[0.04]",children:[o.jsxs("div",{className:"flex w-full items-center justify-between",children:[o.jsx("span",{className:"flex h-9 w-9 items-center justify-center rounded-xl bg-white/[0.05] text-slate-300 group-hover:text-sky-300",children:F.icon}),F.kbd&&o.jsx(Rr,{children:F.kbd})]}),o.jsx("div",{className:"mt-3 text-sm font-medium text-slate-100",children:F.label}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-400",children:F.desc})]},F.label))}),(y||S||k||E||T)&&o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[y&&o.jsxs("button",{type:"button",onClick:y,className:"flex items-center gap-2 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-xs text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(ar,{className:"h-3.5 w-3.5 text-amber-400"}),"Peptide Mutations"]}),S&&o.jsxs("button",{type:"button",onClick:S,className:"flex items-center gap-2 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-xs text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(Fs,{className:"h-3.5 w-3.5 text-emerald-400"}),"CRISPR & Base Editing"]}),k&&o.jsxs("button",{type:"button",onClick:k,className:"flex items-center gap-2 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-xs text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(Dp,{className:"h-3.5 w-3.5 text-sky-400"}),"Workflow Canvas (Nextflow / Snakemake)"]}),E&&o.jsxs("button",{type:"button",onClick:E,className:"flex items-center gap-2 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-xs text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(al,{className:"h-3.5 w-3.5 text-emerald-400"}),"Connect Colab / External GPU"]}),T&&o.jsxs("button",{type:"button",onClick:T,className:"flex items-center gap-2 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2 text-xs text-slate-300 hover:border-sky-400/40 hover:text-sky-200",children:[o.jsx(Lp,{className:"h-3.5 w-3.5 text-violet-400"}),"Plugins & Add-ons"]})]}),o.jsxs("div",{className:"mt-10 grid gap-8 @4xl:grid-cols-[1fr_20rem]",children:[o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-slate-200",children:[o.jsx(Br,{className:"h-4 w-4 text-slate-500"})," Example projects"]}),o.jsx("div",{className:"grid gap-3 @lg:grid-cols-2",children:dE.map(F=>o.jsxs("button",{type:"button",onClick:()=>j(F),className:Ie("group rounded-2xl border p-4 text-left transition-colors",e===F.id?"border-sky-400/50 bg-sky-400/[0.05]":"border-white/[0.08] bg-white/[0.02] hover:border-white/20"),children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("div",{className:"text-sm font-medium text-slate-100",children:F.title}),o.jsx(DA,{className:"mt-0.5 h-4 w-4 shrink-0 text-slate-600 transition group-hover:translate-x-0.5 group-hover:text-sky-300"})]}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-400",children:F.subtitle}),o.jsx("p",{className:"mt-2 line-clamp-2 text-xs leading-relaxed text-slate-500",children:F.blurb}),o.jsx("div",{className:"mt-3 flex flex-wrap gap-1",children:F.tags.slice(0,3).map(he=>o.jsx("span",{className:"rounded-md bg-white/[0.05] px-1.5 py-0.5 text-[0.6875rem] text-slate-400",children:he},he))})]},F.id))})]}),o.jsxs("aside",{className:"space-y-8",children:[o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[o.jsxs("span",{className:"flex items-center gap-2 text-sm font-semibold text-slate-200",children:[o.jsx(sh,{className:"h-4 w-4 text-slate-500"})," Recent in library"]}),o.jsx("button",{type:"button",onClick:x,className:"text-xs text-sky-300 hover:text-sky-200",children:"View all"})]}),z.length===0?o.jsx("p",{className:"text-xs leading-relaxed text-slate-500",children:"Imported structures and compounds will appear here."}):o.jsx("ul",{className:"space-y-0.5",children:z.map(F=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>q(F),className:"flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 text-left hover:bg-white/[0.04]",children:[Qq[F.kind],o.jsx("span",{className:"truncate text-sm text-slate-300",children:F.name})]})},F.id))})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-slate-200",children:[o.jsx(HA,{className:"h-4 w-4 text-slate-500"})," Recent comparisons"]}),r.length===0?o.jsx("p",{className:"text-xs text-slate-500",children:"No comparisons yet."}):o.jsx("ul",{className:"space-y-2",children:r.slice(0,5).map(F=>o.jsxs("li",{className:"rounded-lg px-2 py-1 text-xs",children:[o.jsxs("div",{className:"truncate text-slate-300",children:[F.refLabel," ",o.jsx("span",{className:"text-slate-600",children:"vs"})," ",F.mobLabel]}),o.jsxs("div",{className:"mt-0.5 text-slate-500 tabular-nums",children:["RMSD ",F.rmsdAngstrom.toFixed(3)," Å · ",F.matchedCaCount," Cα ·"," ",new Date(F.createdAtUtc).toLocaleDateString()]})]},F.id))})]})]})]}),o.jsx("p",{className:"mt-12 border-t border-white/[0.06] pt-4 text-xs text-slate-500",children:Cn})]})})}const SA={structure:{label:"Structure",icon:o.jsx(_s,{className:"h-4 w-4"}),tone:"text-sky-300"},compound:{label:"Compound",icon:o.jsx(ia,{className:"h-4 w-4"}),tone:"text-violet-300"},sequence:{label:"Sequence",icon:o.jsx(Fs,{className:"h-4 w-4"}),tone:"text-emerald-300"}};function kA(e,r,n){const s=URL.createObjectURL(new Blob([r],{type:n})),i=document.createElement("a");i.href=s,i.download=e,i.click(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}function Zq(e){if(!e)return"—";const r=Date.now()-Date.parse(e);return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:new Date(e).toLocaleDateString()}function CA({compact:e=!1,onOpenItem:r,loadedShas:n}){const{toast:s,confirm:i}=cl(),[c,d]=C.useState([]),[f,p]=C.useState(!0),[b,x]=C.useState(""),[g,_]=C.useState("all"),[y,S]=C.useState(new Set),[k,E]=C.useState(null),[T,j]=C.useState(!1),q=C.useRef(null),z=C.useRef(null);C.useEffect(()=>{const G=()=>nu().then(d).finally(()=>p(!1));return G(),r0(()=>void G())},[]);const O=C.useMemo(()=>{const G=b.trim().toLowerCase();return c.filter(K=>g==="favorites"&&!K.favorite||g!=="all"&&g!=="favorites"&&K.kind!==g?!1:G?K.name.toLowerCase().includes(G)||K.tags.some(we=>we.toLowerCase().includes(G))||K.notes.toLowerCase().includes(G)||(K.source.accession??"").toLowerCase().includes(G)||K.kind==="compound"&&K.content.toLowerCase().includes(G):!0)},[c,b,g]),V=async G=>{let K=0,we=0;for(const Se of Array.from(G)){const Q=WD(Se.name);if(!Q){s(`${Se.name}: unsupported file type. Use .cif, .pdb, .smi, or .fasta.`,"warn");continue}let F=await Se.text(),he=Se.name.replace(/\.[^.]+$/,"");if(Q.kind==="compound"){const me=F.split(/\r?\n/).find(ge=>ge.trim())??"",[I,...J]=me.trim().split(/\s+/);F=I??"",J.length&&(he=J.join(" "))}if(!F.trim())continue;const{duplicate:W}=await t1({kind:Q.kind,format:Q.format,name:he,content:F,source:{database:null,accession:null,sourceUrl:null,license:null,retrievedAtUtc:null,origin:"local-file"}});W?we++:K++}K&&s(`Added ${K} item${K>1?"s":""} to your library`,"success"),we&&s(`${we} already in library (identical content)`,"info")},P=async G=>{G.length!==0&&(Xv().confirmDeletes&&!await i({title:G.length>1?`Delete ${G.length} items?`:"Delete item?",message:"This removes the stored copy from this device. Structures already loaded on screen stay open. This cannot be undone.",confirmLabel:"Delete",danger:!0})||(await VD(G),S(new Set),s(`Deleted ${G.length} item${G.length>1?"s":""}`,"success")))},$=async G=>{const K=await lE(Cn,G);kA(`synlexa-library-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(K,null,2),"application/json")},H=G=>o.jsx(i1,{trigger:(K,we)=>o.jsx(sl,{label:"More actions",onClick:Se=>(Se.stopPropagation(),we()),children:o.jsx(HR,{className:"h-4 w-4"})}),items:[...G.kind==="structure"?[{label:"Load as Reference",icon:o.jsx(Eb,{className:"h-4 w-4"}),onSelect:()=>r(G,"reference")},{label:"Load as Comparison (mobile)",icon:o.jsx(Eb,{className:"h-4 w-4"}),onSelect:()=>r(G,"mobile")}]:[{label:"Open in workspace",icon:o.jsx(Eb,{className:"h-4 w-4"}),onSelect:()=>r(G,"auto")}],"divider",{label:"Edit details",icon:o.jsx(Ox,{className:"h-4 w-4"}),onSelect:()=>E(G)},{label:G.favorite?"Remove from favorites":"Add to favorites",icon:o.jsx(Mb,{className:"h-4 w-4"}),onSelect:()=>void n1(G.id,{favorite:!G.favorite})},{label:"Duplicate",icon:o.jsx(Lr,{className:"h-4 w-4"}),onSelect:()=>void FD(G.id)},{label:"Download file",icon:o.jsx(sr,{className:"h-4 w-4"}),onSelect:()=>kA(`${G.name}.${G.format==="smiles"?"smi":G.format}`,G.kind==="compound"?`${G.content} ${G.name}
768
+ `:G.content,"text/plain")},"divider",{label:"Delete",icon:o.jsx(Wi,{className:"h-4 w-4"}),danger:!0,onSelect:()=>void P([G.id])}]}),Z=[{id:"all",label:"All"},{id:"structure",label:"Structures"},{id:"compound",label:"Compounds"},{id:"sequence",label:"Sequences"},{id:"favorites",label:"★"}];return o.jsxs("div",{className:Ie("@container relative flex h-full min-h-0 flex-col",!e&&"bg-[#0f131b]"),onDragOver:G=>{G.dataTransfer.types.includes("Files")&&(G.preventDefault(),j(!0))},onDragLeave:G=>{G.currentTarget===G.target&&j(!1)},onDrop:G=>{G.dataTransfer.files.length&&(G.preventDefault(),j(!1),V(G.dataTransfer.files))},children:[o.jsx("input",{ref:q,type:"file",multiple:!0,accept:".cif,.mmcif,.pdb,.ent,.smi,.fasta,.fa,.faa",className:"hidden",onChange:G=>{G.target.files&&V(G.target.files),G.target.value=""}}),o.jsx("input",{ref:z,type:"file",accept:".json",className:"hidden",onChange:async G=>{const K=G.target.files?.[0];if(G.target.value="",!!K)try{const we=await YD(await K.text());s(`Imported ${we} new item${we===1?"":"s"}`,"success")}catch(we){s(we instanceof Error?we.message:String(we),"error")}}}),o.jsxs("div",{className:Ie("shrink-0 space-y-2.5",e?"px-3 pt-1 pb-2.5":"border-b border-white/[0.06] px-6 pt-5 pb-4"),children:[!e&&o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-lg font-semibold text-slate-100",children:"Library"}),o.jsxs("p",{className:"mt-0.5 text-sm text-slate-400",children:[c.length," item",c.length===1?"":"s"," stored on this device ·"," ",Uc(c.reduce((G,K)=>G+K.sizeBytes,0))]})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(rz,{className:"h-3.5 w-3.5"}),onClick:()=>z.current?.click(),children:"Import library"}),o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(sr,{className:"h-3.5 w-3.5"}),onClick:()=>void $(),disabled:!c.length,children:"Export all"}),o.jsx(Oe,{size:"sm",variant:"primary",icon:o.jsx(Oc,{className:"h-3.5 w-3.5"}),onClick:()=>q.current?.click(),children:"Add files"})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative flex-1",children:[o.jsx(Gr,{className:"pointer-events-none absolute top-1/2 left-2.5 h-3.5 w-3.5 -translate-y-1/2 text-slate-500"}),o.jsx(Dn,{value:b,onChange:G=>x(G.target.value),placeholder:"Search name, tag, accession…",className:Ie("pl-8",e&&"h-8 text-[0.8125rem]")})]}),e&&o.jsx(sl,{label:"Add files to library",onClick:()=>q.current?.click(),className:"h-8 w-8",children:o.jsx(Oc,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:Z.map(G=>o.jsx("button",{type:"button",onClick:()=>_(G.id),className:Ie("rounded-md px-2 py-1 text-xs transition-colors",g===G.id?"bg-white/[0.1] text-slate-100":"text-slate-400 hover:bg-white/[0.05] hover:text-slate-200"),children:G.label},G.id))}),!e&&y.size>0&&o.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-sky-500/20 bg-sky-500/[0.06] px-3 py-2 text-sm",children:[o.jsxs("span",{className:"text-sky-200",children:[y.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>void $(Array.from(y)),children:"Export"}),o.jsx(Oe,{size:"sm",variant:"danger",onClick:()=>void P(Array.from(y)),children:"Delete"}),o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>S(new Set),children:"Clear"})]})]}),o.jsx("div",{className:Ie("min-h-0 flex-1 overflow-y-auto",e?"px-1.5 pb-3":"px-4 py-3"),children:f?null:O.length===0?o.jsx(mE,{icon:o.jsx(_s,{className:"h-7 w-7"}),title:c.length===0?"Your library is empty":"No matches",description:c.length===0?"Drop .cif, .pdb, .smi, or .fasta files here, or import from a public database. With auto-save on, every import is saved here.":"Try a different search or filter.",action:c.length===0?o.jsx(Oe,{size:"sm",icon:o.jsx(Oc,{className:"h-3.5 w-3.5"}),onClick:()=>q.current?.click(),children:"Add files"}):void 0}):e?o.jsx("ul",{className:"space-y-0.5",children:O.map(G=>{const K=SA[G.kind],we=n?.has(G.sha256);return o.jsxs("li",{className:"group flex items-center gap-2.5 rounded-lg px-2 py-2 hover:bg-white/[0.04]",onDoubleClick:()=>r(G,"auto"),title:"Double-click to open",children:[o.jsx("span",{className:Ie("shrink-0",K.tone),children:K.icon}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"truncate text-[0.8125rem] text-slate-200",children:G.name}),G.favorite&&o.jsx(Mb,{className:"h-3 w-3 shrink-0 fill-amber-300 text-amber-300"})]}),o.jsxs("div",{className:"truncate text-[0.6875rem] text-slate-500",children:[we?o.jsx("span",{className:"text-emerald-400",children:"On screen"}):K.label," · ",Uc(G.sizeBytes)]})]}),o.jsxs("div",{className:"flex shrink-0 items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[G.kind==="structure"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>r(G,"reference"),className:"rounded px-1.5 py-1 text-[0.6875rem] font-semibold text-sky-300 hover:bg-sky-500/15",title:"Load as Reference",children:"REF"}),o.jsx("button",{type:"button",onClick:()=>r(G,"mobile"),className:"rounded px-1.5 py-1 text-[0.6875rem] font-semibold text-emerald-300 hover:bg-emerald-500/15",title:"Load as Comparison",children:"CMP"})]}):o.jsx("button",{type:"button",onClick:()=>r(G,"auto"),className:"rounded px-1.5 py-1 text-[0.6875rem] font-semibold text-sky-300 hover:bg-sky-500/15",children:"Open"}),H(G)]})]},G.id)})}):o.jsxs("table",{className:"w-full table-fixed text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"text-left text-xs text-slate-500",children:[o.jsx("th",{className:"w-9 pb-2 pl-2",children:o.jsx("input",{type:"checkbox","aria-label":"Select all",className:"accent-sky-500",checked:y.size>0&&y.size===O.length,onChange:G=>S(G.target.checked?new Set(O.map(K=>K.id)):new Set)})}),o.jsx("th",{className:"pb-2 font-medium",children:"Name"}),o.jsx("th",{className:"hidden w-24 pb-2 font-medium @lg:table-cell",children:"Type"}),o.jsx("th",{className:"hidden w-40 pb-2 font-medium @3xl:table-cell",children:"Source"}),o.jsx("th",{className:"hidden w-20 pb-2 font-medium @xl:table-cell",children:"Size"}),o.jsx("th",{className:"hidden w-24 pb-2 font-medium @2xl:table-cell",children:"Updated"}),o.jsx("th",{className:"w-40 pb-2 @xl:w-52"})]})}),o.jsx("tbody",{children:O.map(G=>{const K=SA[G.kind],we=n?.has(G.sha256);return o.jsxs("tr",{className:Ie("group border-t border-white/[0.05] align-middle",y.has(G.id)?"bg-sky-500/[0.05]":"hover:bg-white/[0.02]"),onDoubleClick:()=>r(G,"auto"),children:[o.jsx("td",{className:"py-2.5 pl-2",children:o.jsx("input",{type:"checkbox","aria-label":`Select ${G.name}`,className:"accent-sky-500",checked:y.has(G.id),onChange:Se=>{const Q=new Set(y);Se.target.checked?Q.add(G.id):Q.delete(G.id),S(Q)}})}),o.jsx("td",{className:"py-2.5 pr-3",children:o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("span",{className:Ie("shrink-0",K.tone),children:K.icon}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"truncate font-medium text-slate-100",children:G.name}),G.favorite&&o.jsx(Mb,{className:"h-3.5 w-3.5 shrink-0 fill-amber-300 text-amber-300"}),we&&o.jsx(It,{tone:"good",children:"On screen"})]}),(G.tags.length>0||G.notes)&&o.jsxs("div",{className:"mt-0.5 flex items-center gap-1 truncate text-xs text-slate-500",children:[G.tags.slice(0,4).map(Se=>o.jsx("span",{className:"rounded bg-white/[0.05] px-1.5 py-px text-slate-400",children:Se},Se)),G.notes&&o.jsx("span",{className:"truncate",children:G.notes})]})]})]})}),o.jsxs("td",{className:"hidden py-2.5 text-slate-400 @lg:table-cell",children:[K.label,o.jsx("span",{className:"ml-1 font-mono text-xs text-slate-500 uppercase",children:G.format})]}),o.jsxs("td",{className:"hidden truncate py-2.5 pr-3 text-xs text-slate-400 @3xl:table-cell",children:[G.source.database??(G.source.origin==="local-file"?"Local file":G.source.origin==="manual"?"Edited":"—"),G.source.accession&&o.jsx("span",{className:"ml-1 font-mono text-slate-300",children:G.source.accession})]}),o.jsx("td",{className:"hidden py-2.5 text-xs text-slate-400 tabular-nums @xl:table-cell",children:Uc(G.sizeBytes)}),o.jsx("td",{className:"hidden py-2.5 text-xs text-slate-400 @2xl:table-cell",children:Zq(G.updatedAtUtc)}),o.jsx("td",{className:"py-2.5 pr-1",children:o.jsxs("div",{className:"flex items-center justify-end gap-1",children:[G.kind==="structure"?o.jsxs(o.Fragment,{children:[o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>r(G,"reference"),children:"Reference"}),o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>r(G,"mobile"),children:"Compare"})]}):o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>r(G,"auto"),children:"Open"}),H(G)]})})]},G.id)})})]})}),T&&o.jsx("div",{className:"pointer-events-none absolute inset-2 flex items-center justify-center rounded-xl border-2 border-dashed border-sky-400/60 bg-sky-400/10 text-sm font-medium text-sky-200",children:"Drop to add to library"}),o.jsx(eL,{item:k,onClose:()=>E(null)})]})}function eL({item:e,onClose:r}){const{toast:n}=cl(),[s,i]=C.useState(""),[c,d]=C.useState(""),[f,p]=C.useState(""),[b,x]=C.useState("");if(C.useEffect(()=>{e&&(i(e.name),d(e.tags.join(", ")),p(e.notes),x(e.content))},[e]),!e)return null;const g=e.kind!=="structure",_=async()=>{const y=s.trim();if(!y){n("Name is required","warn");return}await n1(e.id,{name:y,tags:c.split(",").map(S=>S.trim()).filter(Boolean),notes:f,...g?{content:b.trim()}:{}}),n("Saved","success"),r()};return o.jsx(fE,{open:!0,onClose:r,title:"Edit library item",footer:o.jsxs(o.Fragment,{children:[o.jsx(Oe,{variant:"ghost",onClick:r,children:"Cancel"}),o.jsx(Oe,{variant:"primary",onClick:()=>void _(),children:"Save changes"})]}),children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("label",{className:"block space-y-1.5",children:[o.jsx("span",{className:"text-xs font-medium text-slate-400",children:"Name"}),o.jsx(Dn,{value:s,onChange:y=>i(y.target.value),autoFocus:!0})]}),o.jsxs("label",{className:"block space-y-1.5",children:[o.jsx("span",{className:"text-xs font-medium text-slate-400",children:"Tags (comma separated)"}),o.jsx(Dn,{value:c,onChange:y=>d(y.target.value),placeholder:"e.g. kinase, project-a"})]}),o.jsxs("label",{className:"block space-y-1.5",children:[o.jsx("span",{className:"text-xs font-medium text-slate-400",children:"Notes"}),o.jsx(Pp,{rows:3,value:f,onChange:y=>p(y.target.value)})]}),g?o.jsxs("label",{className:"block space-y-1.5",children:[o.jsx("span",{className:"text-xs font-medium text-slate-400",children:e.kind==="compound"?"SMILES":"Sequence"}),o.jsx(Pp,{rows:4,value:b,onChange:y=>x(y.target.value),className:"font-mono text-xs"}),b.trim()!==e.content&&o.jsx("span",{className:"text-xs text-amber-300",children:"Editing content changes its SHA-256 and marks the item as manually edited."})]}):null,o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/20 p-3 text-xs text-slate-400",children:[o.jsx("div",{className:"mb-1 font-medium text-slate-300",children:"Provenance"}),o.jsxs("dl",{className:"grid grid-cols-[7rem_1fr] gap-x-2 gap-y-1",children:[o.jsx("dt",{children:"Origin"}),o.jsx("dd",{className:"text-slate-300",children:e.source.origin??"unknown"}),o.jsx("dt",{children:"Source"}),o.jsx("dd",{className:"truncate text-slate-300",children:e.source.sourceUrl?o.jsx("a",{href:e.source.sourceUrl,target:"_blank",rel:"noreferrer",className:"text-sky-300 hover:underline",children:e.source.sourceUrl}):"unknown"}),o.jsx("dt",{children:"License"}),o.jsx("dd",{className:"text-slate-300",children:e.source.license??"unknown"}),o.jsx("dt",{children:"Retrieved (UTC)"}),o.jsx("dd",{className:"text-slate-300",children:e.source.retrievedAtUtc??"unknown"}),o.jsx("dt",{children:"SHA-256"}),o.jsx("dd",{className:"truncate font-mono text-slate-300",children:e.sha256})]})]})]})})}const NA=[{id:"claude-desktop",label:"Claude Desktop",desc:"claude_desktop_config.json (stdio)"},{id:"claude-code",label:"Claude Code CLI",desc:"One-line terminal setup"},{id:"codex",label:"OpenAI Codex CLI",desc:"Codex CLI & config.toml"},{id:"http-local",label:"Cursor / HTTP Bridge",desc:"http://127.0.0.1:4179/mcp"}];function tL({runtime:e,onOpenAiAssistant:r,onOpenVaultSettings:n}){const[s,i]=C.useState(()=>uA()),[c,d]=C.useState(()=>Zo()),[f,p]=C.useState("claude-desktop"),[b,x]=C.useState(null),[g,_]=C.useState(Lc[0].name),[y,S]=C.useState(`{
769
+ "section": "all",
770
+ "topN": 6
771
+ }`),[k,E]=C.useState(Bd[0].uri),[T,j]=C.useState(""),[q,z]=C.useState(!1);C.useEffect(()=>{const K=PD(()=>i(uA())),we=f3(()=>d(Zo()));return()=>{K(),we()}},[]);const O=DD(4179),V=(K,we)=>{navigator.clipboard?.writeText(we),x(K),setTimeout(()=>x(null),1600)},P=K=>{_(K),S(K==="get_workspace_state"?`{
772
+ "section": "all",
773
+ "topN": 6
774
+ }`:K==="search_scientific_web"?`{
775
+ "query": "carbonic anhydrase II acetazolamide 3HS4",
776
+ "scope": "all",
777
+ "limit": 4
778
+ }`:K==="focus_3d_residues"?`{
779
+ "seqIds": [94, 96, 119]
780
+ }`:K==="inspect_chemical_smiles"?`{
781
+ "name": "Acetazolamide",
782
+ "smiles": "CC(=O)Nc1nnc(S(N)(=O)=O)s1"
783
+ }`:K==="engineer_peptide_mutation"?`{
784
+ "mutations": ["H94A"],
785
+ "focusSeqId": 94
786
+ }`:K==="design_crispr_edit"?`{
787
+ "transcriptId": "NM_000067.3",
788
+ "targetCodonIndex": 94,
789
+ "nuclease": "SpCas9"
790
+ }`:K==="fetch_from_database"?`{
791
+ "source": "rcsb",
792
+ "query": "1UBQ",
793
+ "autoImport": false
794
+ }`:"{}")},$=async()=>{z(!0);try{const K=JSON.parse(y||"{}"),we=await hA({jsonrpc:"2.0",id:Date.now(),method:"tools/call",params:{name:g,arguments:K}},e,"mcp-playground");j(JSON.stringify(we,null,2))}catch(K){j(JSON.stringify({ok:!1,error:K instanceof Error?K.message:String(K)},null,2))}finally{z(!1)}},H=async()=>{z(!0);try{const K=await hA({jsonrpc:"2.0",id:Date.now(),method:"resources/read",params:{uri:k}},e,"mcp-playground");j(JSON.stringify(K,null,2))}finally{z(!1)}},Z=f==="claude-desktop"?O.claudeDesktopJson:f==="claude-code"?O.claudeCodeCmd:f==="codex"?`${O.codexCliCmd}
795
+
796
+ # Or add to ~/.codex/config.toml:
797
+ ${O.codexConfigToml}`:O.httpEndpointJson,G=by();return o.jsx("div",{className:"@container h-full overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-5xl space-y-5 px-5 py-6",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium tracking-wide text-sky-400 uppercase",children:[o.jsx(rl,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"In-App & External MCP Server"})]}),o.jsxs("h1",{className:"mt-1 text-xl font-semibold text-slate-100",children:[py.name," ",o.jsxs("span",{className:"font-mono text-sm font-normal text-slate-400",children:["v",py.version]})]}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm text-slate-400",children:"Model Context Protocol (JSON-RPC 2.0) server exposing all deterministic Wasm/Rust kernels, live workspace resources, and scientific web search to both Studio's internal AI Assistant and external agents (Claude, OpenAI Codex, Cursor)."})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs(Oe,{size:"sm",variant:"secondary",icon:o.jsx(w6,{className:"h-3.5 w-3.5"}),onClick:n,children:["BYOK Vault (",c.storedProviders.length,")"]}),o.jsx(Oe,{size:"sm",variant:"primary",icon:o.jsx(qr,{className:"h-3.5 w-3.5"}),onClick:r,children:"Open AI Assistant"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3 @2xl:grid-cols-4",children:[o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsx("div",{className:"text-xs text-slate-400",children:"MCP Tools"}),o.jsx("div",{className:"mt-1 text-2xl font-semibold text-sky-300 tabular-nums",children:G.length}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-500",children:"Shared by AI & external clients"})]}),o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsx("div",{className:"text-xs text-slate-400",children:"Live Resources"}),o.jsx("div",{className:"mt-1 text-2xl font-semibold text-slate-100 tabular-nums",children:Bd.length}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-500",children:"synlexa:// URIs"})]}),o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsx("div",{className:"text-xs text-slate-400",children:"Local Key Vault"}),o.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-sm font-semibold text-emerald-300",children:[o.jsx(Ki,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{children:"state.vscdb"})]}),o.jsx("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:c.cipher})]}),o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsx("div",{className:"text-xs text-slate-400",children:"Recent MCP Calls"}),o.jsx("div",{className:"mt-1 text-2xl font-semibold text-slate-100 tabular-nums",children:s.length}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-500",children:"JSON-RPC 2.0 trace"})]})]}),o.jsxs(yt,{title:"Connect Claude, OpenAI Codex, or Cursor",description:"Attach any MCP-compatible coding or research agent to Studio's deterministic engines via stdio (`synlexa-studio mcp --stdio`) or local HTTP (`http://127.0.0.1:4179/mcp`).",children:[o.jsx("div",{className:"flex flex-wrap gap-1.5 pb-3",children:NA.map(K=>o.jsxs("button",{type:"button",onClick:()=>p(K.id),className:Ie("rounded-lg border px-3 py-1.5 text-left text-xs transition-colors",f===K.id?"border-sky-400/60 bg-sky-500/10 text-sky-200":"border-white/10 bg-white/[0.02] text-slate-400 hover:border-white/20 hover:text-slate-200"),children:[o.jsx("div",{className:"font-semibold",children:K.label}),o.jsx("div",{className:"text-[0.6875rem] text-slate-500",children:K.desc})]},K.id))}),o.jsxs("div",{className:"relative rounded-xl border border-white/10 bg-black/40 p-3.5",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-slate-400",children:[o.jsxs("span",{className:"flex items-center gap-1.5 font-mono",children:[o.jsx(WA,{className:"h-3.5 w-3.5 text-sky-400"}),NA.find(K=>K.id===f)?.desc]}),o.jsx(Oe,{size:"sm",variant:"secondary",icon:b===f?o.jsx(Fi,{className:"h-3.5 w-3.5 text-emerald-400"}):o.jsx(Lr,{className:"h-3.5 w-3.5"}),onClick:()=>V(f,Z),children:b===f?"Copied":"Copy"})]}),o.jsx("pre",{className:"overflow-x-auto font-mono text-xs leading-relaxed text-sky-100",children:Z})]})]}),o.jsxs("div",{className:"grid gap-5 @3xl:grid-cols-2",children:[o.jsx(yt,{title:"MCP Tool Runner (tools/call)",description:"Execute any in-app MCP tool directly against live workspace data.",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-400",children:"Tool name"}),o.jsx(Na,{value:g,onChange:K=>P(K.target.value),children:G.map(K=>o.jsx("option",{value:K.name,children:K.name},K.name))}),o.jsx("p",{className:"mt-1.5 text-xs text-slate-500",children:Lc.find(K=>K.name===g)?.description})]}),o.jsxs("div",{children:[o.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-400",children:"Arguments (JSON)"}),o.jsx(Pp,{rows:5,value:y,onChange:K=>S(K.target.value),className:"font-mono text-xs"})]}),o.jsx(Oe,{variant:"primary",size:"sm",disabled:q,icon:q?o.jsx(gp,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(qp,{className:"h-3.5 w-3.5"}),onClick:()=>void $(),children:"Execute MCP Tool"})]})}),o.jsx(yt,{title:"MCP Resource Inspector (resources/read)",description:"Inspect live structured resources including state.vscdb vault status.",children:o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"mb-1 block text-xs font-medium text-slate-400",children:"Resource URI"}),o.jsx(Na,{value:k,onChange:K=>E(K.target.value),children:Bd.map(K=>o.jsxs("option",{value:K.uri,children:[K.uri," — ",K.name]},K.uri))}),o.jsx("p",{className:"mt-1.5 text-xs text-slate-500",children:Bd.find(K=>K.uri===k)?.description})]}),o.jsxs("div",{className:"rounded-lg border border-white/[0.06] bg-black/25 p-3 text-xs text-slate-400",children:[o.jsxs("div",{className:"flex items-center gap-1.5 font-medium text-slate-200",children:[o.jsx(Vi,{className:"h-3.5 w-3.5 text-sky-400"}),o.jsxs("span",{children:["Vault: ",c.dbPath]})]}),o.jsxs("div",{className:"mt-1 text-slate-500",children:["Stored BYOK providers: ",c.storedProviders.length>0?c.storedProviders.join(", "):"none yet"]})]}),o.jsx(Oe,{variant:"secondary",size:"sm",disabled:q,icon:o.jsx(Vi,{className:"h-3.5 w-3.5"}),onClick:()=>void H(),children:"Read Resource"})]})})]}),T&&o.jsx(yt,{title:"JSON-RPC 2.0 Output",children:o.jsx("pre",{className:"max-h-72 overflow-auto rounded-lg bg-black/40 p-3 font-mono text-xs leading-relaxed text-slate-200",children:T})}),o.jsx(yt,{title:"Live MCP Activity Log",description:"Calls dispatched by Studio's internal AI Assistant or the MCP playground.",actions:o.jsx(Oe,{size:"sm",variant:"ghost",disabled:s.length===0,icon:o.jsx(Wi,{className:"h-3.5 w-3.5"}),onClick:OD,children:"Clear"}),children:s.length===0?o.jsx("div",{className:"text-xs text-slate-500",children:"No MCP calls recorded yet. Ask the AI Assistant a question or execute a tool above."}):o.jsx("div",{className:"space-y-1.5",children:s.slice(0,15).map(K=>o.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-white/[0.06] bg-black/20 px-3 py-2 text-xs",children:[K.ok?o.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0 text-emerald-400"}):o.jsx(Bc,{className:"h-3.5 w-3.5 shrink-0 text-rose-400"}),o.jsx(It,{tone:K.caller==="internal-ai-agent"?"accent":"neutral",children:K.caller}),o.jsxs("span",{className:"flex items-center gap-1 font-mono text-slate-200",children:[o.jsx(Py,{className:"h-3 w-3 text-slate-500"}),K.target]}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-slate-400",children:K.summary}),o.jsxs("span",{className:"font-mono text-slate-500 tabular-nums",children:[K.durationMs," ms"]})]},K.id))})}),o.jsx("p",{className:"text-xs text-slate-500",children:Cn})]})})}const nL=`#version 300 es
798
+ precision highp float;
799
+
800
+ layout(location = 0) in vec3 aPos;
801
+ layout(location = 1) in vec3 aNormal;
802
+ layout(location = 2) in vec3 aColor;
803
+
804
+ uniform mat4 uViewProj;
805
+ uniform mat4 uView;
806
+
807
+ out vec3 vNormalView;
808
+ out vec3 vPosView;
809
+ out vec3 vColor;
810
+
811
+ void main() {
812
+ vec4 viewPos = uView * vec4(aPos, 1.0);
813
+ vPosView = viewPos.xyz;
814
+ vNormalView = mat3(uView) * aNormal;
815
+ vColor = aColor;
816
+ gl_Position = uViewProj * vec4(aPos, 1.0);
817
+ }
818
+ `,sL=`#version 300 es
819
+ precision highp float;
820
+
821
+ in vec3 vNormalView;
822
+ in vec3 vPosView;
823
+ in vec3 vColor;
824
+
825
+ out vec4 outColor;
826
+
827
+ void main() {
828
+ vec3 N = normalize(vNormalView);
829
+ vec3 V = normalize(-vPosView);
830
+ vec3 L1 = normalize(vec3(0.45, 0.72, 0.85));
831
+ vec3 L2 = normalize(vec3(-0.65, -0.35, 0.40));
832
+
833
+ float diff1 = max(dot(N, L1), 0.0);
834
+ float diff2 = max(dot(N, L2), 0.0) * 0.35;
835
+ vec3 H = normalize(L1 + V);
836
+ float spec = pow(max(dot(N, H), 0.0), 42.0) * 0.38;
837
+ float rim = pow(1.0 - max(dot(N, V), 0.0), 2.4) * 0.16;
838
+
839
+ vec3 shaded = vColor * (0.24 + 0.78 * diff1 + diff2) + vec3(spec + rim);
840
+ // Subtle depth cue
841
+ float fog = clamp((-vPosView.z - 25.0) / 140.0, 0.0, 0.42);
842
+ vec3 bg = vec3(0.035, 0.051, 0.078);
843
+ outColor = vec4(mix(shaded, bg, fog), 1.0);
844
+ }
845
+ `;function Hd(e,r){return[e[0]-r[0],e[1]-r[1],e[2]-r[2]]}function Is(e,r){return[e[0]+r[0],e[1]+r[1],e[2]+r[2]]}function Sn(e,r){return[e[0]*r,e[1]*r,e[2]*r]}function zr(e,r){return[e[1]*r[2]-e[2]*r[1],e[2]*r[0]-e[0]*r[2],e[0]*r[1]-e[1]*r[0]]}function nr(e){const r=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);return r<1e-8?[0,1,0]:[e[0]/r,e[1]/r,e[2]/r]}function Fd(e,r){return Math.sqrt((e[0]-r[0])**2+(e[1]-r[1])**2+(e[2]-r[2])**2)}function aL(e){const r=Math.cos(e.pitch),n=Math.sin(e.pitch),s=Math.cos(e.yaw),i=Math.sin(e.yaw),c=[e.target[0]+e.distance*r*i,e.target[1]+e.distance*n,e.target[2]+e.distance*r*s],d=nr(Hd(e.target,c)),p=nr(zr(d,[0,1,0])),b=zr(p,d);return new Float32Array([p[0],b[0],-d[0],0,p[1],b[1],-d[1],0,p[2],b[2],-d[2],0,-(p[0]*c[0]+p[1]*c[1]+p[2]*c[2]),-(b[0]*c[0]+b[1]*c[1]+b[2]*c[2]),d[0]*c[0]+d[1]*c[1]+d[2]*c[2],1])}function AA(e,r,n,s){const i=1/Math.tan(e/2),c=1/(n-s);return new Float32Array([i/r,0,0,0,0,i,0,0,0,0,(s+n)*c,-1,0,0,2*s*n*c,0])}function jA(e,r){const n=new Float32Array(16);for(let s=0;s<4;s++)for(let i=0;i<4;i++)n[s*4+i]=e[0+i]*r[s*4+0]+e[4+i]*r[s*4+1]+e[8+i]*r[s*4+2]+e[12+i]*r[s*4+3];return n}function $n(e,r,n,s,i,c){const d=e[0]*r[0]+e[4]*r[1]+e[8]*r[2]+e[12],f=e[1]*r[0]+e[5]*r[1]+e[9]*r[2]+e[13],p=e[2]*r[0]+e[6]*r[1]+e[10]*r[2]+e[14],b=e[3]*r[0]+e[7]*r[1]+e[11]*r[2]+e[15];if(b<=.05)return{sx:-9999,sy:-9999,ndcZ:2,visible:!1};const x=d/b,g=f/b,_=p/b;return{sx:n+(x*.5+.5)*i,sy:s+(-g*.5+.5)*c,ndcZ:_,visible:_>=-1&&_<=1}}function rL(e,r,n,s,i){const c=i*i,d=c*i,f=[0,0,0];for(let p=0;p<3;p++)f[p]=.5*(2*r[p]+(-e[p]+n[p])*i+(2*e[p]-5*r[p]+4*n[p]-s[p])*c+(-e[p]+3*r[p]-3*n[p]+s[p])*d);return f}class iL{data=[];pushTri(r,n,s,i,c,d,f,p,b){this.data.push(r[0],r[1],r[2],n[0],n[1],n[2],s[0]/255,s[1]/255,s[2]/255,i[0],i[1],i[2],c[0],c[1],c[2],d[0]/255,d[1]/255,d[2]/255,f[0],f[1],f[2],p[0],p[1],p[2],b[0]/255,b[1]/255,b[2]/255)}addSphere(r,n,s,i=8,c=12){for(let d=0;d<i;d++){const f=d/i*Math.PI,p=(d+1)/i*Math.PI;for(let b=0;b<c;b++){const x=b/c*Math.PI*2,g=(b+1)/c*Math.PI*2,_=[Math.sin(f)*Math.cos(x),Math.cos(f),Math.sin(f)*Math.sin(x)],y=[Math.sin(p)*Math.cos(x),Math.cos(p),Math.sin(p)*Math.sin(x)],S=[Math.sin(p)*Math.cos(g),Math.cos(p),Math.sin(p)*Math.sin(g)],k=[Math.sin(f)*Math.cos(g),Math.cos(f),Math.sin(f)*Math.sin(g)],E=Is(r,Sn(_,n)),T=Is(r,Sn(y,n)),j=Is(r,Sn(S,n)),q=Is(r,Sn(k,n));d>0&&this.pushTri(E,_,s,q,k,s,j,S,s),d<i-1&&this.pushTri(E,_,s,j,S,s,T,y,s)}}}addCylinder(r,n,s,i,c,d=8){const f=Hd(n,r),p=Math.sqrt(f[0]**2+f[1]**2+f[2]**2);if(p<1e-4)return;const b=Sn(f,1/p),x=Math.abs(b[1])<.9?[0,1,0]:[1,0,0],g=nr(zr(b,x)),_=zr(b,g);for(let y=0;y<d;y++){const S=y/d*Math.PI*2,k=(y+1)/d*Math.PI*2,E=Is(Sn(g,Math.cos(S)),Sn(_,Math.sin(S))),T=Is(Sn(g,Math.cos(k)),Sn(_,Math.sin(k))),j=Is(r,Sn(E,s)),q=Is(r,Sn(T,s)),z=Is(n,Sn(E,s)),O=Is(n,Sn(T,s));this.pushTri(j,E,i,q,T,i,O,T,c),this.pushTri(j,E,i,O,T,c,z,E,c)}}addBackboneRibbon(r,n,s,i=4,c=8){if(r.length<2)return;const d=[];let f=[r[0]];for(let p=1;p<r.length;p++)Fd(r[p-1].xyz,r[p].xyz)>6.5?(f.length>=2&&d.push(f),f=[r[p]]):f.push(r[p]);f.length>=2&&d.push(f);for(const p of d){const b=[];for(let k=0;k<p.length-1;k++){const E=p[Math.max(0,k-1)].xyz,T=p[k].xyz,j=p[k+1].xyz,q=p[Math.min(p.length-1,k+2)].xyz,z=p[k].color,O=p[k+1].color,V=k===p.length-2?i+1:i;for(let P=0;P<V;P++){const $=P/i,H=rL(E,T,j,q,$),Z=[z[0]+(O[0]-z[0])*$,z[1]+(O[1]-z[1])*$,z[2]+(O[2]-z[2])*$];b.push({pos:H,col:Z})}}let x=nr(Hd(b[1].pos,b[0].pos));const g=Math.abs(x[1])<.9?[0,1,0]:[1,0,0];let _=nr(zr(x,g)),y=zr(x,_);const S=[];for(let k=0;k<b.length;k++){const E=k===b.length-1?nr(Hd(b[k].pos,b[k-1].pos)):k===0?x:nr(Hd(b[k+1].pos,b[k-1].pos)),T=zr(x,E),j=Math.sqrt(T[0]**2+T[1]**2+T[2]**2);if(j>1e-5){const O=Math.max(-1,Math.min(1,x[0]*E[0]+x[1]*E[1]+x[2]*E[2])),V=Math.acos(O),P=Sn(T,1/j),$=Math.cos(V),H=Math.sin(V),Z=P[0]*_[0]+P[1]*_[1]+P[2]*_[2],G=zr(P,_);_=nr([_[0]*$+G[0]*H+P[0]*Z*(1-$),_[1]*$+G[1]*H+P[1]*Z*(1-$),_[2]*$+G[2]*H+P[2]*Z*(1-$)])}y=nr(zr(E,_)),x=E;const q=[],z=[];for(let O=0;O<c;O++){const V=O/c*Math.PI*2,P=Math.cos(V),$=Math.sin(V),H=Is(Sn(_,P*n),Sn(y,$*s)),Z=nr(Is(Sn(_,P/n),Sn(y,$/s)));q.push(Is(b[k].pos,H)),z.push(Z)}S.push({pts:q,norms:z,col:b[k].col})}for(let k=0;k<S.length-1;k++){const E=S[k],T=S[k+1];for(let j=0;j<c;j++){const q=(j+1)%c;this.pushTri(E.pts[j],E.norms[j],E.col,E.pts[q],E.norms[q],E.col,T.pts[q],T.norms[q],T.col),this.pushTri(E.pts[j],E.norms[j],E.col,T.pts[q],T.norms[q],T.col,T.pts[j],T.norms[j],T.col)}}}}toFloat32Array(){return new Float32Array(this.data)}}class oL{constructor(r){this.glCanvas=r;const n=r.getContext("webgl2",{antialias:!0,alpha:!1,preserveDrawingBuffer:!0});n&&this.initProgram(n)?(this.gl=n,this.mode="webgl2"):this.mode="canvas2d-fallback"}gl=null;program=null;vao=null;vbo=null;uViewProjLoc=null;uViewLoc=null;mode;initProgram(r){const n=r.createShader(r.VERTEX_SHADER),s=r.createShader(r.FRAGMENT_SHADER);if(!n||!s||(r.shaderSource(n,nL),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))||(r.shaderSource(s,sL),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)))return!1;const i=r.createProgram();if(!i||(r.attachShader(i,n),r.attachShader(i,s),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS)))return!1;this.program=i,this.uViewProjLoc=r.getUniformLocation(i,"uViewProj"),this.uViewLoc=r.getUniformLocation(i,"uView"),this.vao=r.createVertexArray(),this.vbo=r.createBuffer(),r.bindVertexArray(this.vao),r.bindBuffer(r.ARRAY_BUFFER,this.vbo);const c=36;return r.enableVertexAttribArray(0),r.vertexAttribPointer(0,3,r.FLOAT,!1,c,0),r.enableVertexAttribArray(1),r.vertexAttribPointer(1,3,r.FLOAT,!1,c,12),r.enableVertexAttribArray(2),r.vertexAttribPointer(2,3,r.FLOAT,!1,c,24),r.bindVertexArray(null),r.enable(r.DEPTH_TEST),r.enable(r.CULL_FACE),r.cullFace(r.BACK),!0}render(r,n,s,i,c,d){const f=[],p=Math.max(1,Math.floor(i*d)),b=Math.max(1,Math.floor(c*d));(this.glCanvas.width!==p||this.glCanvas.height!==b)&&(this.glCanvas.width=p,this.glCanvas.height=b),(s.width!==p||s.height!==b)&&(s.width=p,s.height=b);const x=s.getContext("2d");x&&(x.setTransform(d,0,0,d,0,0),x.clearRect(0,0,i,c));const g=n.layout==="split"?[{x:0,y:0,w:i/2,h:c,showRef:!0,showMob:!1,title:"REFERENCE (EXPERIMENTAL)"},{x:i/2,y:0,w:i/2,h:c,showRef:!1,showMob:!0,title:"PREDICTION (SUPERPOSED)"}]:[{x:0,y:0,w:i,h:c,showRef:n.layout==="overlay"||n.layout==="reference",showMob:n.layout==="overlay"||n.layout==="mobile"}],_=aL(n.camera);if(this.mode==="webgl2"&&this.gl&&this.program&&this.vao&&this.vbo){const y=this.gl;y.disable(y.SCISSOR_TEST),y.viewport(0,0,p,b),y.clearColor(.035,.051,.078,1),y.clear(y.COLOR_BUFFER_BIT|y.DEPTH_BUFFER_BIT),y.enable(y.SCISSOR_TEST),y.useProgram(this.program),y.bindVertexArray(this.vao);for(const S of g){const k=Math.max(.1,S.w/Math.max(1,S.h)),E=AA(38*Math.PI/180,k,.5,600),T=jA(E,_),q=this.buildPanelMesh(r,n,S.showRef,S.showMob).toFloat32Array(),z=Math.floor(S.x*d),O=Math.floor(S.w*d),V=Math.floor(S.h*d);y.viewport(z,0,O,V),y.scissor(z,0,O,V),y.bindBuffer(y.ARRAY_BUFFER,this.vbo),y.bufferData(y.ARRAY_BUFFER,q,y.DYNAMIC_DRAW),y.uniformMatrix4fv(this.uViewLoc,!1,_),y.uniformMatrix4fv(this.uViewProjLoc,!1,T),y.drawArrays(y.TRIANGLES,0,q.length/9),this.collectAndDrawHud(r,n,T,S,x,f)}y.disable(y.SCISSOR_TEST)}else{const y=this.glCanvas.getContext("2d");if(y){y.setTransform(d,0,0,d,0,0),y.fillStyle="#090d14",y.fillRect(0,0,i,c);for(const S of g){const k=Math.max(.1,S.w/Math.max(1,S.h)),E=AA(38*Math.PI/180,k,.5,600),T=jA(E,_);this.render2dPanel(y,r,n,T,S),this.collectAndDrawHud(r,n,T,S,x,f)}}}return n.layout==="split"&&x&&(x.strokeStyle="rgba(148, 163, 184, 0.25)",x.lineWidth=1,x.beginPath(),x.moveTo(i/2,0),x.lineTo(i/2,c),x.stroke()),f}buildPanelMesh(r,n,s,i){const c=new iL,d=n.style==="pocket";if(s&&r.refResidues.length>0)if(n.style==="trace"){for(let p=0;p<r.refResidues.length-1;p++){const b=r.refResidues[p],x=r.refResidues[p+1];Fd(b.xyz,x.xyz)<=6.5&&c.addCylinder(b.xyz,x.xyz,.24,b.color,x.color,6)}for(const p of r.refResidues)c.addSphere(p.xyz,.34,p.color,6,8)}else c.addBackboneRibbon(r.refResidues,d?.34:.44,d?.14:.18,4,8);if(i&&r.mobResidues.length>0)if(n.style==="trace"){for(let p=0;p<r.mobResidues.length-1;p++){const b=r.mobResidues[p],x=r.mobResidues[p+1];Fd(b.xyz,x.xyz)<=6.5&&c.addCylinder(b.xyz,x.xyz,.2,b.color,x.color,6)}for(const p of r.mobResidues)c.addSphere(p.xyz,.3,p.color,6,8)}else c.addBackboneRibbon(r.mobResidues,d?.26:.36,d?.11:.14,4,8);if(s){for(const p of r.ligandBonds)c.addCylinder(p.a,p.b,d?p.radius:p.radius*.75,p.colorA,p.colorB,7);for(const p of r.ligandAtoms)c.addSphere(p.xyz,d?p.radius:p.radius*.85,p.color,9,12);if(d){for(const p of r.pocketBonds)c.addCylinder(p.a,p.b,p.radius,p.colorA,p.colorB,6);for(const p of r.pocketAtoms)c.addSphere(p.xyz,p.radius,p.color,6,8)}}const f=[...s?r.refResidues:[],...i?r.mobResidues:[]];for(const p of f)n.focusedSeqId===p.seqId?c.addSphere(p.xyz,.92,[251,191,36],10,14):n.highlightedSeqIds.has(p.seqId)&&c.addSphere(p.xyz,.68,[244,114,182],8,10);if(n.paePair){const[p,b]=n.paePair,x=f.find(_=>_.seqId===p),g=f.find(_=>_.seqId===b);x&&c.addSphere(x.xyz,.85,[34,211,238],9,12),g&&c.addSphere(g.xyz,.85,[52,211,153],9,12)}return c}render2dPanel(r,n,s,i,c){r.save(),r.beginPath(),r.rect(c.x,c.y,c.w,c.h),r.clip();const d=[],f=(b,x)=>{for(let g=0;g<b.length-1;g++){const _=b[g],y=b[g+1];if(Fd(_.xyz,y.xyz)>6.5)continue;const S=$n(i,_.xyz,c.x,c.y,c.w,c.h),k=$n(i,y.xyz,c.x,c.y,c.w,c.h);if(!S.visible||!k.visible)continue;const E=(S.ndcZ+k.ndcZ)*.5;d.push({depth:E,draw:()=>{r.strokeStyle=`rgb(${_.color[0]},${_.color[1]},${_.color[2]})`,r.lineWidth=x,r.lineCap="round",r.beginPath(),r.moveTo(S.sx,S.sy),r.lineTo(k.sx,k.sy),r.stroke()}})}};c.showRef&&f(n.refResidues,s.style==="pocket"?3:4),c.showMob&&f(n.mobResidues,s.style==="pocket"?2.4:3.2);const p=(b,x)=>{for(const g of x){const _=$n(i,g.a,c.x,c.y,c.w,c.h),y=$n(i,g.b,c.x,c.y,c.w,c.h);!_.visible||!y.visible||d.push({depth:(_.ndcZ+y.ndcZ)*.5,draw:()=>{r.strokeStyle=`rgb(${g.colorA[0]},${g.colorA[1]},${g.colorA[2]})`,r.lineWidth=2,r.beginPath(),r.moveTo(_.sx,_.sy),r.lineTo(y.sx,y.sy),r.stroke()}})}for(const g of b){const _=$n(i,g.xyz,c.x,c.y,c.w,c.h);_.visible&&d.push({depth:_.ndcZ,draw:()=>{r.fillStyle=`rgb(${g.color[0]},${g.color[1]},${g.color[2]})`,r.beginPath(),r.arc(_.sx,_.sy,g.isMetal?6:3.5,0,Math.PI*2),r.fill()}})}};c.showRef&&(p(n.ligandAtoms,n.ligandBonds),s.style==="pocket"&&p(n.pocketAtoms,n.pocketBonds)),d.sort((b,x)=>x.depth-b.depth);for(const b of d)b.draw();r.restore()}collectAndDrawHud(r,n,s,i,c,d){const f=x=>{x.sx>=i.x&&x.sx<=i.x+i.w&&x.sy>=i.y&&x.sy<=i.y+i.h&&d.push(x)};if(i.showRef){for(const x of r.refResidues){const g=$n(s,x.xyz,i.x,i.y,i.w,i.h);g.visible&&f({sx:g.sx,sy:g.sy,depth:g.ndcZ,kind:"residue",seqId:x.seqId,label:`${x.resName3} ${x.seqId} (Ref)`,xyz:x.xyz,chainKind:"ref"})}for(const x of r.ligandAtoms){const g=$n(s,x.xyz,i.x,i.y,i.w,i.h);g.visible&&f({sx:g.sx,sy:g.sy,depth:g.ndcZ,kind:"atom",seqId:x.seqId,label:x.label,xyz:x.xyz,chainKind:"ref"})}}if(i.showMob)for(const x of r.mobResidues){const g=$n(s,x.xyz,i.x,i.y,i.w,i.h);g.visible&&f({sx:g.sx,sy:g.sy,depth:g.ndcZ,kind:"residue",seqId:x.seqId,label:`${x.resName3} ${x.seqId} (Mob)`,xyz:x.xyz,chainKind:"mob"})}if(!c)return;if(c.save(),c.beginPath(),c.rect(i.x,i.y,i.w,i.h),c.clip(),i.showRef&&n.style==="pocket")for(const x of r.coordinationBonds){const g=$n(s,x.a,i.x,i.y,i.w,i.h),_=$n(s,x.b,i.x,i.y,i.w,i.h);!g.visible||!_.visible||(c.save(),c.setLineDash([4,3]),c.strokeStyle="rgba(216, 180, 254, 0.85)",c.lineWidth=1.4,c.beginPath(),c.moveTo(g.sx,g.sy),c.lineTo(_.sx,_.sy),c.stroke(),c.restore())}if(i.showRef){const x=r.ligandAtoms.find(_=>_.element==="ZN");if(x){const _=$n(s,x.xyz,i.x,i.y,i.w,i.h);_.visible&&kc(c,_.sx+10,_.sy-8,"Zn²⁺","#d8b4fe")}const g=r.ligandAtoms.find(_=>_.resName==="AZM"&&_.atomName==="S1");if(g){const _=$n(s,g.xyz,i.x,i.y,i.w,i.h);_.visible&&kc(c,_.sx+10,_.sy+10,"AZM","#67e8f9")}if(n.style==="pocket")for(const _ of[94,96,119]){const y=r.refResidues.find(k=>k.seqId===_);if(!y)continue;const S=$n(s,y.xyz,i.x,i.y,i.w,i.h);S.visible&&kc(c,S.sx+8,S.sy-6,`${y.resName3}${y.seqId}`,"#94a3b8")}}if(n.focusedSeqId!=null){const x=i.showRef&&r.refResidues.find(g=>g.seqId===n.focusedSeqId)||i.showMob&&r.mobResidues.find(g=>g.seqId===n.focusedSeqId);if(x){const g=$n(s,x.xyz,i.x,i.y,i.w,i.h);g.visible&&(c.strokeStyle="#fbbf24",c.lineWidth=2,c.beginPath(),c.arc(g.sx,g.sy,10,0,Math.PI*2),c.stroke(),kc(c,g.sx+12,g.sy-12,`${x.resName3}${x.seqId}`,"#fbbf24"))}}const[p,b]=n.distancePair;if(p&&b){const x=$n(s,p.xyz,i.x,i.y,i.w,i.h),g=$n(s,b.xyz,i.x,i.y,i.w,i.h);if(x.visible&&g.visible){c.save(),c.setLineDash([5,4]),c.strokeStyle="#f43f5e",c.lineWidth=2,c.beginPath(),c.moveTo(x.sx,x.sy),c.lineTo(g.sx,g.sy),c.stroke(),c.restore();const _=Fd(p.xyz,b.xyz),y=(x.sx+g.sx)*.5,S=(x.sy+g.sy)*.5;kc(c,y,S,`${p.resName3}${p.seqId} ↔ ${b.resName3}${b.seqId}: ${_.toFixed(2)} Å`,"#fda4af")}}else if(p){const x=$n(s,p.xyz,i.x,i.y,i.w,i.h);x.visible&&(c.strokeStyle="#f43f5e",c.lineWidth=2,c.beginPath(),c.arc(x.sx,x.sy,9,0,Math.PI*2),c.stroke(),kc(c,x.sx+10,x.sy+10,`A: ${p.resName3}${p.seqId}`,"#fda4af"))}i.title&&(c.fillStyle="rgba(15, 23, 42, 0.78)",c.fillRect(i.x+10,i.y+44,178,20),c.strokeStyle="rgba(51, 65, 85, 0.8)",c.strokeRect(i.x+10,i.y+44,178,20),c.fillStyle="#cbd5e1",c.font="600 10px ui-monospace, monospace",c.fillText(i.title,i.x+16,i.y+57)),c.restore()}}function kc(e,r,n,s,i){e.font="600 10px ui-monospace, SFMono-Regular, Menlo, monospace";const c=e.measureText(s),d=5,f=c.width+d*2,p=16;e.fillStyle="rgba(9, 13, 20, 0.84)",e.fillRect(r,n-11,f,p),e.strokeStyle="rgba(148, 163, 184, 0.35)",e.lineWidth=1,e.strokeRect(r,n-11,f,p),e.fillStyle=i,e.fillText(s,r+d,n)}function ky(e){return e==null||!Number.isFinite(e)?[148,163,184]:e>=90?[38,132,255]:e>=70?[101,203,243]:e>=50?[255,219,19]:[255,125,69]}function Cy(e){if(e==null||!Number.isFinite(e))return[148,163,184];const r=Math.max(0,Math.min(1,(e-4)/46)),n=[[98,45,186],[156,47,148],[222,73,104],[254,159,109],[252,244,152]],s=r*(n.length-1),i=Math.min(n.length-2,Math.floor(s)),c=s-i,d=n[i],f=n[i+1];return[Math.round(d[0]+(f[0]-d[0])*c),Math.round(d[1]+(f[1]-d[1])*c),Math.round(d[2]+(f[2]-d[2])*c)]}function Vd(e){if(e==null||!Number.isFinite(e))return[148,163,184];const r=Math.max(0,Math.min(1,e/4));if(r<.4){const s=r/.4;return[Math.round(16+229*s),Math.round(185+-27*s),Math.round(129+-118*s)]}const n=(r-.4)/.6;return[Math.round(245+-1*n),Math.round(158+-95*n),Math.round(11+83*n)]}function TA(e){switch(e.trim().toUpperCase()){case"ZN":return[192,132,252];case"MG":return[74,222,128];case"FE":return[249,115,22];case"N":return[96,165,250];case"O":return[248,113,113];case"S":return[250,204,21];case"P":return[251,146,60];case"F":case"CL":return[52,211,153];case"BR":return[185,28,28];default:return[203,213,225]}}function lL(e,r=1){return r>=1?`rgb(${e[0]}, ${e[1]}, ${e[2]})`:`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${r})`}function cL(e){const n=Math.max(0,Math.min(30,e))/30;if(n<.35){const i=n/.35;return[Math.round(16+29*i),Math.round(210+-70*i),Math.round(160+-25*i)]}const s=(n-.35)/.65;return[Math.round(45+-30*s),Math.round(140+-117*s),Math.round(135+-93*s)]}function Ny(e,r){const n=e[0]-r[0],s=e[1]-r[1],i=e[2]-r[2];return Math.sqrt(n*n+s*s+i*i)}function uL(e,r){return e.length!==16?r:[e[0]*r[0]+e[1]*r[1]+e[2]*r[2]+e[3],e[4]*r[0]+e[5]*r[1]+e[6]*r[2]+e[7],e[8]*r[0]+e[9]*r[1]+e[10]*r[2]+e[11]]}function EA(e,r,n){const s=[];for(let i=0;i<e.length;i++)for(let c=i+1;c<e.length;c++){const d=e[i],f=e[c];if(d.isMetal||f.isMetal||d.seqId!==f.seqId||d.resName!==f.resName)continue;const p=Ny(d.xyz,f.xyz),b=d.element==="S"||f.element==="S"?r+.35:r;p>.4&&p<=b&&s.push({a:d.xyz,b:f.xyz,colorA:d.color,colorB:f.color,radius:n})}return s}function dL(e){const{comparison:r,refInspect:n,mobInspect:s,refChainId:i,mobChainId:c,colorMode:d}=e,f=new Map,p=new Map,b=new Map,x=new Map;if(r)for(const I of r.matchedResidues)f.set(I.refSeqId,I.distanceAngstrom),p.set(I.mobSeqId,I.distanceAngstrom),b.set(I.refSeqId,I.refBFactor),x.set(I.mobSeqId,I.mobPlddt);const g=[],_=r?.refDisplayAtoms?.residues;if(_&&_.length>0)for(const I of _){const J=f.get(I.seqId)??null,ge=I.bFactor??b.get(I.seqId)??null;let le=[56,189,248];d==="bfactor"?le=Cy(ge):d==="plddt"?le=[100,116,139]:d==="deviation"&&(le=J!=null?Vd(J):[100,116,139]),g.push({kind:"ref",seqId:I.seqId,insCode:I.insCode,resName3:I.resName3,resCode1:I.resCode1,xyz:I.ca,bFactor:ge,plddt:null,deviationA:J,color:le})}else if(n){const I=n.chains.find(J=>J.chainId===i)??n.chains[0];if(I)for(const J of I.residues){if(!J.ca)continue;const ge=f.get(J.seqId)??null;let le=[56,189,248];d==="bfactor"?le=Cy(J.bOrPlddt):d==="plddt"?le=[100,116,139]:d==="deviation"&&(le=Vd(ge)),g.push({kind:"ref",seqId:J.seqId,insCode:J.insCode,resName3:J.resName3,resCode1:J.resCode1,xyz:J.ca,bFactor:J.bOrPlddt,plddt:null,deviationA:ge,color:le})}}const y=[];if(r?.mobTransformedResidues&&r.mobTransformedResidues.length>0)for(const I of r.mobTransformedResidues){const J=p.get(I.seqId)??null,ge=I.plddt??x.get(I.seqId)??null;let le=[52,211,153];d==="plddt"?le=ky(ge):d==="bfactor"?le=[100,116,139]:d==="deviation"&&(le=J!=null?Vd(J):[100,116,139]),y.push({kind:"mob",seqId:I.seqId,insCode:I.insCode,resName3:I.resName3,resCode1:I.resCode1,xyz:I.xyz,bFactor:null,plddt:ge,deviationA:J,color:le})}else if(s){const I=s.chains.find(ge=>ge.chainId===c)??s.chains[0],J=r?.transform.matrixRowMajor4x4;if(I)for(const ge of I.residues){if(!ge.ca)continue;const le=J?uL(J,ge.ca):ge.ca,D=p.get(ge.seqId)??null;let ae=[52,211,153];d==="plddt"?ae=ky(ge.bOrPlddt):d==="bfactor"?ae=[100,116,139]:d==="deviation"&&(ae=Vd(D)),y.push({kind:"mob",seqId:ge.seqId,insCode:ge.insCode,resName3:ge.resName3,resCode1:ge.resCode1,xyz:le,bFactor:null,plddt:ge.bOrPlddt,deviationA:D,color:ae})}}const S=r?.refDisplayAtoms?.ligands??n?.ligands??[],k=[];for(const I of S)for(const J of I.atoms){const ge=J.element.toUpperCase(),le=ge==="ZN"||ge==="MG"||ge==="FE"||ge==="CA"||ge==="MN";k.push({id:`lig-${I.chainId}-${I.seqId}-${I.resName}-${J.name}`,label:`${I.resName} ${I.seqId} · ${J.name}`,seqId:I.seqId,resName:I.resName,atomName:J.name,element:ge,xyz:J.xyz,radius:le?.85:.42,color:TA(ge),isLigand:!0,isMetal:le})}const E=EA(k,1.88,.22),j=(r?.refDisplayAtoms?.pocketAtoms??[]).map((I,J)=>({id:`pocket-${I.seqId}-${I.atomName}-${J}`,label:`${I.resName3}${I.seqId} · ${I.atomName}`,seqId:I.seqId,resName:I.resName3,atomName:I.atomName,element:I.element.toUpperCase(),xyz:I.xyz,radius:.3,color:I.element.toUpperCase()==="C"?[148,163,184]:TA(I.element),isLigand:!1,isMetal:!1})),q=EA(j,1.85,.16),z=[],O=r?.refContacts??[],V=new Map;for(const I of k)V.set(`${I.resName}:${I.seqId}:${I.atomName}`,I);const P=new Map;for(const I of j)P.set(`${I.seqId}:${I.atomName}`,I);const $=new Map;for(const I of g)$.set(I.seqId,I);for(const I of O){const J=V.get(`${I.ligandResName}:${I.ligandSeqId}:${I.ligandAtom}`);if(!J)continue;const le=(P.get(`${I.proteinSeqId}:${I.proteinAtom}`)??void 0)?.xyz??$.get(I.proteinSeqId)?.xyz;le&&(I.ligandResName==="ZN"||I.distanceAngstrom<=3.1)&&z.push({a:J.xyz,b:le,colorA:[216,180,254],colorB:[103,232,249],radius:.1,dashed:!0})}const H=k.find(I=>I.element==="ZN");if(H)for(const I of k)I!==H&&Ny(H.xyz,I.xyz)<=2.6&&z.push({a:H.xyz,b:I.xyz,colorA:[216,180,254],colorB:[96,165,250],radius:.11,dashed:!0});const Z=[...g.map(I=>I.xyz),...y.map(I=>I.xyz)];let G=0,K=0,we=0;for(const I of Z)G+=I[0],K+=I[1],we+=I[2];const Se=Math.max(1,Z.length),Q=[G/Se,K/Se,we/Se];let F=12;for(const I of Z){const J=Ny(I,Q);J>F&&(F=J)}let he=null;if(H)he=[...H.xyz];else{const I=g.filter(J=>J.seqId===94||J.seqId===96||J.seqId===119);if(I.length>0){const J=I.reduce((ge,le)=>[ge[0]+le.xyz[0],ge[1]+le.xyz[1],ge[2]+le.xyz[2]],[0,0,0]);he=[J[0]/I.length,J[1]/I.length,J[2]/I.length]}}const W=g.slice(0,6),me=W.length>0?[W.reduce((I,J)=>I+J.xyz[0],0)/W.length,W.reduce((I,J)=>I+J.xyz[1],0)/W.length,W.reduce((I,J)=>I+J.xyz[2],0)/W.length]:null;return{refResidues:g,mobResidues:y,pocketAtoms:j,pocketBonds:q,ligandAtoms:k,ligandBonds:E,coordinationBonds:z,center:Q,radius:F,activeSiteCenter:he,nTermCenter:me}}const hL=C.forwardRef(function({comparison:r,refInspect:n,mobInspect:s,refChainId:i,mobChainId:c,layout:d,onChangeLayout:f,style:p,onChangeStyle:b,colorMode:x,onChangeColorMode:g,focusedSeqId:_,focusCameraRequest:y,highlightedSeqIds:S,highlightSourceLabel:k,onClearHighlights:E,paePair:T,onPickResidue:j,onRendererModeDetected:q,simpleMode:z=!1},O){const V=C.useRef(null),P=C.useRef(null),$=C.useRef(null),H=C.useRef(null),Z=C.useRef([]),[G,K]=C.useState({width:800,height:420}),[we,Se]=C.useState(!1),[Q,F]=C.useState([null,null]),[he,W]=C.useState(null),me=C.useMemo(()=>dL({comparison:r,refInspect:n,mobInspect:s,refChainId:i,mobChainId:c,colorMode:x}),[r,n,s,i,c,x,S]),[I,J]=C.useState({yaw:.55,pitch:.25,distance:68,target:[0,0,0]}),ge=C.useRef("");C.useEffect(()=>{const ue=`${r?.reference.sha256??""}:${r?.mobile.sha256??""}:${me.refResidues.length}`;ue!==ge.current&&me.refResidues.length+me.mobResidues.length>0&&(ge.current=ue,J({yaw:.55,pitch:.25,distance:Math.max(36,me.radius*2.55),target:[...me.center]}))},[r,me]);const le=ue=>{const He=me.refResidues.find(Pe=>Pe.seqId===ue)??me.mobResidues.find(Pe=>Pe.seqId===ue);He&&J(Pe=>({...Pe,distance:Math.max(14,Math.min(Pe.distance,26)),target:[...He.xyz]}))};C.useEffect(()=>{y&&le(y.seqId)},[y?.nonce,y?.seqId]);const D=C.useMemo(()=>_===null?null:me.refResidues.find(ue=>ue.seqId===_)??me.mobResidues.find(ue=>ue.seqId===_)??null,[_,me.refResidues,me.mobResidues]),ae=ue=>{ue==="active-site"&&me.activeSiteCenter?(J({yaw:.9,pitch:.2,distance:20,target:[...me.activeSiteCenter]}),b("pocket")):ue==="n-terminus"&&me.nTermCenter?J({yaw:-.4,pitch:.3,distance:24,target:[...me.nTermCenter]}):J({yaw:.55,pitch:.25,distance:Math.max(36,me.radius*2.55),target:[...me.center]})},pe=()=>{const ue=P.current,He=$.current;if(!ue||!He)return null;const Pe=document.createElement("canvas");Pe.width=ue.width,Pe.height=ue.height;const ut=Pe.getContext("2d");if(!ut)return null;ut.drawImage(ue,0,0),ut.drawImage(He,0,0);const Je=window.devicePixelRatio||1;return ut.fillStyle="rgba(9, 13, 20, 0.85)",ut.fillRect(0,Pe.height-24*Je,Pe.width,24*Je),ut.fillStyle="#fbbf24",ut.font=`600 ${Math.round(11*Je)}px ui-monospace, monospace`,ut.fillText(`SYNLEXA STUDIO · RESEARCH USE ONLY (RUO) · ${r?`RMSD ${r.metrics.rmsdAngstrom.toFixed(3)} A (${r.metrics.matchedCaCount} Ca)`:"3D Structure View"}`,10*Je,Pe.height-8*Je),Pe.toDataURL("image/png")};C.useImperativeHandle(O,()=>({capturePngDataUrl:pe,applyPreset:ae}));const Ae=()=>{const ue=pe();if(!ue)return;const He=document.createElement("a");He.href=ue,He.download=`synlexa-studio-ruo-viewport-${Date.now()}.png`,He.click()};C.useEffect(()=>{const ue=V.current;if(!ue)return;const He=new ResizeObserver(Pe=>{for(const ut of Pe)K({width:Math.max(200,Math.floor(ut.contentRect.width)),height:Math.max(180,Math.floor(ut.contentRect.height))})});return He.observe(ue),()=>He.disconnect()},[]),C.useEffect(()=>{const ue=P.current;if(!ue||H.current)return;const He=new oL(ue);H.current=He,q?.(He.mode)},[q]),C.useEffect(()=>{const ue=H.current,He=$.current;if(!ue||!He)return;const Pe=Math.min(2,window.devicePixelRatio||1);Z.current=ue.render(me,{layout:d,style:p,camera:I,focusedSeqId:_,highlightedSeqIds:S,distancePair:Q,paePair:T},He,G.width,G.height,Pe)},[me,d,p,I,_,S,Q,T,G]);const Ne=C.useRef({active:!1,moved:!1,startX:0,startY:0,lastX:0,lastY:0,pan:!1}),Re=(ue,He)=>{let Pe=null,ut=1/0;for(const Je of Z.current){const re=Je.sx-ue,ve=Je.sy-He,Qe=re*re+ve*ve;if(Qe<=196){const Fe=Qe+(Je.depth+1)*15;Fe<ut&&(ut=Fe,Pe=Je)}}return Pe},$e=C.useRef(new Map),Ce=C.useRef(null),Ue=ue=>{J(He=>({...He,distance:Math.max(4,Math.min(320,He.distance*ue))}))},be=(ue,He)=>{J(Pe=>{const ut=Pe.distance*.0018,Je=Math.cos(Pe.yaw),re=Math.sin(Pe.yaw);return{...Pe,target:[Pe.target[0]-ue*ut*Je,Pe.target[1]+He*ut,Pe.target[2]+ue*ut*re]}})},bt=(ue,He)=>{J(Pe=>({...Pe,yaw:Pe.yaw-ue*.0085,pitch:Math.max(-1.45,Math.min(1.45,Pe.pitch+He*.0085))}))},Ot=()=>{const ue=Array.from($e.current.values());if(ue.length<2)return null;const[He,Pe]=ue;return{dist:Math.hypot(He.x-Pe.x,He.y-Pe.y),cx:(He.x+Pe.x)/2,cy:(He.y+Pe.y)/2}},St=ue=>{if(!ue.target.closest("[data-viewport-ui]")){if(ue.currentTarget.setPointerCapture(ue.pointerId),$e.current.set(ue.pointerId,{x:ue.clientX,y:ue.clientY}),$e.current.size===2){Ce.current=Ot(),Ne.current.moved=!0;return}Ne.current={active:!0,moved:!1,startX:ue.clientX,startY:ue.clientY,lastX:ue.clientX,lastY:ue.clientY,pan:ue.shiftKey||ue.button===2||ue.button===1}}},Ke=ue=>{const He=ue.currentTarget.getBoundingClientRect(),Pe=ue.clientX-He.left,ut=ue.clientY-He.top;if($e.current.has(ue.pointerId)&&$e.current.set(ue.pointerId,{x:ue.clientX,y:ue.clientY}),$e.current.size>=2&&Ce.current){const ve=Ot();ve&&ve.dist>0&&Ce.current.dist>0&&(Ue(Ce.current.dist/ve.dist),be(ve.cx-Ce.current.cx,ve.cy-Ce.current.cy),Ce.current=ve);return}if(!Ne.current.active){if(ue.pointerType==="mouse"){const ve=Re(Pe,ut);W(ve?ve.label:null)}return}const Je=ue.clientX-Ne.current.lastX,re=ue.clientY-Ne.current.lastY;(Math.abs(ue.clientX-Ne.current.startX)>3||Math.abs(ue.clientY-Ne.current.startY)>3)&&(Ne.current.moved=!0),Ne.current.lastX=ue.clientX,Ne.current.lastY=ue.clientY,Ne.current.pan?be(Je,re):bt(Je,re)},et=ue=>{const He=$e.current.size>=2;if($e.current.delete(ue.pointerId),$e.current.size<2&&(Ce.current=null),He){Ne.current.active=!1;return}if(!Ne.current.active)return;const Pe=Ne.current.moved;if(Ne.current.active=!1,Pe)return;const ut=ue.currentTarget.getBoundingClientRect(),Je=Re(ue.clientX-ut.left,ue.clientY-ut.top);if(Je)if(we){const re=me.refResidues.find(ve=>ve.seqId===Je.seqId)??me.mobResidues.find(ve=>ve.seqId===Je.seqId)??null;re&&F(([ve,Qe])=>!ve||ve&&Qe?[re,null]:[ve,re])}else j(Je.seqId)};return C.useEffect(()=>{const ue=V.current;if(!ue)return;const He=ve=>{if(ve.target.closest("[data-viewport-ui]"))return;ve.preventDefault();const Qe=ve.deltaMode===1?16:ve.deltaMode===2?400:1,Fe=ve.deltaY*Qe;ve.ctrlKey?Ue(Math.exp(Fe*.012)):ve.shiftKey?be(-ve.deltaX*Qe,-Fe):Ue(Math.exp(Fe*.0015))};let Pe=0;const ut=ve=>{ve.preventDefault(),J(Qe=>(Pe=Qe.distance,Qe))},Je=ve=>{ve.preventDefault();const Qe=ve.scale??1;Pe>0&&Qe>0&&J(Fe=>({...Fe,distance:Math.max(4,Math.min(320,Pe/Qe))}))},re=ve=>ve.preventDefault();return ue.addEventListener("wheel",He,{passive:!1}),ue.addEventListener("gesturestart",ut,{passive:!1}),ue.addEventListener("gesturechange",Je,{passive:!1}),ue.addEventListener("gestureend",re,{passive:!1}),()=>{ue.removeEventListener("wheel",He),ue.removeEventListener("gesturestart",ut),ue.removeEventListener("gesturechange",Je),ue.removeEventListener("gestureend",re)}},[]),o.jsxs("div",{ref:V,onContextMenu:ue=>ue.preventDefault(),onPointerDown:St,onPointerMove:Ke,onPointerUp:et,onPointerCancel:et,onPointerLeave:ue=>{ue.pointerType==="mouse"&&!Ne.current.active&&W(null)},style:{touchAction:"none"},className:"relative h-full w-full cursor-grab overflow-hidden bg-[#090d14] select-none overscroll-none active:cursor-grabbing",children:[o.jsx("canvas",{ref:P,className:"absolute inset-0 h-full w-full"}),o.jsx("canvas",{ref:$,className:"pointer-events-none absolute inset-0 h-full w-full"}),o.jsxs("div",{"data-viewport-ui":!0,className:"pointer-events-none absolute top-2.5 right-2.5 left-2.5 flex flex-wrap items-center justify-between gap-2",children:[o.jsx("div",{className:"pointer-events-auto flex flex-wrap items-center gap-1 rounded-xl border border-white/10 bg-[#0d121b]/85 p-1 shadow-xl backdrop-blur-md",children:[["overlay","Overlay","Superpose both structures on the same coordinates"],["split","Split","Show reference and comparison side-by-side"],["reference","Ref Only","Show only the experimental/reference structure"],["mobile","Pred Only","Show only the predicted/mobile structure"]].map(([ue,He,Pe])=>o.jsxs("button",{type:"button",title:Pe,onClick:()=>f(ue),className:`flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] font-medium transition ${d===ue?"bg-white/[0.12] text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:[ue==="split"&&o.jsx(W6,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:He})]},ue))}),o.jsx("div",{className:"pointer-events-auto flex flex-wrap items-center gap-1 rounded-xl border border-white/10 bg-[#0d121b]/85 p-1 shadow-xl backdrop-blur-md",children:[["ribbon","Ribbon","Smooth backbone ribbon representation"],["trace","Cα Trace","Minimal alpha-carbon wire trace"],["pocket","Active Pocket","Highlight co-crystal ligand, metal ion & pocket sidechains"]].map(([ue,He,Pe])=>o.jsx("button",{type:"button",title:Pe,onClick:()=>b(ue),className:`rounded-lg px-2.5 py-1 text-[0.75rem] font-medium transition ${p===ue?"bg-white/[0.12] text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:He},ue))}),o.jsx("div",{className:"pointer-events-auto flex flex-wrap items-center gap-1 rounded-xl border border-white/10 bg-[#0d121b]/85 p-1 shadow-xl backdrop-blur-md",children:[["identity","Identity","Color by structure (blue = reference, green = prediction)"],["plddt","pLDDT","Color by AlphaFold confidence score (0–100)"],["bfactor","B-Factor (Ų)","Color by crystallographic B-factor flexibility"],["deviation","Δd (Å)","Color by per-residue Cα distance between structures"]].map(([ue,He,Pe])=>o.jsx("button",{type:"button",title:Pe,onClick:()=>g(ue),className:`rounded-lg px-2.5 py-1 text-[0.75rem] font-medium transition ${x===ue?"bg-white/[0.12] text-white shadow-sm":"text-slate-400 hover:text-slate-200"}`,children:He},ue))})]}),(D||S.size>0)&&o.jsxs("div",{"data-viewport-ui":!0,className:"pointer-events-none absolute top-14 right-2.5 left-2.5 flex flex-wrap items-center gap-1.5",children:[D&&o.jsxs("button",{type:"button",onClick:()=>le(D.seqId),title:"Click to center 3D camera on this residue",className:"pointer-events-auto inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-[#0d121b]/85 px-2.5 py-1 font-mono text-[0.6875rem] text-amber-200 shadow backdrop-blur-md hover:border-amber-300",children:[o.jsx(Ur,{className:"h-3 w-3 text-amber-300"}),o.jsxs("span",{children:[D.resName3," ",D.seqId,D.deviationA!=null?` · Δd ${D.deviationA.toFixed(2)} Å`:"",D.plddt!=null?` · pLDDT ${D.plddt.toFixed(0)}`:""]}),o.jsx("span",{className:"text-amber-300/75",children:"Center"})]}),S.size>0&&o.jsxs("span",{className:"pointer-events-auto inline-flex items-center gap-1.5 rounded-lg border border-pink-400/40 bg-[#0d121b]/85 px-2.5 py-1 font-mono text-[0.6875rem] text-pink-200 shadow backdrop-blur-md",children:[o.jsx("span",{className:"h-2 w-2 rounded-full bg-pink-400"}),o.jsxs("span",{children:[S.size," highlighted",k?` (${k})`:""]}),E&&o.jsx("button",{type:"button",onClick:E,title:"Clear 3D highlights",className:"rounded p-0.5 text-pink-300 hover:bg-white/10 hover:text-white",children:o.jsx(Xi,{className:"h-3 w-3"})})]})]}),o.jsxs("div",{"data-viewport-ui":!0,className:"pointer-events-none absolute right-2.5 bottom-2.5 left-2.5 flex flex-wrap items-end justify-between gap-2",children:[o.jsxs("div",{className:"pointer-events-auto flex flex-wrap items-center gap-1 rounded-xl border border-white/10 bg-[#0d121b]/85 p-1 shadow-xl backdrop-blur-md",children:[o.jsxs("button",{type:"button",onClick:()=>ae("overview"),className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] text-slate-300 hover:bg-white/[0.07]",children:[o.jsx(Oy,{className:"h-3.5 w-3.5"})," Overview"]}),o.jsxs("button",{type:"button",onClick:()=>ae("active-site"),className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] text-slate-200 hover:bg-white/[0.07]",children:[o.jsx(Ur,{className:"h-3.5 w-3.5"})," Active Site"]}),!z&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",onClick:()=>ae("n-terminus"),className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] text-slate-300 hover:bg-white/[0.07]",children:[o.jsx(OR,{className:"h-3.5 w-3.5"})," N-Term"]}),o.jsx("button",{type:"button",onClick:()=>ae("reset"),className:"rounded-lg px-2.5 py-1 text-[0.75rem] text-slate-400 hover:bg-white/[0.07] hover:text-slate-200",children:"Reset"}),o.jsx("span",{className:"mx-0.5 h-3.5 w-px bg-slate-800"}),o.jsxs("button",{type:"button",onClick:()=>{Se(ue=>!ue),we&&F([null,null])},className:`flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] transition ${we?"border border-rose-500/50 bg-rose-500/20 text-rose-200":"text-slate-300 hover:bg-white/[0.07]"}`,children:[o.jsx(q6,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:we?"Pick 2 Residues":"Distance (Å)"})]})]}),o.jsxs("button",{type:"button",onClick:Ae,className:"flex items-center gap-1 rounded-lg px-2.5 py-1 text-[0.75rem] text-slate-200 hover:bg-white/[0.07]",children:[o.jsx(bR,{className:"h-3.5 w-3.5"})," PNG"]})]}),o.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 rounded-xl border border-white/10 bg-[#0d121b]/85 px-3 py-1.5 font-mono text-[0.75rem] text-slate-300 shadow-lg backdrop-blur-md",children:[he&&o.jsx("span",{className:"border-r border-slate-700 pr-2 text-amber-300",children:he}),x==="identity"&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("i",{className:"inline-block h-2 w-2 rounded-full bg-sky-400"})," Ref"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("i",{className:"inline-block h-2 w-2 rounded-full bg-emerald-400"})," Pred"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("i",{className:"inline-block h-2 w-2 rounded-full bg-purple-400"})," Zn²⁺"]})]}),x==="plddt"&&o.jsxs("span",{className:"flex items-center gap-1.5",title:"AlphaFold pLDDT confidence (distinct from B-factor)",children:[o.jsx("span",{className:"text-slate-400",children:"pLDDT:"}),o.jsx("span",{className:"text-[#2684ff]",children:"■ ≥90"}),o.jsx("span",{className:"text-[#65cbf3]",children:"■ 70-90"}),o.jsx("span",{className:"text-[#ffdb13]",children:"■ 50-70"}),o.jsx("span",{className:"text-[#ff7d45]",children:"■ <50"})]}),x==="bfactor"&&o.jsxs("span",{className:"flex items-center gap-1.5",title:"Experimental B-factor in Angstrom^2 (Plasma scale, never conflated with pLDDT)",children:[o.jsx("span",{className:"text-slate-400",children:"Exp B (Ų):"}),o.jsx("span",{className:"inline-block h-2 w-16 rounded-xs bg-gradient-to-r from-[#622dba] via-[#de4968] to-[#fcf498]"}),o.jsx("span",{children:"4 → 50+"})]}),x==="deviation"&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-slate-400",children:"Δd (Å):"}),o.jsx("span",{className:"inline-block h-2 w-16 rounded-xs bg-gradient-to-r from-emerald-500 via-amber-500 to-rose-500"}),o.jsx("span",{children:"0 → 4+"})]})]})]})]})});function mL({state:e,dispatch:r,result:n,error:s,onFocusResidue:i,simpleMode:c=!1,bridge:d}){const[f,p]=C.useState(""),[b,x]=C.useState(!1),[g,_]=C.useState(!1),[y,S]=C.useState(e.sequence),[k,E]=C.useState(null),T=e.focusSeqId??d?.focusedSeqId??null,j=e.sequence.startsWith("MSHHWGYGKHNGPEHWHK"),q=()=>{const P=f.trim().toUpperCase();P&&(r({type:"add_mutation",notation:P}),p(""))},z=C.useMemo(()=>{if(!T||T<1||T>e.sequence.length)return[];const P=e.sequence[T-1];return P?["A","R","D","W"].filter(H=>H!==P).map(H=>({notation:`${P}${T}${H}`,label:H==="A"?"Ala Scan":H==="R"?"+Charge":H==="D"?"−Charge":"Bulky Trp"})):[]},[T,e.sequence]),O=C.useMemo(()=>{const P=e.sequence.length;if(P===0)return[];const $=T&&T>=1&&T<=P?T:Math.min(P,Math.max(1,e.sliceStart+10)),H=Math.max(1,$-10),Z=Math.min(P,H+20),G=new Map;for(const we of n?.appliedMutations??[])G.set(we.pos,we.to);const K=[];for(let we=H;we<=Z;we++){const Se=e.sequence[we-1]??"X",Q=G.get(we);K.push({pos:we,wt:Se,eng:Q??Se,mutated:!!Q})}return K},[e.sequence,e.sliceStart,T,n?.appliedMutations]),V=(P,$=!1)=>{r({type:"focus_residue",seqId:P}),i(P),$&&d?.focusIn3D(P,{centerCamera:!0})};return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:d,title:"Peptide & Protein Engineering Workbench",subtitle:"Test point mutations and sequence slices, inspect pH 0–14 titration & Kyte-Doolittle shifts, and map 3D contact shells.",icon:o.jsx(ar,{className:"h-4 w-4"}),guideOpen:b,onToggleGuide:()=>x(P=>!P),actions:d&&o.jsxs("button",{type:"button",onClick:()=>{d.savePeptideToProject({name:e.mutations.length>0?e.mutations.join(", "):`Peptide (${e.sliceStart}–${e.sliceEnd})`,sequence:e.sequence,mutations:e.mutations}),E("Saved"),setTimeout(()=>E(null),1600)},className:"inline-flex items-center gap-1 rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1 text-xs font-medium text-slate-200 hover:border-sky-400/40",children:[o.jsx(Qc,{className:"h-3.5 w-3.5 text-sky-300"}),o.jsx("span",{children:k?"Saved!":"Save Variant"})]})}),o.jsx(Qi,{open:b,title:"How Peptide Engineering Works",summary:"Simulate amino-acid substitutions (e.g. H94A) or sequence truncations against the active protein chain in deterministic Rust/WASM. Side-by-side biophysical deltas compare Wild-Type (WT) vs Engineered sequences.",steps:["Click a residue on the sequence strip below (or pick any residue in the 3D Viewer) and click one of the dynamic mutation chips (e.g. Ala Scan) or type any mutation like H94A.","Adjust Slice Start/End to evaluate a cleaved domain or peptide fragment.","Hover the pH 0–14 Titration or Kyte-Doolittle charts to inspect exact shifts, and click any 3D < 5.0 Å neighbor to jump to it in 3D."],connectionTip:"Syncs directly with your loaded 3D structure's sequence and active pocket. Clicking 'Highlight Shell in 3D' illuminates every neighboring residue within 5.0 Å of the mutated site right on the 3D structure.",glossary:[{term:"pI (Isoelectric Point)",desc:"pH where net peptide charge is 0 (Henderson-Hasselbalch model). Shifts affect solubility & purification."},{term:"GRAVY",desc:"Grand Average of Hydropathy (Kyte-Doolittle). Positive = hydrophobic; negative = hydrophilic/soluble."},{term:"ε280 (M⁻¹cm⁻¹)",desc:"Molar extinction coefficient at 280 nm from Trp, Tyr, and cystine disulfide pairs."},{term:"Steric ΔV (ų)",desc:"Net side-chain volume change from substitutions; large positive/negative ΔV inside a packed core can introduce clashes or cavities."}]}),o.jsxs("div",{className:"space-y-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("input",{value:f,onChange:P=>p(P.target.value),onKeyDown:P=>{P.key==="Enter"&&q()},placeholder:"Mutation (e.g. H94A)",className:"h-8 w-36 rounded-lg border border-white/10 bg-slate-950 px-2.5 font-mono text-xs text-slate-100 placeholder-slate-500 outline-none focus:border-cyan-500"}),o.jsxs("button",{type:"button",onClick:q,className:"flex h-8 items-center gap-1 rounded-lg border border-cyan-500/40 bg-cyan-500/15 px-2.5 text-xs font-medium text-cyan-200 hover:bg-cyan-500/25",children:[o.jsx(gh,{className:"h-3.5 w-3.5"})," Add"]})]}),e.mutations.map(P=>o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-emerald-500/40 bg-emerald-500/15 px-2 py-1 font-mono text-[0.75rem] text-emerald-200",children:[P,o.jsx("button",{type:"button",onClick:()=>r({type:"remove_mutation",notation:P}),className:"text-emerald-300 hover:text-white","aria-label":`Remove ${P}`,children:o.jsx(Xi,{className:"h-3 w-3"})})]},P)),e.mutations.length>0&&o.jsx("button",{type:"button",onClick:()=>r({type:"set_mutations_input",raw:""}),className:"rounded-md px-2 py-1 text-[0.6875rem] text-slate-400 hover:bg-white/[0.06] hover:text-slate-200",children:"Clear all"})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2 font-mono text-[0.75rem]",children:[o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-white/10 bg-slate-950/70 px-2 py-1",children:[o.jsx(ar,{className:"h-3 w-3 text-slate-400"}),o.jsx("span",{className:"text-slate-400",children:"Slice"}),o.jsx("input",{type:"number",min:1,max:Math.max(1,e.sequence.length),value:e.sliceStart,onChange:P=>r({type:"set_slice",start:Number(P.target.value)||1,end:e.sliceEnd}),className:"w-14 rounded border border-white/10 bg-slate-900 px-1.5 py-0.5 text-slate-200"}),o.jsx("span",{className:"text-slate-500",children:"–"}),o.jsx("input",{type:"number",min:e.sliceStart,max:Math.max(1,e.sequence.length),value:e.sliceEnd,onChange:P=>r({type:"set_slice",start:e.sliceStart,end:Number(P.target.value)||e.sequence.length}),className:"w-14 rounded border border-white/10 bg-slate-900 px-1.5 py-0.5 text-slate-200"}),o.jsxs("span",{className:"text-[0.6875rem] text-slate-500",children:["/ ",e.sequence.length," aa"]})]}),d&&o.jsxs("div",{className:"flex items-center gap-1 font-sans",children:[d.hasRef&&o.jsxs("button",{type:"button",onClick:()=>d.syncPeptideFromChain("reference"),title:"Load amino-acid sequence from active 3D Reference chain",className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-sky-300 hover:border-sky-400/40",children:[o.jsx(gp,{className:"h-3 w-3"})," Sync Ref"]}),d.hasMob&&o.jsxs("button",{type:"button",onClick:()=>d.syncPeptideFromChain("mobile"),title:"Load amino-acid sequence from active 3D Comparison chain",className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-emerald-300 hover:border-emerald-400/40",children:[o.jsx(gp,{className:"h-3 w-3"})," Sync Mob"]})]}),o.jsxs("button",{type:"button",onClick:()=>{S(e.sequence),_(P=>!P)},className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 font-sans text-[0.6875rem] text-slate-300 hover:border-white/25",children:[o.jsx(T6,{className:"h-3 w-3"})," ",g?"Hide Seq":"Edit Seq"]})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2",children:[z.length>0&&T!==null&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-[0.6875rem] font-medium text-amber-300",children:["At #",T,":"]}),z.map(P=>o.jsxs("button",{type:"button",onClick:()=>r({type:"add_mutation",notation:P.notation}),className:"rounded-md border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 font-mono text-[0.6875rem] text-amber-200 hover:bg-amber-500/20",children:["+",P.notation," ",o.jsxs("span",{className:"font-sans text-amber-300/75",children:["(",P.label,")"]})]},P.notation))]}),j&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"ml-1 text-[0.6875rem] text-slate-500",children:"CA II Active Site:"}),["H94A","T199V","H96A","H119A"].map(P=>o.jsxs("button",{type:"button",onClick:()=>r({type:"add_mutation",notation:P}),className:"rounded-md border border-white/10 bg-slate-900 px-2 py-0.5 font-mono text-[0.6875rem] text-slate-300 hover:border-emerald-500/50 hover:text-emerald-200",children:["+",P]},P))]})]}),g&&o.jsxs("div",{className:"space-y-1.5 border-t border-white/[0.06] pt-2",children:[o.jsx("textarea",{rows:3,value:y,onChange:P=>S(P.target.value),placeholder:"Paste 1-letter protein/peptide sequence…",className:"w-full rounded-lg border border-white/10 bg-slate-950 p-2 font-mono text-xs text-slate-100 outline-none focus:border-sky-500"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:()=>_(!1),className:"rounded-md px-2.5 py-1 text-xs text-slate-400 hover:text-white",children:"Cancel"}),o.jsx("button",{type:"button",onClick:()=>{r({type:"set_sequence",sequence:y}),_(!1)},className:"rounded-md bg-sky-500 px-3 py-1 text-xs font-semibold text-slate-950 hover:bg-sky-400",children:"Apply Sequence"})]})]}),O.length>0&&o.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto border-t border-white/[0.06] pt-2 pb-0.5",children:[o.jsx("span",{className:"mr-1 shrink-0 font-mono text-[0.6875rem] text-slate-500",children:"Window:"}),O.map(P=>{const $=P.pos===T;return o.jsxs("button",{type:"button",onClick:()=>V(P.pos,!0),title:`Residue ${P.pos}: WT ${P.wt}${P.mutated?` → ${P.eng}`:""} (click to focus in 3D)`,className:`flex min-w-7 shrink-0 flex-col items-center rounded-md border px-1 py-0.5 font-mono transition ${$?"border-amber-400 bg-amber-500/20 text-amber-200":P.mutated?"border-emerald-400/50 bg-emerald-500/15 text-emerald-200":"border-white/[0.06] bg-black/25 text-slate-300 hover:border-sky-400/40"}`,children:[o.jsx("span",{className:"text-[0.5625rem] text-slate-500",children:P.pos}),o.jsx("span",{className:"text-[0.75rem] font-semibold",children:P.mutated?`${P.wt}→${P.eng}`:P.wt})]},P.pos)})]})]}),s&&o.jsx("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/10 px-3 py-2 font-mono text-xs text-rose-200",children:s}),n&&o.jsxs("div",{className:"grid grid-cols-1 gap-3 @4xl:grid-cols-2 @6xl:grid-cols-12",children:[o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex items-center justify-between font-mono text-[0.75rem]",children:[o.jsx("span",{className:"font-semibold text-cyan-300",children:"WT vs ENGINEERED DELTAS"}),o.jsxs("span",{className:"text-slate-400",children:[n.engineered.length," aa"]})]}),o.jsx("div",{className:"overflow-x-auto",children:o.jsxs("table",{className:"w-full font-mono text-[0.75rem]",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-white/10 text-slate-500",children:[o.jsx("th",{className:"py-1.5 text-left",children:"Metric"}),o.jsx("th",{className:"py-1.5 text-right",children:"WT"}),o.jsx("th",{className:"py-1.5 text-right",children:"Eng"}),o.jsx("th",{className:"py-1.5 text-right",children:"Δ"})]})}),o.jsxs("tbody",{className:"divide-y divide-white/[0.06] text-slate-200",children:[o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"Avg MW (Da)"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.mwAverageDa.toFixed(1)}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.mwAverageDa.toFixed(1)}),o.jsxs("td",{className:"py-1.5 text-right text-cyan-300",children:[n.deltas.mwAverageDa>=0?"+":"",n.deltas.mwAverageDa.toFixed(1)]})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"Mono MW (Da)"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.mwMonoisotopicDa.toFixed(1)}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.mwMonoisotopicDa.toFixed(1)}),o.jsxs("td",{className:"py-1.5 text-right text-cyan-300",children:[n.deltas.mwMonoisotopicDa>=0?"+":"",n.deltas.mwMonoisotopicDa.toFixed(1)]})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"pI"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.pi.toFixed(2)}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.pi.toFixed(2)}),o.jsxs("td",{className:"py-1.5 text-right text-amber-300",children:[n.deltas.pi>=0?"+":"",n.deltas.pi.toFixed(3)]})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"Charge pH 7.4"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.chargeAtPh74.toFixed(2)}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.chargeAtPh74.toFixed(2)}),o.jsxs("td",{className:"py-1.5 text-right text-emerald-300",children:[n.deltas.chargeAtPh74>=0?"+":"",n.deltas.chargeAtPh74.toFixed(2)]})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"GRAVY"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.gravy.toFixed(3)}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.gravy.toFixed(3)}),o.jsxs("td",{className:"py-1.5 text-right text-violet-300",children:[n.deltas.gravy>=0?"+":"",n.deltas.gravy.toFixed(3)]})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"ε280 (red/ox)"}),o.jsx("td",{className:"py-1.5 text-right",children:n.wildType.extinctionReduced}),o.jsx("td",{className:"py-1.5 text-right",children:n.engineered.extinctionCystine}),o.jsx("td",{className:"py-1.5 text-right text-slate-400",children:"M⁻¹cm⁻¹"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"py-1.5 text-slate-400",children:"Steric ΔV"}),o.jsx("td",{className:"py-1.5 text-right",children:"—"}),o.jsx("td",{className:"py-1.5 text-right",children:"—"}),o.jsxs("td",{className:"py-1.5 text-right text-amber-300",children:[n.deltas.stericVolumeDeltaA3>=0?"+":"",n.deltas.stericVolumeDeltaA3.toFixed(1)," ų"]})]})]})]})}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsx(bs,{label:"Aromatic Fraction",value:`${(n.engineered.aromaticFraction*100).toFixed(1)}%`,hint:"Trp + Tyr + Phe"}),o.jsx(bs,{label:"Hydrophobic",value:`${(n.engineered.hydrophobicFraction*100).toFixed(1)}%`,hint:"Nonpolar residues"})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx(Ca,{insight:yA(n.engineered.pi,n.engineered.chargeAtPh74),compact:!0}),o.jsx(Ca,{insight:_A(n.engineered.gravy),compact:!0})]}),o.jsxs("p",{className:"text-[0.6875rem] leading-relaxed text-slate-400",children:[yA(n.engineered.pi,n.engineered.chargeAtPh74).explanation,c?"":` ${_A(n.engineered.gravy).explanation}`]})]}),o.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @6xl:col-span-5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsx("span",{className:"font-semibold text-cyan-300",children:"pH 0–14 TITRATION & KYTE-DOOLITTLE PROFILE"}),o.jsxs("span",{className:"flex items-center gap-3 text-[0.6875rem]",children:[o.jsx("span",{className:"text-sky-400",children:"— WT"}),o.jsx("span",{className:"text-emerald-400",children:"-- Engineered"})]})]}),o.jsx(fL,{curve:n.titrationCurve}),o.jsx(pL,{profile:n.gravyProfile,focusedPos:T,onPickPos:P=>V(P,!0)})]}),o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @4xl:col-span-2 @6xl:col-span-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("span",{className:"font-mono text-[0.75rem] font-semibold text-violet-300",children:["3D <5.0 Å CONTACT SHELL",T!=null?` (RES ${T})`:""]}),d&&n.local3dContacts.length>0&&o.jsxs("button",{type:"button",onClick:()=>d.highlightIn3D(n.local3dContacts.map(P=>P.seqId),`Peptide Shell #${T??""}`,{focusSeqId:T??void 0,style:"pocket"}),className:"inline-flex items-center gap-1 rounded-md border border-violet-400/40 bg-violet-500/15 px-2 py-0.5 text-[0.6875rem] font-medium text-violet-200 hover:bg-violet-500/25",children:[o.jsx(_s,{className:"h-3 w-3"})," Show in 3D"]})]}),n.local3dContacts.length===0?o.jsx("div",{className:"flex flex-1 flex-col justify-center gap-2 rounded-lg border border-white/[0.06] bg-black/20 p-3 text-slate-400",children:o.jsx("p",{children:"Select a residue (e.g. click in the 3D Viewer or sequence window above) or apply a mutation like H94A to inspect its 3D <5.0 Å neighbor shell."})}):o.jsx("div",{className:"max-h-60 space-y-1.5 overflow-y-auto pr-0.5 font-mono text-[0.75rem]",children:n.local3dContacts.map(P=>o.jsxs("button",{type:"button",onClick:()=>V(P.seqId,!0),className:`flex w-full items-center justify-between rounded-lg border px-2.5 py-1.5 text-left transition ${P.seqId===T?"border-amber-400/60 bg-amber-500/10":"border-white/[0.07] bg-black/30 hover:border-cyan-400/50"}`,children:[o.jsxs("span",{className:"text-slate-200",children:[P.resName3," ",P.seqId]}),o.jsxs("span",{className:"text-emerald-300",children:[P.distanceAngstrom.toFixed(2)," Å"]})]},`${P.seqId}-${P.resName3}`))}),d&&T!==null&&o.jsxs("div",{className:"mt-auto flex flex-wrap gap-1.5 border-t border-white/[0.06] pt-2",children:[o.jsxs("button",{type:"button",onClick:()=>d.focusIn3D(T,{centerCamera:!0,openViewer:"activate"}),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2 py-1 text-[0.6875rem] font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Ur,{className:"h-3 w-3"})," Focus #",T," in 3D"]}),o.jsxs("button",{type:"button",onClick:()=>d.sendResidueToCrispr(T),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-emerald-400/40",children:[o.jsx(Fs,{className:"h-3 w-3 text-emerald-300"})," Codon #",T]})]})]})]})]})}function fL({curve:e}){const[r,n]=C.useState(null);if(e.length<2)return null;const s=360,i=110,c=Math.min(...e.flatMap(E=>[E.wtCharge,E.engCharge]),-10),d=Math.max(...e.flatMap(E=>[E.wtCharge,E.engCharge]),10),f=Math.max(1,d-c),p=E=>28+E/14*(s-40),b=E=>i-18-(E-c)/f*(i-28),x=e.map((E,T)=>`${T===0?"M":"L"}${p(E.ph).toFixed(1)},${b(E.wtCharge).toFixed(1)}`).join(" "),g=e.map((E,T)=>`${T===0?"M":"L"}${p(E.ph).toFixed(1)},${b(E.engCharge).toFixed(1)}`).join(" "),_=b(0),y=p(7.4),S=r!==null?e[r]:null,k=E=>{const T=E.currentTarget.getBoundingClientRect(),j=(E.clientX-T.left)/T.width*s,q=Math.max(0,Math.min(14,(j-28)/(s-40)*14));let z=0,O=1/0;e.forEach((V,P)=>{const $=Math.abs(V.ph-q);$<O&&(O=$,z=P)}),n(z)};return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between font-mono text-[0.6875rem] text-slate-400",children:[o.jsx("span",{children:"Net Charge vs pH (0–14)"}),S?o.jsxs("span",{className:"text-slate-200",children:["pH ",S.ph.toFixed(1)," · WT ",S.wtCharge.toFixed(2)," · Eng ",S.engCharge.toFixed(2)]}):o.jsx("span",{children:"Hover curve to inspect"})]}),o.jsxs("svg",{viewBox:`0 0 ${s} ${i}`,onMouseMove:k,onMouseLeave:()=>n(null),className:"w-full cursor-crosshair rounded-lg border border-white/[0.06] bg-black/35",children:[o.jsx("line",{x1:28,y1:_,x2:s-12,y2:_,stroke:"#334155",strokeDasharray:"3,3",strokeWidth:1}),o.jsx("line",{x1:y,y1:6,x2:y,y2:i-14,stroke:"#f59e0b",strokeDasharray:"2,2",strokeWidth:1}),o.jsx("path",{d:x,fill:"none",stroke:"#38bdf8",strokeWidth:1.8}),o.jsx("path",{d:g,fill:"none",stroke:"#34d399",strokeWidth:1.6,strokeDasharray:"4,2"}),S&&o.jsxs(o.Fragment,{children:[o.jsx("line",{x1:p(S.ph),y1:6,x2:p(S.ph),y2:i-14,stroke:"rgba(148,163,184,0.45)",strokeWidth:1}),o.jsx("circle",{cx:p(S.ph),cy:b(S.wtCharge),r:3,fill:"#38bdf8"}),o.jsx("circle",{cx:p(S.ph),cy:b(S.engCharge),r:3,fill:"#34d399"})]}),o.jsx("text",{x:6,y:_+3,fill:"#64748b",fontSize:8,fontFamily:"monospace",children:"0"}),o.jsx("text",{x:y+3,y:13,fill:"#fbbf24",fontSize:8,fontFamily:"monospace",children:"pH 7.4"}),o.jsx("text",{x:28,y:i-4,fill:"#64748b",fontSize:8,fontFamily:"monospace",children:"0"}),o.jsx("text",{x:s/2,y:i-4,fill:"#64748b",fontSize:8,fontFamily:"monospace",children:"7"}),o.jsx("text",{x:s-20,y:i-4,fill:"#64748b",fontSize:8,fontFamily:"monospace",children:"14"})]})]})}function pL({profile:e,focusedPos:r,onPickPos:n}){const[s,i]=C.useState(null);if(e.length<2)return null;const c=360,d=88,f=S=>10+S/Math.max(1,e.length-1)*(c-20),p=S=>d/2-S/5*(d/2-10),b=e.map((S,k)=>`${k===0?"M":"L"}${f(k).toFixed(1)},${p(S.wtScore).toFixed(1)}`).join(" "),x=e.map((S,k)=>`${k===0?"M":"L"}${f(k).toFixed(1)},${p(S.engScore).toFixed(1)}`).join(" "),g=s!==null?e[s]:null,_=r!==null?e.findIndex(S=>S.index===r):-1,y=S=>{const k=S.currentTarget.getBoundingClientRect(),E=(S.clientX-k.left)/k.width*c,T=Math.max(0,Math.min(1,(E-10)/(c-20)));return Math.round(T*(e.length-1))};return o.jsxs("div",{className:"space-y-1",children:[o.jsxs("div",{className:"flex items-center justify-between font-mono text-[0.6875rem] text-slate-400",children:[o.jsx("span",{children:"Kyte-Doolittle Hydropathy"}),g?o.jsxs("span",{className:"text-slate-200",children:["Res ",g.index," (",g.res,") · WT ",g.wtScore.toFixed(2)," · Eng ",g.engScore.toFixed(2)]}):o.jsx("span",{children:"Click profile to focus 3D residue"})]}),o.jsxs("svg",{viewBox:`0 0 ${c} ${d}`,onMouseMove:S=>i(y(S)),onMouseLeave:()=>i(null),onClick:S=>{const k=y(S),E=e[k];E&&n(E.index)},className:"w-full cursor-pointer rounded-lg border border-white/[0.06] bg-black/35",children:[o.jsx("line",{x1:10,y1:d/2,x2:c-10,y2:d/2,stroke:"#1e293b",strokeWidth:1}),o.jsx("path",{d:b,fill:"none",stroke:"#38bdf8",strokeWidth:1.3,opacity:.85}),o.jsx("path",{d:x,fill:"none",stroke:"#34d399",strokeWidth:1.3,strokeDasharray:"3,2",opacity:.95}),_>=0&&o.jsx("line",{x1:f(_),y1:4,x2:f(_),y2:d-4,stroke:"#fbbf24",strokeWidth:1.4}),g&&s!==null&&o.jsx("circle",{cx:f(s),cy:p(g.engScore),r:3,fill:"#fbbf24"})]})]})}const gL={all:"All Tiers","tier0-core":"Tier 0 · Instant Wasm/Rust","tier1-wasm":"Tier 1 · Browser Engine","tier2-compute":"Tier 2 · External GPU/HPC",database:"Public Databases"},bL=JSON.stringify({schemaVersion:"1.0.0",id:"org.lab.custom-scorer",name:"Custom Scoring Adapter",version:"0.1.0",category:"Cheminformatics ML",tier:"tier2-compute",license:"MIT",commercialSafe:!0,ruoRequired:!0,description:"Example user add-on wrapping a custom scoring script on a connected Compute Node.",computeAdapterId:"ml_property",mcpTools:[{name:"run_custom_ml_scorer",description:"Score candidate SMILES with custom Chemprop/DeepChem checkpoint.",computeToolId:"ml_property",inputSchema:{type:"object",properties:{smiles:{type:"string",description:"Input SMILES"}},required:["smiles"]}}]},null,2);function xL({onOpenComputeNodes:e,onOpenMcpServer:r,onOpenToolTab:n}){const[s,i]=C.useState(()=>Jd()),[c,d]=C.useState(""),[f,p]=C.useState("all"),[b,x]=C.useState(!1),[g,_]=C.useState(bL),[y,S]=C.useState(null);C.useEffect(()=>(i(Jd()),gD(()=>i(Jd()))),[]);const k=C.useMemo(()=>{const T=c.trim().toLowerCase();return s.filter(j=>f!=="all"&&j.tier!==f?!1:T?`${j.name} ${j.category} ${j.license} ${j.description}`.toLowerCase().includes(T):!0)},[s,c,f]),E=()=>{S(null);try{yD(g),x(!1)}catch(T){S(T instanceof Error?T.message:String(T))}};return o.jsx("div",{className:"@container h-full min-h-0 overflow-y-auto p-3 text-xs @xl:p-4",children:o.jsxs("div",{className:"mx-auto max-w-6xl space-y-4",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold text-slate-100",children:[o.jsx(Lp,{className:"h-4 w-4 text-sky-400"}),"Biochemistry Plugins & Add-ons"]}),o.jsxs("p",{className:"mt-1 text-slate-400",children:["Manage built-in open-source engines, external GPU adapters, database connectors, and custom"," ",o.jsx("code",{className:"text-sky-300",children:"synlexa-plugin.v1"})," add-ons. Enabled plugin tools auto-wire into MCP and the AI Assistant."]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(Oe,{size:"sm",variant:"secondary",onClick:e,children:"Configure GPU Nodes"}),o.jsx(Oe,{size:"sm",variant:"secondary",onClick:r,children:"View Exposed MCP Tools"}),o.jsx(Oe,{size:"sm",variant:"primary",icon:o.jsx(gh,{className:"h-3.5 w-3.5"}),onClick:()=>x(T=>!T),children:"Install Custom Manifest"})]})]}),b&&o.jsxs(yt,{className:"space-y-2.5 p-3.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-semibold text-slate-200",children:"Install Custom Plugin (`synlexa-plugin.v1`)"}),o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>x(!1),children:"Close"})]}),o.jsx(Pp,{rows:10,value:g,onChange:T=>_(T.target.value),className:"font-mono text-[0.6875rem]"}),y&&o.jsx("div",{className:"rounded border border-rose-500/40 bg-rose-500/10 px-2.5 py-1.5 text-rose-200",children:y}),o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-[0.6875rem] text-slate-500",children:["Enforces ",o.jsx("code",{className:"text-slate-300",children:"ruoRequired: true"})," and declarative schema validation."]}),o.jsx(Oe,{size:"sm",variant:"primary",onClick:E,children:"Validate & Install"})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs("div",{className:"relative min-w-44 flex-1 @lg:max-w-xs",children:[o.jsx(Gr,{className:"pointer-events-none absolute top-2.5 left-2.5 h-3.5 w-3.5 text-slate-500"}),o.jsx(Dn,{value:c,onChange:T=>d(T.target.value),placeholder:"Filter tools, categories, licenses…",className:"pl-8"})]}),o.jsx("div",{className:"flex flex-wrap gap-1",children:["all","tier0-core","tier1-wasm","tier2-compute","database"].map(T=>o.jsx("button",{type:"button",onClick:()=>p(T),className:`rounded-lg border px-2.5 py-1.5 text-xs transition ${f===T?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-white/[0.03] text-slate-300 hover:border-white/20"}`,children:gL[T]},T))})]}),o.jsx("div",{className:"grid grid-cols-1 gap-3 @2xl:grid-cols-2 @5xl:grid-cols-3",children:k.map(T=>o.jsxs(yt,{className:"flex flex-col justify-between gap-3 p-3.5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"font-semibold text-slate-100",children:T.name}),T.topPick&&o.jsxs(It,{tone:"accent",children:[o.jsx(Gs,{className:"h-2.5 w-2.5"})," Top 8"]})]}),o.jsxs("div",{className:"mt-0.5 text-[0.6875rem] text-slate-400",children:[T.category," · v",T.version]})]}),o.jsx($r,{checked:T.enabled,onChange:j=>H3(T.id,j),label:`Toggle ${T.name}`})]}),o.jsx("p",{className:"text-slate-300 leading-relaxed",children:T.description}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs(It,{tone:T.commercialSafe?"good":"warn",children:[T.commercialSafe?o.jsx(Ki,{className:"h-3 w-3"}):o.jsx(Gc,{className:"h-3 w-3"}),T.license]}),o.jsx(It,{tone:"neutral",children:T.tier}),T.requiresGpu&&o.jsx(It,{tone:"warn",children:"GPU recommended"}),T.mcpTools&&T.mcpTools.length>0&&o.jsxs(It,{tone:"accent",children:[T.mcpTools.length," MCP tool"]})]}),T.installHint&&o.jsx("div",{className:"rounded border border-white/[0.06] bg-[#070b12] px-2 py-1 font-mono text-[0.6875rem] text-slate-400",children:T.installHint})]}),o.jsxs("div",{className:"flex items-center justify-between border-t border-white/[0.06] pt-2 text-[0.6875rem] text-slate-500",children:[o.jsx("span",{className:"truncate font-mono",children:T.id}),o.jsxs("div",{className:"flex items-center gap-2",children:[n&&T.id==="org.synlexa.molstar"&&o.jsx("button",{type:"button",onClick:()=>n("viewer"),className:"text-emerald-300 hover:text-emerald-200",children:"Open 3D"}),n&&T.id==="org.synlexa.rdkit-wasm"&&o.jsx("button",{type:"button",onClick:()=>n("chemistry"),className:"text-emerald-300 hover:text-emerald-200",children:"Open Ligands"}),n&&T.id==="org.synlexa.gemmi-core"&&o.jsx("button",{type:"button",onClick:()=>n("ramachandran"),className:"text-emerald-300 hover:text-emerald-200",children:"Open Tools"}),n&&T.id==="org.synlexa.workflows"&&o.jsx("button",{type:"button",onClick:()=>n("workflow"),className:"text-emerald-300 hover:text-emerald-200",children:"Open Canvas"}),n&&T.tier==="tier2-compute"&&T.id!=="org.synlexa.workflows"&&o.jsx("button",{type:"button",onClick:()=>n("compute"),className:"text-emerald-300 hover:text-emerald-200",children:"GPU Runner"}),T.homepage&&o.jsxs("a",{href:T.homepage,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1 text-sky-300 hover:text-sky-200",children:["Source ",o.jsx(Kd,{className:"h-3 w-3"})]}),!T.builtin&&o.jsx("button",{type:"button",onClick:()=>_D(T.id),className:"text-rose-300 hover:text-rose-200",title:"Uninstall custom plugin",children:o.jsx(Wi,{className:"h-3.5 w-3.5"})})]})]})]},T.id))})]})})}const Er=260,Or=28,Ip=Er-Or*2,Jf=360;function Qn(e){return Or+(e+180)/360*Ip}function Jn(e){return Or+(180-e)/360*Ip}function yL(e){if(e.region==="outlier")return"#fb7185";switch(e.secondary){case"helix":return"#38bdf8";case"sheet":return"#34d399";default:return"#fbbf24"}}function _L({refLabel:e,refChain:r,mobLabel:n,mobChain:s,activeSource:i,onChangeSource:c,result:d,error:f,focusedSeqId:p,onFocusResidue:b,simpleMode:x=!1,bridge:g}){const[_,y]=C.useState(null),[S,k]=C.useState(null),[E,T]=C.useState("all"),[j,q]=C.useState(8),[z,O]=C.useState(!1),[V,P]=C.useState(!1),$=C.useRef(null),H=C.useMemo(()=>{const I=new Map;for(const J of d?.residues??[])I.set(J.seqId,J);return I},[d]),Z=C.useMemo(()=>{if(!d)return null;const I=Math.max(1,d.residueCount),{helix:J,sheet:ge,loop:le}=d.secondaryCounts,{favored:D,allowed:ae,outlier:pe}=d.regionCounts,Ae=Math.max(1,D+ae+pe);return{helixPct:J/I*100,sheetPct:ge/I*100,loopPct:le/I*100,favoredPct:D/Ae*100,allowedPct:ae/Ae*100,outlierPct:pe/Ae*100,classified:Ae}},[d]),G=C.useMemo(()=>(d?.residues??[]).filter(I=>I.phiDeg===null||I.psiDeg===null?!1:I.seqId===p||E==="all"?!0:E==="outlier"?I.region==="outlier":I.secondary===E),[d,E,p]),K=C.useMemo(()=>(d?.residues??[]).filter(I=>I.region==="outlier"),[d]),we=C.useMemo(()=>{if(!d)return[];const I=z?12:4;return d.contactPairs.filter(([J,ge,le])=>le<=j&&Math.abs(J-ge)>=I)},[d,j,z]),Se=C.useMemo(()=>p!==null?H.get(p)??null:null,[H,p]),Q=C.useMemo(()=>p===null?[]:we.filter(([I,J])=>I===p||J===p).sort((I,J)=>I[2]-J[2]),[we,p]),F=C.useMemo(()=>{if(!d||d.residues.length===0)return{min:1,max:1};let I=d.residues[0].seqId,J=d.residues[0].seqId;for(const ge of d.residues)ge.seqId<I&&(I=ge.seqId),ge.seqId>J&&(J=ge.seqId);return{min:I,max:Math.max(I+1,J)}},[d]);C.useEffect(()=>{const I=$.current;if(!I)return;const J=I.getContext("2d");if(!J)return;const ge=Jf;if(J.fillStyle="#070a10",J.fillRect(0,0,ge,ge),!d||d.residues.length===0)return;const le=12,D=F.max-F.min,ae=pe=>le+(pe-F.min)/D*(ge-le*2);J.strokeStyle="rgba(148, 163, 184, 0.08)",J.lineWidth=1;for(let pe=Math.ceil(F.min/50)*50;pe<=F.max;pe+=50){const Ae=ae(pe);J.beginPath(),J.moveTo(Ae,le),J.lineTo(Ae,ge-le),J.moveTo(le,Ae),J.lineTo(ge-le,Ae),J.stroke()}J.strokeStyle="rgba(148, 163, 184, 0.25)",J.lineWidth=1.25,J.beginPath(),J.moveTo(le,le),J.lineTo(ge-le,ge-le),J.stroke();for(const[pe,Ae,Ne]of we){const Re=ae(pe),$e=ae(Ae),Ce=Math.max(0,Math.min(1,(j-Ne)/Math.max(1,j-3.5)));J.fillStyle=Ne<=5.5?`rgba(52, 211, 153, ${.6+Ce*.4})`:`rgba(56, 189, 248, ${.4+Ce*.45})`,J.fillRect(Re-1.6,$e-1.6,3.4,3.4),J.fillRect($e-1.6,Re-1.6,3.4,3.4)}if(p!==null){const pe=ae(p);J.strokeStyle="rgba(251, 191, 36, 0.8)",J.lineWidth=1.5,J.beginPath(),J.moveTo(pe,0),J.lineTo(pe,ge),J.moveTo(0,pe),J.lineTo(ge,pe),J.stroke()}},[d,we,j,F,p]);const he=(I,J=!1)=>{b(I),J&&g?.focusIn3D(I,{centerCamera:!0})},W=(I,J)=>{if(!d||we.length===0)return;const ge=I.currentTarget.getBoundingClientRect(),le=ge.width,D=12/Jf,ae=le*D,pe=F.max-F.min,Ae=F.min+(I.clientX-ge.left-ae)/Math.max(1,le-ae*2)*pe,Ne=F.min+(I.clientY-ge.top-ae)/Math.max(1,le-ae*2)*pe;let Re=null,$e=160;for(const Ce of we){const Ue=(Ce[0]-Ae)**2+(Ce[1]-Ne)**2,be=(Ce[1]-Ae)**2+(Ce[0]-Ne)**2,bt=Math.min(Ue,be);bt<$e&&($e=bt,Re=Ce)}k(Re),J&&Re&&he(Re[0],!0)},me=!!(e||n);return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:g,title:"Ramachandran Geometry & Cα Contact Map",subtitle:"Inspect backbone dihedral angles (φ, ψ), secondary structure packing, conformational outliers, and 3D tertiary contacts.",icon:o.jsx(Qo,{className:"h-4 w-4"}),guideOpen:V,onToggleGuide:()=>P(I=>!I)}),o.jsx(Qi,{open:V,title:"How Ramachandran & Cα Contact Analysis Works",summary:"Every protein residue’s backbone conformation is defined by two dihedral torsion angles: φ (N–Cα) and ψ (Cα–C). Plotting φ vs ψ reveals well-packed α-helices and β-sheets versus strained outliers.",steps:["Switch between Reference (experimental) and Mobile (predicted) structures in the toolbar below.","Filter the Ramachandran plot by Helix, Sheet, Loop, or Outliers Only; click any dot to inspect its φ/ψ angles and sync the 3D Viewer.","Use the Cα–Cα Contact Map to inspect folded tertiary contacts (distant residues in sequence that touch in 3D space). Adjust the Å cutoff or toggle Long-Range contacts."],connectionTip:"Every click on a Ramachandran dot, outlier chip, or contact neighbor synchronizes your focused residue across the 3D Viewer, Sequence Track, Peptide, and CRISPR tabs. Use 'Highlight Outliers in 3D' or 'Highlight Contacts in 3D' to light them up directly on the 3D model.",glossary:[{term:"Favored / Allowed / Outlier",desc:"Empirical backbone angle regions; well-refined proteins typically have ≥ 90% in favored zones (Gly and Pro can legitimately occupy broader regions)."},{term:"Cα–Cα Contact (≤ 8 Å)",desc:"Residues separated by at least 4 sequence positions whose alpha carbons sit within 8 Å in 3D — defining secondary & tertiary fold packing."},{term:"Long-Range (|i−j| ≥ 12)",desc:"Contacts between distant parts of the chain that reveal global domain folding rather than local helix turns."}]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border border-white/[0.08] bg-[#0b1018] p-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 font-mono text-xs",children:[o.jsxs("button",{type:"button",disabled:!e,onClick:()=>c("reference"),className:`rounded-lg border px-2.5 py-1 transition disabled:opacity-40 ${i==="reference"?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-slate-950 text-slate-400 hover:text-slate-200"}`,children:["Ref: ",e||"None"," (",r||"?",")"]}),o.jsxs("button",{type:"button",disabled:!n,onClick:()=>c("mobile"),className:`rounded-lg border px-2.5 py-1 transition disabled:opacity-40 ${i==="mobile"?"border-emerald-400/50 bg-emerald-500/20 text-emerald-200":"border-white/10 bg-slate-950 text-slate-400 hover:text-slate-200"}`,children:["Mob: ",n||"None"," (",s||"?",")"]})]}),o.jsx("div",{className:"flex flex-wrap items-center gap-1",children:[["all","All"],["helix","α-Helix"],["sheet","β-Sheet"],["loop","Loop"],["outlier",`Outliers (${K.length})`]].map(([I,J])=>o.jsx("button",{type:"button",onClick:()=>T(I),className:`rounded-md border px-2 py-1 font-mono text-[0.6875rem] transition ${E===I?"border-cyan-400/50 bg-cyan-500/20 text-cyan-200":"border-white/10 bg-slate-900/70 text-slate-400 hover:text-slate-200"}`,children:J},I))})]}),f&&o.jsx("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/10 px-3 py-2 font-mono text-xs text-rose-200",children:f}),!me&&!d&&!f&&o.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 rounded-xl border border-white/[0.08] bg-[#0b1018] p-6 text-center",children:[o.jsx(Qo,{className:"h-8 w-8 text-slate-500"}),o.jsx("div",{className:"text-sm font-medium text-slate-200",children:"No structure loaded for Ramachandran analysis"}),o.jsx("p",{className:"max-w-md text-xs text-slate-400",children:"Load a PDB or mmCIF structure to compute backbone φ/ψ dihedral angles and tertiary Cα–Cα contact maps."}),g&&o.jsxs("button",{type:"button",onClick:g.loadExample,className:"inline-flex items-center gap-1.5 rounded-lg bg-sky-500 px-3.5 py-2 text-xs font-semibold text-slate-950 hover:bg-sky-400",children:[o.jsx(Br,{className:"h-3.5 w-3.5"})," Load Carbonic Anhydrase II Example"]})]}),me&&!d&&!f&&o.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-white/[0.08] bg-[#0b1018] p-6 font-mono text-xs text-slate-500",children:"Computing backbone φ/ψ dihedral angles and Cα–Cα contact distances in Wasm…"}),d&&Z&&o.jsxs("div",{className:"grid grid-cols-1 gap-3 @3xl:grid-cols-2 @6xl:grid-cols-12",children:[o.jsxs("div",{className:"flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsx("span",{className:"font-semibold text-cyan-300",children:"RAMACHANDRAN PLOT"}),o.jsx("span",{className:"text-slate-300",children:_?`${_.resName3}${_.seqId} (φ ${_.phiDeg?.toFixed(0)}°, ψ ${_.psiDeg?.toFixed(0)}°)`:Se&&Se.phiDeg!==null?`Sel: ${Se.resName3}${Se.seqId} · ${Se.region}`:"Click any dot to focus in 3D"})]}),o.jsx("div",{className:"flex w-full justify-center",children:o.jsxs("svg",{viewBox:`0 0 ${Er} ${Er}`,className:"aspect-square w-full max-w-[330px] rounded-lg border border-white/10 bg-[#070a10]",children:[o.jsx("rect",{x:Qn(-165),y:Jn(175),width:Qn(-65)-Qn(-165),height:Jn(85)-Jn(175),rx:6,fill:"rgba(52, 211, 153, 0.12)",stroke:"rgba(52, 211, 153, 0.35)",strokeWidth:.85}),o.jsx("rect",{x:Qn(-105),y:Jn(-5),width:Qn(-35)-Qn(-105),height:Jn(-70)-Jn(-5),rx:6,fill:"rgba(56, 189, 248, 0.14)",stroke:"rgba(56, 189, 248, 0.38)",strokeWidth:.85}),o.jsx("rect",{x:Qn(35),y:Jn(65),width:Qn(95)-Qn(35),height:Jn(5)-Jn(65),rx:5,fill:"rgba(56, 189, 248, 0.09)",stroke:"rgba(56, 189, 248, 0.25)",strokeWidth:.85}),o.jsx("line",{x1:Qn(0),y1:Or,x2:Qn(0),y2:Er-Or,stroke:"rgba(148,163,184,0.25)",strokeDasharray:"2 2"}),o.jsx("line",{x1:Or,y1:Jn(0),x2:Er-Or,y2:Jn(0),stroke:"rgba(148,163,184,0.25)",strokeDasharray:"2 2"}),o.jsx("rect",{x:Or,y:Or,width:Ip,height:Ip,fill:"none",stroke:"rgba(51,65,85,0.85)"}),o.jsx("text",{x:Er/2,y:Er-7,textAnchor:"middle",fill:"#64748b",fontSize:"9",fontFamily:"monospace",children:"φ (deg) [-180 … +180]"}),o.jsx("text",{x:10,y:Er/2,textAnchor:"middle",fill:"#64748b",fontSize:"9",fontFamily:"monospace",transform:`rotate(-90 10 ${Er/2})`,children:"ψ (deg)"}),o.jsx("text",{x:Qn(-115),y:Jn(135),textAnchor:"middle",fill:"rgba(52,211,153,0.65)",fontSize:"8",fontFamily:"monospace",children:"β-sheet"}),o.jsx("text",{x:Qn(-70),y:Jn(-38),textAnchor:"middle",fill:"rgba(56,189,248,0.75)",fontSize:"8",fontFamily:"monospace",children:"α-helix"}),o.jsx("text",{x:Qn(65),y:Jn(35),textAnchor:"middle",fill:"rgba(56,189,248,0.55)",fontSize:"7",fontFamily:"monospace",children:"L-helix"}),G.map(I=>{const J=Qn(I.phiDeg),ge=Jn(I.psiDeg),le=I.seqId===p;return o.jsxs("g",{children:[le&&o.jsx("circle",{cx:J,cy:ge,r:7.5,fill:"none",stroke:"#fbbf24",strokeWidth:1.8}),o.jsx("circle",{cx:J,cy:ge,r:le?4.2:I.region==="outlier"?3.5:2.5,fill:yL(I),fillOpacity:le?1:.85,className:"cursor-pointer",onMouseEnter:()=>y(I),onMouseLeave:()=>y(null),onClick:()=>he(I.seqId,!0)})]},`${I.seqId}-${I.insCode}`)})]})}),o.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 font-mono text-[0.6875rem] text-slate-400",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-sky-400"})," Helix"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-emerald-400"})," Sheet"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-amber-400"})," Loop"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-rose-400"})," Outlier"]})]})]}),o.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsx("span",{className:"font-semibold text-cyan-300",children:"SECONDARY STRUCTURE & GEOMETRY"}),o.jsxs("span",{className:"text-slate-400",children:[d.residueCount," res"]})]}),o.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-cyan-500/25 bg-cyan-500/8 px-2.5 py-2 text-xs leading-relaxed text-cyan-100",children:[o.jsx(zy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-cyan-300"}),o.jsxs("span",{children:[Z.favoredPct>=90?`${Z.favoredPct.toFixed(1)}% of dihedral pairs sit in favored Ramachandran zones — typical of well-packed backbone geometry.`:`${Z.favoredPct.toFixed(1)}% favored (${d.regionCounts.outlier} outlier${d.regionCounts.outlier===1?"":"s"}). Click rose dots or outlier chips to inspect strained residues in 3D.`,x?"":" Click any residue dot or outlier below to jump in 3D."]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-slate-900",children:[o.jsx("div",{style:{width:`${Z.helixPct}%`},className:"bg-sky-400",title:`α-Helix ${Z.helixPct.toFixed(1)}%`}),o.jsx("div",{style:{width:`${Z.sheetPct}%`},className:"bg-emerald-400",title:`β-Sheet ${Z.sheetPct.toFixed(1)}%`}),o.jsx("div",{style:{width:`${Z.loopPct}%`},className:"bg-amber-400",title:`Loop / Turn ${Z.loopPct.toFixed(1)}%`})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2 font-mono text-xs",children:[o.jsxs("div",{className:"min-w-0 rounded-lg border border-white/[0.07] bg-black/25 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-sky-300",children:"α-Helix"}),o.jsxs("div",{className:"mt-0.5 font-bold text-slate-100",children:[Z.helixPct.toFixed(1),"%"]}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-500",children:[d.secondaryCounts.helix," res"]})]}),o.jsxs("div",{className:"min-w-0 rounded-lg border border-white/[0.07] bg-black/25 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-emerald-300",children:"β-Sheet"}),o.jsxs("div",{className:"mt-0.5 font-bold text-slate-100",children:[Z.sheetPct.toFixed(1),"%"]}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-500",children:[d.secondaryCounts.sheet," res"]})]}),o.jsxs("div",{className:"min-w-0 rounded-lg border border-white/[0.07] bg-black/25 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-amber-300",children:"Loop / Turn"}),o.jsxs("div",{className:"mt-0.5 font-bold text-slate-100",children:[Z.loopPct.toFixed(1),"%"]}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-500",children:[d.secondaryCounts.loop," res"]})]})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2 font-mono text-xs",children:[o.jsxs("div",{className:"min-w-0 rounded-lg border border-emerald-500/30 bg-emerald-500/10 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-emerald-300",children:"Favored"}),o.jsxs("div",{className:"mt-0.5 font-bold text-emerald-200",children:[Z.favoredPct.toFixed(1),"%"]}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-400",children:[d.regionCounts.favored," res"]})]}),o.jsxs("div",{className:"min-w-0 rounded-lg border border-sky-500/30 bg-sky-500/10 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-sky-300",children:"Allowed"}),o.jsxs("div",{className:"mt-0.5 font-bold text-sky-200",children:[Z.allowedPct.toFixed(1),"%"]}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-400",children:[d.regionCounts.allowed," res"]})]}),o.jsxs("div",{className:"min-w-0 rounded-lg border border-rose-500/30 bg-rose-500/10 p-2",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-rose-300",children:"Outliers"}),o.jsx("div",{className:"mt-0.5 font-bold text-rose-200",children:d.regionCounts.outlier}),o.jsxs("div",{className:"text-[0.6875rem] text-slate-400",children:[Z.outlierPct.toFixed(1),"%"]})]})]}),K.length>0&&o.jsxs("div",{className:"space-y-1.5 rounded-lg border border-rose-500/20 bg-rose-500/[0.04] p-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("span",{className:"font-mono text-[0.6875rem] font-medium text-rose-300",children:["Outliers (",K.length,"):"]}),g&&o.jsxs("button",{type:"button",onClick:()=>g.highlightIn3D(K.map(I=>I.seqId),"Ramachandran Outliers",{focusSeqId:K[0]?.seqId}),className:"inline-flex items-center gap-1 rounded-md border border-rose-400/40 bg-rose-500/15 px-2 py-0.5 text-[0.6875rem] font-medium text-rose-200 hover:bg-rose-500/25",children:[o.jsx(_s,{className:"h-3 w-3"})," Highlight Outliers in 3D"]})]}),o.jsx("div",{className:"flex flex-wrap gap-1 font-mono text-[0.6875rem]",children:K.slice(0,14).map(I=>o.jsxs("button",{type:"button",onClick:()=>he(I.seqId,!0),className:`rounded-md border px-2 py-0.5 transition ${I.seqId===p?"border-amber-400 bg-amber-400/20 text-amber-200":"border-rose-500/40 bg-rose-500/10 text-rose-200 hover:bg-rose-500/20"}`,children:[I.resName3,I.seqId]},`${I.seqId}-${I.insCode}`))})]}),Se&&o.jsxs("div",{className:"mt-auto space-y-2 rounded-lg border border-amber-400/30 bg-amber-500/[0.05] p-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("span",{className:"font-mono text-xs font-semibold text-amber-200",children:[Se.resName3," ",Se.seqId," (",Se.resCode1,")"]}),o.jsxs("span",{className:"font-mono text-[0.6875rem] text-slate-300",children:[Se.secondary," · ",Se.region]})]}),o.jsxs("div",{className:"flex flex-wrap gap-3 font-mono text-[0.6875rem] text-slate-300",children:[o.jsxs("span",{children:["φ = ",Se.phiDeg!==null?`${Se.phiDeg.toFixed(1)}°`:"terminal"]}),o.jsxs("span",{children:["ψ = ",Se.psiDeg!==null?`${Se.psiDeg.toFixed(1)}°`:"terminal"]}),o.jsxs("span",{children:["Contacts: ",Q.length]})]}),g&&o.jsxs("div",{className:"flex flex-wrap gap-1.5 pt-0.5",children:[o.jsxs("button",{type:"button",onClick:()=>g.focusIn3D(Se.seqId,{centerCamera:!0,openViewer:"activate"}),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2 py-1 text-[0.6875rem] font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Ur,{className:"h-3 w-3"})," Focus in 3D"]}),o.jsxs("button",{type:"button",onClick:()=>g.openTab("sequence"),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-sky-400/40",children:[o.jsx(Vo,{className:"h-3 w-3"})," Sequence Δd"]}),o.jsxs("button",{type:"button",onClick:()=>g.sendMutationToPeptide(`${Se.resCode1}${Se.seqId}A`,Se.seqId),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-emerald-400/40",children:[o.jsx(ar,{className:"h-3 w-3"})," Ala Scan in Peptide"]})]})]})]}),o.jsxs("div",{className:"@container flex flex-col gap-2.5 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3 @3xl:col-span-2 @6xl:col-span-4",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.75rem]",children:[o.jsxs("span",{className:"font-semibold text-emerald-300",children:["Cα–Cα CONTACT MAP (|i−j|≥",z?12:4,", ≤",j.toFixed(1)," Å)"]}),o.jsx("span",{className:"text-slate-300",children:S?`${S[0]}–${S[1]}: ${S[2].toFixed(2)} Å`:`${we.length} pairs`})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-white/[0.06] bg-black/25 px-2.5 py-1.5 text-[0.6875rem]",children:[o.jsxs("label",{className:"flex items-center gap-2 font-mono text-slate-300",children:[o.jsxs("span",{children:["Cutoff: ",j.toFixed(1)," Å"]}),o.jsx("input",{type:"range",min:5,max:8,step:.2,value:j,onChange:I=>q(Number(I.target.value)),className:"w-24 accent-emerald-400"})]}),o.jsx("button",{type:"button",onClick:()=>O(I=>!I),className:`rounded-md border px-2 py-0.5 font-mono transition ${z?"border-emerald-400/50 bg-emerald-500/20 text-emerald-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:z?"Long-Range |i−j|≥12":"All |i−j|≥4"})]}),o.jsxs("div",{className:"flex flex-col items-center gap-3 @lg:flex-row @lg:items-start",children:[o.jsx("canvas",{ref:$,width:Jf,height:Jf,onMouseMove:I=>W(I,!1),onClick:I=>W(I,!0),onMouseLeave:()=>k(null),className:"aspect-square w-full max-w-[280px] shrink-0 cursor-crosshair rounded-lg border border-white/10"}),o.jsxs("div",{className:"w-full min-w-0 flex-1 space-y-2 font-mono text-xs",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-300",children:p!==null?`Neighbors of ${Se?`${Se.resName3}${p}`:`Res ${p}`} (${Q.length})`:"Click plot or contact map to inspect tertiary neighbors."}),g&&Q.length>0&&o.jsx("button",{type:"button",onClick:()=>{const I=Q.map(([J,ge])=>J===p?ge:J);g.highlightIn3D(I,`Cα Contacts of #${p}`,{focusSeqId:p??void 0})},className:"rounded border border-emerald-400/40 bg-emerald-500/15 px-1.5 py-0.5 font-sans text-[0.6875rem] font-medium text-emerald-200 hover:bg-emerald-500/25",children:"Show in 3D"})]}),o.jsxs("div",{className:"grid max-h-56 grid-cols-1 gap-1 overflow-y-auto pr-0.5 @sm:grid-cols-2",children:[Q.slice(0,24).map(([I,J,ge],le)=>{const D=I===p?J:I,ae=H.get(D);return o.jsxs("button",{type:"button",onClick:()=>he(D,!0),className:"flex items-center justify-between gap-1.5 rounded-lg border border-white/[0.08] bg-black/30 px-2 py-1 text-left text-[0.6875rem] text-slate-200 hover:border-emerald-400/50 hover:text-emerald-200",children:[o.jsx("span",{className:"truncate",children:ae?`${ae.resName3} ${D}`:`Res ${D}`}),o.jsxs("span",{className:"shrink-0 text-emerald-300",children:[ge.toFixed(1)," Å"]})]},`${I}-${J}-${le}`)}),p!==null&&Q.length===0&&o.jsxs("span",{className:"col-span-full text-[0.6875rem] text-slate-500",children:["No non-local Cα contacts within ",j.toFixed(1)," Å."]})]})]})]})]})]})]})}function vL({comparison:e,paeJson:r,busy:n,guided:s,selectedPaePair:i,onSelectPaePair:c,includePng:d,onToggleIncludePng:f,onExportHtml:p,onExportJson:b,onExportBundle:x,bridge:g}){const[_,y]=C.useState(null),[S,k]=C.useState(!1),[E,T]=C.useState(!1),j=C.useMemo(()=>e?Rq(e.matchedResidues.map($=>$.mobPlddt)):null,[e]),q=C.useMemo(()=>zq(r),[r]),z=C.useMemo(()=>e?[...e.matchedResidues].sort(($,H)=>H.distanceAngstrom-$.distanceAngstrom).slice(0,8):[],[e]);if(!e)return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col p-3 @xl:p-4",children:[o.jsx(ir,{bridge:g,title:"Comparison Results & Provenance",subtitle:"Quantitative RMSD, coverage, PAE matrix, top deviation hotspots, and RUO exports.",icon:o.jsx(qi,{className:"h-4 w-4"}),guideOpen:E,onToggleGuide:()=>T($=>!$)}),o.jsx("div",{className:"flex-1",children:o.jsx(mE,{icon:o.jsx(qi,{className:"h-8 w-8"}),title:n?"Running comparison…":"No comparison yet",description:"Load a reference and a comparison structure (from a file, your library, or a public database) to see RMSD, coverage, confidence, and provenance here."})})]});const O=e.metrics,V=$=>{navigator.clipboard?.writeText($),y($),setTimeout(()=>y(null),1500)},P=[{label:"Cα RMSD",value:`${O.rmsdAngstrom.toFixed(3)} Å`,sub:"after rigid superposition",tone:"text-emerald-300"},{label:"Matched Cα",value:String(O.matchedCaCount),sub:"aligned residue pairs"},{label:"Reference coverage",value:`${(O.refCoverage.ratio*100).toFixed(1)}%`,sub:`${O.refCoverage.numerator} / ${O.refCoverage.denominator}`},{label:"Comparison coverage",value:`${(O.mobCoverage.ratio*100).toFixed(1)}%`,sub:`${O.mobCoverage.numerator} / ${O.mobCoverage.denominator}`}];return j!==null&&P.push({label:"Mean pLDDT",value:j.toFixed(1),sub:"prediction confidence (0–100)"}),q!==null&&P.push({label:"Mean PAE",value:`${q.toFixed(1)} Å`,sub:"predicted aligned error"}),o.jsx("div",{className:"@container h-full min-h-0 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-5xl space-y-4 p-3 @xl:px-5 @xl:py-5",children:[o.jsx(ir,{bridge:g,title:`${e.reference.label} (${e.reference.chainId}) vs ${e.mobile.label} (${e.mobile.chainId})`,subtitle:"Deterministic Kabsch rigid superposition metrics, PAE domain confidence, top deviation hotspots & RUO exports.",icon:o.jsx(qi,{className:"h-4 w-4"}),guideOpen:E,onToggleGuide:()=>T($=>!$),actions:g&&o.jsxs("div",{className:"flex flex-wrap gap-1",children:[o.jsx("button",{type:"button",onClick:()=>{g.setColorMode3D("deviation"),g.openTab("viewer",!1)},className:"rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-sky-400/40",children:"Color 3D by Δd"}),o.jsx("button",{type:"button",onClick:()=>{g.setColorMode3D("plddt"),g.openTab("viewer",!1)},className:"rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-emerald-400/40",children:"Color 3D by pLDDT"})]})}),o.jsx(Qi,{open:E,title:"How to Read Comparison Results",summary:"Results summarize deterministic Cα Kabsch superposition between your reference and comparison structures, paired with AlphaFold PAE uncertainty when available.",steps:["Check Cα RMSD and Coverage cards to see global fold similarity and whether termini/loops were excluded.","Inspect Highest Deviation Residues below and click any residue to jump directly to it in 3D.","Click any cell on the PAE heatmap to verify inter-residue domain confidence and focus residue i in 3D."],connectionTip:"Use 'Color 3D by Δd' or click any residue in the deviation table or PAE heatmap to synchronize the 3D Viewer, Sequence Track, and Ramachandran plot."}),o.jsx("div",{className:"grid grid-cols-2 gap-3 @2xl:grid-cols-3",children:P.map($=>o.jsxs("div",{className:"min-w-0 rounded-xl border border-white/[0.08] bg-white/[0.02] p-3.5",children:[o.jsx("div",{className:"truncate text-xs text-slate-400",children:$.label}),o.jsx("div",{className:`mt-1 truncate text-xl font-semibold tabular-nums @2xl:text-2xl ${$.tone??"text-slate-100"}`,children:$.value}),$.sub&&o.jsx("div",{className:"mt-0.5 truncate text-xs text-slate-500",children:$.sub})]},$.label))}),o.jsx(yt,{title:"Plain-English Summary",description:"Deterministic metric interpretations (RUO heuristics).",children:o.jsxs("div",{className:"grid gap-2 @2xl:grid-cols-2",children:[o.jsx(Ca,{insight:Aq(O.rmsdAngstrom)}),o.jsx(Ca,{insight:jq(O.refCoverage.ratio,O.refCoverage.numerator,O.refCoverage.denominator)}),j!==null&&o.jsx(Ca,{insight:wE(j)}),q!==null&&o.jsx(Ca,{insight:Tq(q)})]})}),z.length>0&&o.jsx(yt,{title:"Highest Structural Deviations (Top Δd Residues)",description:"Residues with the largest Cα-to-Cα offset after rigid superposition — click any chip to inspect in 3D.",actions:g&&o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.jsxs("button",{type:"button",onClick:()=>g.highlightIn3D(z.map($=>$.refSeqId),"Top Δd Hotspots",{focusSeqId:z[0]?.refSeqId}),className:"inline-flex items-center gap-1 rounded-md border border-rose-400/40 bg-rose-500/15 px-2 py-1 text-xs font-medium text-rose-200 hover:bg-rose-500/25",children:[o.jsx(_s,{className:"h-3 w-3"})," Highlight Top ",z.length," in 3D"]}),o.jsxs("button",{type:"button",onClick:()=>g.openTab("sequence"),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-xs text-slate-200 hover:border-sky-400/40",children:[o.jsx(Vo,{className:"h-3 w-3"})," Sequence Track"]}),o.jsxs("button",{type:"button",onClick:()=>g.openTab("ramachandran"),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-xs text-slate-200 hover:border-cyan-400/40",children:[o.jsx(Qo,{className:"h-3 w-3"})," Ramachandran"]})]}),children:o.jsx("div",{className:"grid grid-cols-2 gap-2 @xl:grid-cols-4",children:z.map($=>o.jsxs("button",{type:"button",onClick:()=>{c($.mobSeqId,$.mobSeqId),g?.focusIn3D($.refSeqId,{centerCamera:!0})},className:"flex items-center justify-between gap-2 rounded-lg border border-white/[0.08] bg-black/25 px-2.5 py-2 text-left font-mono text-xs transition hover:border-amber-400/50",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"truncate font-semibold text-slate-100",children:[$.resName3," ",$.refSeqId]}),o.jsx("div",{className:"truncate text-[0.6875rem] text-slate-500",children:$.mobPlddt!=null?`pLDDT ${$.mobPlddt.toFixed(0)}`:"Exp/Model"})]}),o.jsxs("span",{className:"shrink-0 font-semibold text-amber-300",children:[$.distanceAngstrom.toFixed(2)," Å"]})]},`${$.refSeqId}-${$.mobSeqId}`))})}),o.jsx(wL,{paeJson:r,selected:i,onSelect:($,H)=>{c($,H),g?.focusIn3D($,{centerCamera:!0})},status:O.paeStatus,onFocusIn3D:g?$=>g.focusIn3D($,{centerCamera:!0,openViewer:"activate"}):void 0}),o.jsx(yt,{title:"Provenance",description:"Exact inputs used for this result.",children:o.jsxs("div",{className:"space-y-2",children:[[{tag:"Reference",rec:e.reference,tone:"text-sky-300"},{tag:"Comparison",rec:e.mobile,tone:"text-emerald-300"}].map(({tag:$,rec:H,tone:Z})=>o.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-white/[0.06] bg-black/20 p-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[o.jsx("span",{className:`font-medium ${Z}`,children:$}),o.jsx("span",{className:"text-slate-200",children:H.label}),o.jsx(It,{children:H.confidenceKind}),o.jsx(It,{children:H.license??"license unknown"})]}),o.jsxs("div",{className:"mt-1 truncate font-mono text-xs text-slate-500",children:["sha256 ",H.sha256]})]}),o.jsx("button",{type:"button",onClick:()=>V(H.sha256),title:"Copy SHA-256",className:"rounded-md p-1.5 text-slate-500 hover:bg-white/[0.06] hover:text-slate-200",children:_===H.sha256?o.jsx(Fi,{className:"h-4 w-4 text-emerald-400"}):o.jsx(Lr,{className:"h-4 w-4"})})]},$)),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 pt-1 text-xs text-slate-500",children:[o.jsxs("span",{children:["Engine ",e.engine.target," · ",e.engine.floatPrecision]}),o.jsxs("span",{children:["Result ",e.resultId.slice(0,16),"…"]}),o.jsx("span",{children:new Date(e.createdAtUtc).toLocaleString()})]}),o.jsxs("button",{type:"button",onClick:()=>k($=>!$),className:"flex items-center gap-1 pt-1 text-xs text-slate-400 hover:text-slate-200",children:[S?o.jsx(ph,{className:"h-3.5 w-3.5"}):o.jsx(Ty,{className:"h-3.5 w-3.5"}),"4×4 transform (",e.transform.direction,")"]}),S&&o.jsx("div",{className:"grid grid-cols-4 gap-1 rounded-lg bg-black/30 p-3 font-mono text-xs text-slate-300",children:e.transform.matrixRowMajor4x4.map(($,H)=>o.jsx("div",{className:"text-right tabular-nums",children:$.toFixed(4)},H))})]})}),o.jsxs(yt,{title:"Export",description:"Every export carries provenance and the research-use-only notice.",children:[o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsx(Oe,{variant:"primary",icon:o.jsx(sr,{className:"h-4 w-4"}),onClick:p,children:"HTML report"}),o.jsx(Oe,{icon:o.jsx(BA,{className:"h-4 w-4"}),onClick:b,children:"JSON manifest"}),o.jsx(Oe,{icon:o.jsx(UA,{className:"h-4 w-4"}),onClick:x,children:"Project bundle"})]}),o.jsxs("label",{className:"mt-4 flex items-center gap-3 text-sm text-slate-300",children:[o.jsx($r,{checked:d,onChange:f,label:"Embed 3D image"}),"Embed the current 3D view in the HTML report"]})]}),o.jsx("p",{className:"text-xs text-slate-500",children:Cn})]})})}function wL({paeJson:e,selected:r,onSelect:n,status:s,onFocusIn3D:i}){const c=C.useRef(null),d=C.useRef(null),[f,p]=C.useState(null),b=C.useMemo(()=>{if(!e)return null;try{const g=JSON.parse(e),y=(Array.isArray(g)?g[0]:g)?.predicted_aligned_error;return Array.isArray(y)&&Array.isArray(y[0])?y:null}catch{return null}},[e]);C.useEffect(()=>{if(!b){d.current=null;return}const g=b.length,_=document.createElement("canvas");_.width=g,_.height=g;const y=_.getContext("2d");if(!y)return;const S=y.createImageData(g,g);for(let k=0;k<g;k++)for(let E=0;E<g;E++){const[T,j,q]=cL(Number(b[k][E]??30)),z=(k*g+E)*4;S.data[z]=T,S.data[z+1]=j,S.data[z+2]=q,S.data[z+3]=255}y.putImageData(S,0,0),d.current=_},[b]),C.useEffect(()=>{const g=c.current,_=d.current;if(!g||!_||!b)return;const y=g.getContext("2d");if(!y)return;const S=g.width;y.imageSmoothingEnabled=!1,y.drawImage(_,0,0,S,S);const k=S/b.length,E=(T,j,q)=>{y.strokeStyle=q,y.lineWidth=1.5,y.beginPath(),y.moveTo((j-.5)*k,0),y.lineTo((j-.5)*k,S),y.moveTo(0,(T-.5)*k),y.lineTo(S,(T-.5)*k),y.stroke()};r&&E(r[0],r[1],"rgba(251,191,36,0.9)"),f&&E(f.i,f.j,"rgba(125,211,252,0.75)")},[b,f,r]);const x=(g,_)=>{if(!b)return;const y=g.currentTarget.getBoundingClientRect(),S=b.length,k=Math.max(0,Math.min(S-1,Math.floor((g.clientX-y.left)/y.width*S))),E=Math.max(0,Math.min(S-1,Math.floor((g.clientY-y.top)/y.height*S)));p({i:E+1,j:k+1,val:Number(b[E][k]??0)}),_&&n(E+1,k+1)};return o.jsx(yt,{title:"Predicted aligned error (PAE)",description:b?`${b.length} × ${b.length} residues · click a cell to focus residue i in 3D`:`No PAE matrix loaded (${s}). AlphaFold DB imports include it automatically.`,actions:o.jsxs("div",{className:"flex items-center gap-2",children:[f?o.jsxs("span",{className:"font-mono text-xs text-slate-300 tabular-nums",children:["(",f.i,", ",f.j,") = ",f.val.toFixed(1)," Å"]}):r?o.jsxs("span",{className:"font-mono text-xs text-amber-300",children:["selected (",r[0],", ",r[1],")"]}):null,r&&i&&o.jsxs("button",{type:"button",onClick:()=>i(r[0]),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2 py-0.5 text-xs text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Ur,{className:"h-3 w-3"})," View in 3D"]})]}),children:b?o.jsxs("div",{className:"flex flex-col items-center gap-3 @lg:flex-row @lg:items-end",children:[o.jsx("canvas",{ref:c,width:520,height:520,onMouseMove:g=>x(g,!1),onClick:g=>x(g,!0),onMouseLeave:()=>p(null),className:"aspect-square w-full max-w-[22rem] cursor-crosshair rounded-lg border border-white/[0.08]"}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 @lg:flex-col @lg:items-start",children:[o.jsx("span",{children:"0 Å · confident"}),o.jsx("span",{className:"inline-block h-2 w-28 rounded-sm bg-gradient-to-r from-[#10d2a0] via-[#2d8c87] to-[#0f172a] @lg:h-28 @lg:w-2 @lg:bg-gradient-to-b"}),o.jsx("span",{children:"30 Å · uncertain"})]})]}):null})}function SL({comparison:e,refInspect:r,mobInspect:n,refChainId:s,mobChainId:i,focusedSeqId:c,onFocusResidue:d,bridge:f}){const p=C.useRef(null),[b,x]=C.useState("deviation"),[g,_]=C.useState("all"),[y,S]=C.useState(""),[k,E]=C.useState(!1),T=C.useMemo(()=>{const P=r?.chains.find(K=>K.chainId===s)??r?.chains[0],$=n?.chains.find(K=>K.chainId===i)??n?.chains[0],H=new Map;if(e)for(const K of e.matchedResidues)H.set(K.mobSeqId,K);const Z=P?.sequence1Letter??"",G=new Map;for(const K of P?.residues??[])G.set(K.seqId,{code:K.resCode1,hasCa:K.ca!=null,b:K.bOrPlddt});return $&&$.residues.length>0?$.residues.map((K,we)=>{const Se=H.get(K.seqId),Q=G.get(K.seqId),F=we<Z.length?Z[we]:null;return Se?{posIndex:we+1,refSeqId:Se.refSeqId,refCode:Se.resCode1,mobSeqId:Se.mobSeqId,mobCode:K.resCode1,distanceA:Se.distanceAngstrom,refBFactor:Se.refBFactor,mobPlddt:Se.mobPlddt,isMissingRefCoord:!1}:{posIndex:we+1,refSeqId:Q?K.seqId:null,refCode:Q?.hasCa?Q.code:"-",mobSeqId:K.seqId,mobCode:K.resCode1,distanceA:null,refBFactor:Q?.b??null,mobPlddt:K.bOrPlddt,isMissingRefCoord:!Q?.hasCa&&F!=null}}):e?e.matchedResidues.map((K,we)=>({posIndex:we+1,refSeqId:K.refSeqId,refCode:K.resCode1,mobSeqId:K.mobSeqId,mobCode:K.resCode1,distanceA:K.distanceAngstrom,refBFactor:K.refBFactor,mobPlddt:K.mobPlddt,isMissingRefCoord:!1})):[]},[e,r,n,s,i]),j=C.useMemo(()=>{let P=0,$=0,H=0,Z=null,G=0,K=[],we=0,Se=0,Q=0,F=0;for(const he of T){const W=he.refSeqId??he.mobSeqId??he.posIndex;he.distanceA!=null?(P++,$+=he.distanceA,he.distanceA>H&&(H=he.distanceA,Z=W),he.distanceA>=2&&(G++,K.push(W))):Se++,he.mobPlddt!=null&&(Q+=he.mobPlddt,F++,he.mobPlddt<70&&we++)}return{matched:P,meanD:P>0?$/P:0,maxD:H,maxDSeqId:Z,highDevCount:G,highDevSeqIds:K,lowPlddtCount:we,gapCount:Se,meanPlddt:F>0?Q/F:null}},[T]),q=C.useMemo(()=>g==="all"?T:T.filter(P=>g==="high_dev"?P.distanceA!=null&&P.distanceA>=2:g==="low_plddt"?P.mobPlddt!=null&&P.mobPlddt<70:g==="gaps"?P.distanceA==null:!0),[T,g]),z=C.useMemo(()=>T.find(P=>P.refSeqId===c||P.mobSeqId===c)??null,[T,c]),O=C.useMemo(()=>{let P=2;for(const $ of T)$.distanceA!=null&&$.distanceA>P&&(P=$.distanceA);return P},[T]),V=P=>{d(P),f?.focusIn3D(P,{centerCamera:!0})};return T.length===0?o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 p-3 @xl:p-4",children:[o.jsx(ir,{bridge:f,title:"Sequence Alignment & Per-Residue Deviation Track",subtitle:"Compare aligned amino-acid sequences, Cα deviations (Δd), pLDDT confidence, and B-factors residue-by-residue.",icon:o.jsx(Vo,{className:"h-4 w-4"}),guideOpen:k,onToggleGuide:()=>E(P=>!P)}),o.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 rounded-xl border border-white/[0.08] bg-[#0b1018] p-6 text-center text-xs text-slate-400",children:[o.jsx(Vo,{className:"h-8 w-8 text-slate-500"}),o.jsx("div",{className:"text-sm font-medium text-slate-200",children:"No structure pair loaded"}),o.jsx("p",{className:"max-w-md",children:"Load reference and comparison structures to inspect aligned sequence columns and per-residue Cα Δd deviations."}),f&&o.jsxs("button",{type:"button",onClick:f.loadExample,className:"inline-flex items-center gap-1.5 rounded-lg bg-sky-500 px-3.5 py-2 text-xs font-semibold text-slate-950 hover:bg-sky-400",children:[o.jsx(Br,{className:"h-3.5 w-3.5"})," Load CA II Example"]})]})]}):o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:f,title:"Sequence Alignment & Per-Residue Δd Track",subtitle:"Inspect aligned residue columns, structural deviation spikes (Δd), experimental B-factors, and AlphaFold pLDDT.",icon:o.jsx(Vo,{className:"h-4 w-4"}),guideOpen:k,onToggleGuide:()=>E(P=>!P)}),o.jsx(Qi,{open:k,title:"How Sequence Deviation Tracking Works",summary:"Each column aligns a reference residue (top letter, sky blue) to the corresponding comparison/predicted residue (bottom letter, emerald). The bar height and color visualize local structural or confidence differences.",steps:["Switch the bar chart metric between Δd (Å), AlphaFold pLDDT, and Experimental B-factor.","Use the Filter pills to isolate only High-Deviation hotspots (Δd ≥ 2.0 Å), Low-Confidence loops (pLDDT < 70), or Missing Coordinate gaps (-).",'Click any residue column to focus it in the 3D Viewer, or click "Highlight High Δd in 3D" to inspect flexible loops on the 3D model.'],connectionTip:"Every column is directly bound to the 3D scene. Focusing a residue here highlights it in the 3D Viewer, updates the Peptide & CRISPR workbenches, and allows 1-click navigation to Ramachandran angles."}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 @lg:grid-cols-4",children:[o.jsx(bs,{label:"Aligned / Total",value:`${j.matched} / ${T.length}`,hint:`${j.gapCount} missing coords (-)`}),o.jsx(bs,{label:"Mean Δd",value:`${j.meanD.toFixed(3)} Å`,hint:"Average Cα offset"}),o.jsxs("button",{type:"button",onClick:()=>j.maxDSeqId!==null&&V(j.maxDSeqId),disabled:j.maxDSeqId===null,className:"min-w-0 rounded-lg border border-amber-400/25 bg-amber-500/[0.06] px-2.5 py-2 text-left transition hover:border-amber-400/50 disabled:opacity-50",title:"Click to jump to the highest-deviating residue",children:[o.jsx("div",{className:"truncate text-[0.6875rem] text-amber-300",children:"Max Δd (Jump ↗)"}),o.jsxs("div",{className:"mt-0.5 truncate font-mono text-sm font-semibold text-amber-200 tabular-nums",children:[j.maxD.toFixed(2)," Å ",j.maxDSeqId!==null?`(#${j.maxDSeqId})`:""]}),o.jsxs("div",{className:"mt-0.5 truncate text-[0.625rem] text-slate-400",children:[j.highDevCount," res ≥ 2.0 Å"]})]}),o.jsx(bs,{label:"Mean pLDDT",value:j.meanPlddt!==null?j.meanPlddt.toFixed(1):"n/a",hint:j.meanPlddt!==null?`${j.lowPlddtCount} res < 70`:"No pLDDT"})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-xl border border-white/[0.08] bg-[#0b1018] p-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-400",children:"Bar Metric:"}),[["deviation","Δd (Å)"],["plddt","pLDDT"],["bfactor","B-Factor"]].map(([P,$])=>o.jsx("button",{type:"button",onClick:()=>{x(P),f?.setColorMode3D(P)},className:`rounded-md border px-2 py-1 font-mono text-[0.6875rem] transition ${b===P?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:$},P))]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[[["all",`All (${T.length})`],["high_dev",`Δd ≥ 2Å (${j.highDevCount})`],["low_plddt",`pLDDT < 70 (${j.lowPlddtCount})`],["gaps",`Gaps (${j.gapCount})`]].map(([P,$])=>o.jsx("button",{type:"button",onClick:()=>_(P),className:`rounded-md border px-2 py-1 text-[0.6875rem] transition ${g===P?"border-emerald-400/50 bg-emerald-500/20 text-emerald-200":"border-white/10 bg-slate-900 text-slate-400 hover:text-slate-200"}`,children:$},P)),f&&j.highDevSeqIds.length>0&&o.jsxs("button",{type:"button",onClick:()=>f.highlightIn3D(j.highDevSeqIds,"High Δd ≥ 2.0 Å",{focusSeqId:j.maxDSeqId??j.highDevSeqIds[0]}),className:"inline-flex items-center gap-1 rounded-md border border-rose-400/40 bg-rose-500/15 px-2 py-1 text-[0.6875rem] font-medium text-rose-200 hover:bg-rose-500/25",children:[o.jsx(_s,{className:"h-3 w-3"})," Highlight High Δd in 3D"]})]}),o.jsxs("form",{onSubmit:P=>{P.preventDefault();const $=Number.parseInt(y.trim(),10);Number.isFinite($)&&$>0&&V($)},className:"flex items-center gap-1",children:[o.jsx("input",{value:y,onChange:P=>S(P.target.value),placeholder:"Jump res #",className:"h-7 w-20 rounded-md border border-white/10 bg-slate-950 px-2 font-mono text-[0.6875rem] text-slate-200 outline-none focus:border-sky-400"}),o.jsx("button",{type:"submit",className:"h-7 rounded-md border border-white/10 bg-white/[0.04] px-2 text-[0.6875rem] text-slate-300 hover:text-white",children:"Go"})]})]}),o.jsx("div",{ref:p,className:"min-h-36 flex-1 overflow-x-auto overflow-y-hidden rounded-xl border border-white/[0.08] bg-[#070a10] p-3",children:q.length===0?o.jsx("div",{className:"flex h-full items-center justify-center text-slate-500",children:"No residues match this filter."}):o.jsx("div",{className:"inline-flex min-w-max items-end gap-[3px]",children:q.map(P=>{const $=P.refSeqId??P.mobSeqId??P.posIndex,H=c!=null&&(P.refSeqId===c||P.mobSeqId===c);let Z=3,G=[71,85,105],K=!1;return b==="deviation"&&P.distanceA!=null?(K=!0,Z=Math.max(4,Math.round(P.distanceA/O*56)),G=Vd(P.distanceA)):b==="plddt"&&P.mobPlddt!=null?(K=!0,Z=Math.max(4,Math.round(P.mobPlddt/100*56)),G=ky(P.mobPlddt)):b==="bfactor"&&P.refBFactor!=null&&(K=!0,Z=Math.max(4,Math.min(56,Math.round(P.refBFactor/60*56))),G=Cy(P.refBFactor)),o.jsxs("button",{type:"button",onClick:()=>V($),title:`Pos ${P.posIndex} | Ref: ${P.refCode}${P.refSeqId??"-"} | Mob: ${P.mobCode}${P.mobSeqId??"-"} | Δd=${P.distanceA!=null?`${P.distanceA.toFixed(3)} Å`:"missing"} | B=${P.refBFactor??"n/a"} | pLDDT=${P.mobPlddt??"n/a"}`,className:`group flex w-4.5 shrink-0 flex-col items-center rounded py-1 font-mono transition ${H?"bg-amber-500/25 ring-1 ring-amber-400":"hover:bg-slate-800/80"}`,children:[o.jsx("span",{className:"h-3.5 text-[0.5625rem] text-slate-500",children:P.posIndex%10===0||P.posIndex===1?P.posIndex:""}),o.jsx("div",{className:"flex h-15 w-full items-end justify-center pb-1",children:o.jsx("div",{className:"w-2.5 rounded-t-[2px] transition-all",style:{height:`${Z}px`,backgroundColor:lL(G),opacity:K?.94:.3}})}),o.jsx("span",{className:`text-[0.75rem] font-semibold leading-tight ${P.refCode==="-"?"text-amber-400":"text-sky-300"}`,children:P.refCode}),o.jsx("span",{className:"text-[0.75rem] leading-tight text-emerald-300",children:P.mobCode})]},`${P.posIndex}-${P.mobSeqId??""}`)})})}),z?o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-xl border border-amber-400/35 bg-amber-500/[0.06] px-3 py-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-3 font-mono text-xs text-amber-100",children:[o.jsxs("span",{className:"font-semibold text-amber-200",children:["Focus: ",z.mobCode,z.refSeqId??z.mobSeqId]}),o.jsxs("span",{children:["Δd=",z.distanceA!=null?`${z.distanceA.toFixed(3)} Å`:"gap (-)"]}),o.jsxs("span",{children:["B=",z.refBFactor!=null?`${z.refBFactor.toFixed(2)} Ų`:"n/a"]}),o.jsxs("span",{children:["pLDDT=",z.mobPlddt!=null?z.mobPlddt.toFixed(1):"n/a"]}),z.mobPlddt!==null&&o.jsx("span",{className:"font-sans",children:o.jsx(Ca,{insight:wE(z.mobPlddt),compact:!0})})]}),f&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs("button",{type:"button",onClick:()=>f.focusIn3D(z.refSeqId??z.mobSeqId??z.posIndex,{centerCamera:!0,openViewer:"activate"}),className:"inline-flex items-center gap-1 rounded-md border border-sky-400/40 bg-sky-500/15 px-2 py-1 text-[0.6875rem] font-medium text-sky-200 hover:bg-sky-500/25",children:[o.jsx(Ur,{className:"h-3 w-3"})," Focus in 3D"]}),o.jsxs("button",{type:"button",onClick:()=>f.sendResidueToRamachandran(z.refSeqId??z.mobSeqId??z.posIndex),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-cyan-400/40",children:[o.jsx(Qo,{className:"h-3 w-3 text-cyan-300"})," Ramachandran"]}),o.jsxs("button",{type:"button",onClick:()=>{const P=z.refSeqId??z.mobSeqId??z.posIndex,$=z.mobCode!=="-"?z.mobCode:z.refCode;f.sendMutationToPeptide(`${$}${P}A`,P)},className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-emerald-400/40",children:[o.jsx(ar,{className:"h-3 w-3 text-emerald-300"})," Ala Scan"]}),o.jsxs("button",{type:"button",onClick:()=>f.sendResidueToCrispr(z.refSeqId??z.mobSeqId??z.posIndex),className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-white/[0.04] px-2 py-1 text-[0.6875rem] text-slate-200 hover:border-violet-400/40",children:[o.jsx(Fs,{className:"h-3 w-3 text-violet-300"})," CRISPR Codon"]})]})]}):o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 font-mono text-[0.6875rem] text-slate-400",children:[o.jsx("span",{children:"Click any column to synchronize 3D Viewer, Peptide, CRISPR & Ramachandran."}),o.jsx("span",{className:"text-amber-300/90",children:"[-] = Missing coordinates in experimental structure"})]})]})}const SE=[[{id:"account",label:"Account",icon:o.jsx(ah,{className:"h-4 w-4"}),keywords:"sign in sign out profile email synlexa.com login"},{id:"usage",label:"Usage",icon:o.jsx(yR,{className:"h-4 w-4"}),keywords:"tokens requests cost history"}],[{id:"ai",label:"AI & API keys",icon:o.jsx(tp,{className:"h-4 w-4"}),keywords:"assistant claude anthropic gemini google model byok key synlexa cloud"}],[{id:"viewer",label:"3D viewer",icon:o.jsx(A6,{className:"h-4 w-4"}),keywords:"render style color cartoon surface layout png report"},{id:"workspace",label:"Workspace",icon:o.jsx(VA,{className:"h-4 w-4"}),keywords:"interface size scale zoom text tabs layout auto-save guided demo"}],[{id:"data",label:"Data & storage",icon:o.jsx(Vi,{className:"h-4 w-4"}),keywords:"library export import backup clear history storage"}]],pp={id:"about",label:"About",icon:o.jsx(zy,{className:"h-4 w-4"}),keywords:"version license engine keyboard shortcuts research use only"},Mx=[...SE.flat(),pp];function MA({item:e,active:r,onSelect:n}){return o.jsxs("button",{type:"button",onClick:n,"aria-current":r?"page":void 0,className:Ie("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-[0.4375rem] text-left text-sm transition-colors",r?"bg-white/[0.08] text-white":"text-slate-300 hover:bg-white/[0.04] hover:text-white"),children:[o.jsx("span",{className:r?"text-white":"text-slate-400",children:e.icon}),e.label]})}function kL(e){const{open:r,onClose:n,section:s,onSectionChange:i}=e,[c,d]=C.useState(""),f=C.useRef(null),p=C.useRef(null);C.useEffect(()=>{if(!r)return;d("");const k=E=>{E.key==="Escape"&&(E.stopPropagation(),n())};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[r,n]),C.useEffect(()=>{p.current?.scrollTo({top:0})},[s]);const b=c.trim().toLowerCase(),x=k=>!b||`${k.label} ${k.keywords}`.toLowerCase().includes(b),g=SE.map(k=>k.filter(x)).filter(k=>k.length>0),_=x(pp),y=g.length>0||_;if(!r)return null;const S=Mx.find(k=>k.id===s)??Mx[0];return o.jsx("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-black/55 p-3 backdrop-blur-[2px] sm:p-6",onMouseDown:k=>{k.target===k.currentTarget&&n()},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Settings",className:"flex h-[min(46rem,100%)] w-[min(64rem,100%)] flex-col overflow-hidden rounded-2xl border border-white/10 bg-[#161a22] shadow-[0_24px_80px_-12px_rgba(0,0,0,0.7)]",children:[o.jsxs("div",{className:"flex h-12 shrink-0 items-center justify-between border-b border-white/[0.07] pr-2 pl-5",children:[o.jsx("h2",{className:"text-[0.9375rem] font-semibold text-slate-100",children:"Settings"}),o.jsx(sl,{label:"Close settings",onClick:n,children:o.jsx(Xi,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[o.jsxs("aside",{className:"hidden w-60 shrink-0 flex-col border-r border-white/[0.07] md:flex",children:[o.jsx("div",{className:"p-3 pb-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-white/[0.05] px-2.5 py-1.5 focus-within:ring-1 focus-within:ring-sky-400/50",children:[o.jsx(Gr,{className:"h-4 w-4 shrink-0 text-slate-500"}),o.jsx("input",{ref:f,value:c,onChange:k=>d(k.target.value),onKeyDown:k=>{if(k.key==="Enter"){const E=[...g.flat(),..._?[pp]:[]][0];E&&i(E.id)}},placeholder:"Search","aria-label":"Search settings",className:"min-w-0 flex-1 bg-transparent text-sm text-slate-100 placeholder:text-slate-500 focus:outline-none"})]})}),o.jsxs("nav",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-3",children:[g.map((k,E)=>o.jsx("div",{className:Ie("space-y-0.5 py-1.5",E>0&&"border-t border-white/[0.06]"),children:k.map(T=>o.jsx(MA,{item:T,active:s===T.id,onSelect:()=>i(T.id)},T.id))},k[0].id)),!y&&o.jsxs("p",{className:"px-2.5 py-2 text-sm text-slate-500",children:["No settings match “",c,"”."]})]}),_&&o.jsx("div",{className:"border-t border-white/[0.06] p-3",children:o.jsx(MA,{item:pp,active:s==="about",onSelect:()=>i("about")})})]}),o.jsx("div",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-white/[0.07] px-3 py-2 [scrollbar-width:none] md:hidden",children:Mx.map(k=>o.jsxs("button",{type:"button",onClick:()=>i(k.id),className:Ie("flex shrink-0 items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs whitespace-nowrap",s===k.id?"bg-white/[0.08] text-white":"text-slate-400 hover:bg-white/[0.04]"),children:[k.icon,k.label]},k.id))}),o.jsx("div",{ref:p,className:"@container min-w-0 flex-1 overflow-y-auto","aria-label":S.label,children:o.jsxs("div",{className:"mx-auto max-w-3xl space-y-5 px-5 py-6 @2xl:px-8",children:[s==="account"&&o.jsx(CL,{...e}),s==="ai"&&o.jsx(jL,{...e}),s==="usage"&&o.jsx(TL,{}),s==="viewer"&&o.jsx(EL,{}),s==="workspace"&&o.jsx(ML,{onResetLayout:e.onResetLayout}),s==="data"&&o.jsx(RL,{onClearedHistory:e.onClearedHistory}),s==="about"&&o.jsx(OL,{})]})})]})]})})}function ul({title:e,description:r}){return o.jsxs("div",{className:"pb-1",children:[o.jsx("h1",{className:"text-xl font-semibold text-slate-100",children:e}),r&&o.jsx("p",{className:"mt-1 text-sm text-slate-400",children:r})]})}function CL({session:e,onSessionChange:r,onSignIn:n,onCancelSignIn:s,signInPending:i,aiConfig:c}){const{confirm:d,toast:f}=cl(),p=(e?.displayName??e?.email??"?").split(/[\s@.]+/).filter(Boolean).slice(0,2).map(b=>b[0]?.toUpperCase()).join("");return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"Account",description:"Your synlexa.com connection and how Studio uses it."}),o.jsx(yt,{children:e?o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-gradient-to-br from-sky-400 to-indigo-500 text-base font-semibold text-white",children:p||o.jsx(ah,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-base font-medium text-slate-100",children:e.displayName??e.email??"Signed in"}),o.jsx("div",{className:"truncate text-sm text-slate-400",children:e.email??"Email not shared"}),o.jsxs("div",{className:"mt-1.5 flex gap-1.5",children:[e.serverVerified?o.jsx(It,{tone:"good",children:"Verified by synlexa.com"}):o.jsx(It,{tone:"warn",children:"Not confirmed by synlexa.com"}),o.jsxs(It,{children:["Since ",new Date(e.establishedAtUtc).toLocaleDateString()]})]})]}),!e.serverVerified&&o.jsx(Oe,{variant:"primary",disabled:i,onClick:()=>n("signin"),children:i?"Waiting…":"Reconnect"}),o.jsx(Oe,{variant:"ghost",icon:o.jsx(k6,{className:"h-4 w-4"}),onClick:async()=>{await d({title:"Sign out?",message:"Your local library, settings, and API keys stay on this device.",confirmLabel:"Sign out"})&&(UI(),r(null),f("Signed out","success"))},children:"Sign out"})]}):i?o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-sky-400/10 text-sky-300",children:o.jsx(qs,{className:"h-5 w-5 animate-spin"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-medium text-slate-100",children:"Waiting for synlexa.com…"}),o.jsx("div",{className:"text-sm text-slate-400",children:"Finish signing in in the window that opened. Studio connects automatically."})]})]}),o.jsx(Oe,{variant:"ghost",onClick:s,children:"Cancel"})]}):o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-white/[0.06] text-slate-400",children:o.jsx(ah,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-medium text-slate-100",children:"Not signed in"}),o.jsx("div",{className:"text-sm text-slate-400",children:"Studio works fully offline. Sign in to use Synlexa Cloud and connect your organization."})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Oe,{variant:"ghost",onClick:()=>n("signup"),children:"Create account"}),o.jsx(Oe,{variant:"primary",onClick:()=>n("signin"),children:"Sign in"})]})]})}),o.jsx(yt,{title:"Where your data lives",children:o.jsxs("ul",{className:"space-y-2 text-sm text-slate-300",children:[o.jsxs("li",{className:"flex gap-2",children:[o.jsx(Gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-400"}),"Structures, compounds, and your library are stored in this browser (IndexedDB) and never uploaded."]}),o.jsxs("li",{className:"flex gap-2",children:[o.jsx(Gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-400"}),"Calculations run locally in the WebAssembly engine."]}),o.jsxs("li",{className:"flex gap-2",children:[o.jsx(Gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-400"}),c[c.provider]?.apiKey?c.provider==="synlexa"?o.jsx(o.Fragment,{children:"AI requests go through synlexa.com to Google Gemini, with a summary of the loaded workspace. Synlexa does not store prompts or replies."}):o.jsxs(o.Fragment,{children:["AI requests go directly from this browser to"," ",c.provider==="anthropic"?"Anthropic":"Google"," using your own key, with a summary of the loaded workspace."]}):o.jsx(o.Fragment,{children:"Nothing is sent to an AI provider until you sign in for Synlexa Cloud or add your own key. The built-in assistant runs locally."})]})]})})]})}function NL({provider:e,value:r,onSave:n}){const[s,i]=C.useState(""),[c,d]=C.useState(!1),f=s.length>0;return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative min-w-0 flex-1",children:[o.jsx(Dn,{type:c?"text":"password",value:s,onChange:p=>i(p.target.value),placeholder:r?ZI(r):es[e].keyHint,autoComplete:"off",spellCheck:!1,className:"pr-9 font-mono text-[0.8125rem]",onKeyDown:p=>{p.key==="Enter"&&s.trim()&&(n(s.trim()),i(""))}}),o.jsx("button",{type:"button",onClick:()=>d(p=>!p),"aria-label":c?"Hide key":"Show key",className:"absolute top-1/2 right-2 -translate-y-1/2 text-slate-500 hover:text-slate-200",children:c?o.jsx(WR,{className:"h-4 w-4"}):o.jsx(LA,{className:"h-4 w-4"})})]}),f?o.jsx(Oe,{variant:"primary",onClick:()=>{n(s.trim()),i("")},children:"Save"}):r?o.jsx(Oe,{variant:"ghost",onClick:()=>n(""),children:"Remove"}):null]})}async function AL(e,r,n){if(e==="anthropic"){const c=new aa({apiKey:r,dangerouslyAllowBrowser:!0,maxRetries:0});try{const d=await c.models.retrieve(n);return`Connected · ${d.display_name??d.id}`}catch(d){throw d instanceof aa.AuthenticationError?new Error("Invalid API key"):d instanceof aa.NotFoundError?new Error(`Model "${n}" not available for this key`):d instanceof aa.APIConnectionError?new Error("Could not reach api.anthropic.com"):d instanceof Error?d:new Error(String(d))}}if(e==="openai"){const c=await fetch(`https://api.openai.com/v1/models/${encodeURIComponent(n)}`,{headers:{Authorization:`Bearer ${r}`}}),d=await c.json().catch(()=>({}));if(!c.ok)throw new Error(d.error?.message??`HTTP ${c.status}`);return`Connected · ${d.id??n}`}const s=await fetch(`${y3}/${encodeURIComponent(n)}`,{headers:{"x-goog-api-key":r}}),i=await s.json().catch(()=>({}));if(!s.ok)throw new Error(i.error?.message??`HTTP ${s.status}`);return`Connected · ${i.displayName??n}`}function jL({aiConfig:e,onUpdateAiConfig:r,onPermissionsChange:n,session:s,onSignIn:i,signInPending:c}){const[d,f]=C.useState(null),[p,b]=C.useState({}),[x,g]=C.useState(()=>Zo()),[_,y]=C.useState(()=>t0());C.useEffect(()=>f3(()=>g(Zo())),[]);const S=Xc(e),k=e.routingPreference??"byok-first",E=(j,q)=>{const z=gI({..._,[j]:q});y(z),n?.(z)},T=async j=>{f(j);try{const q=e[j]??{apiKey:"",model:""},z=await AL(j,q.apiKey,q.model);b(O=>({...O,[j]:{ok:!0,msg:z}}))}catch(q){b(z=>({...z,[j]:{ok:!1,msg:q instanceof Error?q.message:String(q)}}))}finally{f(null)}};return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"AI & API keys",description:"Bring your own Anthropic, Gemini, or OpenAI/Codex key (BYOK), or choose Synlexa Cloud. When a BYOK key is entered in default mode, Studio routes directly to your provider instead of Synlexa Cloud."}),o.jsx(yt,{title:"Active AI routing & key priority",description:"Control whether your local BYOK keys always override Synlexa Cloud or whether you switch manually.",actions:o.jsx(It,{tone:S.isByok?"good":S.hasCloudToken?"accent":"neutral",children:S.isByok?`Using BYOK (${es[S.provider].label})`:S.provider==="synlexa"&&S.hasCloudToken?"Using Synlexa Cloud":"Local Deterministic Copilot"}),children:o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsx("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-white/[0.08] bg-white/[0.02] px-3 py-2.5 text-xs",children:o.jsxs("div",{className:"flex items-center gap-2 text-slate-200",children:[o.jsx(Ki,{className:"h-4 w-4 shrink-0 text-emerald-400"}),S.isByok?o.jsxs("span",{children:["Requests go directly to ",o.jsx("strong",{children:es[S.provider].label})," using your encrypted BYOK key — Synlexa Cloud is bypassed."]}):S.provider==="synlexa"&&S.hasCloudToken?o.jsxs("span",{children:["Requests route through ",o.jsx("strong",{children:"Synlexa Cloud"})," (`synlexa.com` account).",S.hasByok?" (Manual override active; your BYOK keys are saved for instant switch.)":""]}):o.jsx("span",{children:"No BYOK key or Cloud token active — using offline deterministic Copilot."})]})}),o.jsx(Qt,{label:"Key routing priority",hint:"Prefer BYOK guarantees your personal API key is used instead of Synlexa Cloud whenever any key is saved.",children:o.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.jsx(Oe,{size:"sm",variant:k==="byok-first"?"primary":"secondary",onClick:()=>{const j=["anthropic","gemini","openai"].find(q=>!!e[q]?.apiKey?.trim());r({routingPreference:"byok-first",...j&&e.provider==="synlexa"?{provider:j}:{}})},children:"Prefer BYOK keys"}),o.jsx(Oe,{size:"sm",variant:k==="manual"?"primary":"secondary",onClick:()=>r({routingPreference:"manual"}),children:"Choose manually (BYOK / Cloud)"})]})})]})}),o.jsx(yt,{title:"Encrypted Local Key Vault (state.vscdb)",description:"BYOK keys are stored in the local ItemTable store and encrypted with a non-extractable key.",actions:o.jsx(It,{tone:"good",children:x.cipher}),children:o.jsxs("div",{className:"divide-y divide-white/[0.05] text-sm",children:[o.jsx(Qt,{label:"Storage backend",hint:"Never saved inside project files or plain-text localStorage.",children:o.jsx("span",{className:"font-mono text-xs text-sky-300",children:x.dbPath})}),o.jsx(Qt,{label:"Allow AI scientific web search",hint:"Lets the assistant query Europe PMC & ClinicalTrials.gov via MCP.",children:o.jsx($r,{checked:e.enableWebSearch!==!1,onChange:j=>r({enableWebSearch:j}),label:"Allow AI scientific web search"})})]})}),o.jsxs(yt,{title:"Default assistant",description:"Choose between your BYOK providers or Synlexa Cloud.",children:[o.jsx("div",{className:"grid gap-3 @lg:grid-cols-2",children:Uv.map(j=>{const q=S.provider===j,z=e[j]??{apiKey:"",model:es[j].models[0]?.id??""},O=!!z.apiKey,V=es[j].models.find(P=>P.id===z.model)?.label??z.model;return o.jsxs("button",{type:"button",onClick:()=>r({provider:j,...j==="synlexa"&&S.hasByok?{routingPreference:"manual"}:{}}),className:Ie("rounded-xl border p-4 text-left transition-colors",q?"border-sky-400/60 bg-sky-500/[0.07]":"border-white/10 hover:border-white/20 hover:bg-white/[0.02]"),children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm font-semibold text-slate-100",children:es[j].label}),o.jsx("span",{className:Ie("h-4 w-4 rounded-full border-2",q?"border-sky-400 bg-sky-400 shadow-[inset_0_0_0_2px_#121722]":"border-slate-600")})]}),o.jsx("div",{className:"mt-1 text-xs text-slate-400",children:j==="synlexa"?O?`Signed in · ${V}`:"Sign in required":O?`BYOK key encrypted · ${V}`:"No key yet"})]},j)})}),!e[S.provider]?.apiKey&&o.jsx("p",{className:"mt-3 text-xs text-slate-400",children:"Until you add a BYOK key or sign in to Synlexa Cloud, the assistant answers with the built-in deterministic helper."})]}),o.jsxs(yt,{title:"Synlexa Cloud",description:"Gemini through your synlexa.com account. Used only when selected and no BYOK override is active.",children:[o.jsxs("div",{className:"divide-y divide-white/[0.05]",children:[o.jsx(Qt,{label:"Account",hint:e.synlexa.apiKey?"Connected":"Not connected",children:e.synlexa.apiKey?o.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-200",children:[o.jsx(Gs,{className:"h-4 w-4 text-emerald-400"}),s?.email??s?.displayName??"Signed in"]}):o.jsxs(Oe,{size:"sm",variant:"primary",disabled:c,onClick:()=>i("signin"),children:[c?o.jsx(qs,{className:"h-3.5 w-3.5 animate-spin"}):null,c?"Waiting for synlexa.com…":s?"Reconnect to synlexa.com":"Sign in to synlexa.com"]})}),o.jsx(Qt,{label:"Model",children:o.jsx("div",{className:"w-full @xl:w-80",children:o.jsx(Na,{value:e.synlexa.model,onChange:j=>r({synlexa:{model:j.target.value}}),children:es.synlexa.models.map(j=>o.jsxs("option",{value:j.id,children:[j.label," — ",j.note]},j.id))})})})]}),s&&!e.synlexa.apiKey&&o.jsx("p",{className:"mt-3 text-xs text-slate-400",children:"Your current sign-in was not confirmed by synlexa.com, so Studio has no account token. Sign in again to connect."})]}),["anthropic","gemini","openai"].map(j=>{const q=es[j],z=e[j]??{apiKey:"",model:q.models[0]?.id??""},O=q.models.some(P=>P.id===z.model),V=p[j];return o.jsxs(yt,{title:q.label,description:o.jsxs(o.Fragment,{children:["Get a key at"," ",o.jsx("a",{href:q.keyUrl,target:"_blank",rel:"noreferrer",className:"text-sky-300 hover:underline",children:new URL(q.keyUrl).host})]}),actions:o.jsxs(Oe,{size:"sm",disabled:!z.apiKey||d!==null,onClick:()=>void T(j),children:[d===j?o.jsx(qs,{className:"h-3.5 w-3.5 animate-spin"}):null,"Test connection"]}),children:[o.jsxs("div",{className:"divide-y divide-white/[0.05]",children:[o.jsx(Qt,{label:"API key",hint:z.apiKey?"Encrypted in state.vscdb · Active when saved":"Not set",children:o.jsx("div",{className:"w-full @xl:w-80",children:o.jsx(NL,{provider:j,value:z.apiKey,onSave:P=>{const $=P.trim();r({[j]:{apiKey:$},...$?{provider:j}:{}}),b(H=>({...H,[j]:void 0}))}})})}),o.jsx(Qt,{label:"Model",children:o.jsxs("div",{className:"w-full space-y-2 @xl:w-80",children:[o.jsxs(Na,{value:O?z.model:"__custom",onChange:P=>{P.target.value!=="__custom"?r({[j]:{model:P.target.value}}):r({[j]:{model:""}})},children:[q.models.map(P=>o.jsxs("option",{value:P.id,children:[P.label," — ",P.note]},P.id)),o.jsx("option",{value:"__custom",children:"Custom model ID…"})]}),!O&&o.jsx(Dn,{defaultValue:z.model,placeholder:"exact model ID",className:"font-mono text-[0.8125rem]",onBlur:P=>P.target.value.trim()&&r({[j]:{model:P.target.value.trim()}})})]})})]}),V&&o.jsx("div",{className:Ie("mt-3 rounded-lg px-3 py-2 text-sm",V.ok?"bg-emerald-500/10 text-emerald-200":"bg-rose-500/10 text-rose-200"),children:V.msg}),j==="anthropic"&&(z.model==="claude-opus-5-5"||z.model==="claude-sonnet-5-5")&&o.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"If the selected model declines a request, the API automatically retries it on a fallback model (server-side fallback)."})]},j)}),o.jsx(yt,{title:"Agent Tool Permissions",description:"Control when the AI Assistant asks for interactive confirmation before acting across Studio tools.",children:o.jsx("div",{className:"divide-y divide-white/[0.05]",children:Object.keys(Z5).map(j=>{const q=Z5[j];return o.jsx(Qt,{label:q.label,hint:q.description,children:o.jsxs(Na,{value:_[j],onChange:z=>E(j,z.target.value),className:"w-44",children:[o.jsx("option",{value:"ask",children:"Ask before running"}),o.jsx("option",{value:"always-allow",children:"Always allow"}),o.jsx("option",{value:"deny",children:"Block (deny)"})]})},j)})})})]})}function TL(){const[e,r]=C.useState(iy),[n,s]=C.useState(30),{confirm:i}=cl();C.useEffect(()=>vI(()=>r(iy())),[]);const c=C.useMemo(()=>SI(e,n),[e,n]),d=Math.max(1,...c.days.map(p=>p.tokens)),f=new Intl.NumberFormat;return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"Usage",description:"AI requests and tokens made from this browser, as reported by each provider. Billing happens on your provider account."}),o.jsx("div",{className:"flex gap-1",children:[7,30].map(p=>o.jsxs("button",{type:"button",onClick:()=>s(p),className:Ie("rounded-lg px-3 py-1.5 text-sm",n===p?"bg-white/[0.1] text-white":"text-slate-400 hover:bg-white/[0.05]"),children:["Last ",p," days"]},p))}),o.jsx("div",{className:"grid grid-cols-2 gap-3 @2xl:grid-cols-4",children:[["Requests",c.totals.requests],["Input tokens",c.totals.inputTokens],["Output tokens",c.totals.outputTokens],["Tool calls",c.totals.toolCalls]].map(([p,b])=>o.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] p-4",children:[o.jsx("div",{className:"text-xs text-slate-400",children:p}),o.jsx("div",{className:"mt-1 text-2xl font-semibold text-slate-100 tabular-nums",children:f.format(b)})]},p))}),o.jsxs(yt,{title:"Tokens per day",children:[o.jsx("div",{className:"flex h-32 items-end gap-[3px]",children:c.days.map(p=>o.jsxs("div",{className:"group relative flex h-full flex-1 items-end",children:[o.jsx("div",{className:"w-full rounded-t-sm bg-sky-400/70 transition-colors group-hover:bg-sky-300",style:{height:`${p.tokens?Math.max(3,p.tokens/d*100):0}%`}}),o.jsxs("div",{className:"pointer-events-none absolute bottom-full left-1/2 z-10 mb-1 hidden -translate-x-1/2 rounded-md bg-black/90 px-2 py-1 text-xs whitespace-nowrap text-slate-200 group-hover:block",children:[p.date,": ",f.format(p.tokens)," tokens · ",p.requests," req"]})]},p.date))}),o.jsxs("div",{className:"mt-2 flex justify-between text-xs text-slate-500",children:[o.jsx("span",{children:c.days[0]?.date}),o.jsx("span",{children:"Today"})]})]}),o.jsx(yt,{title:"By model",actions:o.jsx(Oe,{size:"sm",variant:"ghost",disabled:!e.length,onClick:async()=>{await i({title:"Clear usage history?",message:"This only resets the local counters.",confirmLabel:"Clear"})&&wI()},children:"Reset counters"}),children:c.byProvider.length===0?o.jsx("div",{className:"text-sm text-slate-400",children:"No AI requests in this period."}):o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"text-left text-xs text-slate-500",children:[o.jsx("th",{className:"pb-2 font-medium",children:"Model"}),o.jsx("th",{className:"pb-2 text-right font-medium",children:"Requests"}),o.jsx("th",{className:"pb-2 text-right font-medium",children:"Input"}),o.jsx("th",{className:"pb-2 text-right font-medium",children:"Output"}),o.jsx("th",{className:"pb-2 text-right font-medium",children:"Errors"})]})}),o.jsx("tbody",{className:"tabular-nums",children:c.byProvider.map(([p,b])=>{const[x,g]=p.split("::");return o.jsxs("tr",{className:"border-t border-white/[0.05]",children:[o.jsxs("td",{className:"py-2",children:[o.jsx("span",{className:"text-slate-200",children:g})," ",o.jsx("span",{className:"text-xs text-slate-500",children:x==="local"?"built-in":x})]}),o.jsx("td",{className:"py-2 text-right text-slate-300",children:f.format(b.requests)}),o.jsx("td",{className:"py-2 text-right text-slate-300",children:f.format(b.inputTokens)}),o.jsx("td",{className:"py-2 text-right text-slate-300",children:f.format(b.outputTokens)}),o.jsx("td",{className:Ie("py-2 text-right",b.errors?"text-rose-300":"text-slate-500"),children:b.errors})]},p)})})]})})]})}function EL(){const[e,r]=Zv(),n=e.viewer,s=i=>r(c=>({...c,viewer:{...c.viewer,...i}}));return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"3D viewer",description:"Defaults applied when Studio opens."}),o.jsx(yt,{children:o.jsxs("div",{className:"divide-y divide-white/[0.05]",children:[o.jsx(Qt,{label:"Representation",children:o.jsxs(Na,{className:"w-full @xl:w-56",value:n.defaultStyle,onChange:i=>s({defaultStyle:i.target.value}),children:[o.jsx("option",{value:"ribbon",children:"Ribbon"}),o.jsx("option",{value:"trace",children:"Cα trace"}),o.jsx("option",{value:"pocket",children:"Active pocket"})]})}),o.jsx(Qt,{label:"Color by",children:o.jsxs(Na,{className:"w-full @xl:w-56",value:n.defaultColorMode,onChange:i=>s({defaultColorMode:i.target.value}),children:[o.jsx("option",{value:"identity",children:"Structure identity"}),o.jsx("option",{value:"plddt",children:"pLDDT (predictions)"}),o.jsx("option",{value:"bfactor",children:"B-factor (experimental)"}),o.jsx("option",{value:"deviation",children:"Per-residue deviation Δd"})]})}),o.jsx(Qt,{label:"Layout",children:o.jsxs(Na,{className:"w-full @xl:w-56",value:n.defaultLayout,onChange:i=>s({defaultLayout:i.target.value}),children:[o.jsx("option",{value:"overlay",children:"Overlay"}),o.jsx("option",{value:"split",children:"Side by side"}),o.jsx("option",{value:"reference",children:"Reference only"}),o.jsx("option",{value:"mobile",children:"Comparison only"})]})}),o.jsx(Qt,{label:"Embed viewport image in HTML reports",children:o.jsx($r,{checked:n.embedPngInReports,onChange:i=>s({embedPngInReports:i})})})]})}),o.jsxs(yt,{title:"Controls",children:[o.jsxs("dl",{className:"grid grid-cols-[11rem_1fr] gap-y-2.5 text-sm",children:[o.jsx("dt",{className:"text-slate-400",children:"Rotate"}),o.jsx("dd",{className:"text-slate-200",children:"Drag · one-finger drag"}),o.jsx("dt",{className:"text-slate-400",children:"Zoom"}),o.jsx("dd",{className:"text-slate-200",children:"Scroll · trackpad pinch · two-finger pinch"}),o.jsx("dt",{className:"text-slate-400",children:"Pan"}),o.jsx("dd",{className:"text-slate-200",children:"Shift + drag · right-drag · two-finger drag"}),o.jsx("dt",{className:"text-slate-400",children:"Select residue"}),o.jsx("dd",{className:"text-slate-200",children:"Click"})]}),o.jsx("p",{className:"mt-3 text-xs text-slate-500",children:"Pinch and ctrl-scroll only zoom the 3D scene; the rest of the interface stays fixed."})]})]})}function ML({onResetLayout:e}){const[r,n]=Zv(),{toast:s}=cl();return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"Workspace",description:"Interface size, tabs, and behavior."}),o.jsx(yt,{children:o.jsxs("div",{className:"divide-y divide-white/[0.05]",children:[o.jsx(Qt,{label:"Interface size",hint:o.jsxs(o.Fragment,{children:["Also ",o.jsx(Rr,{children:"⌘"})," ",o.jsx(Rr,{children:"+"})," / ",o.jsx(Rr,{children:"⌘"})," ",o.jsx(Rr,{children:"−"})," / ",o.jsx(Rr,{children:"⌘"})," ",o.jsx(Rr,{children:"0"})]}),children:o.jsxs("div",{className:"flex w-full items-center gap-3 @xl:w-64",children:[o.jsx("input",{type:"range",min:nE,max:sE,step:aE,value:r.uiScale,onChange:i=>n({uiScale:Number(i.target.value)}),className:"flex-1 accent-sky-400","aria-label":"Interface size"}),o.jsxs("span",{className:"w-12 text-right text-sm text-slate-300 tabular-nums",children:[Math.round(r.uiScale*100),"%"]})]})}),o.jsx(Qt,{label:"Guided explanations",hint:"Plain-language notes next to metrics and in tools.",children:o.jsx($r,{checked:r.guidedMode,onChange:i=>n({guidedMode:i})})}),o.jsx(Qt,{label:"Reopen tabs on launch",children:o.jsx($r,{checked:r.restoreTabs,onChange:i=>n({restoreTabs:i})})}),o.jsx(Qt,{label:"Load example comparison on launch",hint:"Carbonic anhydrase II: crystal vs AlphaFold.",children:o.jsx($r,{checked:r.loadDemoOnStart,onChange:i=>n({loadDemoOnStart:i})})}),o.jsx(Qt,{label:"Save imports to library automatically",children:o.jsx($r,{checked:r.autoSaveImports,onChange:i=>n({autoSaveImports:i})})}),o.jsx(Qt,{label:"Confirm before deleting",children:o.jsx($r,{checked:r.confirmDeletes,onChange:i=>n({confirmDeletes:i})})}),o.jsx(Qt,{label:"Tab layout",children:o.jsx(Oe,{size:"sm",onClick:()=>{e(),s("Tab layout reset","success")},children:"Reset layout"})})]})}),o.jsx(yt,{title:"Keyboard shortcuts",actions:o.jsx(g6,{className:"h-4 w-4 text-slate-500"}),children:o.jsx("dl",{className:"grid grid-cols-[1fr_auto] gap-y-2.5 text-sm",children:[["Command palette",["⌘","K"]],["Open file",["⌘","O"]],["Search databases",["⌘","Shift","F"]],["Close tab",["Alt","W"]],["Toggle sidebar",["⌘","B"]],["Settings",["⌘",","]],["Interface size",["⌘","+ / −"]]].map(([i,c])=>o.jsxs("div",{className:"contents",children:[o.jsx("dt",{className:"text-slate-300",children:i}),o.jsx("dd",{className:"flex gap-1",children:c.map(d=>o.jsx(Rr,{children:d},d))})]},i))})})]})}function RL({onClearedHistory:e}){const{confirm:r,toast:n}=cl(),[s,i]=C.useState({count:0,bytes:0}),[c,d]=C.useState(null);return C.useEffect(()=>{const f=()=>nu().then(p=>i({count:p.length,bytes:p.reduce((b,x)=>b+x.sizeBytes,0)}));return f(),navigator.storage?.estimate?.().then(d).catch(()=>{}),r0(()=>void f())},[]),o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"Data & storage",description:"Everything here is stored on this device only."}),o.jsx(yt,{children:o.jsxs("div",{className:"divide-y divide-white/[0.05]",children:[o.jsx(Qt,{label:"Library",hint:`${s.count} items · ${Uc(s.bytes)}`,children:o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Oe,{size:"sm",disabled:!s.count,onClick:async()=>{const f=await lE(Cn),p=URL.createObjectURL(new Blob([JSON.stringify(f,null,2)],{type:"application/json"})),b=document.createElement("a");b.href=p,b.download=`synlexa-library-${new Date().toISOString().slice(0,10)}.json`,b.click(),setTimeout(()=>URL.revokeObjectURL(p),1e3)},children:"Export"}),o.jsx(Oe,{size:"sm",variant:"danger",disabled:!s.count,onClick:async()=>{await r({title:`Delete all ${s.count} library items?`,message:"This permanently removes every stored structure, compound, and sequence from this device. Export first if you want a backup.",confirmLabel:"Delete all",danger:!0})&&(await KD(),n("Library cleared","success"))},children:"Delete all"})]})}),o.jsx(Qt,{label:"Comparison run history",children:o.jsx(Oe,{size:"sm",variant:"danger",onClick:async()=>{await r({title:"Clear run history?",message:"Removes the list of past comparisons.",confirmLabel:"Clear",danger:!0})&&(await uE(),e(),n("Run history cleared","success"))},children:"Clear"})}),o.jsx(Qt,{label:"Settings",hint:"Restore every preference to its default.",children:o.jsx(Oe,{size:"sm",onClick:async()=>{await r({title:"Reset all settings?",message:"API keys and your library are not affected.",confirmLabel:"Reset"})&&(GD(),n("Settings reset","success"))},children:"Reset"})}),c?.usage!==void 0&&o.jsx(Qt,{label:"Browser storage used by Studio",children:o.jsxs("span",{className:"text-sm text-slate-300 tabular-nums",children:[Uc(c.usage??0),c.quota?` of ${Uc(c.quota)}`:""]})})]})})]})}const zL="0.4.4";function OL(){return o.jsxs(o.Fragment,{children:[o.jsx(ul,{title:"About Synlexa Studio"}),o.jsx(yt,{children:o.jsxs("dl",{className:"grid grid-cols-[10rem_1fr] gap-y-2.5 text-sm",children:[o.jsx("dt",{className:"text-slate-400",children:"Version"}),o.jsx("dd",{className:"text-slate-200",children:zL}),o.jsx("dt",{className:"text-slate-400",children:"Compute engine"}),o.jsx("dd",{className:"text-slate-200",children:"synlexa-bio-core (Rust → WebAssembly), runs locally"}),o.jsx("dt",{className:"text-slate-400",children:"Storage"}),o.jsx("dd",{className:"text-slate-200",children:"On this device (IndexedDB + localStorage)"})]})}),o.jsxs("div",{className:"rounded-xl border border-amber-500/20 bg-amber-500/[0.06] p-4 text-sm leading-relaxed text-amber-100/90",children:[Cn," Computational outputs are exploratory and have not been clinically validated."]})]})}const Cc=[{id:1,title:"Start Page & Multi-Project Workspaces",subtitle:"Create isolated projects from templates and keep structures, ligands, and edits organized",icon:Qc,targetTab:"home",actionLabel:"Open Start Page",tryActionKey:"home",summary:"Synlexa Studio starts on the Start Page so you can create a new research project, launch starter benchmarks, or resume saved workspaces before diving into 3D inspection.",bullets:['Click "+ New project" on the Start Page or Workspace Explorer to create a dedicated project (Structure Compare, Ligand Design & Binding, or Peptide & CRISPR Test).',"Switch between projects anytime — all imported structures, designed SMILES molecules, peptides, and CRISPR targets stay organized inside each project.","Alt-click any tool in the Tools sidebar to open tabs side-by-side."]},{id:2,title:"Import Multiple Structures & Split Chains / Ligands",subtitle:"Load PDB/mmCIF files or fetch RCSB, AlphaFold, UniProt, and PubChem records",icon:Px,targetTab:"viewer",actionLabel:"Open 3D Viewer",tryActionKey:"viewer",summary:"Import multiple local structures by drag-and-drop or fetch public IDs directly. Split multi-chain complexes or co-crystallized ligands into standalone project assets.",bullets:["Load structures into Reference and Comparison slots from your disk or Public Databases.",'Click "Split Ref" or "Split Comp" in the Workspace Explorer (or ask the AI Assistant) to split polymer chains and non-water HETATM ligands into independent assets.',"Inspect deterministic float64 Kabsch RMSD, TM-score, GDT-TS, and per-residue Cα distances in 3D."]},{id:3,title:"Design Molecules in the 2D Sketcher & RDKit Engine",subtitle:"Edit ligands visually or by SMILES, score drug-likeness & PAINS alerts, and save to project",icon:ia,targetTab:"chemistry",actionLabel:"Open Ligands & 2D Sketcher",tryActionKey:"chemistry",summary:"Draw ring systems and bonds on the interactive 2D SVG canvas or enter SMILES strings directly. Studio runs RDKit in WebAssembly to compute deterministic descriptors offline.",bullets:["Check exact molecular formula, MW, cLogP, TPSA, HBD/HBA, rotatable bonds, SA score, and Lipinski/Veber checks.","Flag PAINS structural alerts locally before saving promising analogs into your active project.",'Click "Bind" next to any saved project molecule to stage docking/binding tests.']},{id:4,title:"Peptide Engineering & CRISPR / Base-Editing Workbenches",subtitle:"Mutate residues, check 3D active-site contacts, and score SpCas9/SaCas9/Cas12a guides",icon:Fs,targetTab:"peptide",actionLabel:"Open Peptide Workbench",tryActionKey:"peptide",summary:"Test point mutations in loaded protein sequences and inspect base-editing CRISPR targets with automatic PAM matching and codon delta computation.",bullets:["In Peptide Engineering, apply mutations (e.g. H94A), track isoelectric point / charge shifts, and focus those positions in Mol* 3D.","In Gene & CRISPR, switch nucleases (SpCas9 NGG, SaCas9, Cas12a), inspect guide RNAs, and preview amino-acid consequences."]},{id:5,title:"External GPU Nodes (Colab / SSH) & Workflow Canvas",subtitle:"Connect AutoDock Vina, OpenMM MD, Boltz-2, RFdiffusion, and PySCF backends",icon:al,targetTab:"compute",actionLabel:"Open GPU & Compute Nodes",tryActionKey:"compute",summary:"Light visualization and cheminformatics run in-browser via Rust WASM & RDKit. Heavy GPU jobs dispatch cleanly to a local sidecar, Google Colab, or cluster worker.",bullets:["Connect your Google Colab / FastAPI compute worker URL & bearer token in GPU & Compute Nodes.","Design multi-step pipelines in Workflow Canvas and export reproducible Nextflow (`main.nf`) or Snakemake (`Snakefile`) definitions."]},{id:6,title:"Autonomous AI Agent: Live Thinking, Octopus Tools & Permissions",subtitle:"Full UI + project control with interactive permission prompts",icon:qr,targetTab:"assistant",actionLabel:"Open AI Assistant",tryActionKey:"assistant",summary:'The AI Assistant uses Studio’s in-app MCP server as "octopus arms" to create projects, design molecules, split structures, run workflows, and switch UI tabs.',bullets:["Watch the live Thinking & Tool Trace accordion while the agent plans rounds and runs tools.","Sensitive categories (external web/database fetches and remote GPU/workflow execution) pause for your interactive Allow Once / Session / Deny approval.","Adjust per-category policies anytime in Settings → Agent Tool Permissions."]},{id:7,title:"BYOK Key Vault (state.vscdb) vs Synlexa Cloud & Exports",subtitle:"Keep your own Anthropic/Gemini/OpenAI keys encrypted locally with full control",icon:Ki,actionLabel:"Open AI & Key Settings",tryActionKey:"settings",summary:"When you enter your own API key (Anthropic, Gemini, or OpenAI), Studio encrypts it in local state.vscdb and routes directly to your provider instead of Synlexa Cloud.",bullets:['Use "Prefer BYOK keys" (default) so personal API keys always take priority, or switch to manual mode to choose Synlexa Cloud anytime.',"Export RUO-labeled HTML reports, JSON manifests, and reproducible `.synlexa.bundle.json` project archives."]}];function PL({open:e,onClose:r,onExecuteStepAction:n}){const[s,i]=C.useState(0);if(C.useEffect(()=>{if(!e)return;const f=p=>{p.key==="Escape"&&r()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[e,r]),!e)return null;const c=Cc[s]??Cc[0],d=c.icon;return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-xs",role:"dialog","aria-modal":"true","aria-label":"Synlexa Studio Interactive Tutorial",onClick:f=>{f.target===f.currentTarget&&r()},children:o.jsxs("div",{className:"flex max-h-[88vh] w-full max-w-3xl flex-col overflow-hidden rounded-2xl border border-white/15 bg-[#0e131c] shadow-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-white/[0.08] px-5 py-3.5",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-sky-500/15 text-sky-300",children:o.jsx(jy,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold text-slate-100",children:"Synlexa Studio Interactive Guide"}),o.jsxs("p",{className:"text-xs text-slate-400",children:["Step ",c.id," of ",Cc.length," · Research-Use-Only (RUO)"]})]})]}),o.jsx("button",{type:"button",onClick:r,"aria-label":"Close guide",className:"rounded-lg p-1.5 text-slate-400 hover:bg-white/[0.06] hover:text-white",children:o.jsx(Xi,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"flex flex-wrap gap-1.5 border-b border-white/[0.06] bg-white/[0.015] px-5 py-2.5",children:Cc.map((f,p)=>{const b=p===s;return o.jsxs("button",{type:"button",onClick:()=>i(p),className:Ie("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors",b?"border-sky-400/50 bg-sky-500/15 text-sky-200":"border-white/10 bg-white/[0.02] text-slate-400 hover:text-slate-200"),children:[o.jsx("span",{className:"font-mono text-[0.6875rem]",children:f.id}),o.jsx("span",{className:"hidden sm:inline",children:f.title.split("&")[0]?.trim()})]},f.id)})}),o.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-6 py-5",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border border-sky-400/30 bg-sky-500/10 text-sky-300",children:o.jsx(d,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-slate-100",children:c.title}),o.jsxs(It,{tone:"accent",children:["Step ",c.id]})]}),o.jsx("p",{className:"mt-1 text-sm text-slate-400",children:c.subtitle})]})]}),o.jsx("p",{className:"mt-4 rounded-xl border border-white/[0.08] bg-white/[0.02] p-3.5 text-sm leading-relaxed text-slate-200",children:c.summary}),o.jsx("ul",{className:"mt-4 space-y-2.5",children:c.bullets.map((f,p)=>o.jsxs("li",{className:"flex items-start gap-2.5 text-sm text-slate-300",children:[o.jsx(Gs,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-400"}),o.jsx("span",{children:f})]},p))}),o.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2 rounded-xl border border-sky-500/20 bg-sky-500/[0.06] px-4 py-3",children:[o.jsx("span",{className:"text-xs text-slate-300",children:"Try this feature directly inside the Studio workspace:"}),o.jsx(Oe,{size:"sm",variant:"primary",className:"ml-auto",onClick:()=>{n(c.tryActionKey),r()},children:c.actionLabel??"Try in Studio"})]})]}),o.jsxs("div",{className:"flex items-center justify-between border-t border-white/[0.08] px-5 py-3",children:[o.jsx(Oe,{size:"sm",variant:"ghost",disabled:s===0,icon:o.jsx(iR,{className:"h-3.5 w-3.5"}),onClick:()=>i(f=>Math.max(0,f-1)),children:"Previous"}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[o.jsx(qi,{className:"h-3.5 w-3.5"}),o.jsx("span",{children:"Press Esc anytime · Reopen via Guide in the top bar"})]}),s<Cc.length-1?o.jsxs(Oe,{size:"sm",variant:"primary",onClick:()=>i(f=>Math.min(Cc.length-1,f+1)),children:["Next",o.jsx(DA,{className:"ml-1 h-3.5 w-3.5"})]}):o.jsx(Oe,{size:"sm",variant:"primary",onClick:r,children:"Done"})]})]})})}function $L({onExecuteNode:e,activeComputeLabel:r,onOpenComputeNodes:n,bridge:s}){const[i,c]=C.useState(()=>Zd[0]),[d,f]=C.useState(Zd[0].nodes[0]?.id??null),[p,b]=C.useState(null),[x,g]=C.useState({}),[_,y]=C.useState(!1),[S,k]=C.useState(null),[E,T]=C.useState(!1),j=C.useRef(null),q=C.useMemo(()=>new Map(i.nodes.map(W=>[W.id,W])),[i.nodes]),z=C.useMemo(()=>{let W=960,me=340;for(const I of i.nodes)I.x+230>W&&(W=I.x+230),I.y+130>me&&(me=I.y+130);return{width:W,height:me}},[i.nodes]),O=W=>{const me=Zn[W],I=`n${Date.now().toString(36).slice(-4)}`,J=i.nodes.length%4,ge=Math.floor(i.nodes.length/4);c(le=>({...le,nodes:[...le.nodes,{id:I,kind:W,x:40+J*235,y:45+ge*125,params:{...me.defaultParams}}]})),f(I)},V=W=>{c(me=>({...me,nodes:me.nodes.filter(I=>I.id!==W),edges:me.edges.filter(I=>I.from!==W&&I.to!==W)})),d===W&&f(null)},P=W=>{c(me=>({...me,edges:me.edges.filter(I=>I.id!==W)}))},$=W=>{if(!p||p===W){b(null);return}i.edges.some(I=>I.from===p&&I.to===W)||c(I=>({...I,edges:[...I.edges,{id:`e-${p}-${W}`,from:p,to:W}]})),b(null)},H=()=>{let W=i.nodes;try{W=fh(i)}catch{}const me=new Map;for(const J of W)me.set(J.id,0);for(const J of W){const ge=me.get(J.id)??0;for(const le of i.edges)le.from===J.id&&me.set(le.to,Math.max(me.get(le.to)??0,ge+1))}const I=new Map;for(const J of W){const ge=me.get(J.id)??0,le=I.get(ge)??[];le.push(J.id),I.set(ge,le)}c(J=>({...J,nodes:J.nodes.map(ge=>{const le=me.get(ge.id)??0,ae=(I.get(le)??[ge.id]).indexOf(ge.id);return{...ge,x:32+le*235,y:44+ae*124}})}))},Z=(W,me,I)=>{c(J=>({...J,nodes:J.nodes.map(ge=>ge.id===W?{...ge,params:{...ge.params,[me]:I}}:ge)}))},G=async()=>{k(null);let W;try{W=fh(i)}catch(I){k(I instanceof Error?I.message:String(I));return}y(!0);const me={};for(const I of W)me[I.id]={status:"idle"};g(me);try{for(const I of W){g(J=>({...J,[I.id]:{status:"running"}}));try{const J=await e(I.kind,I.params);g(ge=>({...ge,[I.id]:{status:"completed",summary:J.summary,metrics:J.metrics}}))}catch(J){const ge=J instanceof Error?J.message:String(J);g(le=>({...le,[I.id]:{status:"failed",error:ge}})),k(`Stopped at ${Zn[I.kind].label}: ${ge}`);break}}}finally{y(!1)}},K=(W,me)=>{const I=new Blob([me],{type:"text/plain;charset=utf-8"}),J=URL.createObjectURL(I),ge=document.createElement("a");ge.href=J,ge.download=W,ge.click(),setTimeout(()=>URL.revokeObjectURL(J),1e3)},we=(W,me,I,J)=>{W.target.closest("button")||(W.currentTarget.setPointerCapture(W.pointerId),j.current={id:me,startClientX:W.clientX,startClientY:W.clientY,origX:I,origY:J,moved:!1})},Se=W=>{const me=j.current;if(!me)return;const I=W.clientX-me.startClientX,J=W.clientY-me.startClientY;if((Math.abs(I)>4||Math.abs(J)>4)&&(me.moved=!0),!me.moved)return;const ge=Math.max(16,me.origX+I),le=Math.max(16,me.origY+J);c(D=>({...D,nodes:D.nodes.map(ae=>ae.id===me.id?{...ae,x:ge,y:le}:ae)}))},Q=W=>{const me=j.current;j.current=null,me&&!me.moved&&(p&&p!==W?$(W):f(W))},F=d?q.get(d)??null:null,he=F?i.edges.filter(W=>W.from===F.id||W.to===F.id):[];return o.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-3 overflow-y-auto p-3 text-xs @xl:p-4",children:[o.jsx(ir,{bridge:s,title:"Visual Workflow Canvas (DAG)",subtitle:"Chain local Wasm/RDKit steps and external GPU jobs using your active 3D structure & ligand, or export Nextflow / Snakemake.",icon:o.jsx(Dp,{className:"h-4 w-4"}),guideOpen:E,onToggleGuide:()=>T(W=>!W),actions:o.jsxs("button",{type:"button",onClick:n,className:"rounded-lg border border-white/10 bg-white/[0.04] px-2.5 py-1 text-xs text-slate-300 hover:border-sky-500/40",children:["GPU Node: ",o.jsx("strong",{className:r?"text-emerald-300":"text-amber-300",children:r??"Not paired"})]})}),o.jsx(Qi,{open:E,title:"How the Visual Workflow Canvas Works",summary:"Design reproducible Directed Acyclic Graph (DAG) pipelines combining Tier-0/Tier-1 browser Wasm steps (Kabsch, RDKit, Reports) and Tier-2 GPU Compute Node workloads (Vina, OpenMM, Boltz-2, RFdiffusion, PySCF).",steps:["Pick a starter template or click + buttons to add processing nodes onto the canvas.","Drag nodes to organize them, click Link → on one node then click a target node to connect edges, and edit node parameters in the Inspector below.","Click Run DAG to execute topologically using your active 3D structures & ligand SMILES, or export a reproducible Nextflow / Snakemake script."],connectionTip:"The Workspace Inputs node automatically pulls your currently loaded 3D Reference/Comparison structures, active SMILES ligand, and 3D Vina pocket box."}),o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx(Oe,{size:"sm",variant:"secondary",icon:o.jsx(VA,{className:"h-3.5 w-3.5"}),onClick:H,children:"Auto-Layout"}),o.jsx(Oe,{size:"sm",variant:"secondary",icon:o.jsx(sr,{className:"h-3.5 w-3.5"}),onClick:()=>K("main.nf",X3(i)),children:"Nextflow"}),o.jsx(Oe,{size:"sm",variant:"secondary",icon:o.jsx(sr,{className:"h-3.5 w-3.5"}),onClick:()=>K("Snakefile",Q3(i)),children:"Snakemake"}),o.jsx(Oe,{size:"sm",variant:"secondary",icon:o.jsx(sr,{className:"h-3.5 w-3.5"}),onClick:()=>K(`${i.id}.synlexa-flow.json`,JSON.stringify(i,null,2)),children:"JSON"})]}),o.jsx(Oe,{size:"sm",variant:"primary",disabled:_,icon:_?o.jsx(qs,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(qp,{className:"h-3.5 w-3.5"}),onClick:()=>void G(),children:_?"Running Pipeline…":"Run DAG"})]}),o.jsxs("div",{className:"space-y-2 rounded-xl border border-white/[0.08] bg-[#0b1018] p-3",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] font-semibold text-slate-400 uppercase",children:"Templates:"}),Zd.map(W=>o.jsx("button",{type:"button",onClick:()=>{c(W),f(W.nodes[0]?.id??null),g({}),k(null)},className:Ie("rounded-lg border px-2.5 py-1 text-xs transition",i.id===W.id?"border-sky-400/50 bg-sky-500/20 text-sky-200":"border-white/10 bg-slate-900 text-slate-300 hover:border-white/25"),children:W.name},W.id))]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-400",children:"Add Node:"}),Object.keys(Zn).map(W=>{const me=Zn[W];return o.jsxs("button",{type:"button",onClick:()=>O(W),title:`${me.toolName} (${me.tier})`,className:"flex items-center gap-1 rounded-md border border-white/10 bg-slate-950 px-2 py-1 text-[0.6875rem] text-slate-300 hover:border-sky-500/40",children:[o.jsx(gh,{className:"h-3 w-3 text-sky-300"}),me.label]},W)})]})]}),S&&o.jsx("div",{className:"rounded-xl border border-rose-500/40 bg-rose-500/10 px-3 py-2 text-rose-200",children:S}),o.jsx("div",{className:"relative min-h-[300px] flex-1 overflow-auto rounded-xl border border-white/[0.08] bg-[#070b12]",children:o.jsxs("div",{className:"relative",style:{width:z.width,height:z.height},children:[o.jsxs("svg",{className:"pointer-events-none absolute inset-0 h-full w-full",children:[o.jsx("defs",{children:o.jsx("pattern",{id:"synlexa-dag-grid",width:"28",height:"28",patternUnits:"userSpaceOnUse",children:o.jsx("path",{d:"M 28 0 L 0 0 0 28",fill:"none",stroke:"rgba(148,163,184,0.05)",strokeWidth:"1"})})}),o.jsx("rect",{width:"100%",height:"100%",fill:"url(#synlexa-dag-grid)"}),i.edges.map(W=>{const me=q.get(W.from),I=q.get(W.to);if(!me||!I)return null;const J=me.x+196,ge=me.y+46,le=I.x,D=I.y+46,ae=(J+le)/2,pe=d===W.from||d===W.to;return o.jsx("path",{d:`M ${J} ${ge} C ${ae} ${ge}, ${ae} ${D}, ${le} ${D}`,fill:"none",stroke:pe?"rgba(56,189,248,0.85)":"rgba(56,189,248,0.4)",strokeWidth:pe?2.5:2},W.id)})]}),i.nodes.map(W=>{const me=Zn[W.kind],I=x[W.id],J=d===W.id;return o.jsxs("div",{style:{left:W.x,top:W.y,width:196},onPointerDown:ge=>we(ge,W.id,W.x,W.y),onPointerMove:Se,onPointerUp:()=>Q(W.id),className:Ie("absolute cursor-grab rounded-xl border bg-[#0d121b]/95 p-2.5 shadow-lg transition select-none active:cursor-grabbing",J?"border-sky-400/80 ring-1 ring-sky-400/35":"border-white/10 hover:border-white/25"),children:[o.jsxs("div",{className:"flex items-start justify-between gap-1",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"truncate font-semibold text-slate-100",children:me.label}),o.jsx("div",{className:"truncate font-mono text-[0.6875rem] text-slate-400",children:me.toolName})]}),I?.status==="running"&&o.jsx(qs,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-sky-400"}),I?.status==="completed"&&o.jsx(Gs,{className:"h-3.5 w-3.5 shrink-0 text-emerald-400"}),I?.status==="failed"&&o.jsx(Bc,{className:"h-3.5 w-3.5 shrink-0 text-rose-400"})]}),o.jsxs("div",{className:"mt-2 flex items-center justify-between gap-1",children:[o.jsx(It,{tone:me.tier==="tier2-gpu"?"warn":me.tier==="tier1-wasm"?"accent":"good",children:me.tier}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),b(p===W.id?null:W.id)},className:Ie("rounded border px-1.5 py-0.5 text-[0.625rem]",p===W.id?"border-sky-400 bg-sky-500/20 text-sky-200":"border-white/10 text-slate-400 hover:text-slate-200"),children:p===W.id?"Click target…":"Link →"}),o.jsx("button",{type:"button",onClick:ge=>{ge.stopPropagation(),V(W.id)},className:"rounded p-0.5 text-slate-500 hover:text-rose-300",title:"Delete node",children:o.jsx(Wi,{className:"h-3 w-3"})})]})]}),I?.summary&&o.jsx("div",{className:"mt-1.5 truncate font-mono text-[0.6875rem] text-emerald-300",title:I.summary,children:I.summary}),I?.error&&o.jsx("div",{className:"mt-1.5 truncate font-mono text-[0.6875rem] text-rose-300",title:I.error,children:I.error})]},W.id)})]})}),F&&o.jsxs(yt,{className:"space-y-3 p-3.5",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-semibold text-slate-100",children:Zn[F.kind].label}),o.jsxs("span",{className:"font-mono text-[0.6875rem] text-slate-500",children:["(",F.id,")"]}),o.jsx(It,{tone:Zn[F.kind].tier==="tier2-gpu"?"warn":"good",children:Zn[F.kind].tier})]}),o.jsxs("div",{className:"mt-0.5 text-[0.6875rem] text-slate-400",children:["Input: ",Zn[F.kind].inputPort," → Output: ",Zn[F.kind].outputPort]})]}),Zn[F.kind].tier==="tier2-gpu"&&!r&&o.jsx("button",{type:"button",onClick:n,className:"rounded-lg border border-amber-400/40 bg-amber-500/10 px-2.5 py-1 text-[0.6875rem] font-medium text-amber-200 hover:bg-amber-500/20",children:"Requires Online GPU Node — Pair Colab / Local →"})]}),Object.keys(F.params).length>0&&o.jsx("div",{className:"grid grid-cols-1 gap-2 @lg:grid-cols-2 @3xl:grid-cols-3",children:Object.entries(F.params).map(([W,me])=>o.jsxs("label",{className:"flex flex-col gap-1 rounded-lg border border-white/[0.07] bg-black/25 px-2.5 py-2",children:[o.jsx("span",{className:"font-mono text-[0.6875rem] text-slate-400",children:W}),typeof me=="boolean"?o.jsxs("span",{className:"flex items-center gap-2 text-xs text-slate-200",children:[o.jsx("input",{type:"checkbox",checked:me,onChange:I=>Z(F.id,W,I.target.checked),className:"accent-sky-400"}),me?"Enabled":"Disabled"]}):typeof me=="number"?o.jsx("input",{type:"number",value:me,onChange:I=>Z(F.id,W,Number(I.target.value)||0),className:"h-7 rounded border border-white/10 bg-slate-950 px-2 font-mono text-xs text-slate-100 outline-none focus:border-sky-400"}):o.jsx("input",{value:String(me),onChange:I=>Z(F.id,W,I.target.value),className:"h-7 rounded border border-white/10 bg-slate-950 px-2 font-mono text-xs text-slate-100 outline-none focus:border-sky-400"})]},W))}),he.length>0&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-white/[0.06] pt-2",children:[o.jsx("span",{className:"text-[0.6875rem] text-slate-500",children:"Connections:"}),he.map(W=>{const me=Zn[q.get(W.from)?.kind??"load_structures"].label,I=Zn[q.get(W.to)?.kind??"load_structures"].label;return o.jsxs("button",{type:"button",onClick:()=>P(W.id),title:"Click to unlink edge",className:"inline-flex items-center gap-1 rounded-md border border-white/10 bg-black/30 px-2 py-0.5 text-[0.6875rem] text-slate-300 hover:border-rose-400/50 hover:text-rose-200",children:[o.jsxs("span",{children:[me," → ",I]}),o.jsx(sz,{className:"h-3 w-3"})]},W.id)})]})]})]})}const qd="application/x-synlexa-tab";function IL({layout:e,dispatch:r,meta:n,renderTab:s,keepAlive:i}){const c=C.useRef(null),[d,f]=C.useState(null),[p,b]=C.useState(null);C.useEffect(()=>{if(!p)return;const y=()=>b(null);return window.addEventListener("mousedown",y),window.addEventListener("blur",y),()=>{window.removeEventListener("mousedown",y),window.removeEventListener("blur",y)}},[p]);const x=y=>{y.preventDefault();const S=c.current;if(!S)return;const k=S.getBoundingClientRect(),E=j=>{r({type:"set_split",split:(j.clientX-k.left)/k.width})},T=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",T),document.body.style.cursor=""};document.body.style.cursor="col-resize",window.addEventListener("pointermove",E),window.addEventListener("pointerup",T)},g=(y,S,k)=>{const E=y.dataTransfer.getData(qd);f(null),E&&(y.preventDefault(),r({type:"move",tab:E,toGroup:S,index:k}))},_=e.groups.length===2;return o.jsxs("div",{ref:c,className:"relative flex min-h-0 min-w-0 flex-1",children:[e.groups.map((y,S)=>o.jsxs("div",{style:_?{width:`${(S===0?e.split:1-e.split)*100}%`}:void 0,className:Ie("relative flex min-h-0 min-w-0 flex-col",!_&&"flex-1"),onMouseDownCapture:()=>e.focused!==S&&r({type:"focus_group",group:S}),children:[o.jsxs("div",{role:"tablist",className:Ie("flex h-10 shrink-0 items-stretch border-b border-white/[0.06] bg-[#0d1119]",e.focused===S&&_&&"shadow-[inset_0_-1px_0_0_rgba(56,189,248,0.25)]"),onDragOver:k=>{k.dataTransfer.types.includes(qd)&&k.preventDefault()},onDrop:k=>g(k,S),children:[o.jsx("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto [scrollbar-width:none]",children:y.tabs.map((k,E)=>{const T=n[k],j=y.active===k,q=!Op.has(k);return o.jsxs("div",{role:"tab","aria-selected":j,tabIndex:0,draggable:!0,onDragStart:z=>{z.dataTransfer.setData(qd,k),z.dataTransfer.effectAllowed="move",f(k)},onDragEnd:()=>f(null),onDragOver:z=>{z.dataTransfer.types.includes(qd)&&z.preventDefault()},onDrop:z=>{z.stopPropagation(),g(z,S,E)},onClick:()=>r({type:"activate",tab:k}),onAuxClick:z=>{z.button===1&&q&&r({type:"close",tab:k})},onKeyDown:z=>{(z.key==="Enter"||z.key===" ")&&r({type:"activate",tab:k})},onContextMenu:z=>{z.preventDefault(),b({tab:k,x:z.clientX,y:z.clientY})},className:Ie("group relative flex max-w-56 min-w-0 shrink-0 cursor-pointer items-center gap-2 border-r border-white/[0.05] pr-1.5 pl-3 text-[0.8125rem] transition-colors select-none",j?"bg-[#121722] text-slate-100":"text-slate-400 hover:bg-white/[0.03] hover:text-slate-200",d===k&&"opacity-40"),children:[j&&o.jsx("span",{className:Ie("absolute inset-x-0 top-0 h-0.5",e.focused===S?"bg-sky-400":"bg-slate-600")}),o.jsx("span",{className:Ie("shrink-0",j?"text-sky-300":"text-slate-500"),children:T.icon}),o.jsx("span",{className:"truncate",children:T.title}),T.badge,q?o.jsx("button",{type:"button","aria-label":`Close ${T.title}`,title:"Close (middle-click)",onClick:z=>{z.stopPropagation(),r({type:"close",tab:k})},className:Ie("flex h-5 w-5 items-center justify-center rounded text-slate-500 hover:bg-white/10 hover:text-slate-100",j?"opacity-100":"opacity-0 group-hover:opacity-100"),children:o.jsx(Xi,{className:"h-3.5 w-3.5"})}):o.jsx("span",{className:"w-1"})]},k)})}),o.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 px-1.5",children:[y.active&&o.jsx("button",{type:"button",title:_?"Move tab to the other side":"Split editor right","aria-label":"Split editor",onClick:()=>y.active&&r({type:"open",tab:y.active,toSide:!0}),disabled:!_&&y.tabs.length<2,className:"flex h-7 w-7 items-center justify-center rounded-md text-slate-500 hover:bg-white/[0.07] hover:text-slate-200 disabled:opacity-30",children:o.jsx(Ey,{className:"h-4 w-4"})}),_&&o.jsx("button",{type:"button",title:"Merge split panes into single full-width view","aria-label":"Merge split panes",onClick:()=>r({type:"merge_split"}),className:"flex h-7 w-7 items-center justify-center rounded-md text-slate-500 hover:bg-white/[0.07] hover:text-sky-300",children:o.jsx(Oy,{className:"h-3.5 w-3.5"})})]})]}),o.jsxs("div",{className:"relative min-h-0 flex-1 bg-[#0f131b]",onDragOver:k=>{k.dataTransfer.types.includes(qd)&&k.preventDefault()},onDrop:k=>g(k,S),children:[y.tabs.map(k=>{const E=y.active===k;return!E&&!i?.has(k)?null:o.jsx("div",{role:"tabpanel",className:Ie("absolute inset-0 overflow-hidden",!E&&"invisible"),"aria-hidden":!E,children:s(k)},k)}),d&&o.jsx("div",{className:"pointer-events-none absolute inset-2 rounded-xl border-2 border-dashed border-sky-400/30 bg-sky-400/[0.03]"})]})]},S)),_&&o.jsx("div",{onPointerDown:x,onDoubleClick:()=>r({type:"set_split",split:.6}),style:{left:`calc(${e.split*100}% - 3px)`},className:"absolute top-0 bottom-0 z-20 w-1.5 cursor-col-resize bg-transparent transition-colors hover:bg-sky-400/40",title:"Drag to resize · double-click to reset"}),_&&o.jsx("div",{style:{left:`${e.split*100}%`},className:"pointer-events-none absolute top-0 bottom-0 z-10 w-px bg-white/[0.08]"}),!_&&d&&o.jsx("div",{onDragOver:y=>y.preventDefault(),onDrop:y=>g(y,1),className:"absolute top-10 right-0 bottom-0 z-30 flex w-1/3 items-center justify-center rounded-l-xl border-2 border-dashed border-sky-400/50 bg-sky-400/10 text-sm font-medium text-sky-200",children:"Drop to open on the side"}),p&&o.jsx("div",{onMouseDown:y=>y.stopPropagation(),style:{left:p.x,top:p.y},className:"fixed z-[75] min-w-52 overflow-hidden rounded-xl border border-white/10 bg-[#161c28] py-1 text-sm shadow-2xl",children:[{label:_?"Move to other side":"Open to the side",run:()=>r({type:"open",tab:p.tab,toSide:!0}),disabled:!_&&e.groups[0].tabs.length<2},..._?[{label:"Merge split panes",run:()=>r({type:"merge_split"}),disabled:!1}]:[],{label:"Close",run:()=>r({type:"close",tab:p.tab}),disabled:Op.has(p.tab)},{label:"Close others",run:()=>r({type:"close_others",tab:p.tab})}].map(y=>o.jsx("button",{type:"button",disabled:y.disabled,onClick:()=>{y.run(),b(null)},className:"flex w-full px-3 py-2 text-left text-slate-200 hover:bg-white/[0.06] disabled:opacity-40",children:y.label},y.label))})]})}function DL({projectTitle:e,session:r,onOpenPalette:n,onOpenFile:s,onSearchDatabases:i,onOpenMcp:c,onOpenTutorial:d,onExportHtml:f,onExportJson:p,onExportBundle:b,canExport:x,onOpenAccount:g}){const _=(r?.displayName??r?.email??"").split(/[\s@.]+/).filter(Boolean).slice(0,2).map(y=>y[0]?.toUpperCase()).join("");return o.jsxs("header",{className:"relative flex h-12 shrink-0 items-center gap-3 border-b border-white/[0.06] bg-[#0a0d13] px-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[o.jsx("span",{className:"text-sm font-semibold tracking-tight text-slate-100",children:"Synlexa Studio"}),o.jsx("span",{className:"hidden text-slate-700 md:inline",children:"/"}),o.jsx("span",{className:"hidden max-w-[18rem] truncate text-sm text-slate-400 md:inline",title:e,children:e})]}),o.jsxs("button",{type:"button",onClick:n,className:"absolute left-1/2 hidden h-8 w-[min(25rem,30vw)] -translate-x-1/2 items-center gap-2 rounded-lg border border-white/[0.08] bg-white/[0.03] px-3 text-sm text-slate-500 transition-colors hover:border-white/15 hover:text-slate-300 xl:flex",children:[o.jsx(Gr,{className:"h-4 w-4"}),o.jsx("span",{className:"flex-1 text-left",children:"Search commands, tools, MCP, settings…"}),o.jsx(Rr,{children:"⌘K"})]}),o.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(My,{className:"h-4 w-4"}),onClick:s,children:o.jsx("span",{className:"hidden sm:inline",children:"Open"})}),o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(Vi,{className:"h-4 w-4"}),onClick:i,children:o.jsx("span",{className:"hidden sm:inline",children:"Databases"})}),d&&o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(jy,{className:"h-4 w-4 text-emerald-400"}),onClick:d,children:o.jsx("span",{className:"hidden sm:inline",children:"Guide"})}),c&&o.jsx(Oe,{size:"sm",variant:"ghost",icon:o.jsx(rl,{className:"h-4 w-4 text-sky-400"}),onClick:c,children:o.jsx("span",{className:"hidden sm:inline",children:"MCP"})}),o.jsx(i1,{trigger:(y,S)=>o.jsxs(Oe,{size:"sm",variant:"secondary",onClick:S,icon:o.jsx(sr,{className:"h-4 w-4"}),children:[o.jsx("span",{className:"hidden sm:inline",children:"Export"}),o.jsx(ph,{className:Ie("h-3.5 w-3.5 transition-transform",y&&"rotate-180")})]}),items:[{label:"HTML report",icon:o.jsx(sr,{className:"h-4 w-4"}),onSelect:f,disabled:!x},{label:"JSON manifest",icon:o.jsx(BA,{className:"h-4 w-4"}),onSelect:p,disabled:!x},{label:"Project bundle",icon:o.jsx(UA,{className:"h-4 w-4"}),onSelect:b}]}),o.jsx("button",{type:"button",onClick:g,title:r?`Signed in as ${r.email??r.displayName??"user"}`:"Account & Settings",className:Ie("ml-1 flex h-8 w-8 items-center justify-center rounded-full text-xs font-semibold transition",r?"bg-gradient-to-br from-blue-500 to-blue-700 text-white":"border border-white/10 bg-white/[0.04] text-slate-400 hover:text-slate-200"),children:r?_||o.jsx(ah,{className:"h-4 w-4"}):o.jsx(ah,{className:"h-4 w-4"})})]})]})}function qL({view:e,sidebarOpen:r,onSelect:n,onOpenSettings:s,onOpenAssistant:i,onOpenMcp:c,libraryCount:d}){const f=[{id:"explorer",label:"Workspace",icon:o.jsx(qi,{className:"h-5 w-5"})},{id:"library",label:"Library",icon:o.jsx(sh,{className:"h-5 w-5"})},{id:"tools",label:"Tools",icon:o.jsx(Py,{className:"h-5 w-5"})},{id:"history",label:"History",icon:o.jsx(HA,{className:"h-5 w-5"})}];return o.jsxs("nav",{className:"flex w-14 shrink-0 flex-col items-center gap-1 border-r border-white/[0.06] bg-[#0a0d13] py-2",children:[f.map(p=>{const b=r&&e===p.id;return o.jsxs("button",{type:"button",title:p.label,"aria-label":p.label,onClick:()=>n(p.id),className:Ie("relative flex h-11 w-11 flex-col items-center justify-center rounded-xl transition-colors",b?"bg-white/[0.08] text-slate-100":"text-slate-500 hover:bg-white/[0.04] hover:text-slate-200"),children:[b&&o.jsx("span",{className:"absolute top-2 bottom-2 -left-1.5 w-0.5 rounded-full bg-sky-400"}),p.icon,p.id==="library"&&d>0&&o.jsx("span",{className:"absolute top-1 right-1 min-w-4 rounded-full bg-sky-500 px-1 text-[0.625rem] leading-4 font-semibold text-slate-950",children:d>99?"99+":d})]},p.id)}),o.jsx("div",{className:"flex-1"}),c&&o.jsx("button",{type:"button",title:"In-App MCP Server","aria-label":"In-App MCP Server",onClick:c,className:"flex h-11 w-11 items-center justify-center rounded-xl text-slate-500 hover:bg-white/[0.04] hover:text-sky-300",children:o.jsx(rl,{className:"h-5 w-5"})}),o.jsx("button",{type:"button",title:"AI Assistant","aria-label":"AI Assistant",onClick:i,className:"flex h-11 w-11 items-center justify-center rounded-xl text-slate-500 hover:bg-white/[0.04] hover:text-sky-300",children:o.jsx(qr,{className:"h-5 w-5"})}),o.jsx("button",{type:"button",title:"Settings (⌘,)","aria-label":"Settings",onClick:s,className:"flex h-11 w-11 items-center justify-center rounded-xl text-slate-500 hover:bg-white/[0.04] hover:text-slate-200",children:o.jsx(H6,{className:"h-5 w-5"})})]})}function LL({title:e,actions:r,children:n,width:s}){return o.jsxs("aside",{style:{width:s},className:"flex shrink-0 flex-col border-r border-white/[0.06] bg-[#0c1017]",children:[o.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between px-3",children:[o.jsx("span",{className:"text-xs font-semibold tracking-wide text-slate-400 uppercase",children:e}),o.jsx("div",{className:"flex items-center gap-0.5",children:r})]}),o.jsx("div",{className:"min-h-0 flex-1",children:n})]})}function RA({role:e,label:r,inspect:n,chain:s,onChangeChain:i,onReplace:c,onSaveToLibrary:d,hasContent:f}){const p=e==="reference",b=n&&n.chains.length>1&&!s;return o.jsxs("div",{className:Ie("rounded-xl border p-3",b?"border-amber-500/40 bg-amber-500/[0.04]":"border-white/[0.07] bg-white/[0.02]"),children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:Ie("text-[0.6875rem] font-semibold tracking-wide uppercase",p?"text-sky-300":"text-emerald-300"),children:p?"Reference":"Comparison"}),o.jsxs("div",{className:"flex items-center",children:[f&&o.jsx(sl,{label:"Save to library",onClick:d,children:o.jsx(qA,{className:"h-4 w-4"})}),o.jsx(sl,{label:`Replace ${p?"reference":"comparison"} file`,onClick:c,children:o.jsx(Oc,{className:"h-4 w-4"})})]})]}),f?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mt-1 truncate text-sm font-medium text-slate-100",title:r,children:r}),o.jsx("div",{className:"mt-0.5 text-xs text-slate-500",children:n?`${n.format.toUpperCase()} · ${n.chains.length} chain${n.chains.length===1?"":"s"} · ${n.confidenceKind==="prediction_plddt"?"predicted":n.confidenceKind==="experimental_b_factor"?"experimental":"unknown confidence"}`:"Reading…"}),n&&n.chains.length>0&&o.jsx("div",{className:"mt-2.5 flex flex-wrap gap-1",children:n.chains.map(x=>o.jsx("button",{type:"button",onClick:()=>i(x.chainId),title:`${x.observedCaCount} observed Cα`,className:Ie("rounded-md border px-2 py-1 font-mono text-xs transition-colors",s===x.chainId?p?"border-sky-400/50 bg-sky-400/15 text-sky-200":"border-emerald-400/50 bg-emerald-400/15 text-emerald-200":"border-white/10 text-slate-400 hover:border-white/25 hover:text-slate-200"),children:x.chainId},x.chainId))}),b&&o.jsx("div",{className:"mt-2 text-xs text-amber-300",children:"Pick a chain to run the comparison."})]}):o.jsx("button",{type:"button",onClick:c,className:"mt-1.5 text-sm text-slate-400 hover:text-sky-300",children:"Load a structure…"})]})}function UL(e){const r=C.useRef(null),n=C.useRef("auto"),[s,i]=C.useState(!1),[c,d]=C.useState(!1),[f,p]=C.useState(""),[b,x]=C.useState("ligand-docking"),g=y=>{n.current=y,r.current?.click()},_=()=>{e.onCreateProject&&(e.onCreateProject({name:f.trim()||"Untitled Research Project",template:b}),p(""),d(!1))};return o.jsxs("div",{className:"relative flex h-full flex-col overflow-y-auto px-3 pb-4",onDragOver:y=>{y.dataTransfer.types.includes("Files")&&(y.preventDefault(),i(!0))},onDragLeave:y=>y.currentTarget===y.target&&i(!1),onDrop:y=>{y.dataTransfer.files.length&&(y.preventDefault(),i(!1),e.onUploadFiles(y.dataTransfer.files,"auto"))},children:[o.jsx("input",{ref:r,type:"file",multiple:!0,accept:".cif,.mmcif,.pdb,.ent,.json,.fasta,.fa,.smi",className:"hidden",onChange:y=>{y.target.files?.length&&e.onUploadFiles(y.target.files,n.current),y.target.value=""}}),e.projects&&e.activeProject&&e.onSwitchProject&&o.jsxs("div",{className:"mb-3 rounded-xl border border-white/[0.08] bg-white/[0.02] p-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[o.jsx("span",{className:"text-[0.6875rem] font-semibold tracking-wide text-slate-400 uppercase",children:"Project"}),e.onCreateProject&&o.jsxs("button",{type:"button",onClick:()=>d(y=>!y),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[0.6875rem] text-sky-300 hover:bg-sky-500/10",children:[o.jsx(Qc,{className:"h-3 w-3"}),"New"]})]}),o.jsx(Na,{value:e.activeProject.id,onChange:y=>e.onSwitchProject?.(y.target.value),className:"mt-1.5 h-8 text-xs",children:e.projects.map(y=>o.jsx("option",{value:y.id,children:y.name},y.id))}),c&&o.jsxs("div",{className:"mt-2 space-y-1.5 border-t border-white/[0.06] pt-2",children:[o.jsx(Dn,{value:f,onChange:y=>p(y.target.value),placeholder:"Project name…",className:"h-7 text-xs"}),o.jsxs(Na,{value:b,onChange:y=>x(y.target.value),className:"h-7 text-xs",children:[o.jsx("option",{value:"structure-compare",children:"Structure Compare"}),o.jsx("option",{value:"ligand-docking",children:"Ligand Design & Binding"}),o.jsx("option",{value:"peptide-crispr",children:"Peptide & CRISPR Test"}),o.jsx("option",{value:"blank",children:"Blank Workspace"})]}),o.jsxs("div",{className:"flex gap-1.5",children:[o.jsx(Oe,{size:"sm",variant:"primary",className:"flex-1",onClick:_,children:"Create"}),o.jsx(Oe,{size:"sm",variant:"ghost",onClick:()=>d(!1),children:"Cancel"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(RA,{role:"reference",label:e.refLabel,inspect:e.refInspect,chain:e.refChain,onChangeChain:e.onChangeRefChain,onReplace:()=>g("reference"),onSaveToLibrary:()=>e.onSaveToLibrary("reference"),hasContent:e.hasRef}),o.jsx(RA,{role:"mobile",label:e.mobLabel,inspect:e.mobInspect,chain:e.mobChain,onChangeChain:e.onChangeMobChain,onReplace:()=>g("mobile"),onSaveToLibrary:()=>e.onSaveToLibrary("mobile"),hasContent:e.hasMob}),(e.hasRef||e.hasMob)&&e.onSplitStructure&&o.jsxs("div",{className:"flex gap-1.5",children:[e.hasRef&&o.jsx(Oe,{size:"sm",variant:"secondary",className:"flex-1 text-[0.6875rem]",icon:o.jsx(Px,{className:"h-3 w-3"}),onClick:()=>e.onSplitStructure?.("reference"),title:"Split Reference chains & non-water HETATM ligands into project assets",children:"Split Ref"}),e.hasMob&&o.jsx(Oe,{size:"sm",variant:"secondary",className:"flex-1 text-[0.6875rem]",icon:o.jsx(Px,{className:"h-3 w-3"}),onClick:()=>e.onSplitStructure?.("mobile"),title:"Split Comparison chains & non-water HETATM ligands into project assets",children:"Split Comp"})]}),o.jsxs("div",{className:"flex items-center gap-2 px-1 pt-1 text-xs text-slate-500",children:[o.jsx("span",{className:Ie("h-1.5 w-1.5 rounded-full",e.paePresent?"bg-emerald-400":"bg-slate-600")}),e.paePresent?"PAE matrix loaded":"No PAE matrix"]}),e.chainError&&o.jsxs("div",{className:"flex gap-2 rounded-lg border border-amber-500/30 bg-amber-500/[0.06] p-2.5 text-xs leading-relaxed text-amber-200",children:[o.jsx(Gc,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),e.chainError]})]}),o.jsxs("div",{className:"mt-3 space-y-1.5",children:[o.jsx(Oe,{className:"w-full",variant:"primary",size:"sm",icon:o.jsx(Oc,{className:"h-3.5 w-3.5"}),onClick:()=>g("auto"),children:"Import structures / files"}),o.jsx(Oe,{className:"w-full",size:"sm",icon:o.jsx(Vi,{className:"h-3.5 w-3.5"}),onClick:e.onSearchDatabases,children:"Search public databases"}),o.jsxs("div",{className:"grid grid-cols-3 gap-1 pt-0.5",children:[e.onOpenChemistry&&o.jsx(Oe,{size:"sm",variant:"secondary",className:"text-[0.6875rem]",icon:o.jsx(gh,{className:"h-3 w-3"}),onClick:e.onOpenChemistry,children:"Mol"}),e.onOpenPeptide&&o.jsx(Oe,{size:"sm",variant:"secondary",className:"text-[0.6875rem]",icon:o.jsx(ar,{className:"h-3 w-3"}),onClick:e.onOpenPeptide,children:"Pep"}),e.onOpenCrispr&&o.jsx(Oe,{size:"sm",variant:"secondary",className:"text-[0.6875rem]",icon:o.jsx(Fs,{className:"h-3 w-3"}),onClick:e.onOpenCrispr,children:"CRISPR"})]})]}),e.activeProject&&(e.activeProject.structures.length>0||e.activeProject.molecules.length>0||e.activeProject.peptides.length>0||e.activeProject.crisprs.length>0)&&o.jsxs("div",{className:"mt-4 space-y-2 border-t border-white/[0.06] pt-3",children:[o.jsxs("div",{className:"text-[0.6875rem] font-semibold tracking-wide text-slate-400 uppercase",children:["Project Assets (",e.activeProject.structures.length+e.activeProject.molecules.length+e.activeProject.peptides.length+e.activeProject.crisprs.length,")"]}),e.activeProject.structures.map(y=>o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-white/[0.06] bg-white/[0.02] px-2 py-1.5 text-xs",children:[o.jsx(_s,{className:"h-3.5 w-3.5 shrink-0 text-sky-300"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-slate-200",title:y.label,children:y.label}),e.onLoadProjectStructure&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>e.onLoadProjectStructure?.(y,"reference"),className:"rounded px-1 py-0.5 text-[0.625rem] text-sky-300 hover:bg-sky-500/15",title:"Load as Reference",children:"Ref"}),o.jsx("button",{type:"button",onClick:()=>e.onLoadProjectStructure?.(y,"mobile"),className:"rounded px-1 py-0.5 text-[0.625rem] text-emerald-300 hover:bg-emerald-500/15",title:"Load as Comparison",children:"Comp"})]})]},y.id)),e.activeProject.molecules.map(y=>o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-white/[0.06] bg-white/[0.02] px-2 py-1.5 text-xs",children:[o.jsx(ia,{className:"h-3.5 w-3.5 shrink-0 text-violet-300"}),o.jsx("button",{type:"button",onClick:()=>e.onOpenProjectMolecule?.(y),className:"min-w-0 flex-1 truncate text-left text-slate-200 hover:text-sky-300",title:y.smiles,children:y.name}),e.onDockMolecule&&o.jsxs("button",{type:"button",onClick:()=>e.onDockMolecule?.(y),className:"inline-flex items-center gap-0.5 rounded bg-emerald-500/10 px-1.5 py-0.5 text-[0.625rem] text-emerald-300 hover:bg-emerald-500/20",title:"Test binding / AutoDock Vina against active protein",children:[o.jsx(Br,{className:"h-2.5 w-2.5"}),"Bind"]}),e.onRemoveProjectAsset&&o.jsx("button",{type:"button",onClick:()=>e.onRemoveProjectAsset?.("molecule",y.id),className:"text-slate-500 hover:text-rose-400","aria-label":`Remove ${y.name}`,children:"×"})]},y.id)),e.activeProject.peptides.map(y=>o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-white/[0.06] bg-white/[0.02] px-2 py-1.5 text-xs",children:[o.jsx(ar,{className:"h-3.5 w-3.5 shrink-0 text-amber-300"}),o.jsx("button",{type:"button",onClick:()=>e.onOpenPeptide?.(),className:"min-w-0 flex-1 truncate text-left text-slate-200 hover:text-sky-300",children:y.name})]},y.id)),e.activeProject.crisprs.map(y=>o.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-white/[0.06] bg-white/[0.02] px-2 py-1.5 text-xs",children:[o.jsx(Fs,{className:"h-3.5 w-3.5 shrink-0 text-emerald-300"}),o.jsx("button",{type:"button",onClick:()=>e.onOpenCrispr?.(),className:"min-w-0 flex-1 truncate text-left text-slate-200 hover:text-sky-300",children:y.name})]},y.id))]}),o.jsx("div",{className:Ie("mt-4 rounded-xl border border-dashed px-3 py-4 text-center text-xs leading-relaxed transition-colors",s?"border-sky-400/70 bg-sky-400/10 text-sky-200":"border-white/10 text-slate-500"),children:"Drop .cif / .pdb / PAE .json / .fasta / .smi / .synlexa.bundle.json here"}),o.jsx("button",{type:"button",onClick:e.onLoadExample,className:"mt-3 text-xs text-slate-500 hover:text-sky-300",children:"Load example comparison (CA II)"})]})}const BL=[{id:"viewer",group:"Structures & 3D",label:"3D Viewer",desc:"Superposed structures, residue picking, distances",icon:o.jsx(_s,{className:"h-4 w-4"})},{id:"results",group:"Structures & 3D",label:"Results",desc:"RMSD, coverage, confidence, PAE, exports",icon:o.jsx(qi,{className:"h-4 w-4"})},{id:"sequence",group:"Structures & 3D",label:"Sequence deviation",desc:"Per-residue Δd along the alignment",icon:o.jsx(Vo,{className:"h-4 w-4"})},{id:"ramachandran",group:"Structures & 3D",label:"Ramachandran",desc:"Backbone φ/ψ and Cα contacts",icon:o.jsx(Qo,{className:"h-4 w-4"})},{id:"chemistry",group:"Design & Editing",label:"Ligands & 2D Sketcher",desc:"RDKit WASM, PAINS alerts, 2D editor",icon:o.jsx(ia,{className:"h-4 w-4"})},{id:"peptide",group:"Design & Editing",label:"Peptide engineering",desc:"Point mutations, pI, charge, 3D contacts",icon:o.jsx(ar,{className:"h-4 w-4"})},{id:"crispr",group:"Design & Editing",label:"Gene & CRISPR",desc:"Codon edits and PAM sites",icon:o.jsx(Fs,{className:"h-4 w-4"})},{id:"workflow",group:"Pipelines & GPU",label:"Workflow Canvas",desc:"DAG pipelines + Nextflow/Snakemake",icon:o.jsx(Dp,{className:"h-4 w-4"})},{id:"compute",group:"Pipelines & GPU",label:"GPU & Compute Nodes",desc:"Colab, Vina, OpenMM, Boltz-2, PySCF",icon:o.jsx(al,{className:"h-4 w-4"})},{id:"plugins",group:"Pipelines & GPU",label:"Plugins & Add-ons",desc:"Open-source tools & license ledger",icon:o.jsx(Lp,{className:"h-4 w-4"})},{id:"assistant",group:"Agent & Workspace",label:"AI Assistant",desc:"Reasoning trace, octopus tools, search",icon:o.jsx(qr,{className:"h-4 w-4"})},{id:"mcp",group:"Agent & Workspace",label:"MCP Server",desc:"In-app MCP & Claude/Codex bridge",icon:o.jsx(rl,{className:"h-4 w-4"})},{id:"library",group:"Agent & Workspace",label:"Library manager",desc:"Organize saved molecules",icon:o.jsx(sh,{className:"h-4 w-4"})},{id:"home",group:"Agent & Workspace",label:"Start page",desc:"Projects, tutorial, quick actions",icon:o.jsx(FA,{className:"h-4 w-4"})}],GL=["Structures & 3D","Design & Editing","Pipelines & GPU","Agent & Workspace"];function HL({openTabs:e,onOpen:r}){return o.jsxs("div",{className:"h-full overflow-y-auto px-2 pb-4",children:[o.jsx("p",{className:"px-2 pb-2 text-xs text-slate-500",children:"Click to open a tab, or use the split icon to open beside 3D."}),o.jsx("div",{className:"space-y-3",children:GL.map(n=>o.jsxs("div",{children:[o.jsx("div",{className:"px-2.5 pb-1 text-[0.6875rem] font-semibold tracking-wider text-slate-500 uppercase",children:n}),o.jsx("ul",{className:"space-y-0.5",children:BL.filter(s=>s.group===n).map(s=>o.jsxs("li",{className:"group flex items-center gap-1 rounded-lg pr-1 hover:bg-white/[0.04]",children:[o.jsxs("button",{type:"button",onClick:i=>r(s.id,i.altKey),className:"flex min-w-0 flex-1 items-start gap-3 px-2.5 py-2 text-left",children:[o.jsx("span",{className:"mt-0.5 text-slate-500 group-hover:text-sky-300",children:s.icon}),o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsxs("span",{className:"flex items-center gap-2 text-[0.8125rem] text-slate-200",children:[s.label,e.has(s.id)&&o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sky-400",title:"Open"})]}),o.jsx("span",{className:"block truncate text-xs text-slate-500",children:s.desc})]})]}),o.jsx("button",{type:"button",title:`Open ${s.label} side-by-side`,"aria-label":`Open ${s.label} side-by-side`,onClick:()=>r(s.id,!0),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-slate-500 opacity-0 transition group-hover:opacity-100 hover:bg-white/[0.08] hover:text-sky-300",children:o.jsx(Ey,{className:"h-3.5 w-3.5"})})]},s.id))})]},n))})]})}function FL({runs:e,onClear:r}){return o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 pb-3",children:e.length===0?o.jsx("p",{className:"px-2 py-6 text-center text-xs text-slate-500",children:"Comparisons you run appear here."}):o.jsx("ul",{className:"space-y-1",children:e.map(n=>o.jsxs("li",{className:"rounded-lg px-2.5 py-2 hover:bg-white/[0.03]",children:[o.jsxs("div",{className:"truncate text-[0.8125rem] text-slate-200",children:[n.refLabel," ",o.jsx("span",{className:"text-slate-600",children:"vs"})," ",n.mobLabel]}),o.jsxs("div",{className:"mt-0.5 flex justify-between text-xs text-slate-500 tabular-nums",children:[o.jsxs("span",{children:[n.rmsdAngstrom.toFixed(3)," Å · ",n.matchedCaCount," Cα · ",n.refChain,"/",n.mobChain]}),o.jsx("span",{children:new Date(n.createdAtUtc).toLocaleDateString()})]})]},n.id))})}),e.length>0&&o.jsx("div",{className:"border-t border-white/[0.06] p-2",children:o.jsx(Oe,{size:"sm",variant:"ghost",className:"w-full",icon:o.jsx(Wi,{className:"h-3.5 w-3.5"}),onClick:r,children:"Clear history"})})]})}function VL({busyLabel:e,wasmReady:r,rendererMode:n,rmsd:s,focusedSeqId:i,computeNodeLabel:c,computeOnline:d,onOpenComputeNodes:f,aiLabel:p,aiReady:b,onOpenAiSettings:x}){return o.jsxs("footer",{className:"flex h-7 shrink-0 items-center gap-4 border-t border-white/[0.06] bg-[#0a0d13] px-3 text-[0.6875rem] text-slate-500",children:[o.jsx("span",{className:"flex items-center gap-1.5",children:e?o.jsxs(o.Fragment,{children:[o.jsx(qs,{className:"h-3 w-3 animate-spin text-sky-400"}),o.jsx("span",{className:"text-slate-300",children:e})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:Ie("h-1.5 w-1.5 rounded-full",r?"bg-emerald-400":"bg-amber-400")}),r?"Engine ready":"Starting engine…"]})}),o.jsxs("span",{className:"hidden items-center gap-1 sm:flex",children:[o.jsx(al,{className:"h-3 w-3"})," ",n==="webgl2"?"WebGL2":"Canvas fallback"]}),f&&o.jsxs("button",{type:"button",onClick:f,className:"hidden items-center gap-1.5 hover:text-slate-300 md:flex",children:[o.jsx("span",{className:Ie("h-1.5 w-1.5 rounded-full",d?"bg-emerald-400":"bg-slate-600")}),c?`GPU: ${c}`:"Connect Colab / GPU"]}),s!==null&&o.jsxs("span",{className:"tabular-nums",children:["RMSD ",s.toFixed(3)," Å"]}),i!==null&&o.jsxs("span",{className:"tabular-nums",children:["Residue ",i]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{type:"button",onClick:x,className:"flex items-center gap-1.5 hover:text-slate-300",children:[o.jsx(qr,{className:Ie("h-3 w-3",b?"text-sky-400":"text-slate-600")}),p]}),o.jsx("span",{className:"font-medium text-amber-400/80",children:"Research use only"})]})}const KL=C.lazy(()=>Aa(()=>import("./MolStarViewport-BEGb0UZJ.js"),__vite__mapDeps([0,1])).then(e=>({default:e.MolStarViewport}))),zA="MSHHWGYGKHNGPEHWHKDFPIAKGERQSPVDIDTHTAKYDPSLKPLSVSYDQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPPLLECVTWIVLKEPISVSSEQVLKFRKLNFNGEGEPEELMVDNWRPAQPLKNRQIKASFK",YL=new Set(["viewer"]);function Rx(e,r,n){const s=new Blob([r],{type:n}),i=URL.createObjectURL(s),c=document.createElement("a");c.href=i,c.download=e,c.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}function Zf(e){return e?{sourceTypeHint:e.confidenceKind==="experimental_b_factor"?"experimental":e.confidenceKind==="prediction_plddt"?"prediction":"auto",sourceUrl:e.sourceUrl,dataRevision:e.dataRevision,retrievedAtUtc:e.retrievedAtUtc,license:e.license}:{sourceTypeHint:"auto"}}function OA(e){if(!e)return null;try{const r=new URL(e).host;return r.includes("rcsb")?"RCSB PDB":r.includes("alphafold")?"AlphaFold DB":r.includes("uniprot")?"UniProtKB":r.includes("pubchem")||r.includes("ncbi")?"PubChem":r}catch{return null}}function ep(e){return e.replace(/\.(cif|mmcif|pdb|ent)$/i,"")}function WL(){const{toast:e}=cl(),[r,n]=Zv(),s=C.useRef(null);s.current||(s.current=new $y);const i=C.useRef(null),c=C.useRef(null),[d,f]=C.useState(!1),[p,b]=C.useState(null),[x,g]=C.useState(null),[_,y]=C.useState(null),[S,k]=C.useState("webgl2"),[E,T]=C.useReducer(_y,r.restoreTabs,cq),[j,q]=C.useState("explorer"),[z,O]=C.useState(!0),[V,P]=C.useState("account"),[$,H]=C.useState(!1),[Z,G]=C.useState(!1),[K,we]=C.useState(!1),[Se,Q]=C.useState(!1),F=C.useRef(null),[he,W]=C.useState(()=>rA()),[me,I]=C.useState(null),[J,ge]=C.useState([]),[le,D]=C.useState("webgl2"),[ae,pe]=C.useState(null),[Ae,Ne]=C.useState(null),[Re,$e]=C.useState(()=>Di()),[Ce,Ue]=C.useState(r.viewer.defaultLayout),[be,bt]=C.useState(r.viewer.defaultStyle),[Ot,St]=C.useState(r.viewer.defaultColorMode),[Ke,et]=C.useState(""),[ue,He]=C.useState(""),[Pe,ut]=C.useState({sourceTypeHint:"auto"}),[Je,re]=C.useState(null),[ve,Qe]=C.useState(""),[Fe,Fn]=C.useState(""),[We,Yr]=C.useState(""),[ss,su]=C.useState({sourceTypeHint:"auto"}),[qn,Wr]=C.useState(null),[_t,ja]=C.useState(""),[Nn,Ji]=C.useState(null),[tt,Mh]=C.useState(null),[Ln,dl]=C.useState(null),[Zi,Rh]=C.useState(null),[oa,hl]=C.useState(null),[zh,eo]=C.useState(null),[st,Lt]=C.useReducer(rq,{sequence:zA,mutationsInput:"H94A",mutations:["H94A"],sliceStart:1,sliceEnd:zA.length,focusSeqId:94}),[Ct,Oh]=C.useState(null),[i0,Ph]=C.useState(null),[Nt,An]=C.useReducer(iq,{transcriptId:"NM_000067.3",customDna:"",useCustomDna:!1,targetCodonIndex:94,baseEditOffset:0,newBase:"G",nuclease:"SpCas9"}),[as,Ta]=C.useState(null),[ml,Xr]=C.useState(null),[Mt,Un]=C.useReducer(oq,{selectedPresetId:Xo[0].id,name:Xo[0].name,smiles:Xo[0].smiles}),[Vs,to]=C.useState(null),[no,$h]=C.useState(null),[so,au]=C.useState("reference"),[Qr,fl]=C.useState(null),[ru,iu]=C.useState(null),[ou,rs]=C.useState([]),[Ut,on]=C.useState(()=>Ac()),[la,lu]=C.useState(!1),[cu,uu]=C.useState([]),[Ih,or]=C.useState([]),[pl,Jr]=C.useState(null),[Ea,Zr]=C.useState(()=>t0()),Ma=C.useRef(null),ei=C.useRef(new Set),[At,Dh]=C.useState(()=>dp()),[qh,lr]=C.useState(!1);C.useEffect(()=>(Jv(r.uiScale),dq(Cx)),[]),C.useEffect(()=>{r.restoreTabs&&uq(E)},[E,r.restoreTabs]),C.useEffect(()=>{const M=()=>nu().then(ge);return M(),r0(()=>void M())},[]),C.useEffect(()=>{x&&(e(x,"error"),g(null))},[x,e]);const je=C.useCallback((M,R=!1)=>{T({type:"open",tab:M,toSide:R})},[]),Jt=C.useCallback(M=>{M&&P(M),we(!0)},[]),Lh=C.useCallback(M=>new Promise(R=>{je("assistant"),Jr(M),Ma.current=R}),[je]),Uh=C.useCallback(M=>{const R=Ma.current;Ma.current=null,Jr(null),R?.(M)},[]),ti=C.useCallback(M=>{const R=SD(M);return M.template==="ligand-docking"?je("chemistry"):M.template==="peptide-crispr"?je("peptide"):M.template==="structure-compare"&&je("viewer"),e(`Created project "${R.name}"`,"success"),R},[je,e]),o0=C.useCallback(M=>{Un({type:"set_custom_smiles",smiles:M.smiles,name:M.name}),Ne({tool:"vina",nonce:Date.now()}),je("compute"),e(`Staged ${M.name} for receptor binding / Vina`,"info")},[je,e]),ct=C.useMemo(()=>{if(oa&&oa.seqIds.length>0)return new Set(oa.seqIds);const M=new Set;if(Ct?.local3dContacts)for(const R of Ct.local3dContacts)M.add(R.seqId);return M},[oa,Ct]),ao=C.useMemo(()=>oa&&oa.seqIds.length>0?oa.source:Ct?.local3dContacts&&Ct.local3dContacts.length>0?"Peptide <5 Å shell":null,[oa,Ct]),ca=C.useCallback(async(M,R={})=>{try{const{item:X,duplicate:oe}=await t1(M);return R.silent||e(oe?`${X.name} is already in your library`:`Saved ${X.name} to library`,oe?"info":"success"),X}catch(X){return e(`Could not save to library: ${X instanceof Error?X.message:String(X)}`,"error"),null}},[e]),ws=C.useCallback(M=>{r.autoSaveImports&&ca(M,{silent:!0})},[ca,r.autoSaveImports]),Pt=C.useCallback(async M=>{if(!M.rContent||!M.mContent)return null;if(!M.rChain||!M.mChain)return y("Select a chain for both the reference and the comparison structure."),null;b("Superposing structures…"),y(null);try{const R=await s.current.compareStructures({refLabel:M.rLabel,refContent:M.rContent,refChain:M.rChain,refMeta:M.rMeta,mobLabel:M.mLabel,mobContent:M.mContent,mobChain:M.mChain,mobMeta:M.mMeta,paeJson:M.pae??void 0});Mh(R),f(!0);const X=await nq({id:`${R.reference.sha256.slice(0,8)}-${R.mobile.sha256.slice(0,8)}-${R.reference.chainId}-${R.mobile.chainId}`,createdAtUtc:R.createdAtUtc,refLabel:R.reference.label,refChain:R.reference.chainId,refSha256:R.reference.sha256,mobLabel:R.mobile.label,mobChain:R.mobile.chainId,mobSha256:R.mobile.sha256,rmsdAngstrom:R.metrics.rmsdAngstrom,matchedCaCount:R.metrics.matchedCaCount,paeStatus:R.metrics.paeStatus});return rs(X),R}catch(R){return R instanceof Tr||(R instanceof XA&&R.code==="ERR_AMBIGUOUS_CHAIN"?y(R.message):g(R instanceof Error?R.message:String(R))),null}finally{b(null)}},[]),fn=()=>({rLabel:Ke,rContent:ue,rChain:ve,rMeta:Pe,mLabel:Fe,mContent:We,mChain:_t,mMeta:ss,pae:Nn}),ua=C.useCallback(async M=>{y(null),I(null),b(`Reading ${M.label}…`);try{const R=await s.current.inspectStructure(M.role==="reference"?"inspect-ref":"inspect-mob",{label:M.label,content:M.content,...M.meta});f(!0);const X=R.chains.length===1?R.chains[0].chainId:"";if(!X&&R.chains.length>1&&(q("explorer"),O(!0),y(`${M.label} has ${R.chains.length} chains (${R.chains.map(oe=>oe.chainId).join(", ")}). Pick one in the Workspace panel.`)),M.role==="reference")et(M.label),He(M.content),ut(M.meta),re(R),Qe(X),wx({label:M.label,role:"reference",content:M.content,paeJson:M.pae,sourceUrl:M.meta.sourceUrl??null,license:M.meta.license??null}),X&&We&&_t&&await Pt({rLabel:M.label,rContent:M.content,rChain:X,rMeta:M.meta,mLabel:Fe,mContent:We,mChain:_t,mMeta:ss,pae:Nn});else{const oe=M.pae!==void 0?M.pae:Nn;Fn(M.label),Yr(M.content),su(M.meta),Wr(R),ja(X),Ji(oe),wx({label:M.label,role:"mobile",content:M.content,paeJson:oe,sourceUrl:M.meta.sourceUrl??null,license:M.meta.license??null});const fe=(R.chains.find(ke=>ke.chainId===X)??R.chains[0])?.sequence1Letter;fe&&(Lt({type:"set_sequence",sequence:fe}),Lt({type:"set_mutations_input",raw:""})),X&&ue&&ve&&await Pt({rLabel:Ke,rContent:ue,rChain:ve,rMeta:Pe,mLabel:M.label,mContent:M.content,mChain:X,mMeta:M.meta,pae:oe})}return T({type:"activate",tab:"viewer"}),R}catch(R){return R instanceof Tr||g(R instanceof Error?R.message:String(R)),null}finally{b(null)}},[We,_t,Fe,ss,ue,ve,Ke,Pe,Nn,Pt]),gl=C.useCallback(M=>{const R=M==="reference"?ue:We,X=M==="reference"?Ke:Fe;if(!R)return e(`No ${M} structure loaded to split`,"error"),[];const oe=ND(R,X||M);for(const fe of oe)wx({label:fe.label,role:"extra",content:fe.pdbContent});return q("explorer"),O(!0),e(`Split ${X||M} into ${oe.length} chain/ligand part(s)`,"success"),oe},[ue,Ke,We,Fe,e]),du=C.useCallback((M,R)=>{ua({role:R,label:M.label,content:M.content,meta:{sourceTypeHint:"auto",sourceUrl:M.sourceUrl??void 0,license:M.license??void 0},pae:M.paeJson??void 0})},[ua]),bl=C.useRef(null),cr=C.useCallback(async()=>{b("Loading example…"),y(null),I("ca2-azm");try{const M=await uz(),R=Zf(M.manifest.fixtures.find(Be=>Be.fileName==="3HS4.cif")),X=Zf(M.manifest.fixtures.find(Be=>Be.fileName==="AF-P00918-F1-model_v6.cif"));et("3HS4.cif"),He(M.refCif),ut(R),Fn("AF-P00918-F1-model_v6.cif"),Yr(M.mobCif),su(X),Ji(M.paeJson);const[oe,fe]=await Promise.all([s.current.inspectStructure("inspect-ref",{label:"3HS4.cif",content:M.refCif,...R}),s.current.inspectStructure("inspect-mob",{label:"AF-P00918-F1-model_v6.cif",content:M.mobCif,...X})]);f(!0),re(oe),Wr(fe);const ke=oe.chains.length===1?oe.chains[0].chainId:"",Le=fe.chains.length===1?fe.chains[0].chainId:"";Qe(ke),ja(Le),dl(94),fe.chains[0]?.sequence1Letter&&(Lt({type:"set_sequence",sequence:fe.chains[0].sequence1Letter}),Lt({type:"add_mutation",notation:"H94A"})),ke&&Le&&await Pt({rLabel:"3HS4.cif",rContent:M.refCif,rChain:ke,rMeta:R,mLabel:"AF-P00918-F1-model_v6.cif",mContent:M.mobCif,mChain:Le,mMeta:X,pae:M.paeJson})}catch(M){if(M instanceof Tr)return;g(M instanceof Error?M.message:String(M))}finally{b(null)}},[Pt]);C.useEffect(()=>{fI().then(()=>on(Ac())),iD(),bD(),wD();const M=vD(()=>Dh(dp())),R=L3(()=>$e(Di()));return cE().then(rs).catch(()=>{}),r.loadDemoOnStart&&cr(),()=>{M(),R(),s.current?.dispose()}},[]),C.useEffect(()=>{const M=()=>{cy();try{F.current?.close()}catch{}F.current=null},R=(Le,Be)=>{Be||M(),qI(Le).then(ft=>{W(ft),on(Ac()),Be&&window.history.replaceState({},"",`${window.location.pathname}${window.location.hash}`||"/");const vt=ft.displayName??ft.email;e(ft.serverVerified?`Signed in${vt?` as ${vt}`:""}`:"Signed in, but synlexa.com could not confirm the session. Synlexa Cloud stays off until you reconnect.",ft.serverVerified?"success":"warn")}).catch(ft=>e(ft instanceof Error?ft.message:String(ft),"error")).finally(()=>{Q(!1),M()})},X=j3(window.location.href);X&&R(X,!0);const oe=WI(Le=>R(Le,!1)),fe=HI(Le=>R(Le,!1)),ke=Le=>{Le.key===n0&&(W(rA()),on(Ac()),Q(!1))};return window.addEventListener("storage",ke),()=>{oe(),fe(),window.removeEventListener("storage",ke)}},[e]),C.useEffect(()=>{if(!Se||!F.current)return;const M=window.setInterval(()=>{const R=F.current;R&&R.closed&&(window.clearInterval(M),window.setTimeout(()=>{F.current===R&&(F.current=null,Q(!1))},1500))},500);return()=>window.clearInterval(M)},[Se]);const Bn=C.useCallback(M=>{const R=VI(),X=R?null:KI("about:blank");PI(M,{platform:R?"desktop":"web"}).then(async({url:oe})=>{if(R){if(!await FI(oe))throw new Error("Could not open your browser.");Q(!0);return}X&&!X.closed?(X.location.href=oe,X.focus(),F.current=X,Q(!0)):window.location.assign(oe)}).catch(oe=>{X?.close(),e(oe instanceof Error?oe.message:String(oe),"error")})},[e]),hu=C.useCallback(()=>{cy();try{F.current?.close()}catch{}F.current=null,up(),Q(!1)},[]);C.useEffect(()=>{if(!st.sequence)return;let M=!0;return Ph(null),s.current?.analyzePeptide({sequence:st.sequence,mutations:st.mutations,sliceStart:st.sliceStart,sliceEnd:st.sliceEnd,structureContent:ue||void 0,chainId:ve||void 0,focusSeqId:st.focusSeqId??void 0}).then(R=>{M&&(f(!0),Oh(R))}).catch(R=>{R instanceof Tr||!M||Ph(R instanceof Error?R.message:String(R))}),()=>{M=!1}},[st.sequence,st.mutations,st.sliceStart,st.sliceEnd,st.focusSeqId,ue,ve]),C.useEffect(()=>{let M=!0;return Xr(null),s.current?.analyzeGeneCrispr({transcriptId:Nt.useCustomDna?void 0:Nt.transcriptId,codingDna:Nt.useCustomDna?Nt.customDna:void 0,targetCodonIndex:Nt.targetCodonIndex,baseEditIndex:(Nt.targetCodonIndex-1)*3+Nt.baseEditOffset+1,newBase:Nt.newBase,nuclease:Nt.nuclease}).then(R=>{M&&(f(!0),Ta(R))}).catch(R=>{R instanceof Tr||!M||Xr(R instanceof Error?R.message:String(R))}),()=>{M=!1}},[Nt]),C.useEffect(()=>{if(!Mt.smiles)return;let M=!0;return $h(null),s.current?.analyzeMoleculeSmiles({name:Mt.name,smiles:Mt.smiles}).then(R=>{M&&(f(!0),to(R))}).catch(R=>{R instanceof Tr||!M||$h(R instanceof Error?R.message:String(R))}),()=>{M=!1}},[Mt]),C.useEffect(()=>{const M=so==="reference"?ue:We,R=so==="reference"?ve:_t;if(!M)return;let X=!0;return iu(null),s.current?.analyzeRamachandran({content:M,chainId:R||void 0}).then(oe=>{X&&(f(!0),fl(oe))}).catch(oe=>{oe instanceof Tr||!X||iu(oe instanceof Error?oe.message:String(oe))}),()=>{X=!1}},[so,ue,ve,We,_t]);const Yt=C.useCallback(M=>{dl(M),Lt({type:"focus_residue",seqId:M}),An({type:"set_target_codon",codonIndex:M})},[]),mu=C.useCallback(async M=>{if(I(M.id),y(null),M.kind==="chemistry-panel"){M.smilesPresetId&&Un({type:"select_preset",presetId:M.smilesPresetId}),je("chemistry");return}if(!(!M.reference||!M.mobile)){b(`Loading ${M.title}…`);try{const[R,X,oe,fe]=await Promise.all([cz(),Rb(M.reference.fileName),Rb(M.mobile.fileName),M.paeFileName?Rb(M.paeFileName).catch(()=>null):Promise.resolve(null)]),ke=Zf(R.fixtures.find(Zt=>Zt.fileName===M.reference.fileName)),Le=Zf(R.fixtures.find(Zt=>Zt.fileName===M.mobile.fileName));et(M.reference.label),He(X),ut(ke),Fn(M.mobile.label),Yr(oe),su(Le),Ji(fe);const[Be,ft]=await Promise.all([s.current.inspectStructure("inspect-ref",{label:M.reference.label,content:X,...ke}),s.current.inspectStructure("inspect-mob",{label:M.mobile.label,content:oe,...Le})]);f(!0),re(Be),Wr(ft),Qe(M.reference.chainId),ja(M.mobile.chainId);const vt=ft.chains.find(Zt=>Zt.chainId===M.mobile.chainId)??ft.chains[0];vt?.sequence1Letter&&(Lt({type:"set_sequence",sequence:vt.sequence1Letter}),Lt({type:"set_mutations_input",raw:(M.peptideMutations??[]).join(", ")})),M.crispr&&(An({type:"select_transcript",transcriptId:M.crispr.transcriptId}),An({type:"set_target_codon",codonIndex:M.crispr.targetCodonIndex}),An({type:"set_base_edit",offset:M.crispr.baseEditOffset,newBase:M.crispr.newBase}),An({type:"set_nuclease",nuclease:M.crispr.nuclease})),M.smilesPresetId&&Un({type:"select_preset",presetId:M.smilesPresetId}),M.focusSeqId&&(dl(M.focusSeqId),Lt({type:"focus_residue",seqId:M.focusSeqId})),await Pt({rLabel:M.reference.label,rContent:X,rChain:M.reference.chainId,rMeta:ke,mLabel:M.mobile.label,mContent:oe,mChain:M.mobile.chainId,mMeta:Le,pae:fe}),T({type:"activate",tab:"viewer"}),M.openTab&&M.openTab!=="sequence"&&je(M.openTab)}catch(R){R instanceof Tr||g(R instanceof Error?R.message:String(R))}finally{b(null)}}},[Pt,je]),Ra=C.useCallback(async(M,R)=>{const X={sourceTypeHint:M.sourceTypeHint,sourceUrl:M.sourceUrl,dataRevision:M.dataRevision??void 0,retrievedAtUtc:M.retrievedAtUtc,license:M.license};await ua({role:R,label:M.label,content:M.content,meta:X,pae:R==="mobile"?M.paeJson??null:void 0}),ws({kind:"structure",format:/\.pdb$/i.test(M.label)?"pdb":"cif",name:ep(M.label),content:M.content,paeJson:M.paeJson,source:{database:OA(M.sourceUrl),accession:M.uniprotAccession??ep(M.label),sourceUrl:M.sourceUrl,license:M.license,retrievedAtUtc:M.retrievedAtUtc,origin:M.origin,sourceTypeHint:M.sourceTypeHint,dataRevision:M.dataRevision}})},[ua,ws]),xl=C.useCallback(M=>{Un({type:"set_custom_smiles",smiles:M.smiles,name:M.name}),je("chemistry"),ws({kind:"compound",format:"smiles",name:M.name,content:M.smiles,source:{database:"PubChem",accession:M.cid!==null?`CID ${M.cid}`:null,sourceUrl:M.sourceUrl,license:M.license,retrievedAtUtc:M.retrievedAtUtc,origin:M.origin}})},[je,ws]),fu=C.useCallback(async(M,R="auto")=>{I(null);const X=()=>({database:null,accession:null,sourceUrl:null,license:null,retrievedAtUtc:null,origin:"local-file"});let oe=!!ue,fe=!!We;for(const ke of Array.from(M)){const Le=ke.name.toLowerCase(),Be=await ke.text();if(Le.endsWith(".synlexa.bundle.json")){try{const vt=await ZD(Be),Zt=vt.files.find($a=>$a.role==="reference"),ks=vt.files.find($a=>$a.role==="mobile"),ri=vt.files.find($a=>$a.role==="pae");if(Zt&&ks){et(Zt.label),He(Zt.content),Fn(ks.label),Yr(ks.content),Ji(ri?.content??null);const[$a,u0]=await Promise.all([s.current.inspectStructure("inspect-ref",{label:Zt.label,content:Zt.content}),s.current.inspectStructure("inspect-mob",{label:ks.label,content:ks.content})]);re($a),Wr(u0),Qe(vt.state.refChain),ja(vt.state.mobChain),vt.comparisonResult&&Mh(vt.comparisonResult),e(`Opened project ${ke.name}`,"success")}}catch(vt){g(vt instanceof Error?vt.message:String(vt))}continue}if(/\.(fasta|fa|faa)$/.test(Le)){const vt=Be.split(/\r?\n/).filter(Zt=>!Zt.startsWith(">")).join("").trim().toUpperCase();/^[ACGTU\s]+$/i.test(vt)&&vt.length>=9?(An({type:"set_custom_dna",dna:vt.replace(/U/g,"T")}),je("crispr")):(Lt({type:"set_sequence",sequence:vt}),je("peptide")),ws({kind:"sequence",format:"fasta",name:ke.name.replace(/\.[^.]+$/,""),content:vt,source:X()});continue}if(Le.endsWith(".smi")){const vt=Be.split(/\r?\n/).find(ri=>ri.trim().length>0)??"",[Zt,...ks]=vt.trim().split(/\s+/);if(Zt){const ri=ks.join(" ")||ke.name.replace(/\.[^.]+$/,"");Un({type:"set_custom_smiles",smiles:Zt,name:ri}),je("chemistry"),ws({kind:"compound",format:"smiles",name:ri,content:Zt,source:X()})}continue}if(Le.endsWith(".json")){Ji(Be),e("PAE matrix loaded","success"),ue&&We&&ve&&_t&&await Pt({...fn(),pae:Be});continue}if(!/\.(cif|mmcif|pdb|ent)$/.test(Le)){e(`${ke.name}: unsupported file type`,"warn");continue}const ft=R!=="auto"?R:oe&&(Le.includes("af-")||Le.includes("model")||!fe)?"mobile":"reference";ft==="reference"?oe=!0:fe=!0,await ua({role:ft,label:ke.name,content:Be,meta:{sourceTypeHint:"auto"}}),ws({kind:"structure",format:/\.(pdb|ent)$/.test(Le)?"pdb":"cif",name:ep(ke.name),content:Be,source:X()})}},[Ke,ue,ve,Pe,Fe,We,_t,ss,Nn,Pt,ua,je,ws,e]),za=C.useCallback(async(M,R)=>{if(n1(M.id,{lastOpenedAtUtc:new Date().toISOString()}),M.kind==="compound"){Un({type:"set_custom_smiles",smiles:M.content,name:M.name}),je("chemistry");return}if(M.kind==="sequence"){/^[ACGT]+$/.test(M.content)&&M.content.length>=9?(An({type:"set_custom_dna",dna:M.content}),je("crispr")):(Lt({type:"set_sequence",sequence:M.content}),je("peptide"));return}const X=R!=="auto"?R:ue&&(M.source.sourceTypeHint==="prediction"||!We)?"mobile":"reference";await ua({role:X,label:`${M.name}.${M.format==="pdb"?"pdb":"cif"}`,content:M.content,meta:{sourceTypeHint:M.source.sourceTypeHint??"auto",sourceUrl:M.source.sourceUrl??void 0,license:M.source.license??void 0,retrievedAtUtc:M.source.retrievedAtUtc??void 0,dataRevision:M.source.dataRevision??void 0},pae:X==="mobile"?M.paeJson??null:void 0}),e(`${M.name} loaded as ${X==="reference"?"reference":"comparison"}`,"success")},[ue,We,ua,je,e]),l0=C.useCallback(M=>{const R=M==="reference"?Ke:Fe,X=M==="reference"?ue:We,oe=M==="reference"?Pe:ss;X&&ca({kind:"structure",format:/\.(pdb|ent)$/i.test(R)?"pdb":"cif",name:ep(R),content:X,paeJson:M==="mobile"?Nn:null,source:{database:OA(oe.sourceUrl),accession:null,sourceUrl:oe.sourceUrl??null,license:oe.license??null,retrievedAtUtc:oe.retrievedAtUtc??null,origin:oe.sourceUrl?"pinned-local-cache":"local-file",sourceTypeHint:oe.sourceTypeHint,dataRevision:oe.dataRevision??null}})},[Ke,Fe,ue,We,Pe,ss,Nn,ca]),ni=r.viewer.embedPngInReports,da=C.useCallback(()=>{if(!tt){e("Run a comparison first","warn");return}const M=lI({comparison:tt,peptide:Ct,crispr:as,smiles:Vs,viewportPngDataUrl:ni?i.current?.capturePngDataUrl()??null:null});Rx(`synlexa-ruo-report-${tt.resultId.slice(0,12)}.html`,M,"text/html;charset=utf-8")},[tt,Ct,as,Vs,ni,e]),is=C.useCallback(()=>{if(!tt){e("Run a comparison first","warn");return}const M=oI({comparison:tt,peptide:Ct,crispr:as,smiles:Vs,viewportPngDataUrl:ni?i.current?.capturePngDataUrl()??null:null});Rx(`synlexa-ruo-manifest-${tt.resultId.slice(0,12)}.json`,M,"application/json;charset=utf-8")},[tt,Ct,as,Vs,ni,e]),si=C.useCallback(async()=>{if(!ue||!We){e("Load a reference and a comparison structure first","warn");return}const M=await JD({refLabel:Ke,refContent:ue,mobLabel:Fe,mobContent:We,paeJson:Nn,comparisonResult:tt,state:{refChain:ve,mobChain:_t,focusedSeqId:Ln,peptide:{sequence:st.sequence,mutations:st.mutations,sliceStart:st.sliceStart,sliceEnd:st.sliceEnd},crispr:{transcriptId:Nt.transcriptId,customDna:Nt.customDna,targetCodonIndex:Nt.targetCodonIndex,baseEditIndex:Nt.baseEditOffset,newBase:Nt.newBase,nuclease:Nt.nuclease},smiles:{name:Mt.name,smiles:Mt.smiles}}});Rx(`synlexa-project-${Date.now()}.synlexa.bundle.json`,JSON.stringify(M,null,2),"application/json;charset=utf-8")},[Ke,ue,Fe,We,Nn,tt,ve,_t,Ln,st,Nt,Mt,e]),Bh=C.useCallback(M=>{M.type==="focus_residues"&&M.seqIds.length>0?Yt(M.seqIds[0]):M.type==="compare_structures"?Pt(fn()):M.type==="request_report"?M.format==="json"?is():da():M.type==="switch_tab"?je(M.tab):M.type==="apply_peptide_mutation"?Lt({type:"add_mutation",notation:M.notation}):M.type==="analyze_smiles"?Un({type:"set_custom_smiles",smiles:M.smiles,name:M.name}):M.type==="focus_crispr_codon"&&Yt(M.codonIndex)},[Yt,Pt,Ke,ue,ve,Pe,Fe,We,_t,ss,Nn,is,da,je]),ro=C.useCallback(async(M,R)=>{switch(M){case"fetch_from_database":{const X=String(R.source||"rcsb"),oe=String(R.query||""),fe=await Iy(X,oe);if(fe.records.length===0)return{ok:!1,summary:`No matches in ${X} for "${oe}"`,data:{origin:fe.origin,records:[]}};const ke=fe.records[0];if(R.autoImport!==!1){if(ke.source==="pubchem"){const ft=dj(ke);return xl(ft),{ok:!0,summary:`Imported ${ft.name} (${ft.origin})`,data:ft}}const Le=R.role==="reference"?"reference":R.role==="mobile"?"mobile":ke.source==="rcsb"?"reference":"mobile",Be=await uj(ke);return await Ra(Be,Le),{ok:!0,summary:`Imported ${Be.label} as ${Le}`,data:{label:Be.label,role:Le,sha256:Be.sha256,origin:Be.origin,sourceUrl:Be.sourceUrl,license:Be.license}}}return{ok:!0,summary:`Found ${fe.records.length} record(s) in ${X}`,data:{origin:fe.origin,records:fe.records.slice(0,5)}}}case"run_structure_superposition":{const X=typeof R.refChain=="string"&&R.refChain?R.refChain:ve,oe=typeof R.mobChain=="string"&&R.mobChain?R.mobChain:_t;X!==ve&&Qe(X),oe!==_t&&ja(oe);const fe=await Pt({...fn(),rChain:X,mChain:oe});return fe?(je("results"),{ok:!0,summary:`RMSD ${fe.metrics.rmsdAngstrom.toFixed(4)} Å (${fe.metrics.matchedCaCount} Cα)`,data:{resultId:fe.resultId,metrics:fe.metrics,refSha256:fe.reference.sha256,mobSha256:fe.mobile.sha256}}):{ok:!1,summary:"Superposition did not complete (check chains)",data:null}}case"focus_3d_residues":{const X=(Array.isArray(R.seqIds)?R.seqIds:[]).map(Number).filter(fe=>Number.isFinite(fe)&&fe>0);if(X.length===0)return{ok:!1,summary:"No positive residue IDs supplied",data:null};Yt(X[0]);const oe=X.map(fe=>tt?.matchedResidues.find(ke=>ke.refSeqId===fe)??{refSeqId:fe,note:"not in matched Cα set"});return{ok:!0,summary:`Focused residue(s) ${X.join(", ")}`,data:{seqIds:X,matched:oe}}}case"engineer_peptide_mutation":{const X=Array.isArray(R.mutations)?R.mutations.map(ke=>String(ke).trim().toUpperCase()).filter(Boolean):[],oe=typeof R.focusSeqId=="number"&&Number.isFinite(R.focusSeqId)?R.focusSeqId:st.focusSeqId??void 0;je("peptide");for(const ke of X)Lt({type:"add_mutation",notation:ke});oe&&Yt(oe);const fe=await s.current.analyzePeptide({sequence:st.sequence,mutations:Array.from(new Set([...st.mutations,...X])),sliceStart:st.sliceStart,sliceEnd:st.sliceEnd,structureContent:ue||void 0,chainId:ve||void 0,focusSeqId:oe});return Oh(fe),lA({name:X.join(", ")||`Peptide (${fe.engineered.length} aa)`,sequence:st.sequence,mutations:Array.from(new Set([...st.mutations,...X]))}),{ok:!0,summary:`Applied ${X.join(", ")||"peptide analysis"} (ΔMW ${fe.deltas.mwAverageDa.toFixed(1)} Da, pI ${fe.engineered.pi.toFixed(2)})`,data:fe}}case"design_crispr_edit":{const X=typeof R.transcriptId=="string"&&R.transcriptId?R.transcriptId:Nt.transcriptId,oe=Math.max(1,Number(R.targetCodonIndex)||Nt.targetCodonIndex),fe=[0,1,2].includes(Number(R.baseEditOffset))?Number(R.baseEditOffset):Nt.baseEditOffset,ke=["A","C","G","T"].includes(String(R.newBase).toUpperCase())?String(R.newBase).toUpperCase():Nt.newBase,Le=["SpCas9","SaCas9","Cas12a"].includes(String(R.nuclease))?String(R.nuclease):Nt.nuclease;je("crispr"),An({type:"select_transcript",transcriptId:X}),An({type:"set_target_codon",codonIndex:oe}),An({type:"set_base_edit",offset:fe,newBase:ke}),An({type:"set_nuclease",nuclease:Le});const Be=await s.current.analyzeGeneCrispr({transcriptId:X,targetCodonIndex:oe,baseEditIndex:(oe-1)*3+fe+1,newBase:ke,nuclease:Le});return Ta(Be),cA({name:`${Be.geneSymbol} codon ${oe} (${Be.targetCodon.wtCodon}→${Be.targetCodon.editedCodon})`,transcriptId:X,targetCodonIndex:oe,baseEditOffset:fe,newBase:ke,nuclease:Le}),{ok:!0,summary:`${Be.geneSymbol} codon ${oe}: ${Be.targetCodon.wtCodon}→${Be.targetCodon.editedCodon} (${Be.targetCodon.consequence}), ${Be.pamSites.length} PAMs`,data:{...Be,pamSites:Be.pamSites.slice(0,8)}}}case"inspect_chemical_smiles":{const X=String(R.smiles||"").trim(),oe=typeof R.name=="string"&&R.name.trim()?R.name.trim():"Assistant SMILES";je("chemistry"),Un({type:"set_custom_smiles",smiles:X,name:oe});const fe=await s.current.analyzeMoleculeSmiles({name:oe,smiles:X});return to(fe),{ok:!0,summary:`${fe.formula}, MW ${fe.molecularWeight.toFixed(2)} Da, TPSA ${fe.tpsa.toFixed(1)} Ų`,data:fe}}case"analyze_ramachandran":{const X=R.target==="mobile"?"mobile":"reference",oe=X==="reference"?ue:We,fe=typeof R.chainId=="string"&&R.chainId?R.chainId:X==="reference"?ve:_t;au(X),je("ramachandran");const ke=await s.current.analyzeRamachandran({content:oe,chainId:fe||void 0});return fl(ke),{ok:!0,summary:`${X} (${ke.chainId}): ${ke.regionCounts.favored}/${ke.residueCount} favored, ${ke.contactPairs.length} contacts`,data:{chainId:ke.chainId,residueCount:ke.residueCount,secondaryCounts:ke.secondaryCounts,regionCounts:ke.regionCounts,contactCount:ke.contactPairs.length,outliers:ke.residues.filter(Le=>Le.region==="outlier").slice(0,10)}}}case"export_ruo_report":{const X=String(R.format||"html");return X==="json"?is():X==="bundle"?await si():da(),{ok:!0,summary:`Started ${X.toUpperCase()} download`,data:{exported:X}}}case"get_workspace_state":{const X=typeof R.section=="string"?R.section:"all",oe=typeof R.topN=="number"&&Number.isFinite(R.topN)?R.topN:10,ke=Ii({refLabel:Ke,mobLabel:Fe,refChain:ve,mobChain:_t,refInspect:Je,mobInspect:qn,comparison:tt,peptide:Ct,crispr:as,smiles:Vs,ramachandran:Qr},J,X,oe);return{ok:!0,summary:`Inspected workspace (${X}, ${tt?`RMSD ${tt.metrics.rmsdAngstrom.toFixed(3)} Å`:"no comparison"})`,data:ke}}case"search_scientific_web":{const X=String(R.query||"").trim(),oe=["all","literature","trials"].includes(String(R.scope))?String(R.scope):"all",fe=typeof R.limit=="number"&&Number.isFinite(R.limit)?R.limit:5,ke=await UD(X,{scope:oe,limit:fe});return{ok:!0,summary:`Web search "${X}": ${ke.hits.length} record(s) (${ke.origin})`,data:ke}}case"query_local_library":{const X=typeof R.kind=="string"?R.kind:"all",oe=typeof R.query=="string"?R.query.trim().toLowerCase():"",fe=J.filter(ke=>X==="all"?!0:ke.kind===X).filter(ke=>oe?`${ke.name} ${ke.source.accession??""} ${ke.tags.join(" ")}`.toLowerCase().includes(oe):!0).slice(0,20).map(ke=>({id:ke.id,kind:ke.kind,name:ke.name,format:ke.format,sha256:ke.sha256,source:ke.source}));return{ok:!0,summary:`Found ${fe.length} local library item(s)`,data:{count:fe.length,items:fe}}}case"list_compute_nodes":{const X=Di();return{ok:!0,summary:`${X.nodes.length} paired node(s); active=${X.activeNode?.label??"none"}`,data:{activeNodeId:X.activeNodeId,nodes:X.nodes.map(oe=>({id:oe.id,label:oe.label,kind:oe.kind,online:oe.online,gpus:oe.capabilities?.gpus??[],installedTools:oe.capabilities?.tools.filter(fe=>fe.installed).map(fe=>fe.id)??[]}))}}}case"run_compute_job":{const oe=Di().activeNode;if(!oe||!oe.online)return{ok:!1,summary:"No online Compute Node connected. Open Compute Nodes tab to pair Colab or a local GPU daemon.",data:null};const fe=String(R.toolId||"vina_docking"),ke=typeof R.smiles=="string"&&R.smiles.trim()?R.smiles.trim():Mt.smiles,Le=oA(tt,Ln),Be=fe==="vina_docking"?{ligandSmiles:ke,receptorPdb:ue,center:Le?.center??[0,0,0],size:Le?.size??[22,22,22]}:fe==="openmm_md"?{pdbContent:ue,steps:Number(R.steps??1e3)}:fe==="pyscf_qm"?{smiles:ke}:fe==="boltz_predict"?{sequences:[{id:"A",sequence:st.sequence}]}:{...R};je("compute");const ft=await dy(oe.id,fe,Be);return hy(oe.id,ft.job_id),{ok:!0,summary:`Dispatched ${fe} (${ft.job_id}) to ${oe.label}`,data:ft}}case"control_app_ui":{const X=["home","viewer","results","sequence","ramachandran","peptide","crispr","chemistry","workflow","compute","plugins","assistant","mcp","library"],oe=typeof R.tab=="string"&&X.includes(R.tab)?R.tab:null;oe&&je(oe,!!R.toSide),typeof R.sidebarView=="string"&&["explorer","library","tools","history"].includes(R.sidebarView)&&q(R.sidebarView),typeof R.sidebarOpen=="boolean"&&O(R.sidebarOpen),(R.viewportEngine==="webgl2"||R.viewportEngine==="molstar")&&D(R.viewportEngine),(R.viewportLayout==="overlay"||R.viewportLayout==="split"||R.viewportLayout==="reference"||R.viewportLayout==="mobile")&&Ue(R.viewportLayout),(R.renderStyle==="ribbon"||R.renderStyle==="trace"||R.renderStyle==="pocket")&&bt(R.renderStyle),(R.colorMode==="plddt"||R.colorMode==="bfactor"||R.colorMode==="deviation"||R.colorMode==="identity")&&St(R.colorMode);const fe=R.cameraPreset??R.applyPreset;return(fe==="overview"||fe==="active-site"||fe==="n-terminus"||fe==="reset")&&i.current?.applyPreset(fe),R.openTutorial===!0||R.openModal==="tutorial"?lr(!0):R.openModal==="databases"?G(!0):R.openModal==="settings"?Jt("ai"):R.openModal==="palette"?H(!0):R.openModal==="close"&&(lr(!1),G(!1),we(!1),H(!1)),R.resetLayout===!0&&T({type:"reset"}),{ok:!0,summary:`Updated UI (${[oe?`tab=${oe}`:null,R.sidebarView?`sidebar=${String(R.sidebarView)}`:null,R.openModal?`modal=${String(R.openModal)}`:null].filter(Boolean).join(", ")||"applied state"})`,data:{tab:oe,sidebarView:R.sidebarView??null,viewportEngine:R.viewportEngine??null}}}case"manage_project":{const X=String(R.action||"list");if(X==="list"){const oe=dp();return{ok:!0,summary:`${oe.projects.length} project(s); active="${oe.activeProject?.name??"none"}"`,data:{activeProjectId:oe.activeProject?.id??null,projects:oe.projects.map(fe=>({id:fe.id,name:fe.name,template:fe.template,structures:fe.structures.map(ke=>ke.label),molecules:fe.molecules.map(ke=>({name:ke.name,smiles:ke.smiles})),peptides:fe.peptides.length,crisprs:fe.crisprs.length}))}}}if(X==="create"){const oe=["blank","structure-compare","ligand-docking","peptide-crispr"].includes(String(R.template))?String(R.template):"ligand-docking",fe=ti({name:String(R.name||"AI Research Project"),description:typeof R.description=="string"?R.description:void 0,template:oe});return{ok:!0,summary:`Created project "${fe.name}" (${fe.id})`,data:fe}}if(X==="switch"){const oe=vx(String(R.projectId||""));return oe?{ok:!0,summary:`Switched active project to "${oe.name}"`,data:oe}:{ok:!1,summary:`Project "${String(R.projectId)}" not found`,data:null}}if(X==="add_molecule"){const oe=String(R.smiles||Mt.smiles).trim(),fe=String(R.name||"Designed Ligand").trim(),ke=Sx({name:fe,smiles:oe,note:typeof R.note=="string"?R.note:void 0});return Un({type:"set_custom_smiles",smiles:oe,name:fe}),je("chemistry"),{ok:!0,summary:`Saved "${fe}" (${oe}) into active project`,data:ke}}if(X==="split_chains"){const oe=(R.target??R.role)==="mobile"?"mobile":"reference",fe=gl(oe);return fe.length===0?{ok:!1,summary:`No ${oe} structure loaded or no chains found`,data:[]}:{ok:!0,summary:`Split ${oe} into ${fe.length} chain/ligand assets`,data:fe.map(ke=>({label:ke.label,kind:ke.kind,chainId:ke.chainId,atomCount:ke.atomCount}))}}if(X==="stage_binding"){const oe=typeof R.smiles=="string"&&R.smiles.trim()?R.smiles.trim():Mt.smiles,fe=typeof R.name=="string"&&R.name.trim()?R.name.trim():Mt.name;return Un({type:"set_custom_smiles",smiles:oe,name:fe}),Ne({tool:"vina",nonce:Date.now()}),je("compute"),{ok:!0,summary:`Staged "${fe}" + "${Ke||"active receptor"}" for binding`,data:{smiles:oe,name:fe,receptor:Ke}}}return{ok:!1,summary:`Unknown project action: ${X}`,data:null}}case"design_molecule_rdkit":{let X=String(R.smiles||Mt.smiles).trim();const oe=String(R.name||"Designed Analog").trim(),fe=typeof R.modifyAction=="string"?R.modifyAction:"";fe==="add_fluoro"&&!X.includes("F")?X=`${X}F`:fe==="add_methyl"?X=`${X}C`:fe==="add_hydroxyl"&&(X=`${X}O`),je("chemistry"),Un({type:"set_custom_smiles",smiles:X,name:oe});const ke=await s.current.analyzeMoleculeSmiles({name:oe,smiles:X});to(ke);let Le=[],Be=X,ft=null;if(typeof Worker<"u")try{const Zt=await Fo().analyzeMolecule(X);Be=Zt.canonicalSmiles||X,Le=Zt.alerts.map(ks=>`${ks.family}: ${ks.label}`),typeof R.smartsQuery=="string"&&R.smartsQuery.trim()&&(ft=!!(await Fo().searchLibrary(R.smartsQuery.trim(),[{id:oe,name:oe,smiles:Be}]))[0]?.substructureMatch)}catch{}const vt=R.saveToProject===!1?null:Sx({name:oe,smiles:Be,note:Le.length?`Alerts: ${Le.join("; ")}`:"Clean PAINS/Brenk"});return{ok:!0,summary:`Designed "${oe}" (${ke.formula}, MW ${ke.molecularWeight.toFixed(1)}, cLogP ${ke.crippenLogP.toFixed(2)}, TPSA ${ke.tpsa.toFixed(1)})`,data:{name:oe,canonicalSmiles:Be,descriptors:ke,alerts:Le,smartsMatched:ft,savedProjectAssetId:vt?.id??null}}}case"run_workflow_pipeline":{const X=Zd.find(Be=>Be.id===R.templateId)??Zd[0],oe=String(R.action||"run");if(je("workflow"),oe==="export_nextflow"){const Be=X3(X);return{ok:!0,summary:`Exported Nextflow DSL2 for "${X.name}"`,data:{templateId:X.id,nextflow:Be}}}if(oe==="export_snakemake"){const Be=Q3(X);return{ok:!0,summary:`Exported Snakemake Snakefile for "${X.name}"`,data:{templateId:X.id,snakefile:Be}}}const fe=fh(X);je("workflow");const ke=[];for(const Be of fe){if(!bl.current)break;try{const ft=await bl.current(Be.kind,Be.params);ke.push({id:Be.id,kind:Be.kind,ok:!0,summary:ft.summary})}catch(ft){const vt=ft instanceof Error?ft.message:String(ft);ke.push({id:Be.id,kind:Be.kind,ok:!1,summary:vt});break}}return{ok:ke.length===fe.length&&ke.every(Be=>Be.ok),summary:`${X.name}: completed ${ke.filter(Be=>Be.ok).length}/${fe.length} workflow step(s)`,data:{templateId:X.id,templateName:X.name,steps:ke}}}case"manage_plugins":{const X=String(R.action||"list");if(X==="list"){const ke=Jd();return{ok:!0,summary:`${ke.filter(Le=>Le.enabled).length}/${ke.length} plugin(s) enabled`,data:ke.map(Le=>({id:Le.id,name:Le.name,category:Le.category,tier:Le.tier,license:Le.license,commercialSafe:Le.commercialSafe,enabled:Le.enabled}))}}const oe=String(R.pluginId||"").trim();if(!oe)return{ok:!1,summary:"pluginId required",data:null};const fe=X==="enable";return H3(oe,fe),je("plugins"),{ok:!0,summary:`${fe?"Enabled":"Disabled"} plugin ${oe}`,data:{pluginId:oe,enabled:fe}}}}},[Ke,ue,ve,Pe,Je,Fe,We,_t,ss,qn,Nn,tt,st,Ct,Nt,as,Mt.smiles,Mt.name,Vs,Qr,J,Ln,Pt,Yt,Ra,xl,da,is,si,je,Jt,ti,gl]),jn=C.useMemo(()=>oA(tt,Ln),[tt,Ln]),yl=C.useMemo(()=>(tt?.refDisplayAtoms?.ligands??Je?.ligands??[]).filter(R=>R.resName.toUpperCase()!=="HOH"&&R.atoms.length>0).map(R=>{let X=0,oe=0,fe=0;for(const Le of R.atoms)X+=Le.xyz[0],oe+=Le.xyz[1],fe+=Le.xyz[2];const ke=Math.max(1,R.atoms.length);return{resName:R.resName,chainId:R.chainId,seqId:R.seqId,atomCount:R.atoms.length,centroid:[X/ke,oe/ke,fe/ke]}}),[tt,Je]),Ks=C.useMemo(()=>({activeProjectName:At.activeProject?.name??null,refLabel:Ke,refChain:ve,mobLabel:Fe,mobChain:_t,hasRef:!!ue,hasMob:!!We,hasComparison:!!tt,focusedSeqId:Ln,activeHighlight:ct.size>0?{source:ao??"Selection",seqIds:Array.from(ct)}:null,projectMolecules:At.activeProject?.molecules??[],projectStructures:At.activeProject?.structures??[],coCrystalLigands:yl,dockingBox:jn,focusIn3D:(M,R)=>{Yt(M),R?.style&&bt(R.style),R?.centerCamera!==!1&&Rh({seqId:M,nonce:Date.now()}),R?.openViewer==="activate"?je("viewer",!1):R?.openViewer==="side"&&je("viewer",!0)},highlightIn3D:(M,R,X)=>{const oe=Array.from(new Set(M.filter(fe=>Number.isFinite(fe)&&fe>0)));hl(oe.length>0?{source:R,seqIds:oe}:null),X?.focusSeqId!==void 0&&(Yt(X.focusSeqId),Rh({seqId:X.focusSeqId,nonce:Date.now()})),X?.style&&bt(X.style),X?.openViewer==="activate"?je("viewer",!1):X?.openViewer==="side"&&je("viewer",!0),oe.length>0&&e(`Highlighted ${oe.length} residue(s) in 3D (${R})`,"info")},clearHighlights3D:()=>hl(null),setStyle3D:M=>bt(M),setColorMode3D:M=>St(M),openTab:je,openDatabases:()=>G(!0),loadExample:()=>void cr(),saveMoleculeToProject:M=>{Sx(M),e(`Saved ${M.name} to active project`,"success")},saveMoleculeToLibrary:M=>{ca({kind:"compound",format:"smiles",name:M.name,content:M.smiles,source:{database:null,accession:null,sourceUrl:null,license:null,retrievedAtUtc:new Date().toISOString(),origin:"manual"}})},savePeptideToProject:M=>{lA(M),e(`Saved peptide "${M.name}" to active project`,"success")},saveCrisprToProject:M=>{cA(M),e(`Saved CRISPR edit "${M.name}" to active project`,"success")},syncPeptideFromChain:M=>{const R=M==="reference"?Je:qn,X=M==="reference"?ve:_t,oe=R?.chains.find(fe=>fe.chainId===X)??R?.chains[0];if(!oe?.sequence1Letter){e(`No amino-acid sequence found on ${M} chain`,"warn");return}Lt({type:"set_sequence",sequence:oe.sequence1Letter}),e(`Synced ${oe.sequence1Letter.length} aa from ${M} chain ${oe.chainId}`,"success")},sendMutationToPeptide:(M,R)=>{Lt({type:"add_mutation",notation:M}),R&&Yt(R),je("peptide"),e(`Applied ${M} in Peptide Workbench`,"info")},sendResidueToCrispr:M=>{Yt(M),je("crispr")},sendResidueToRamachandran:M=>{Yt(M),je("ramachandran")}}),[At.activeProject,Ke,ve,Fe,_t,ue,We,tt,Ln,ct,ao,yl,jn,Je,qn,Yt,je,cr,ca,e]),ur=C.useCallback(async(M,R)=>{switch(M){case"load_structures":if(!ue&&!Mt.smiles)throw new Error("Load a structure or SMILES first.");return{summary:`${Ke||"No structure"} · ${Mt.name}`};case"kabsch_compare":{const X=await Pt({rLabel:Ke,rContent:ue,rChain:ve,rMeta:Pe,mLabel:Fe,mContent:We,mChain:_t,mMeta:ss,pae:Nn});if(!X)throw new Error("Superposition failed; verify reference & mobile chains.");return{summary:`RMSD ${X.metrics.rmsdAngstrom.toFixed(3)} Å (${X.metrics.matchedCaCount} Cα)`,metrics:X.metrics}}case"rdkit_prep":{if(typeof Worker>"u")return{summary:`Wasm SMILES (${Mt.smiles})`};const X=await Fo().analyzeMolecule(Mt.smiles);return{summary:`${X.canonicalSmiles} · ${X.alerts.length} alerts`,metrics:X.descriptors}}case"export_report":return is(),{summary:"Exported RUO JSON provenance manifest"};default:{const oe=Di().activeNode;if(!oe||!oe.online)throw new Error(`Node "${M}" requires an online Tier-2 GPU/Compute Node (pair Colab or local worker).`);const fe={...R,smiles:Mt.smiles,ligandSmiles:Mt.smiles,pdbContent:ue,receptorPdb:ue,targetPdb:ue,center:jn?.center??[0,0,0],size:jn?.size??[22,22,22],sequences:[{id:"A",sequence:st.sequence}]},ke=await dy(oe.id,M,fe),Le=await hy(oe.id,ke.job_id);if(Le.status!=="completed")throw new Error(Le.error_message||`Remote job ${Le.status}`);return{summary:`${M} complete on ${oe.label}`,metrics:Le.metrics}}}},[Ke,ue,ve,Pe,Fe,We,_t,ss,Nn,Mt.name,Mt.smiles,st.sequence,jn,Pt,is]);bl.current=ur;const ha=C.useMemo(()=>({refLabel:Ke,mobLabel:Fe,refChain:ve,mobChain:_t,refInspect:Je,mobInspect:qn,comparison:tt,peptide:Ct,crispr:as,smiles:Vs,ramachandran:Qr}),[Ke,Fe,ve,_t,Je,qn,tt,Ct,as,Vs,Qr]),_l=C.useMemo(()=>({workspace:ha,libraryItems:J,executeTool:ro}),[ha,J,ro]),pu=C.useCallback(async M=>{const R=M.trim();if(!R||la)return;const X={id:`u-${Date.now()}`,role:"user",text:R,timestampUtc:new Date().toISOString()},oe=cu;uu(fe=>[...fe,X]),or([]),lu(!0);try{const fe=await rD({prompt:R,history:oe,workspace:ha,executeTool:(ke,Le)=>eE(_l,ke,Le,"internal-ai-agent"),onFallbackAction:Bh,onProgress:or,requestToolPermission:Lh,sessionApprovedCategories:ei.current,permissionPolicies:Ea,config:Ut});uu(ke=>[...ke,fe])}finally{or([]),Ma.current=null,Jr(null),lu(!1)}},[la,cu,ha,_l,Bh,Lh,Ea,Ut]),vl=C.useCallback(M=>on(JI(M)),[]),io=C.useCallback(M=>{W(M),on(Ac())},[]),Ss=E.groups[E.focused]?.active??null;C.useEffect(()=>{const M=R=>{const X=R.metaKey||R.ctrlKey,oe=R.key.toLowerCase();X&&oe==="k"?(R.preventDefault(),H(fe=>!fe)):X&&oe==="o"?(R.preventDefault(),c.current?.click()):X&&R.shiftKey&&oe==="f"?(R.preventDefault(),G(!0)):X&&oe==="b"?(R.preventDefault(),O(fe=>!fe)):X&&R.key===","?(R.preventDefault(),Jt()):R.altKey&&R.code==="KeyW"&&Ss&&(R.preventDefault(),T({type:"close",tab:Ss}))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[Ss,Jt]);const gu=C.useMemo(()=>[{id:"tutorial",category:"Help",label:"Open Interactive Studio Tutorial & Guide",run:()=>lr(!0)},{id:"new-project",category:"Project",label:"Create New Research Project",run:()=>{ti({name:`Project ${(At.projects.length||0)+1}`,template:"ligand-docking"})}},{id:"split-ref",category:"Project",label:"Split Reference Chains & HETATM Ligands",run:()=>{gl("reference")}},{id:"open-file",category:"File",label:"Open file…",shortcut:"⌘O",run:()=>c.current?.click()},{id:"db",category:"File",label:"Search public databases",shortcut:"⌘⇧F",run:()=>G(!0)},{id:"example",category:"File",label:"Load example comparison (carbonic anhydrase II)",run:()=>void cr()},{id:"tab-viewer",category:"Open tab",label:"3D Viewer",run:()=>je("viewer")},{id:"tab-results",category:"Open tab",label:"Results",run:()=>je("results")},{id:"tab-seq",category:"Open tab",label:"Sequence deviation",run:()=>je("sequence")},{id:"tab-rama",category:"Open tab",label:"Ramachandran plot",run:()=>je("ramachandran")},{id:"tab-pep",category:"Open tab",label:"Peptide engineering",run:()=>je("peptide")},{id:"tab-crispr",category:"Open tab",label:"Gene & CRISPR",run:()=>je("crispr")},{id:"tab-chem",category:"Open tab",label:"Ligands & 2D Sketcher",run:()=>je("chemistry")},{id:"tab-workflow",category:"Open tab",label:"Workflow Canvas",run:()=>je("workflow")},{id:"tab-compute",category:"Open tab",label:"GPU & Compute Nodes",run:()=>je("compute")},{id:"tab-plugins",category:"Open tab",label:"Plugins & Add-ons",run:()=>je("plugins")},{id:"toggle-molstar",category:"3D view",label:`Switch 3D Engine (${le==="molstar"?"Fast WebGL2":"Mol* Pro"})`,run:()=>D(M=>M==="molstar"?"webgl2":"molstar")},{id:"tab-ai",category:"Open tab",label:"AI Assistant",run:()=>je("assistant")},{id:"tab-mcp",category:"Open tab",label:"MCP Server",run:()=>je("mcp")},{id:"tab-lib",category:"Open tab",label:"Library",run:()=>je("library")},{id:"tab-home",category:"Open tab",label:"Start page",run:()=>je("home")},{id:"cam-site",category:"3D view",label:"Focus active site",run:()=>i.current?.applyPreset("active-site")},{id:"cam-reset",category:"3D view",label:"Reset camera",run:()=>i.current?.applyPreset("overview")},{id:"color-plddt",category:"3D view",label:"Color by pLDDT",run:()=>St("plddt")},{id:"color-b",category:"3D view",label:"Color by B-factor",run:()=>St("bfactor")},{id:"color-dev",category:"3D view",label:"Color by deviation Δd",run:()=>St("deviation")},{id:"color-id",category:"3D view",label:"Color by structure",run:()=>St("identity")},{id:"export-html",category:"Export",label:"HTML report",run:da},{id:"export-json",category:"Export",label:"JSON manifest",run:is},{id:"export-bundle",category:"Export",label:"Project bundle",run:()=>void si()},{id:"settings",category:"Settings",label:"Open settings",shortcut:"⌘,",run:()=>Jt()},{id:"settings-ai",category:"Settings",label:"AI & API keys",run:()=>Jt("ai")},{id:"settings-usage",category:"Settings",label:"Usage",run:()=>Jt("usage")},{id:"settings-account",category:"Settings",label:he?"Account":"Sign in",run:()=>he?Jt("account"):Bn("signin")},{id:"ui-bigger",category:"View",label:"Increase interface size",shortcut:"⌘+",run:()=>Cx(1)},{id:"ui-smaller",category:"View",label:"Decrease interface size",shortcut:"⌘−",run:()=>Cx(-1)},{id:"sidebar",category:"View",label:"Toggle sidebar",shortcut:"⌘B",run:()=>O(M=>!M)},{id:"layout-reset",category:"View",label:"Reset tab layout",run:()=>T({type:"reset"})}],[cr,je,da,is,si,Jt,he,Bn]),oo=C.useMemo(()=>new Set(E.groups.flatMap(M=>M.tabs)),[E]),ma=C.useMemo(()=>{const M=new Set;return Je&&M.add(Je.sha256),qn&&M.add(qn.sha256),M},[Je,qn]),bn="h-4 w-4",wl={home:{title:"Start",icon:o.jsx(FA,{className:bn})},viewer:{title:"3D Viewer",icon:o.jsx(_s,{className:bn})},results:{title:"Results",icon:o.jsx(qi,{className:bn})},sequence:{title:"Sequence",icon:o.jsx(Vo,{className:bn})},ramachandran:{title:"Ramachandran",icon:o.jsx(Qo,{className:bn})},peptide:{title:"Peptide",icon:o.jsx(ar,{className:bn})},crispr:{title:"CRISPR",icon:o.jsx(Fs,{className:bn})},chemistry:{title:"Ligands",icon:o.jsx(ia,{className:bn})},workflow:{title:"Workflows",icon:o.jsx(Dp,{className:bn})},compute:{title:"GPU Nodes",icon:o.jsx(al,{className:bn}),badge:Re.activeNode?.online?o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400"}):void 0},plugins:{title:"Plugins",icon:o.jsx(Lp,{className:bn})},assistant:{title:"Assistant",icon:o.jsx(qr,{className:bn}),badge:la?o.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-sky-400"}):void 0},mcp:{title:"MCP Server",icon:o.jsx(rl,{className:bn})},library:{title:"Library",icon:o.jsx(sh,{className:bn})}},ai=r.guidedMode,Oa=M=>o.jsx("div",{className:"h-full min-h-0",children:M}),Sl=M=>{switch(M){case"home":return o.jsx(Jq,{activeStarterId:me,runHistory:ou,projects:At.projects,activeProject:At.activeProject,onCreateProject:ti,onSwitchProject:R=>{vx(R),e("Switched active project","info")},onDeleteProject:R=>{kD(R),e("Deleted project","info")},onOpenTutorial:()=>lr(!0),onImportFile:()=>c.current?.click(),onSearchDatabases:()=>G(!0),onOpenLibrary:()=>je("library"),onOpenAssistant:()=>je("assistant"),onOpenChemistry:()=>je("chemistry"),onOpenPeptide:()=>je("peptide"),onOpenCrispr:()=>je("crispr"),onOpenWorkflows:()=>je("workflow"),onOpenComputeNodes:()=>je("compute"),onOpenPlugins:()=>je("plugins"),onLaunchStarter:R=>void mu(R),onOpenLibraryItem:R=>void za(R,"auto")});case"viewer":return o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsxs("div",{className:"flex h-8 shrink-0 items-center justify-between border-b border-white/[0.06] bg-[#0a0d13] px-2.5 text-[0.75rem]",children:[o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"mr-1 text-slate-500",children:"3D Engine:"}),o.jsx("button",{type:"button",onClick:()=>D("webgl2"),className:`rounded-md px-2 py-0.5 font-medium transition ${le==="webgl2"?"bg-sky-500/20 text-sky-200":"text-slate-400 hover:text-slate-200"}`,children:"Fast WebGL2"}),o.jsx("button",{type:"button",onClick:()=>D("molstar"),className:`rounded-md px-2 py-0.5 font-medium transition ${le==="molstar"?"bg-sky-500/20 text-sky-200":"text-slate-400 hover:text-slate-200"}`,children:"Mol* Pro"})]}),ae&&o.jsxs("div",{className:"flex items-center gap-2 font-mono text-[0.6875rem] text-emerald-300",children:[o.jsxs("span",{children:["Overlay: ",ae.label]}),o.jsx("button",{type:"button",onClick:()=>pe(null),className:"text-slate-400 hover:text-slate-200",children:"Clear"})]})]}),o.jsxs("div",{className:"relative min-h-0 flex-1",children:[le==="molstar"?o.jsx(C.Suspense,{fallback:o.jsx("div",{className:"flex h-full items-center justify-center bg-[#070b12] text-xs text-slate-400",children:"Loading Mol* Pro 3D engine…"}),children:o.jsx(KL,{ref:i,refLabel:Ke,refContent:ue,mobLabel:Fe,mobContent:We,comparison:tt,layout:Ce,style:be,colorMode:Ot,focusedSeqId:Ln,focusCameraRequest:Zi,highlightSourceLabel:ao,highlightCount:ct.size,onClearHighlights:()=>hl(null),extraOverlay:ae,onPickResidue:Yt,onSendPocketToDocking:()=>{Ne({tool:"vina",nonce:Date.now()}),je("compute")}})}):o.jsx(hL,{ref:i,comparison:tt,refInspect:Je,mobInspect:qn,refChainId:ve,mobChainId:_t,layout:Ce,onChangeLayout:Ue,style:be,onChangeStyle:bt,colorMode:Ot,onChangeColorMode:St,focusedSeqId:Ln,focusCameraRequest:Zi,highlightedSeqIds:ct,highlightSourceLabel:ao,onClearHighlights:()=>hl(null),paePair:zh,onPickResidue:Yt,onRendererModeDetected:k,simpleMode:!1}),!ue&&!We&&!p&&o.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center p-6",children:o.jsxs("div",{className:"pointer-events-auto max-w-sm rounded-2xl border border-white/10 bg-[#121722]/95 p-6 text-center shadow-2xl backdrop-blur",children:[o.jsx(_s,{className:"mx-auto h-8 w-8 text-slate-500"}),o.jsx("div",{className:"mt-3 text-base font-medium text-slate-100",children:"No structure loaded"}),o.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Open a file, pick one from your library, or search a public database."}),o.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>c.current?.click(),className:"rounded-lg bg-sky-500 px-3.5 py-2 text-sm font-semibold text-slate-950 hover:bg-sky-400",children:"Open file"}),o.jsx("button",{type:"button",onClick:()=>G(!0),className:"rounded-lg border border-white/10 px-3.5 py-2 text-sm text-slate-200 hover:bg-white/[0.06]",children:"Search databases"})]}),o.jsx("button",{type:"button",onClick:()=>void cr(),className:"mt-3 text-xs text-slate-500 hover:text-sky-300",children:"or load the example comparison"})]})})]})]});case"results":return o.jsx(vL,{comparison:tt,paeJson:Nn,busy:!!p,guided:ai,selectedPaePair:zh,onSelectPaePair:(R,X)=>{eo([R,X]),Yt(R)},includePng:ni,onToggleIncludePng:R=>n(X=>({...X,viewer:{...X.viewer,embedPngInReports:R}})),onExportHtml:da,onExportJson:is,onExportBundle:()=>void si(),bridge:Ks});case"sequence":return Oa(o.jsx(SL,{comparison:tt,refInspect:Je,mobInspect:qn,refChainId:ve,mobChainId:_t,focusedSeqId:Ln,onFocusResidue:Yt,bridge:Ks}));case"ramachandran":return Oa(o.jsx(_L,{refLabel:Ke,refChain:ve,mobLabel:Fe,mobChain:_t,activeSource:so,onChangeSource:au,result:Qr,error:ru,focusedSeqId:Ln,onFocusResidue:Yt,simpleMode:ai,bridge:Ks}));case"peptide":return Oa(o.jsx(mL,{state:st,dispatch:Lt,result:Ct,error:i0,onFocusResidue:Yt,simpleMode:ai,bridge:Ks}));case"crispr":return Oa(o.jsx(Yq,{state:Nt,dispatch:An,result:as,error:ml,onFocusResidue:Yt,simpleMode:ai,bridge:Ks}));case"chemistry":return Oa(o.jsx(Bq,{state:Mt,dispatch:Un,result:Vs,comparison:tt,error:no,onFocusResidue:Yt,onStageForCompute:(R,X)=>{Un({type:"set_custom_smiles",smiles:X.smiles,name:X.name}),Ne({tool:R,nonce:Date.now()}),je("compute")},libraryCompounds:J.filter(R=>R.kind==="compound").map(R=>({id:R.id,name:R.name,smiles:R.content})),simpleMode:ai,bridge:Ks}));case"workflow":return o.jsx($L,{onExecuteNode:ur,activeComputeLabel:Re.activeNode?.online?Re.activeNode.label:null,onOpenComputeNodes:()=>je("compute"),bridge:Ks});case"compute":return o.jsx(Fq,{activeSmiles:Mt.smiles,activeSmilesName:Mt.name,activeRefPdbOrCif:ue,activeRefLabel:Ke,pocketBox:jn,stagedComputeTarget:Ae,onImportArtifactToViewer:R=>{pe({id:`art-${Date.now()}`,...R}),D("molstar"),je("viewer")},bridge:Ks});case"plugins":return o.jsx(xL,{onOpenComputeNodes:()=>je("compute"),onOpenMcpServer:()=>je("mcp"),onOpenToolTab:R=>je(R)});case"assistant":return o.jsx(Nq,{messages:cu,busy:la,config:Ut,liveSteps:Ih,pendingPermission:pl,onResolvePermission:Uh,onSelectProvider:(R,X)=>vl({provider:R,...R==="synlexa"&&Xc(Ut).hasByok?{routingPreference:"manual"}:{},...X?{[R]:{model:X}}:{}}),onToggleWebSearch:R=>vl({enableWebSearch:R}),onSend:R=>void pu(R),onClear:()=>uu([]),onOpenKeySettings:()=>Jt("ai"),onOpenMcpServer:()=>je("mcp")});case"mcp":return o.jsx(tL,{runtime:_l,onOpenAiAssistant:()=>je("assistant"),onOpenVaultSettings:()=>Jt("ai")});case"library":return o.jsx(CA,{onOpenItem:(R,X)=>void za(R,X),loadedShas:ma})}},lo=Xc(Ut),ln=Ut[lo.provider]??{apiKey:"",model:""},Pa=es[lo.provider].models.find(M=>M.id===ln.model)?.label??ln.model,kl=ln.apiKey?`${lo.isByok?"BYOK":"Cloud"}: ${Pa}`:lo.provider==="synlexa"?"AI: sign in or add BYOK":"AI: no key",co=At.activeProject?.name??(me?sq(me)?.title:null)??(Ke||Fe?[Ke,Fe].filter(Boolean).join(" vs "):"Untitled workspace"),c0=M=>{M==="settings"?Jt("ai"):je(M)},bu={explorer:"Workspace",library:"Library",tools:"Tools",history:"History"};return o.jsxs("div",{className:"flex h-dvh w-screen flex-col overflow-hidden bg-[#0b0e14] text-slate-100",children:[o.jsx("input",{ref:c,type:"file",multiple:!0,accept:".cif,.mmcif,.pdb,.ent,.json,.fasta,.fa,.faa,.smi",className:"hidden",onChange:M=>{M.target.files?.length&&fu(M.target.files,"auto"),M.target.value=""}}),o.jsx(DL,{projectTitle:co,session:he,onOpenPalette:()=>H(!0),onOpenFile:()=>c.current?.click(),onSearchDatabases:()=>G(!0),onOpenMcp:()=>je("mcp"),onOpenTutorial:()=>lr(!0),onExportHtml:da,onExportJson:is,onExportBundle:()=>void si(),canExport:!!tt,onOpenAccount:()=>Jt("account")}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx(qL,{view:j,sidebarOpen:z,onSelect:M=>{z&&M===j?O(!1):(q(M),O(!0))},onOpenSettings:()=>Jt(),onOpenAssistant:()=>je("assistant"),onOpenMcp:()=>je("mcp"),libraryCount:J.length}),z&&o.jsxs(LL,{title:bu[j],width:j==="library"?304:276,actions:j==="library"?o.jsx(sl,{label:"Open full library manager",onClick:()=>je("library"),children:o.jsx(Oy,{className:"h-3.5 w-3.5"})}):void 0,children:[j==="explorer"&&o.jsx(UL,{refLabel:Ke,mobLabel:Fe,refInspect:Je,mobInspect:qn,refChain:ve,mobChain:_t,hasRef:!!ue,hasMob:!!We,paePresent:!!Nn,chainError:_,onChangeRefChain:M=>{Qe(M),Pt({...fn(),rChain:M})},onChangeMobChain:M=>{ja(M);const R=qn?.chains.find(X=>X.chainId===M)?.sequence1Letter;R&&Lt({type:"set_sequence",sequence:R}),Pt({...fn(),mChain:M})},onUploadFiles:(M,R)=>void fu(M,R),onSaveToLibrary:l0,onSearchDatabases:()=>G(!0),onLoadExample:()=>void cr(),projects:At.projects,activeProject:At.activeProject,onCreateProject:ti,onSwitchProject:M=>vx(M),onSplitStructure:M=>gl(M),onLoadProjectStructure:du,onOpenProjectMolecule:M=>{Un({type:"set_custom_smiles",smiles:M.smiles,name:M.name}),je("chemistry")},onDockMolecule:o0,onRemoveProjectAsset:(M,R)=>CD(M,R),onOpenChemistry:()=>je("chemistry"),onOpenPeptide:()=>je("peptide"),onOpenCrispr:()=>je("crispr")}),j==="library"&&o.jsx(CA,{compact:!0,onOpenItem:(M,R)=>void za(M,R),loadedShas:ma}),j==="tools"&&o.jsx(HL,{openTabs:oo,onOpen:(M,R)=>je(M,R)}),j==="history"&&o.jsx(FL,{runs:ou,onClear:()=>void uE().then(()=>rs([]))})]}),o.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:o.jsx(IL,{layout:E,dispatch:T,meta:wl,renderTab:Sl,keepAlive:YL})})]}),o.jsx(VL,{busyLabel:p,wasmReady:d,rendererMode:S,rmsd:tt?.metrics.rmsdAngstrom??null,focusedSeqId:Ln,computeNodeLabel:Re.activeNode?.label??null,computeOnline:!!Re.activeNode?.online,onOpenComputeNodes:()=>je("compute"),aiLabel:kl,aiReady:!!ln.apiKey,onOpenAiSettings:()=>Jt("ai")}),o.jsx(Hq,{open:$,onClose:()=>H(!1),commands:gu}),o.jsx(Xq,{open:Z,onClose:()=>G(!1),onImportStructure:Ra,onImportCompound:xl}),o.jsx(kL,{open:K,onClose:()=>we(!1),section:V,onSectionChange:P,aiConfig:Ut,onUpdateAiConfig:vl,onPermissionsChange:Zr,session:he,onSessionChange:io,onSignIn:Bn,onCancelSignIn:hu,signInPending:Se,onResetLayout:()=>T({type:"reset"}),onClearedHistory:()=>rs([])}),o.jsx(PL,{open:qh,onClose:()=>lr(!1),onExecuteStepAction:c0})]})}Jv(Xv().uiScale);const PA=JM.createRoot(document.getElementById("root"));if(YI(window.location.href)){window.history.replaceState({},"",window.location.pathname||"/");try{window.close()}catch{}PA.render(o.jsx("div",{className:"flex h-full items-center justify-center bg-[#0d1117] p-6 text-center",children:o.jsxs("div",{children:[o.jsx("div",{className:"text-base font-medium text-slate-100",children:"You're signed in"}),o.jsx("p",{className:"mt-1 text-sm text-slate-400",children:"Closing sign-in window and returning to Synlexa Studio…"}),o.jsx("button",{type:"button",onClick:()=>window.close(),className:"mt-4 rounded-md border border-slate-700 bg-slate-800 px-3 py-1.5 text-xs font-medium text-slate-200 hover:bg-slate-700",children:"Close window"})]})})),window.setTimeout(()=>{try{window.close()}catch{}},80),window.setTimeout(()=>{try{window.close()}catch{}},350)}else PA.render(o.jsx(C.StrictMode,{children:o.jsx(pq,{children:o.jsx(WL,{})})}));export{De as A,_s as B,OR as C,eU as D,sC as M,XL as R,Ur as a,bR as b,oA as c,JM as d,GM as g,o as j,C as r};