@rizom/brain 0.2.0-alpha.585 → 0.2.0-alpha.586

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.
@@ -1343,6 +1343,7 @@
1343
1343
  .xdo6va6:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-err) 7%,transparent)}
1344
1344
  .x1xlsm2u:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-frame) 94%,transparent)}
1345
1345
  .x382npu:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-text) 4%,transparent)}
1346
+ .x18jj7c1:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-text) 5%,transparent)}
1346
1347
  .x1ghvq8m:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-text) 7%,transparent)}
1347
1348
  .x1mh3lbe:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-warn) 15%,transparent)}
1348
1349
  .xc1c755:not(#\#):not(#\#):not(#\#){background-color:color-mix(in srgb,var(--console-warn) 7%,transparent)}
@@ -1,4 +1,4 @@
1
- import{a as YM,b as XM,e as $M,f as GM}from"./studio-chunks/main-xvgffskk.js";import{$ as Mg,A as v1,Aa as Fn,B as Ni,Ba as os,C as CT,Ca as Wm,D as gm,Da as ba,E as HM,Ea as Wn,F as M1,Fa as lg,G as Ng,Ga as Ed,H as Og,Ha as Fm,I as D1,Ia as DR,J as LL,Ja as RR,K as BL,Ka as Td,L as oL,La as ZD,M as k1,Ma as eR,N as Nn,Na as F,O as dM,Oa as OO,P as it,Pa as r1,Q as bg,Qa as dO,R as lL,Ra as bO,S as sL,Sa as ug,T as rL,U as Ui,V as aL,W as uL,X as cL,Y as R1,Z as fL,_ as dL,aa as Lg,ba as gc,ca as xa,da as Gd,ea as C1,fa as UM,g as HL,ga as $d,h as RL,ha as Bg,i as _L,ia as SM,j as yg,ja as vg,k as Eo,ka as zL,l as Rg,la as kL,m as OL,ma as CL,n as qL,na as PL,o as ML,oa as Eg,p as Ug,pa as mc,q as Qt,qa as ti,r as ke,ra as yr,s as pm,sa as _M,t as mr,ta as Cg,u as xT,ua as qM,v as yt,va as LM,w as nr,wa as BM,x as Hg,xa as Ag,y as nd,ya as EL,z as NM,za as WM}from"./studio-chunks/main-drkb8mk1.js";import"./studio-chunks/main-5vgqdq6h.js";import{$a as Gn,Ab as kg,Fb as Cv,Gb as Jn,Hb as zn,Ib as DM,Jb as zg,Lb as td,Mb as cg,Nb as xv,Ob as gM,Yb as Li,_a as V,ab as Se,ac as Ao,bb as Ue,bc as IL,cc as VL,dc as Ji,eb as OM,ec as er,fb as Ce,fc as An,gb as Sa,gc as kT,hb as Wl,hc as tr,ib as VM,kb as AM,kc as ei,lc as Iu,mc as Aa,nc as gL,ob as EM,oc as Zn,pb as TM,pc as mm,qb as Mn,qc as pi,rb as PM,sb as KO,tb as JO,ub as ZO,wb as jM,xb as Sg,yb as wg,zb as xg}from"./studio-chunks/main-4vaeqvhy.js";import{rc as se,tc as Sv,wc as DL,xc as ln,zc as CN}from"./studio-chunks/main-h3ka07k3.js";var fT=Sv(function(kN){(function(){function t(){if(j=!1,he){var Q=kN.unstable_now();ce=Q;var le=!0;try{e:{U=!1,q&&(q=!1,ee(Je),Je=-1),B=!0;var te=R;try{t:{u(Q);for(C=l(S);C!==null&&!(C.expirationTime>Q&&h());){var K=C.callback;if(typeof K==="function"){C.callback=null,R=C.priorityLevel;var me=K(C.expirationTime<=Q);if(Q=kN.unstable_now(),typeof me==="function"){C.callback=me,u(Q),le=!0;break t}C===l(S)&&s(S),u(Q)}else s(S);C=l(S)}if(C!==null)le=!0;else{var Fe=l(k);Fe!==null&&p(f,Fe.startTime-Q),le=!1}}break e}finally{C=null,R=te,B=!1}le=void 0}}finally{le?X():he=!1}}}function i(Q,le){var te=Q.length;Q.push(le);e:for(;0<te;){var K=te-1>>>1,me=Q[K];if(0<a(me,le))Q[K]=le,Q[te]=me,te=K;else break e}}function l(Q){return Q.length===0?null:Q[0]}function s(Q){if(Q.length===0)return null;var le=Q[0],te=Q.pop();if(te!==le){Q[0]=te;e:for(var K=0,me=Q.length,Fe=me>>>1;K<Fe;){var Ie=2*(K+1)-1,pt=Q[Ie],Ze=Ie+1,Be=Q[Ze];if(0>a(pt,te))Ze<me&&0>a(Be,pt)?(Q[K]=Be,Q[Ze]=te,K=Ze):(Q[K]=pt,Q[Ie]=te,K=Ie);else if(Ze<me&&0>a(Be,te))Q[K]=Be,Q[Ze]=te,K=Ze;else break e}}return le}function a(Q,le){var te=Q.sortIndex-le.sortIndex;return te!==0?te:Q.id-le.id}function u(Q){for(var le=l(k);le!==null;){if(le.callback===null)s(k);else if(le.startTime<=Q)s(k),le.sortIndex=le.expirationTime,i(S,le);else break;le=l(k)}}function f(Q){if(q=!1,u(Q),!U)if(l(S)!==null)U=!0,he||(he=!0,X());else{var le=l(k);le!==null&&p(f,le.startTime-Q)}}function h(){return j?!0:kN.unstable_now()-ce<_?!1:!0}function p(Q,le){Je=P(function(){Q(kN.unstable_now())},le)}if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),kN.unstable_now=void 0,typeof performance==="object"&&typeof performance.now==="function"){var g=performance;kN.unstable_now=function(){return g.now()}}else{var b=Date,v=b.now();kN.unstable_now=function(){return b.now()-v}}var S=[],k=[],A=1,C=null,R=3,B=!1,U=!1,q=!1,j=!1,P=typeof setTimeout==="function"?setTimeout:null,ee=typeof clearTimeout==="function"?clearTimeout:null,Ae=typeof setImmediate<"u"?setImmediate:null,he=!1,Je=-1,_=5,ce=-1;if(typeof Ae==="function")var X=function(){Ae(t)};else if(typeof MessageChannel<"u"){var ge=new MessageChannel,ot=ge.port2;ge.port1.onmessage=t,X=function(){ot.postMessage(null)}}else X=function(){P(t,0)};kN.unstable_IdlePriority=5,kN.unstable_ImmediatePriority=1,kN.unstable_LowPriority=4,kN.unstable_NormalPriority=3,kN.unstable_Profiling=null,kN.unstable_UserBlockingPriority=2,kN.unstable_cancelCallback=function(Q){Q.callback=null},kN.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<Q?Math.floor(1000/Q):5},kN.unstable_getCurrentPriorityLevel=function(){return R},kN.unstable_next=function(Q){switch(R){case 1:case 2:case 3:var le=3;break;default:le=R}var te=R;R=le;try{return Q()}finally{R=te}},kN.unstable_requestPaint=function(){j=!0},kN.unstable_runWithPriority=function(Q,le){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var te=R;R=Q;try{return le()}finally{R=te}},kN.unstable_scheduleCallback=function(Q,le,te){var K=kN.unstable_now();switch(typeof te==="object"&&te!==null?(te=te.delay,te=typeof te==="number"&&0<te?K+te:K):te=K,Q){case 1:var me=-1;break;case 2:me=250;break;case 5:me=1073741823;break;case 4:me=1e4;break;default:me=5000}return me=te+me,Q={id:A++,callback:le,priorityLevel:Q,startTime:te,expirationTime:me,sortIndex:-1},te>K?(Q.sortIndex=te,i(k,Q),l(S)===null&&Q===l(k)&&(q?(ee(Je),Je=-1):q=!0,p(f,te-K))):(Q.sortIndex=me,i(S,Q),U||B||(U=!0,he||(he=!0,X()))),Q},kN.unstable_shouldYield=h,kN.unstable_wrapCallback=function(Q){var le=R;return function(){var te=R;R=le;try{return Q.apply(this,arguments)}finally{R=te}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var dT=Sv(function(AN){var Ye=se(fT()),Uu=se(ln()),wv=se(CN());(function(){function t(e,n){for(e=e.memoizedState;e!==null&&0<n;)e=e.next,n--;return e}function i(e,n,o,r){if(o>=n.length)return r;var c=n[o],d=sn(e)?e.slice():Ne({},e);return d[c]=i(e[c],n,o+1,r),d}function l(e,n,o){if(n.length!==o.length)console.warn("copyWithRename() expects paths of the same length");else{for(var r=0;r<o.length-1;r++)if(n[r]!==o[r]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return s(e,n,o,0)}}function s(e,n,o,r){var c=n[r],d=sn(e)?e.slice():Ne({},e);return r+1===n.length?(d[o[r]]=d[c],sn(d)?d.splice(c,1):delete d[c]):d[c]=s(e[c],n,o,r+1),d}function a(e,n,o){var r=n[o],c=sn(e)?e.slice():Ne({},e);if(o+1===n.length)return sn(c)?c.splice(r,1):delete c[r],c;return c[r]=a(e[r],n,o+1),c}function u(){return!1}function f(){return null}function h(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function p(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function g(){}function b(){}function v(e){var n=[];return e.forEach(function(o){n.push(o)}),n.sort().join(", ")}function S(e,n,o,r){return new dB(e,n,o,r)}function k(e,n){e.context===Ls&&(I0(e.current,2,n,e,null,null),Xa())}function A(e,n){if(Pi!==null){var o=n.staleFamilies;n=n.updatedFamilies,Wc(),yw(e.current,n,o),Xa()}}function C(e){Pi=e}function R(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function B(e){var n=e,o=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(o=n.return),e=n.return;while(e)}return n.tag===3?o:null}function U(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function q(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function j(e){if(B(e)!==e)throw Error("Unable to find node on an unmounted component.")}function P(e){var n=e.alternate;if(!n){if(n=B(e),n===null)throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var o=e,r=n;;){var c=o.return;if(c===null)break;var d=c.alternate;if(d===null){if(r=c.return,r!==null){o=r;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===o)return j(c),e;if(d===r)return j(c),n;d=d.sibling}throw Error("Unable to find node on an unmounted component.")}if(o.return!==r.return)o=c,r=d;else{for(var m=!1,y=c.child;y;){if(y===o){m=!0,o=c,r=d;break}if(y===r){m=!0,r=c,o=d;break}y=y.sibling}if(!m){for(y=d.child;y;){if(y===o){m=!0,o=d,r=c;break}if(y===r){m=!0,r=d,o=c;break}y=y.sibling}if(!m)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(o.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(o.tag!==3)throw Error("Unable to find node on an unmounted component.");return o.stateNode.current===o?e:n}function ee(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=ee(e),n!==null)return n;e=e.sibling}return null}function Ae(e){if(e===null||typeof e!=="object")return null;return e=CC&&e[CC]||e["@@iterator"],typeof e==="function"?e:null}function he(e){if(e==null)return null;if(typeof e==="function")return e.$$typeof===Bz?null:e.displayName||e.name||null;if(typeof e==="string")return e;switch(e){case tu:return"Fragment";case Q0:return"Profiler";case sp:return"StrictMode";case X0:return"Suspense";case W0:return"SuspenseList";case F0:return"Activity"}if(typeof e==="object")switch(typeof e.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case eu:return"Portal";case sl:return e.displayName||"Context";case Y0:return(e._context.displayName||"Context")+".Consumer";case sf:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rp:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case Ci:n=e._payload,e=e._init;try{return he(e(n))}catch(o){}}return null}function Je(e){return typeof e.tag==="number"?_(e):typeof e.name==="string"?e.name:null}function _(e){var n=e.type;switch(e.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(n._context.displayName||"Context")+".Consumer";case 10:return n.displayName||"Context";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===sp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof n==="function")return n.displayName||n.name||null;if(typeof n==="string")return n;break;case 29:if(n=e._debugInfo,n!=null){for(var o=n.length-1;0<=o;o--)if(typeof n[o].name==="string")return n[o].name}if(e.return!==null)return _(e.return)}return null}function ce(e){return{current:e}}function X(e,n){0>Ll?console.error("Unexpected pop."):(n!==J0[Ll]&&console.error("Unexpected Fiber popped."),e.current=K0[Ll],K0[Ll]=null,J0[Ll]=null,Ll--)}function ge(e,n,o){Ll++,K0[Ll]=e.current,J0[Ll]=o,e.current=n}function ot(e){return e===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),e}function Q(e,n){ge(Es,n,e),ge(rf,e,e),ge(As,null,e);var o=n.nodeType;switch(o){case 9:case 11:o=o===9?"#document":"#fragment",n=(n=n.documentElement)?(n=n.namespaceURI)?Xk(n):Ql:Ql;break;default:if(o=n.tagName,n=n.namespaceURI)n=Xk(n),n=Wk(n,o);else switch(o){case"svg":n=Nu;break;case"math":n=lm;break;default:n=Ql}}o=o.toLowerCase(),o=P1(null,o),o={context:n,ancestorInfo:o},X(As,e),ge(As,o,e)}function le(e){X(As,e),X(rf,e),X(Es,e)}function te(){return ot(As.current)}function K(e){e.memoizedState!==null&&ge(ap,e,e);var n=ot(As.current),o=e.type,r=Wk(n.context,o);o=P1(n.ancestorInfo,o),r={context:r,ancestorInfo:o},n!==r&&(ge(rf,e,e),ge(As,r,e))}function me(e){rf.current===e&&(X(As,e),X(rf,e)),ap.current===e&&(X(ap,e),Jf._currentValue=aa)}function Fe(){}function Ie(){if(af===0){AC=console.log,EC=console.info,TC=console.warn,DC=console.error,RC=console.group,OC=console.groupCollapsed,MC=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Fe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}af++}function pt(){if(af--,af===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ne({},e,{value:AC}),info:Ne({},e,{value:EC}),warn:Ne({},e,{value:TC}),error:Ne({},e,{value:DC}),group:Ne({},e,{value:RC}),groupCollapsed:Ne({},e,{value:OC}),groupEnd:Ne({},e,{value:MC})})}0>af&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function Ze(e){var n=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,e=e.stack,Error.prepareStackTrace=n,e.startsWith(`Error: react-stack-top-frame
1
+ import{a as YM,b as XM,e as $M,f as GM}from"./studio-chunks/main-m8wmpxz1.js";import{$ as Mg,A as v1,Aa as Fn,B as Ni,Ba as os,C as CT,Ca as Wm,D as gm,Da as ba,E as HM,Ea as Wn,F as M1,Fa as lg,G as Ng,Ga as Ed,H as Og,Ha as Fm,I as D1,Ia as DR,J as LL,Ja as RR,K as BL,Ka as Td,L as oL,La as ZD,M as k1,Ma as eR,N as Nn,Na as F,O as dM,Oa as OO,P as it,Pa as r1,Q as bg,Qa as dO,R as lL,Ra as bO,S as sL,Sa as ug,T as rL,U as Ui,V as aL,W as uL,X as cL,Y as R1,Z as fL,_ as dL,aa as Lg,ba as gc,ca as xa,da as Gd,ea as C1,fa as UM,g as HL,ga as $d,h as RL,ha as Bg,i as _L,ia as SM,j as yg,ja as vg,k as Eo,ka as zL,l as Rg,la as kL,m as OL,ma as CL,n as qL,na as PL,o as ML,oa as Eg,p as Ug,pa as mc,q as Qt,qa as ti,r as ke,ra as yr,s as pm,sa as _M,t as mr,ta as Cg,u as xT,ua as qM,v as yt,va as LM,w as nr,wa as BM,x as Hg,xa as Ag,y as nd,ya as EL,z as NM,za as WM}from"./studio-chunks/main-drkb8mk1.js";import"./studio-chunks/main-5vgqdq6h.js";import{$a as Gn,Ab as kg,Fb as Cv,Gb as Jn,Hb as zn,Ib as DM,Jb as zg,Lb as td,Mb as cg,Nb as xv,Ob as gM,Yb as Li,_a as V,ab as Se,ac as Ao,bb as Ue,bc as IL,cc as VL,dc as Ji,eb as OM,ec as er,fb as Ce,fc as An,gb as Sa,gc as kT,hb as Wl,hc as tr,ib as VM,kb as AM,kc as ei,lc as Iu,mc as Aa,nc as gL,ob as EM,oc as Zn,pb as TM,pc as mm,qb as Mn,qc as pi,rb as PM,sb as KO,tb as JO,ub as ZO,wb as jM,xb as Sg,yb as wg,zb as xg}from"./studio-chunks/main-4vaeqvhy.js";import{rc as se,tc as Sv,wc as DL,xc as ln,zc as CN}from"./studio-chunks/main-h3ka07k3.js";var fT=Sv(function(kN){(function(){function t(){if(j=!1,he){var Q=kN.unstable_now();ce=Q;var le=!0;try{e:{U=!1,q&&(q=!1,ee(Je),Je=-1),B=!0;var te=R;try{t:{u(Q);for(C=l(S);C!==null&&!(C.expirationTime>Q&&h());){var K=C.callback;if(typeof K==="function"){C.callback=null,R=C.priorityLevel;var me=K(C.expirationTime<=Q);if(Q=kN.unstable_now(),typeof me==="function"){C.callback=me,u(Q),le=!0;break t}C===l(S)&&s(S),u(Q)}else s(S);C=l(S)}if(C!==null)le=!0;else{var Fe=l(k);Fe!==null&&p(f,Fe.startTime-Q),le=!1}}break e}finally{C=null,R=te,B=!1}le=void 0}}finally{le?X():he=!1}}}function i(Q,le){var te=Q.length;Q.push(le);e:for(;0<te;){var K=te-1>>>1,me=Q[K];if(0<a(me,le))Q[K]=le,Q[te]=me,te=K;else break e}}function l(Q){return Q.length===0?null:Q[0]}function s(Q){if(Q.length===0)return null;var le=Q[0],te=Q.pop();if(te!==le){Q[0]=te;e:for(var K=0,me=Q.length,Fe=me>>>1;K<Fe;){var Ie=2*(K+1)-1,pt=Q[Ie],Ze=Ie+1,Be=Q[Ze];if(0>a(pt,te))Ze<me&&0>a(Be,pt)?(Q[K]=Be,Q[Ze]=te,K=Ze):(Q[K]=pt,Q[Ie]=te,K=Ie);else if(Ze<me&&0>a(Be,te))Q[K]=Be,Q[Ze]=te,K=Ze;else break e}}return le}function a(Q,le){var te=Q.sortIndex-le.sortIndex;return te!==0?te:Q.id-le.id}function u(Q){for(var le=l(k);le!==null;){if(le.callback===null)s(k);else if(le.startTime<=Q)s(k),le.sortIndex=le.expirationTime,i(S,le);else break;le=l(k)}}function f(Q){if(q=!1,u(Q),!U)if(l(S)!==null)U=!0,he||(he=!0,X());else{var le=l(k);le!==null&&p(f,le.startTime-Q)}}function h(){return j?!0:kN.unstable_now()-ce<_?!1:!0}function p(Q,le){Je=P(function(){Q(kN.unstable_now())},le)}if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error()),kN.unstable_now=void 0,typeof performance==="object"&&typeof performance.now==="function"){var g=performance;kN.unstable_now=function(){return g.now()}}else{var b=Date,v=b.now();kN.unstable_now=function(){return b.now()-v}}var S=[],k=[],A=1,C=null,R=3,B=!1,U=!1,q=!1,j=!1,P=typeof setTimeout==="function"?setTimeout:null,ee=typeof clearTimeout==="function"?clearTimeout:null,Ae=typeof setImmediate<"u"?setImmediate:null,he=!1,Je=-1,_=5,ce=-1;if(typeof Ae==="function")var X=function(){Ae(t)};else if(typeof MessageChannel<"u"){var ge=new MessageChannel,ot=ge.port2;ge.port1.onmessage=t,X=function(){ot.postMessage(null)}}else X=function(){P(t,0)};kN.unstable_IdlePriority=5,kN.unstable_ImmediatePriority=1,kN.unstable_LowPriority=4,kN.unstable_NormalPriority=3,kN.unstable_Profiling=null,kN.unstable_UserBlockingPriority=2,kN.unstable_cancelCallback=function(Q){Q.callback=null},kN.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<Q?Math.floor(1000/Q):5},kN.unstable_getCurrentPriorityLevel=function(){return R},kN.unstable_next=function(Q){switch(R){case 1:case 2:case 3:var le=3;break;default:le=R}var te=R;R=le;try{return Q()}finally{R=te}},kN.unstable_requestPaint=function(){j=!0},kN.unstable_runWithPriority=function(Q,le){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var te=R;R=Q;try{return le()}finally{R=te}},kN.unstable_scheduleCallback=function(Q,le,te){var K=kN.unstable_now();switch(typeof te==="object"&&te!==null?(te=te.delay,te=typeof te==="number"&&0<te?K+te:K):te=K,Q){case 1:var me=-1;break;case 2:me=250;break;case 5:me=1073741823;break;case 4:me=1e4;break;default:me=5000}return me=te+me,Q={id:A++,callback:le,priorityLevel:Q,startTime:te,expirationTime:me,sortIndex:-1},te>K?(Q.sortIndex=te,i(k,Q),l(S)===null&&Q===l(k)&&(q?(ee(Je),Je=-1):q=!0,p(f,te-K))):(Q.sortIndex=me,i(S,Q),U||B||(U=!0,he||(he=!0,X()))),Q},kN.unstable_shouldYield=h,kN.unstable_wrapCallback=function(Q){var le=R;return function(){var te=R;R=le;try{return Q.apply(this,arguments)}finally{R=te}}},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var dT=Sv(function(AN){var Ye=se(fT()),Uu=se(ln()),wv=se(CN());(function(){function t(e,n){for(e=e.memoizedState;e!==null&&0<n;)e=e.next,n--;return e}function i(e,n,o,r){if(o>=n.length)return r;var c=n[o],d=sn(e)?e.slice():Ne({},e);return d[c]=i(e[c],n,o+1,r),d}function l(e,n,o){if(n.length!==o.length)console.warn("copyWithRename() expects paths of the same length");else{for(var r=0;r<o.length-1;r++)if(n[r]!==o[r]){console.warn("copyWithRename() expects paths to be the same except for the deepest key");return}return s(e,n,o,0)}}function s(e,n,o,r){var c=n[r],d=sn(e)?e.slice():Ne({},e);return r+1===n.length?(d[o[r]]=d[c],sn(d)?d.splice(c,1):delete d[c]):d[c]=s(e[c],n,o,r+1),d}function a(e,n,o){var r=n[o],c=sn(e)?e.slice():Ne({},e);if(o+1===n.length)return sn(c)?c.splice(r,1):delete c[r],c;return c[r]=a(e[r],n,o+1),c}function u(){return!1}function f(){return null}function h(){console.error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://react.dev/link/rules-of-hooks")}function p(){console.error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().")}function g(){}function b(){}function v(e){var n=[];return e.forEach(function(o){n.push(o)}),n.sort().join(", ")}function S(e,n,o,r){return new dB(e,n,o,r)}function k(e,n){e.context===Ls&&(I0(e.current,2,n,e,null,null),Xa())}function A(e,n){if(Pi!==null){var o=n.staleFamilies;n=n.updatedFamilies,Wc(),yw(e.current,n,o),Xa()}}function C(e){Pi=e}function R(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function B(e){var n=e,o=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(o=n.return),e=n.return;while(e)}return n.tag===3?o:null}function U(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function q(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function j(e){if(B(e)!==e)throw Error("Unable to find node on an unmounted component.")}function P(e){var n=e.alternate;if(!n){if(n=B(e),n===null)throw Error("Unable to find node on an unmounted component.");return n!==e?null:e}for(var o=e,r=n;;){var c=o.return;if(c===null)break;var d=c.alternate;if(d===null){if(r=c.return,r!==null){o=r;continue}break}if(c.child===d.child){for(d=c.child;d;){if(d===o)return j(c),e;if(d===r)return j(c),n;d=d.sibling}throw Error("Unable to find node on an unmounted component.")}if(o.return!==r.return)o=c,r=d;else{for(var m=!1,y=c.child;y;){if(y===o){m=!0,o=c,r=d;break}if(y===r){m=!0,r=c,o=d;break}y=y.sibling}if(!m){for(y=d.child;y;){if(y===o){m=!0,o=d,r=c;break}if(y===r){m=!0,r=d,o=c;break}y=y.sibling}if(!m)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(o.alternate!==r)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(o.tag!==3)throw Error("Unable to find node on an unmounted component.");return o.stateNode.current===o?e:n}function ee(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=ee(e),n!==null)return n;e=e.sibling}return null}function Ae(e){if(e===null||typeof e!=="object")return null;return e=CC&&e[CC]||e["@@iterator"],typeof e==="function"?e:null}function he(e){if(e==null)return null;if(typeof e==="function")return e.$$typeof===Bz?null:e.displayName||e.name||null;if(typeof e==="string")return e;switch(e){case tu:return"Fragment";case Q0:return"Profiler";case sp:return"StrictMode";case X0:return"Suspense";case W0:return"SuspenseList";case F0:return"Activity"}if(typeof e==="object")switch(typeof e.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case eu:return"Portal";case sl:return e.displayName||"Context";case Y0:return(e._context.displayName||"Context")+".Consumer";case sf:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case rp:return n=e.displayName||null,n!==null?n:he(e.type)||"Memo";case Ci:n=e._payload,e=e._init;try{return he(e(n))}catch(o){}}return null}function Je(e){return typeof e.tag==="number"?_(e):typeof e.name==="string"?e.name:null}function _(e){var n=e.type;switch(e.tag){case 31:return"Activity";case 24:return"Cache";case 9:return(n._context.displayName||"Context")+".Consumer";case 10:return n.displayName||"Context";case 18:return"DehydratedFragment";case 11:return e=n.render,e=e.displayName||e.name||"",n.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 26:case 27:case 5:return n;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(n);case 8:return n===sp?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 14:case 15:if(typeof n==="function")return n.displayName||n.name||null;if(typeof n==="string")return n;break;case 29:if(n=e._debugInfo,n!=null){for(var o=n.length-1;0<=o;o--)if(typeof n[o].name==="string")return n[o].name}if(e.return!==null)return _(e.return)}return null}function ce(e){return{current:e}}function X(e,n){0>Ll?console.error("Unexpected pop."):(n!==J0[Ll]&&console.error("Unexpected Fiber popped."),e.current=K0[Ll],K0[Ll]=null,J0[Ll]=null,Ll--)}function ge(e,n,o){Ll++,K0[Ll]=e.current,J0[Ll]=o,e.current=n}function ot(e){return e===null&&console.error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue."),e}function Q(e,n){ge(Es,n,e),ge(rf,e,e),ge(As,null,e);var o=n.nodeType;switch(o){case 9:case 11:o=o===9?"#document":"#fragment",n=(n=n.documentElement)?(n=n.namespaceURI)?Xk(n):Ql:Ql;break;default:if(o=n.tagName,n=n.namespaceURI)n=Xk(n),n=Wk(n,o);else switch(o){case"svg":n=Nu;break;case"math":n=lm;break;default:n=Ql}}o=o.toLowerCase(),o=P1(null,o),o={context:n,ancestorInfo:o},X(As,e),ge(As,o,e)}function le(e){X(As,e),X(rf,e),X(Es,e)}function te(){return ot(As.current)}function K(e){e.memoizedState!==null&&ge(ap,e,e);var n=ot(As.current),o=e.type,r=Wk(n.context,o);o=P1(n.ancestorInfo,o),r={context:r,ancestorInfo:o},n!==r&&(ge(rf,e,e),ge(As,r,e))}function me(e){rf.current===e&&(X(As,e),X(rf,e)),ap.current===e&&(X(ap,e),Jf._currentValue=aa)}function Fe(){}function Ie(){if(af===0){AC=console.log,EC=console.info,TC=console.warn,DC=console.error,RC=console.group,OC=console.groupCollapsed,MC=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Fe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}af++}function pt(){if(af--,af===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ne({},e,{value:AC}),info:Ne({},e,{value:EC}),warn:Ne({},e,{value:TC}),error:Ne({},e,{value:DC}),group:Ne({},e,{value:RC}),groupCollapsed:Ne({},e,{value:OC}),groupEnd:Ne({},e,{value:MC})})}0>af&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function Ze(e){var n=Error.prepareStackTrace;if(Error.prepareStackTrace=void 0,e=e.stack,Error.prepareStackTrace=n,e.startsWith(`Error: react-stack-top-frame
2
2
  `)&&(e=e.slice(29)),n=e.indexOf(`
3
3
  `),n!==-1&&(e=e.slice(n+1)),n=e.indexOf("react_stack_bottom_frame"),n!==-1&&(n=e.lastIndexOf(`
4
4
  `,n)),n!==-1)e=e.slice(0,n);else return"";return e}function Be(e){if(Z0===void 0)try{throw Error()}catch(o){var n=o.stack.trim().match(/\n( *(at )?)/);Z0=n&&n[1]||"",LC=-1<o.stack.indexOf(`
@@ -242,6 +242,6 @@ You might need to use a local HTTP server (instead of file://): https://react.de
242
242
 
243
243
  [Open the Inbox item](${i.backlink})`;return{draft:l,body:i.body?`${i.body}
244
244
 
245
- ${s}`:s}}function h5(){let t=window.history.state;return td(t)?t:{}}function wL(t){let{api:i,queryClient:l,history:s,studioBasePath:a,routeTarget:u,routePathname:f,routeSearch:h,currentStudioPathname:p,createMode:g,entityType:b,collectionType:v,activeType:S,entityCollectionQuery:k,preferredMobilePane:A,dispatchEditor:C,setMobilePane:R,setBodyMode:B,setFieldAssistState:U}=t,q=S?.capabilities.canCreate===!0,j=S?.hierarchy.nested!==!1,[P,ee]=mi.useState(null),[Ae,he]=mi.useState(0),Je=mi.useRef(null),_=mi.useRef(0),ce=mi.useRef(b);ce.current=b,mi.useEffect(()=>{if(u.kind==="grouping"){C({type:"collectionChanged"});return}if(!b||u.kind==="workspace"||u.kind==="not-found")return;let le=u.kind==="entity"&&u.entityType===b?u.id:null,te=++_.current;C({type:"collectionChanged"}),R("details"),U({kind:"idle"});let K=!0,me=()=>K&&te===_.current;return l.fetchQuery({...Mg(i,b),staleTime:0}).then(async(Fe)=>{if(!K||te!==_.current)return;let Ie=FM(Fe,A.current);if(R(Ie),window.matchMedia("(max-width: 640px)").matches&&Ie!=="details")B(Ie==="write"?"source":"preview");if(g&&le===null){if(!q){ee(`Creating ${b} is not allowed.`);return}let pt=vL(window.history.state,b,()=>window.history.replaceState(bL(h5()),"",window.location.href)),Ze=SL(Fe.fields,pt);C({type:"creationStarted",draft:Ze.draft,body:Ze.body,...Fe.isSingleton&&{singleton:!0},...pt&&{prefilled:!0},...!pt&&!Fe.isSingleton&&{prefix:j?mc(h).prefix:null}});return}if(le!==null)return l.fetchQuery({...gc(i,b,le),staleTime:0}).then((pt)=>{if(!K||te!==_.current)return;let Ze=hc(pt),Be=Je.current,fn=Aa(a,b,le),ni=Be?.pathname===fn?Be.save:{kind:"idle"};if(Be?.pathname===fn)Je.current=null;C({type:"documentOpened",document:Ze,save:ni})});if(Fe.isSingleton){let pt=await l.ensureQueryData(Lg(i,b,mc("?scope=collection")));if(!me())return;let Ze=pt.entities[0];if(Ze)return l.fetchQuery({...gc(i,b,Ze.id),staleTime:0}).then((Be)=>{if(!K||te!==_.current)return;let fn=hc(Be);C({type:"documentOpened",document:fn})});C({type:"creationStarted",singleton:!0,draft:Hg(Fe.fields)})}return}).catch((Fe)=>{if(K&&te===_.current)ee(br(Fe))}),()=>{K=!1}},[g,p,b,Ae,l,f,h,u,q,j]);let X=mi.useCallback((le,te={kind:"idle"},K=b)=>{if(!K||!b)return;let me=Aa(a,K,le);if(!(K===b&&u.kind==="entity"&&u.entityType===b&&u.id===le)){Je.current={pathname:me,save:te};let Ze=`${ei(a,v??b)}${ti(k)}`,Be=g&&te.kind==="saved",fn=s.location.state,ni=!Be||td(fn)&&fn.studioCollectionPath===Ze;s[Be?"replace":"push"](`${me}${ti(k)}`,ni?{studioCollectionPath:Ze}:void 0,te.kind==="saved"?{ignoreBlocker:!0}:void 0);return}let Ie=++_.current,pt=b;l.fetchQuery({...gc(i,b,le),staleTime:0}).then((Ze)=>{if(Ie!==_.current||ce.current!==pt)return;let Be=hc(Ze);C({type:"documentOpened",document:Be,save:te}),U({kind:"idle"})}).catch((Ze)=>{if(Ie===_.current)ee(br(Ze))})},[a,p,u,g,b,v,k,l,s]),ge=mi.useCallback(()=>{he((le)=>le+1)},[]),ot=mi.useCallback(()=>{_.current+=1},[]),Q=mi.useCallback(()=>_.current,[]);return{openEntity:X,loadError:P,setLoadError:ee,retryOpen:ge,supersedeOpen:ot,currentOpenRequest:Q,pendingOpenState:Je}}var _o=se(ln(),1);function xL(t){let{api:i,queryClient:l,history:s,studioBasePath:a,entityType:u,collectionType:f,entityCollectionQuery:h,groupReturnPath:p,activeCapabilities:g,schema:b,editor:v,dispatchEditor:S,createPath:k,syncStatus:A,deleting:C,saveEntityMutation:R,deleteEntityMutation:B,openEntity:U,currentOpenRequest:q,setMobilePane:j,setFieldAssistState:P}=t,{mode:ee,draft:Ae,body:he,save:Je}=v,[_,ce]=_o.useState(null),X=_o.useRef(0);_o.useEffect(()=>{if(Je.kind!=="saved"||!A?.git)return;if(bm({save:Je,git:A.git,baselineCommit:_}).committed==="done")return;if(Date.now()-X.current>20000)return;let K=window.setTimeout(()=>{l.invalidateQueries({queryKey:Ui.syncStatus()})},900);return()=>window.clearTimeout(K)},[Je,A,_,l]);let ge=_o.useCallback((te,K)=>{if(!u||ee.kind!=="edit"||g?.canUpdate!==!0||g.canAssist!==!0||he.trim().length===0)return;P({kind:"loading",field:K,variant:te}),i.requestFieldAssist({variant:te,entityType:u,id:ee.entity.id,targetField:K}).then((me)=>{let Fe=me.variant==="summarize"?me.suggestion:me.suggestions;P({kind:"suggested",field:me.targetField,variant:me.variant,suggestion:Fe})}).catch((me)=>{P({kind:"error",field:K,message:Ni(me)})})},[g,he,u,ee]),ot=_o.useCallback((te,K)=>{S({type:"fieldAssistApplied",field:te,suggestion:K}),P({kind:"idle"})},[]),Q=_o.useCallback(()=>{if(!u||ee.kind==="browse"||!b||u===rs&&!b.groupingDefinitions||Vd(v)||(ee.kind==="create"&&b.isSingleton||u===rs)&&!dg(v))return;if(ee.kind==="create"?g?.canCreate!==!0:g?.canUpdate!==!0)return;X.current=Date.now(),ce(A?.git?.lastCommit??null),S({type:"saveStarted"});let te=b.hasBody?{body:he}:{},K=Bg(b.fields,Ae),me=ee.kind==="create"?{kind:"create",entityType:u,...k&&{idPath:k},frontmatter:K,...te}:{kind:"update",entityType:u,id:ee.entity.id,frontmatter:K,baseContentHash:ee.entity.contentHash,...te},Fe=q();R.mutate(me,{onSuccess:async(Ie)=>{if(await Promise.all([l.invalidateQueries({queryKey:["studio","groupings"]}),l.invalidateQueries({queryKey:Ui.entities(u)}),...f&&f!==u?[l.invalidateQueries({queryKey:Ui.entities(f)})]:[],l.invalidateQueries({queryKey:Ui.syncStatus()}),...u===rs?[l.invalidateQueries({queryKey:["studio","schema"]})]:[],...ee.kind==="create"||u===rs?[l.invalidateQueries({queryKey:Ui.navigation()})]:[]]),Fe!==q())return;let pt="skipped"in Ie&&Ie.skipped===!0;U(Ie.entityId,{kind:"saved",noop:pt})},onError:(Ie)=>{if(Fe!==q())return;if(Ie instanceof Ao&&(Ie.status===400||Ie.status===409))Promise.all([l.invalidateQueries({queryKey:Ui.navigation()}),l.invalidateQueries({queryKey:["studio","schema"]}),l.invalidateQueries({queryKey:["studio","groupings"]})]);if(Ie instanceof Ao&&Ie.issues.length>0)j("details");S({type:"saveFailed",save:Ie instanceof Ao&&Ie.status===409&&ee.kind==="edit"?{kind:"conflict",message:Ni(Ie)}:{kind:"error",message:Ie instanceof Ao&&Ie.issues.length>0?Ie.message||"Validation failed":Ni(Ie),...Ie instanceof Ao?{issues:Ie.issues}:{}}})}})},[g,u,f,ee,k,v,Ae,he,b,U,A,l,R]),le=_o.useCallback(()=>{if(!u||ee.kind!=="edit"||C||g?.canDelete!==!0)return;let{id:te}=ee.entity;B.mutate({entityType:u,id:te},{onSuccess:async()=>{S({type:"deleteSucceeded"}),l.removeQueries({queryKey:Ui.entity(u,te)}),await Promise.all([l.invalidateQueries({queryKey:["studio","groupings"]}),l.invalidateQueries({queryKey:Ui.entityLists()}),l.invalidateQueries({queryKey:Ui.syncStatus()}),l.invalidateQueries({queryKey:Ui.navigation()})]),s.replace(p??`${ei(a,f??u)}${ti(h)}`,void 0,{ignoreBlocker:!0})},onError:(K)=>{S({type:"deleteFailed",message:Ni(K)})}})},[g,a,u,f,ee,C,l,B,s,p,h]);return{runFieldAssist:ge,applyFieldAssist:ot,save:Q,remove:le,baselineCommit:_}}var Qd=se(ln(),1);function AL(t){let{history:i,queryClient:l,studioBasePath:s,routeTarget:a,routePathname:u,routeSearch:f,entityType:h,activeWorkspaceId:p,types:g,groupings:b,workspaces:v,activeType:S,activeWorkspace:k,entityCollectionQuery:A,entityListOffset:C,entityListTotal:R,declarativeWorkspaceData:B,initialUrlWorkspaceQuery:U,setActiveWorkspaceId:q,setEntityType:j,setLoadError:P,supersedeOpen:ee}=t;Qd.useEffect(()=>{if(!h||!S||p||a.kind!=="collection"&&a.kind!=="entity"||a.entityType!==h)return;if(R===void 0)return;let Ae=Math.floor(Math.max(0,R-1)/A.limit)*A.limit;if(C>Ae)i.replace(`${u}${ti({...A,offset:Ae})}`,i.location.state)},[S,p,C,R,A,h,u,a,i]),Qd.useEffect(()=>{if(!p||!B?.refreshAfterMs)return;let Ae=window.setTimeout(()=>{l.invalidateQueries({queryKey:Ui.workspace(p)})},B.refreshAfterMs);return()=>window.clearTimeout(Ae)},[p,B,l]),Qd.useEffect(()=>{if(k?.urlQuery!==!0||a.kind!=="workspace"||a.workspaceId!==k.id)return;let Ae=Zn(s,k.id);if(Ca(Ae,U)!==`${Ae}${f}`)Dg(i,Ae,U,window.location.pathname)},[k,s,U,f,a,i]),Qd.useEffect(()=>{if(!g)return;if(P(null),a.kind==="not-found"){ee(),P(`Studio route not found: ${a.pathname}`);return}if(a.kind==="grouping"){if(ee(),q(null),j(null),!b.some((_)=>_.key===a.grouping))P("Collection unavailable for this account.");return}if(a.kind==="workspace"){let _=v.find((ce)=>ce.id===a.workspaceId);if(!_){let ce=kL(s,a.workspaceId,f,v);if(ce){i.replace(ce);return}ee(),P(`Workspace unavailable for this account: ${a.workspaceId}`);return}q(_.id),j(null);return}let Ae=a.kind==="collection"||a.kind==="entity"?a.entityType:void 0,he=g.find((_)=>!_.isSingleton)??g[0];if(a.kind==="home"){let _=CL(s,g,v);if(_!==s){i.replace(_);return}}let Je=Ae??he?.entityType??null;if(Ae!==void 0&&!g.some((_)=>_.entityType===Ae)){ee(),P(`Collection unavailable for this account: ${Ae}`);return}q(null),j(Je)},[f,a,i,s,g,b,v])}var O1=se(ln(),1);function TL(t){let{queryClient:i,workspaces:l,activeWorkspaceId:s,entityType:a,mode:u,declarativeWorkspaceActionMutation:f,openEntity:h}=t,p=O1.useCallback(async(b)=>{let v=EL(l,b.entityType);if(!v)throw Error("Publishing is unavailable");let S={entityType:b.entityType,entityId:b.entityId,...b.type==="reorder"?{position:b.position}:{}};if(b.type==="publish"&&!b.confirmation){let C=await f.mutateAsync({workspaceId:v.id,action:{actionId:"publish",label:"Publish now",input:S,invocation:{mode:"prepare"}}});if(typeof C!=="object"||C===null||!("kind"in C)||C.kind!=="prepared-confirmation"||!("token"in C)||typeof C.token!=="string"||!("summary"in C)||typeof C.summary!=="string"||!("expiresAt"in C)||typeof C.expiresAt!=="string")throw Error("Publishing confirmation is unavailable");return{needsConfirmation:!0,summary:C.summary,args:{confirmed:!0,confirmationToken:C.token,contentHash:C.token,expiresAt:C.expiresAt}}}let k=await f.mutateAsync({workspaceId:v.id,action:{actionId:b.type,label:b.type,input:S,...b.type==="publish"&&b.confirmation?{invocation:{mode:"execute",token:b.confirmation.confirmationToken}}:{}}});if(typeof k!=="object"||k===null)throw Error("Publishing returned an invalid result");let A="success"in k&&k.success===!1?{success:!1,error:"error"in k&&typeof k.error==="string"?k.error:"Publishing failed",..."code"in k&&typeof k.code==="string"?{code:k.code}:{}}:{success:!0};if(!g1(A)&&!y1(A)){if(await R1(i,v.id),u.kind==="edit"&&a===b.entityType&&u.entity.id===b.entityId)h(b.entityId)}return A},[a,u,h,i,f,l]),g=O1.useCallback(async(b)=>{if(!s)throw Error("Declarative workspace is unavailable");try{let v=await f.mutateAsync({workspaceId:s,action:b});return await R1(i,s),v}finally{f.reset()}},[s,f,i]);return{performPublishingAction:p,performDeclarativeAction:g}}var Wt=se(Ue(),1),p5=ut.lazy(()=>Ev(async()=>({default:(await import("./studio-chunks/account-view-8z403hx4.js")).AccountApp}))),m5=ut.lazy(()=>Ev(async()=>({default:(await import("./studio-chunks/studio-chat-workspace-5h9qka59.js")).StudioChatWorkspace}),()=>Wt.jsxDEV(ka,{message:"Chat could not open.",children:Wt.jsxDEV(Av,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)));function g5(t){let i=new URLSearchParams(t).get("session")?.trim();return i&&i.length<=256?i:null}var y5=["public","trusted","admin"];function b5(t,i,l){let s=document.querySelector("[data-studio-root]"),a=s?.getAttribute("data-studio-principal-name")??"Your account",u=s?.getAttribute("data-studio-principal-role"),f=y5.find((g)=>g===u)??"public",h=s?.getAttribute("data-studio-mcp-url")??void 0,p=new URLSearchParams(l).get("section")??void 0;return{displayName:a,role:f,routePath:t,studioPath:i,...h?{mcpUrl:h}:{},...p?{initialSection:p}:{}}}function NL(){let t=OL(),i=Ug({select:(Te)=>Te.location.pathname}),l=Ug({select:(Te)=>Te.location.searchStr}),s=Ug({select:(Te)=>Te.location.state}),a=zL(),u=ut.useMemo(()=>i===M1?{kind:"workspace",workspaceId:Ng}:mm(i,a),[i,a]),f=ut.useMemo(()=>u.kind==="collection"&&new URLSearchParams(l).get("mode")==="create",[l,u]),h=i,[p,g]=ut.useState(null),[b,v]=ut.useState(null),[S,k]=ut.useState({}),[A,C]=ut.useReducer(oM,Id),{mode:R}=A,B=dg(A),[U]=ut.useState(()=>new BL),q=ut.useSyncExternalStore(U.subscribe,U.hasDrafts,U.hasDrafts),[j,P]=ut.useState({hasDraft:!1,busy:!1}),ee=ML({shouldBlockFn:({next:Te})=>B||i===M1&&LL({...j,hasDraft:q},Te.pathname),enableBeforeUnload:B||q||j.busy,withResolver:!0}),[Ae,he]=ut.useState({kind:"idle"}),[Je,_]=ut.useState("preview"),ce=A.mode.kind==="create";ut.useEffect(()=>{if(ce)_("source")},[ce]);let[X,ge]=ut.useState("details"),ot=ut.useRef(null),Q=ut.useCallback((Te)=>{ot.current=Te,ge(Te)},[]),le=RL(),te=Ji(),{navigationQuery:K,types:me,groupings:Fe,activeType:Ie,collectionType:pt,activeCapabilities:Ze,entityCollectionQuery:Be,entityListOffset:fn,workspaces:ni,activeWorkspace:qo,activeAccount:vr,activeChat:us,initialUrlWorkspaceQuery:yc,workspaceRequestQuery:ie,workspaceQuery:Tn,workspaceData:Ea,workspaceError:Sr,agentTargets:wr,syncStatus:ct,entityListQuery:ao,entities:bc,entityListTotal:Yd,schema:lt,createPath:Ig,destinationQuery:uo,saveEntityMutation:Ta,deleteEntityMutation:xr,declarativeWorkspaceActionMutation:Vg,deleting:Da,declarativeWorkspaceData:Ra}=hL({api:te,entityType:b,activeWorkspaceId:p,routeSearch:l,workspaceQueries:S,editor:A}),_i=u.kind==="grouping"?Fe.find((Te)=>Te.key===u.grouping):void 0,Oa=ut.useMemo(()=>kv(l),[l]),Ma=u.kind==="entity"?ST(s,a,Fe):null,vc=Ma?.path,Xd=ut.useMemo(()=>b?Fe.filter((Te)=>Te.types.includes(b)):[],[Fe,b]),Sc=tL(Xd),{openEntity:La,loadError:Wd,setLoadError:Ba,retryOpen:Fd,supersedeOpen:Kd,currentOpenRequest:wc,pendingOpenState:kl}=wL({api:te,queryClient:le,history:t.history,studioBasePath:a,routeTarget:u,routePathname:i,routeSearch:l,currentStudioPathname:h,createMode:f,entityType:b,collectionType:pt,activeType:Ie,entityCollectionQuery:Be,preferredMobilePane:ot,dispatchEditor:C,setMobilePane:ge,setBodyMode:_,setFieldAssistState:he});AL({history:t.history,queryClient:le,studioBasePath:a,routeTarget:u,routePathname:i,routeSearch:l,entityType:b,activeWorkspaceId:p,types:me,groupings:Fe,workspaces:ni,activeType:Ie,activeWorkspace:qo,entityCollectionQuery:Be,entityListOffset:fn,entityListTotal:Yd,declarativeWorkspaceData:Ra,initialUrlWorkspaceQuery:yc,setActiveWorkspaceId:g,setEntityType:v,setLoadError:Ba,supersedeOpen:Kd});let{openWorkspaceEntity:Io,openWorkspaceLaunch:kr,selectEntityType:Vo,changeEntityPage:Ft,selectWorkspace:co,selectFolder:cs,startCreate:fs,backToList:xc,changeWorkspaceQuery:Jd}=yL({history:t.history,studioBasePath:a,routeSearch:l,entityType:b,collectionType:pt,entityCollectionQuery:Be,groupReturnPath:vc,workspaces:ni,schema:lt,activeCapabilities:Ze,pendingOpenState:kl,setFieldAssistState:he,setWorkspaceQueries:k}),{runFieldAssist:za,applyFieldAssist:Na,save:fo,remove:ii,baselineCommit:Zd}=xL({api:te,queryClient:le,history:t.history,studioBasePath:a,entityType:b,collectionType:pt,entityCollectionQuery:Be,groupReturnPath:vc,activeCapabilities:Ze,schema:lt,editor:A,dispatchEditor:C,createPath:Ig,syncStatus:ct,deleting:Da,saveEntityMutation:Ta,deleteEntityMutation:xr,openEntity:La,currentOpenRequest:wc,setMobilePane:ge,setFieldAssistState:he}),{performPublishingAction:Pg,performDeclarativeAction:kc}=TL({queryClient:le,workspaces:ni,activeWorkspaceId:p,entityType:b,mode:R,declarativeWorkspaceActionMutation:Vg,openEntity:La}),ho=Wd??(K.error?br(K.error):ao.error?br(ao.error):null),Cr=()=>{if(Ba(null),K.error)K.refetch();if(ao.error)ao.refetch();if(Tn.error)Tn.refetch();if(R.kind==="browse")Fd()};if(ho&&!me)return Wt.jsxDEV(ka,{message:ho,error:!0,onRetry:Cr},void 0,!1,void 0,this);if(!me)return Wt.jsxDEV(ka,{message:"Loading…"},void 0,!1,void 0,this);if(vr&&qo){let Te=Zn(a,zg);return Wt.jsxDEV(KM,{types:me,workspaces:ni,workspaceId:qo.id,selectEntityType:Vo,selectWorkspace:co,children:Wt.jsxDEV(ut.Suspense,{fallback:Wt.jsxDEV(ke,{children:"Opening Account…"},void 0,!1,void 0,this),children:Wt.jsxDEV(p5,{bootstrap:b5(Te,a,l)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(us&&qo)return Wt.jsxDEV(Wt.Fragment,{children:[Wt.jsxDEV(ut.Suspense,{fallback:Wt.jsxDEV(ka,{message:"Opening Chat…"},void 0,!1,void 0,this),children:Wt.jsxDEV(m5,{apiPath:qo.chatApiPath,draftStore:U,onNavigationStateChange:P,studioBasePath:a,sessionId:g5(l),types:me,workspaces:ni,handoff:eL(s),navigate:(Te,Po)=>{t.history.push(Te,void 0,{ignoreBlocker:Po?.preserveWork===!0})},selectEntityType:Vo,selectWorkspace:co},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.status==="blocked"&&Wt.jsxDEV(Mn,{mark:"↩",title:"Leave this conversation?",titleId:"chat-navigation-title",cancelLabel:"Stay",confirmLabel:"Leave",onCancel:()=>ee.reset(),onConfirm:()=>ee.proceed(),children:Wt.jsxDEV("p",{children:"Your draft stays in this tab. Leaving stops receiving the response, but does not undo completed actions or background jobs."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(p?!Ea&&!Sr:b&&!lt&&!ho)return Wt.jsxDEV(ka,{message:"Loading…"},void 0,!1,void 0,this);if(!_i&&!p&&(!b||!lt&&!ho))return Wt.jsxDEV(ka,{message:ho??"No readable collections are available for this account.",error:Boolean(ho),...ho?{onHome:()=>t.history.push(a)}:{}},void 0,!1,void 0,this);return Wt.jsxDEV(JM,{groupings:{items:Fe,active:_i?.key??Ma?.grouping??null,onSelect:(Te)=>t.history.push(Iu(a,Te))},groupReturnLabel:Ma?.label,groupingSuggestions:Sc,groupingView:_i?Wt.jsxDEV(AT,{basePath:a,grouping:_i,types:me,query:Oa,onChange:(Te,Po)=>{let ds=`${Iu(a,_i.key)}${qu(Te)}`,eh=Te.value!==Oa.value||Te.offset!==Oa.offset;t.history[eh&&Po?.replace!==!0?"push":"replace"](ds)},onOpen:(Te,Po)=>{let ds=Aa(a,Te,Po);kl.current={pathname:ds,save:{kind:"idle"}},t.history.push(ds,{studioGroupingPath:`${Iu(a,_i.key)}${qu(Oa)}`})}},void 0,!1,void 0,this):null,activeWorkspaceId:p,types:me,workspaces:ni,workspaceError:Sr,readError:ho,onRetryRead:Cr,declarativeWorkspaceData:Ra,workspaceQuery:ie,entityType:b,entities:bc,folders:ao.data?.folders??[],collectionTrail:ao.data?.trail,collectionPath:pt?ei(a,pt):a,selectFolder:cs,creationDestination:{data:uo.data??null,pending:uo.isPending,error:uo.error},entityOffset:fn,entityLimit:Be.limit,entityTotal:Yd??0,collectionQuery:Be,onCollectionQueryChange:(Te)=>{if(!pt)return;t.history.push(`${ei(a,pt)}${ti({...Te,offset:0})}`),window.scrollTo({top:0,left:0})},entityListLoading:ao.isPending,schema:lt,editor:A,fieldAssistState:Ae,bodyMode:Je,mobilePane:X,syncStatus:ct,baselineCommit:Zd,agentTargets:wr,deleting:Da,hasUnsavedChanges:B,navigationBlocked:ee.status==="blocked",dispatchEditor:C,setFieldAssistState:he,setBodyMode:_,setMobilePane:Q,backToList:xc,selectEntityType:Vo,selectWorkspace:co,changeEntityPage:Ft,openWorkspaceEntity:Io,openWorkspaceLaunch:kr,performPublishingAction:Pg,performDeclarativeAction:kc,onWorkspaceQueryChange:Jd,startCreate:fs,openEntity:(Te,Po)=>La(Te,void 0,Po),runFieldAssist:za,applyFieldAssist:Na,save:fo,remove:ii,onNavigationReset:()=>ee.reset?.(),onNavigationProceed:()=>ee.proceed?.()},void 0,!1,void 0,this)}function UL(){return new HL({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1},mutations:{retry:!1}}})}var qg=se(Ue(),1),_g=document.querySelector("[data-studio-root]");if(_g){let t=_g.getAttribute("data-studio-base-path")??"/studio",i=new IL({basePath:t});_g.textContent="";let l=UL(),s=PL(t,NL);jL.createRoot(_g).render(qg.jsxDEV(_L,{client:l,children:qg.jsxDEV(VL,{api:i,children:qg.jsxDEV(qL,{router:s},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this))}
245
+ ${s}`:s}}function h5(){let t=window.history.state;return td(t)?t:{}}function wL(t){let{api:i,queryClient:l,history:s,studioBasePath:a,routeTarget:u,routePathname:f,routeSearch:h,currentStudioPathname:p,createMode:g,entityType:b,collectionType:v,activeType:S,entityCollectionQuery:k,preferredMobilePane:A,dispatchEditor:C,setMobilePane:R,setBodyMode:B,setFieldAssistState:U}=t,q=S?.capabilities.canCreate===!0,j=S?.hierarchy.nested!==!1,[P,ee]=mi.useState(null),[Ae,he]=mi.useState(0),Je=mi.useRef(null),_=mi.useRef(0),ce=mi.useRef(b);ce.current=b,mi.useEffect(()=>{if(u.kind==="grouping"){C({type:"collectionChanged"});return}if(!b||u.kind==="workspace"||u.kind==="not-found")return;let le=u.kind==="entity"&&u.entityType===b?u.id:null,te=++_.current;C({type:"collectionChanged"}),R("details"),U({kind:"idle"});let K=!0,me=()=>K&&te===_.current;return l.fetchQuery({...Mg(i,b),staleTime:0}).then(async(Fe)=>{if(!K||te!==_.current)return;let Ie=FM(Fe,A.current);if(R(Ie),window.matchMedia("(max-width: 640px)").matches&&Ie!=="details")B(Ie==="write"?"source":"preview");if(g&&le===null){if(!q){ee(`Creating ${b} is not allowed.`);return}let pt=vL(window.history.state,b,()=>window.history.replaceState(bL(h5()),"",window.location.href)),Ze=SL(Fe.fields,pt);C({type:"creationStarted",draft:Ze.draft,body:Ze.body,...Fe.isSingleton&&{singleton:!0},...pt&&{prefilled:!0},...!pt&&!Fe.isSingleton&&{prefix:j?mc(h).prefix:null}});return}if(le!==null)return l.fetchQuery({...gc(i,b,le),staleTime:0}).then((pt)=>{if(!K||te!==_.current)return;let Ze=hc(pt),Be=Je.current,fn=Aa(a,b,le),ni=Be?.pathname===fn?Be.save:{kind:"idle"};if(Be?.pathname===fn)Je.current=null;C({type:"documentOpened",document:Ze,save:ni})});if(Fe.isSingleton){let pt=await l.ensureQueryData(Lg(i,b,mc("?scope=collection")));if(!me())return;let Ze=pt.entities[0];if(Ze)return l.fetchQuery({...gc(i,b,Ze.id),staleTime:0}).then((Be)=>{if(!K||te!==_.current)return;let fn=hc(Be);C({type:"documentOpened",document:fn})});C({type:"creationStarted",singleton:!0,draft:Hg(Fe.fields)})}return}).catch((Fe)=>{if(K&&te===_.current)ee(br(Fe))}),()=>{K=!1}},[g,p,b,Ae,l,f,h,u,q,j]);let X=mi.useCallback((le,te={kind:"idle"},K=b)=>{if(!K||!b)return;let me=Aa(a,K,le);if(!(K===b&&u.kind==="entity"&&u.entityType===b&&u.id===le)){Je.current={pathname:me,save:te};let Ze=`${ei(a,v??b)}${ti(k)}`,Be=g&&te.kind==="saved",fn=s.location.state,ni=!Be||td(fn)&&fn.studioCollectionPath===Ze;s[Be?"replace":"push"](`${me}${ti(k)}`,ni?{studioCollectionPath:Ze}:void 0,te.kind==="saved"?{ignoreBlocker:!0}:void 0);return}let Ie=++_.current,pt=b;l.fetchQuery({...gc(i,b,le),staleTime:0}).then((Ze)=>{if(Ie!==_.current||ce.current!==pt)return;let Be=hc(Ze);C({type:"documentOpened",document:Be,save:te}),U({kind:"idle"})}).catch((Ze)=>{if(Ie===_.current)ee(br(Ze))})},[a,p,u,g,b,v,k,l,s]),ge=mi.useCallback(()=>{he((le)=>le+1)},[]),ot=mi.useCallback(()=>{_.current+=1},[]),Q=mi.useCallback(()=>_.current,[]);return{openEntity:X,loadError:P,setLoadError:ee,retryOpen:ge,supersedeOpen:ot,currentOpenRequest:Q,pendingOpenState:Je}}var _o=se(ln(),1);function xL(t){let{api:i,queryClient:l,history:s,studioBasePath:a,entityType:u,collectionType:f,entityCollectionQuery:h,groupReturnPath:p,activeCapabilities:g,schema:b,editor:v,dispatchEditor:S,createPath:k,syncStatus:A,deleting:C,saveEntityMutation:R,deleteEntityMutation:B,openEntity:U,currentOpenRequest:q,setMobilePane:j,setFieldAssistState:P}=t,{mode:ee,draft:Ae,body:he,save:Je}=v,[_,ce]=_o.useState(null),X=_o.useRef(0);_o.useEffect(()=>{if(Je.kind!=="saved"||!A?.git)return;if(bm({save:Je,git:A.git,baselineCommit:_}).committed==="done")return;if(Date.now()-X.current>20000)return;let K=window.setTimeout(()=>{l.invalidateQueries({queryKey:Ui.syncStatus()})},900);return()=>window.clearTimeout(K)},[Je,A,_,l]);let ge=_o.useCallback((te,K)=>{if(!u||ee.kind!=="edit"||g?.canUpdate!==!0||g.canAssist!==!0||he.trim().length===0)return;P({kind:"loading",field:K,variant:te}),i.requestFieldAssist({variant:te,entityType:u,id:ee.entity.id,targetField:K}).then((me)=>{let Fe=me.variant==="summarize"?me.suggestion:me.suggestions;P({kind:"suggested",field:me.targetField,variant:me.variant,suggestion:Fe})}).catch((me)=>{P({kind:"error",field:K,message:Ni(me)})})},[g,he,u,ee]),ot=_o.useCallback((te,K)=>{S({type:"fieldAssistApplied",field:te,suggestion:K}),P({kind:"idle"})},[]),Q=_o.useCallback(()=>{if(!u||ee.kind==="browse"||!b||u===rs&&!b.groupingDefinitions||Vd(v)||(ee.kind==="create"&&b.isSingleton||u===rs)&&!dg(v))return;if(ee.kind==="create"?g?.canCreate!==!0:g?.canUpdate!==!0)return;X.current=Date.now(),ce(A?.git?.lastCommit??null),S({type:"saveStarted"});let te=b.hasBody?{body:he}:{},K=Bg(b.fields,Ae),me=ee.kind==="create"?{kind:"create",entityType:u,...k&&{idPath:k},frontmatter:K,...te}:{kind:"update",entityType:u,id:ee.entity.id,frontmatter:K,baseContentHash:ee.entity.contentHash,...te},Fe=q();R.mutate(me,{onSuccess:async(Ie)=>{if(await Promise.all([l.invalidateQueries({queryKey:["studio","groupings"]}),l.invalidateQueries({queryKey:Ui.entities(u)}),...f&&f!==u?[l.invalidateQueries({queryKey:Ui.entities(f)})]:[],l.invalidateQueries({queryKey:Ui.syncStatus()}),...u===rs?[l.invalidateQueries({queryKey:["studio","schema"]})]:[],...ee.kind==="create"||u===rs?[l.invalidateQueries({queryKey:Ui.navigation()})]:[]]),Fe!==q())return;let pt="skipped"in Ie&&Ie.skipped===!0;U(Ie.entityId,{kind:"saved",noop:pt})},onError:(Ie)=>{if(Fe!==q())return;if(Ie instanceof Ao&&(Ie.status===400||Ie.status===409))Promise.all([l.invalidateQueries({queryKey:Ui.navigation()}),l.invalidateQueries({queryKey:["studio","schema"]}),l.invalidateQueries({queryKey:["studio","groupings"]})]);if(Ie instanceof Ao&&Ie.issues.length>0)j("details");S({type:"saveFailed",save:Ie instanceof Ao&&Ie.status===409&&ee.kind==="edit"?{kind:"conflict",message:Ni(Ie)}:{kind:"error",message:Ie instanceof Ao&&Ie.issues.length>0?Ie.message||"Validation failed":Ni(Ie),...Ie instanceof Ao?{issues:Ie.issues}:{}}})}})},[g,u,f,ee,k,v,Ae,he,b,U,A,l,R]),le=_o.useCallback(()=>{if(!u||ee.kind!=="edit"||C||g?.canDelete!==!0)return;let{id:te}=ee.entity;B.mutate({entityType:u,id:te},{onSuccess:async()=>{S({type:"deleteSucceeded"}),l.removeQueries({queryKey:Ui.entity(u,te)}),await Promise.all([l.invalidateQueries({queryKey:["studio","groupings"]}),l.invalidateQueries({queryKey:Ui.entityLists()}),l.invalidateQueries({queryKey:Ui.syncStatus()}),l.invalidateQueries({queryKey:Ui.navigation()})]),s.replace(p??`${ei(a,f??u)}${ti(h)}`,void 0,{ignoreBlocker:!0})},onError:(K)=>{S({type:"deleteFailed",message:Ni(K)})}})},[g,a,u,f,ee,C,l,B,s,p,h]);return{runFieldAssist:ge,applyFieldAssist:ot,save:Q,remove:le,baselineCommit:_}}var Qd=se(ln(),1);function AL(t){let{history:i,queryClient:l,studioBasePath:s,routeTarget:a,routePathname:u,routeSearch:f,entityType:h,activeWorkspaceId:p,types:g,groupings:b,workspaces:v,activeType:S,activeWorkspace:k,entityCollectionQuery:A,entityListOffset:C,entityListTotal:R,declarativeWorkspaceData:B,initialUrlWorkspaceQuery:U,setActiveWorkspaceId:q,setEntityType:j,setLoadError:P,supersedeOpen:ee}=t;Qd.useEffect(()=>{if(!h||!S||p||a.kind!=="collection"&&a.kind!=="entity"||a.entityType!==h)return;if(R===void 0)return;let Ae=Math.floor(Math.max(0,R-1)/A.limit)*A.limit;if(C>Ae)i.replace(`${u}${ti({...A,offset:Ae})}`,i.location.state)},[S,p,C,R,A,h,u,a,i]),Qd.useEffect(()=>{if(!p||!B?.refreshAfterMs)return;let Ae=window.setTimeout(()=>{l.invalidateQueries({queryKey:Ui.workspace(p)})},B.refreshAfterMs);return()=>window.clearTimeout(Ae)},[p,B,l]),Qd.useEffect(()=>{if(k?.urlQuery!==!0||a.kind!=="workspace"||a.workspaceId!==k.id)return;let Ae=Zn(s,k.id);if(Ca(Ae,U)!==`${Ae}${f}`)Dg(i,Ae,U,window.location.pathname)},[k,s,U,f,a,i]),Qd.useEffect(()=>{if(!g)return;if(P(null),a.kind==="not-found"){ee(),P(`Studio route not found: ${a.pathname}`);return}if(a.kind==="grouping"){if(ee(),q(null),j(null),!b.some((_)=>_.key===a.grouping))P("Collection unavailable for this account.");return}if(a.kind==="workspace"){let _=v.find((ce)=>ce.id===a.workspaceId);if(!_){let ce=kL(s,a.workspaceId,f,v);if(ce){i.replace(ce);return}ee(),P(`Workspace unavailable for this account: ${a.workspaceId}`);return}q(_.id),j(null);return}let Ae=a.kind==="collection"||a.kind==="entity"?a.entityType:void 0,he=g.find((_)=>!_.isSingleton)??g[0];if(a.kind==="home"){let _=CL(s,g,v);if(_!==s){i.replace(_);return}}let Je=Ae??he?.entityType??null;if(Ae!==void 0&&!g.some((_)=>_.entityType===Ae)){ee(),P(`Collection unavailable for this account: ${Ae}`);return}q(null),j(Je)},[f,a,i,s,g,b,v])}var O1=se(ln(),1);function TL(t){let{queryClient:i,workspaces:l,activeWorkspaceId:s,entityType:a,mode:u,declarativeWorkspaceActionMutation:f,openEntity:h}=t,p=O1.useCallback(async(b)=>{let v=EL(l,b.entityType);if(!v)throw Error("Publishing is unavailable");let S={entityType:b.entityType,entityId:b.entityId,...b.type==="reorder"?{position:b.position}:{}};if(b.type==="publish"&&!b.confirmation){let C=await f.mutateAsync({workspaceId:v.id,action:{actionId:"publish",label:"Publish now",input:S,invocation:{mode:"prepare"}}});if(typeof C!=="object"||C===null||!("kind"in C)||C.kind!=="prepared-confirmation"||!("token"in C)||typeof C.token!=="string"||!("summary"in C)||typeof C.summary!=="string"||!("expiresAt"in C)||typeof C.expiresAt!=="string")throw Error("Publishing confirmation is unavailable");return{needsConfirmation:!0,summary:C.summary,args:{confirmed:!0,confirmationToken:C.token,contentHash:C.token,expiresAt:C.expiresAt}}}let k=await f.mutateAsync({workspaceId:v.id,action:{actionId:b.type,label:b.type,input:S,...b.type==="publish"&&b.confirmation?{invocation:{mode:"execute",token:b.confirmation.confirmationToken}}:{}}});if(typeof k!=="object"||k===null)throw Error("Publishing returned an invalid result");let A="success"in k&&k.success===!1?{success:!1,error:"error"in k&&typeof k.error==="string"?k.error:"Publishing failed",..."code"in k&&typeof k.code==="string"?{code:k.code}:{}}:{success:!0};if(!g1(A)&&!y1(A)){if(await R1(i,v.id),u.kind==="edit"&&a===b.entityType&&u.entity.id===b.entityId)h(b.entityId)}return A},[a,u,h,i,f,l]),g=O1.useCallback(async(b)=>{if(!s)throw Error("Declarative workspace is unavailable");try{let v=await f.mutateAsync({workspaceId:s,action:b});return await R1(i,s),v}finally{f.reset()}},[s,f,i]);return{performPublishingAction:p,performDeclarativeAction:g}}var Wt=se(Ue(),1),p5=ut.lazy(()=>Ev(async()=>({default:(await import("./studio-chunks/account-view-0yz326ez.js")).AccountApp}))),m5=ut.lazy(()=>Ev(async()=>({default:(await import("./studio-chunks/studio-chat-workspace-5h9qka59.js")).StudioChatWorkspace}),()=>Wt.jsxDEV(ka,{message:"Chat could not open.",children:Wt.jsxDEV(Av,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)));function g5(t){let i=new URLSearchParams(t).get("session")?.trim();return i&&i.length<=256?i:null}var y5=["public","trusted","admin"];function b5(t,i,l){let s=document.querySelector("[data-studio-root]"),a=s?.getAttribute("data-studio-principal-name")??"Your account",u=s?.getAttribute("data-studio-principal-role"),f=y5.find((g)=>g===u)??"public",h=s?.getAttribute("data-studio-mcp-url")??void 0,p=new URLSearchParams(l).get("section")??void 0;return{displayName:a,role:f,routePath:t,studioPath:i,...h?{mcpUrl:h}:{},...p?{initialSection:p}:{}}}function NL(){let t=OL(),i=Ug({select:(Te)=>Te.location.pathname}),l=Ug({select:(Te)=>Te.location.searchStr}),s=Ug({select:(Te)=>Te.location.state}),a=zL(),u=ut.useMemo(()=>i===M1?{kind:"workspace",workspaceId:Ng}:mm(i,a),[i,a]),f=ut.useMemo(()=>u.kind==="collection"&&new URLSearchParams(l).get("mode")==="create",[l,u]),h=i,[p,g]=ut.useState(null),[b,v]=ut.useState(null),[S,k]=ut.useState({}),[A,C]=ut.useReducer(oM,Id),{mode:R}=A,B=dg(A),[U]=ut.useState(()=>new BL),q=ut.useSyncExternalStore(U.subscribe,U.hasDrafts,U.hasDrafts),[j,P]=ut.useState({hasDraft:!1,busy:!1}),ee=ML({shouldBlockFn:({next:Te})=>B||i===M1&&LL({...j,hasDraft:q},Te.pathname),enableBeforeUnload:B||q||j.busy,withResolver:!0}),[Ae,he]=ut.useState({kind:"idle"}),[Je,_]=ut.useState("preview"),ce=A.mode.kind==="create";ut.useEffect(()=>{if(ce)_("source")},[ce]);let[X,ge]=ut.useState("details"),ot=ut.useRef(null),Q=ut.useCallback((Te)=>{ot.current=Te,ge(Te)},[]),le=RL(),te=Ji(),{navigationQuery:K,types:me,groupings:Fe,activeType:Ie,collectionType:pt,activeCapabilities:Ze,entityCollectionQuery:Be,entityListOffset:fn,workspaces:ni,activeWorkspace:qo,activeAccount:vr,activeChat:us,initialUrlWorkspaceQuery:yc,workspaceRequestQuery:ie,workspaceQuery:Tn,workspaceData:Ea,workspaceError:Sr,agentTargets:wr,syncStatus:ct,entityListQuery:ao,entities:bc,entityListTotal:Yd,schema:lt,createPath:Ig,destinationQuery:uo,saveEntityMutation:Ta,deleteEntityMutation:xr,declarativeWorkspaceActionMutation:Vg,deleting:Da,declarativeWorkspaceData:Ra}=hL({api:te,entityType:b,activeWorkspaceId:p,routeSearch:l,workspaceQueries:S,editor:A}),_i=u.kind==="grouping"?Fe.find((Te)=>Te.key===u.grouping):void 0,Oa=ut.useMemo(()=>kv(l),[l]),Ma=u.kind==="entity"?ST(s,a,Fe):null,vc=Ma?.path,Xd=ut.useMemo(()=>b?Fe.filter((Te)=>Te.types.includes(b)):[],[Fe,b]),Sc=tL(Xd),{openEntity:La,loadError:Wd,setLoadError:Ba,retryOpen:Fd,supersedeOpen:Kd,currentOpenRequest:wc,pendingOpenState:kl}=wL({api:te,queryClient:le,history:t.history,studioBasePath:a,routeTarget:u,routePathname:i,routeSearch:l,currentStudioPathname:h,createMode:f,entityType:b,collectionType:pt,activeType:Ie,entityCollectionQuery:Be,preferredMobilePane:ot,dispatchEditor:C,setMobilePane:ge,setBodyMode:_,setFieldAssistState:he});AL({history:t.history,queryClient:le,studioBasePath:a,routeTarget:u,routePathname:i,routeSearch:l,entityType:b,activeWorkspaceId:p,types:me,groupings:Fe,workspaces:ni,activeType:Ie,activeWorkspace:qo,entityCollectionQuery:Be,entityListOffset:fn,entityListTotal:Yd,declarativeWorkspaceData:Ra,initialUrlWorkspaceQuery:yc,setActiveWorkspaceId:g,setEntityType:v,setLoadError:Ba,supersedeOpen:Kd});let{openWorkspaceEntity:Io,openWorkspaceLaunch:kr,selectEntityType:Vo,changeEntityPage:Ft,selectWorkspace:co,selectFolder:cs,startCreate:fs,backToList:xc,changeWorkspaceQuery:Jd}=yL({history:t.history,studioBasePath:a,routeSearch:l,entityType:b,collectionType:pt,entityCollectionQuery:Be,groupReturnPath:vc,workspaces:ni,schema:lt,activeCapabilities:Ze,pendingOpenState:kl,setFieldAssistState:he,setWorkspaceQueries:k}),{runFieldAssist:za,applyFieldAssist:Na,save:fo,remove:ii,baselineCommit:Zd}=xL({api:te,queryClient:le,history:t.history,studioBasePath:a,entityType:b,collectionType:pt,entityCollectionQuery:Be,groupReturnPath:vc,activeCapabilities:Ze,schema:lt,editor:A,dispatchEditor:C,createPath:Ig,syncStatus:ct,deleting:Da,saveEntityMutation:Ta,deleteEntityMutation:xr,openEntity:La,currentOpenRequest:wc,setMobilePane:ge,setFieldAssistState:he}),{performPublishingAction:Pg,performDeclarativeAction:kc}=TL({queryClient:le,workspaces:ni,activeWorkspaceId:p,entityType:b,mode:R,declarativeWorkspaceActionMutation:Vg,openEntity:La}),ho=Wd??(K.error?br(K.error):ao.error?br(ao.error):null),Cr=()=>{if(Ba(null),K.error)K.refetch();if(ao.error)ao.refetch();if(Tn.error)Tn.refetch();if(R.kind==="browse")Fd()};if(ho&&!me)return Wt.jsxDEV(ka,{message:ho,error:!0,onRetry:Cr},void 0,!1,void 0,this);if(!me)return Wt.jsxDEV(ka,{message:"Loading…"},void 0,!1,void 0,this);if(vr&&qo){let Te=Zn(a,zg);return Wt.jsxDEV(KM,{types:me,workspaces:ni,workspaceId:qo.id,selectEntityType:Vo,selectWorkspace:co,children:Wt.jsxDEV(ut.Suspense,{fallback:Wt.jsxDEV(ke,{children:"Opening Account…"},void 0,!1,void 0,this),children:Wt.jsxDEV(p5,{bootstrap:b5(Te,a,l)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}if(us&&qo)return Wt.jsxDEV(Wt.Fragment,{children:[Wt.jsxDEV(ut.Suspense,{fallback:Wt.jsxDEV(ka,{message:"Opening Chat…"},void 0,!1,void 0,this),children:Wt.jsxDEV(m5,{apiPath:qo.chatApiPath,draftStore:U,onNavigationStateChange:P,studioBasePath:a,sessionId:g5(l),types:me,workspaces:ni,handoff:eL(s),navigate:(Te,Po)=>{t.history.push(Te,void 0,{ignoreBlocker:Po?.preserveWork===!0})},selectEntityType:Vo,selectWorkspace:co},void 0,!1,void 0,this)},void 0,!1,void 0,this),ee.status==="blocked"&&Wt.jsxDEV(Mn,{mark:"↩",title:"Leave this conversation?",titleId:"chat-navigation-title",cancelLabel:"Stay",confirmLabel:"Leave",onCancel:()=>ee.reset(),onConfirm:()=>ee.proceed(),children:Wt.jsxDEV("p",{children:"Your draft stays in this tab. Leaving stops receiving the response, but does not undo completed actions or background jobs."},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);if(p?!Ea&&!Sr:b&&!lt&&!ho)return Wt.jsxDEV(ka,{message:"Loading…"},void 0,!1,void 0,this);if(!_i&&!p&&(!b||!lt&&!ho))return Wt.jsxDEV(ka,{message:ho??"No readable collections are available for this account.",error:Boolean(ho),...ho?{onHome:()=>t.history.push(a)}:{}},void 0,!1,void 0,this);return Wt.jsxDEV(JM,{groupings:{items:Fe,active:_i?.key??Ma?.grouping??null,onSelect:(Te)=>t.history.push(Iu(a,Te))},groupReturnLabel:Ma?.label,groupingSuggestions:Sc,groupingView:_i?Wt.jsxDEV(AT,{basePath:a,grouping:_i,types:me,query:Oa,onChange:(Te,Po)=>{let ds=`${Iu(a,_i.key)}${qu(Te)}`,eh=Te.value!==Oa.value||Te.offset!==Oa.offset;t.history[eh&&Po?.replace!==!0?"push":"replace"](ds)},onOpen:(Te,Po)=>{let ds=Aa(a,Te,Po);kl.current={pathname:ds,save:{kind:"idle"}},t.history.push(ds,{studioGroupingPath:`${Iu(a,_i.key)}${qu(Oa)}`})}},void 0,!1,void 0,this):null,activeWorkspaceId:p,types:me,workspaces:ni,workspaceError:Sr,readError:ho,onRetryRead:Cr,declarativeWorkspaceData:Ra,workspaceQuery:ie,entityType:b,entities:bc,folders:ao.data?.folders??[],collectionTrail:ao.data?.trail,collectionPath:pt?ei(a,pt):a,selectFolder:cs,creationDestination:{data:uo.data??null,pending:uo.isPending,error:uo.error},entityOffset:fn,entityLimit:Be.limit,entityTotal:Yd??0,collectionQuery:Be,onCollectionQueryChange:(Te)=>{if(!pt)return;t.history.push(`${ei(a,pt)}${ti({...Te,offset:0})}`),window.scrollTo({top:0,left:0})},entityListLoading:ao.isPending,schema:lt,editor:A,fieldAssistState:Ae,bodyMode:Je,mobilePane:X,syncStatus:ct,baselineCommit:Zd,agentTargets:wr,deleting:Da,hasUnsavedChanges:B,navigationBlocked:ee.status==="blocked",dispatchEditor:C,setFieldAssistState:he,setBodyMode:_,setMobilePane:Q,backToList:xc,selectEntityType:Vo,selectWorkspace:co,changeEntityPage:Ft,openWorkspaceEntity:Io,openWorkspaceLaunch:kr,performPublishingAction:Pg,performDeclarativeAction:kc,onWorkspaceQueryChange:Jd,startCreate:fs,openEntity:(Te,Po)=>La(Te,void 0,Po),runFieldAssist:za,applyFieldAssist:Na,save:fo,remove:ii,onNavigationReset:()=>ee.reset?.(),onNavigationProceed:()=>ee.proceed?.()},void 0,!1,void 0,this)}function UL(){return new HL({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1},mutations:{retry:!1}}})}var qg=se(Ue(),1),_g=document.querySelector("[data-studio-root]");if(_g){let t=_g.getAttribute("data-studio-base-path")??"/studio",i=new IL({basePath:t});_g.textContent="";let l=UL(),s=PL(t,NL);jL.createRoot(_g).render(qg.jsxDEV(_L,{client:l,children:qg.jsxDEV(VL,{api:i,children:qg.jsxDEV(qL,{router:s},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this))}
246
246
 
247
247
  //# debugId=F4324C4CF1BCCC2564756E2164756E21
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "version": 2,
3
3
  "entrypoints": {
4
- "script": "studio-app-cmq8cwna.js",
5
- "stylesheet": "studio-app-589ca178b493c37825116e19389e661774e7a872452f23d3e48b467ca1514a60.css"
4
+ "script": "studio-app-e55r86r3.js",
5
+ "stylesheet": "studio-app-1d8a85ef60f4d93da4506c0d76de4cc4bfbfcb91a83e2453da2f013b67988223.css"
6
6
  },
7
7
  "assets": {
8
- "studio-app-589ca178b493c37825116e19389e661774e7a872452f23d3e48b467ca1514a60.css": "studio-app-589ca178b493c37825116e19389e661774e7a872452f23d3e48b467ca1514a60.css",
9
- "studio-app-cmq8cwna.js": "studio-app-cmq8cwna.js",
10
- "studio-app-cmq8cwna.js.map": "studio-app-cmq8cwna.js.map",
11
- "studio-chunks/account-view-8z403hx4.js": "studio-chunks/account-view-8z403hx4.js",
12
- "studio-chunks/account-view-8z403hx4.js.map": "studio-chunks/account-view-8z403hx4.js.map",
8
+ "studio-app-1d8a85ef60f4d93da4506c0d76de4cc4bfbfcb91a83e2453da2f013b67988223.css": "studio-app-1d8a85ef60f4d93da4506c0d76de4cc4bfbfcb91a83e2453da2f013b67988223.css",
9
+ "studio-app-e55r86r3.js": "studio-app-e55r86r3.js",
10
+ "studio-app-e55r86r3.js.map": "studio-app-e55r86r3.js.map",
11
+ "studio-chunks/account-view-0yz326ez.js": "studio-chunks/account-view-0yz326ez.js",
12
+ "studio-chunks/account-view-0yz326ez.js.map": "studio-chunks/account-view-0yz326ez.js.map",
13
13
  "studio-chunks/highlighted-body-OFNGDK62-ag1bvcvz.js": "studio-chunks/highlighted-body-OFNGDK62-ag1bvcvz.js",
14
14
  "studio-chunks/highlighted-body-OFNGDK62-ag1bvcvz.js.map": "studio-chunks/highlighted-body-OFNGDK62-ag1bvcvz.js.map",
15
15
  "studio-chunks/main-4vaeqvhy.js": "studio-chunks/main-4vaeqvhy.js",
@@ -20,8 +20,8 @@
20
20
  "studio-chunks/main-drkb8mk1.js.map": "studio-chunks/main-drkb8mk1.js.map",
21
21
  "studio-chunks/main-h3ka07k3.js": "studio-chunks/main-h3ka07k3.js",
22
22
  "studio-chunks/main-h3ka07k3.js.map": "studio-chunks/main-h3ka07k3.js.map",
23
- "studio-chunks/main-xvgffskk.js": "studio-chunks/main-xvgffskk.js",
24
- "studio-chunks/main-xvgffskk.js.map": "studio-chunks/main-xvgffskk.js.map",
23
+ "studio-chunks/main-m8wmpxz1.js": "studio-chunks/main-m8wmpxz1.js",
24
+ "studio-chunks/main-m8wmpxz1.js.map": "studio-chunks/main-m8wmpxz1.js.map",
25
25
  "studio-chunks/mermaid-GHXKKRXX-wa9tt0zt.js": "studio-chunks/mermaid-GHXKKRXX-wa9tt0zt.js",
26
26
  "studio-chunks/mermaid-GHXKKRXX-wa9tt0zt.js.map": "studio-chunks/mermaid-GHXKKRXX-wa9tt0zt.js.map",
27
27
  "studio-chunks/studio-chat-workspace-5h9qka59.js": "studio-chunks/studio-chat-workspace-5h9qka59.js",
@@ -1,3 +1,3 @@
1
- import{a as c,b as i,c as re,d as pe}from"./main-xvgffskk.js";import{Gb as a,Hb as H,Ib as Ce,Kb as M,bb as C,dc as we,ec as Ie,fb as y,gb as X,gc as Me,hc as Ue,jb as ue,oc as de,qb as Ne,qc as q,sb as Pe,tb as Oe,ub as w,vb as I}from"./main-4vaeqvhy.js";import{rc as f,xc as Q}from"./main-h3ka07k3.js";var z=f(Q(),1);var $e=a.object({displayName:a.string(),role:a.enum(["admin","trusted","public"]),profileEntityId:a.string().optional(),passkeys:a.array(a.object({id:a.string(),transports:a.array(a.string()).optional(),credentialDeviceType:a.string().optional(),credentialBackedUp:a.boolean(),createdAt:a.number(),updatedAt:a.number()})),connectedChannels:a.array(a.object({type:a.string(),label:a.string(),verifiedAt:a.number()})),pluginSettings:a.array(a.object({id:a.string(),title:a.string(),description:a.string().optional(),configured:a.boolean(),revision:a.number().nullable(),fields:a.array(a.object({name:a.string(),label:a.string(),control:a.enum(["text","url","number","checkbox"]),secret:a.boolean(),required:a.boolean(),value:a.union([a.string(),a.number(),a.boolean(),a.null()]).optional(),set:a.boolean().optional()}))})),sessions:a.array(a.object({id:a.string(),current:a.boolean(),createdAt:a.number(),expiresAt:a.number()}))});function Re(e){return $e.safeParse(e).success}var ne=a.custom(Re,{message:"Invalid account response"}),Y=a.object({account:ne}),Ee=a.object({account:ne.optional(),revoked:a.object({sessions:a.number(),refreshTokens:a.number().optional()}).optional(),signedOut:a.boolean().optional()});function De(e){return Ee.safeParse(e).success}var _e=a.custom(De,{message:"Invalid account mutation response"}),je=a.custom((e)=>{if(!H(e))return!1;return typeof e.challenge==="string"&&H(e.rp)&&H(e.user)&&Array.isArray(e.pubKeyCredParams)},{message:"Invalid passkey registration options"});class oe extends Error{status;constructor(e,t){super(e);this.name="AccountApiError",this.status=t}}async function D(e,t){let n;try{n=await e.json()}catch{n={}}if(!e.ok){let s=typeof n==="object"&&n!==null&&"error"in n&&typeof n.error==="string"?n.error:"Account request failed";throw new oe(s,e.status)}return t.parse(n)}function G(e){let t=e.replaceAll("-","+").replaceAll("_","/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),(n)=>n.charCodeAt(0)).buffer}function W(e){let t=new Uint8Array(e),n="";for(let s of t)n+=String.fromCharCode(s);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Le(e){return{challenge:G(e.challenge),rp:e.rp,user:{...e.user,id:G(e.user.id)},pubKeyCredParams:e.pubKeyCredParams,...e.timeout!==void 0?{timeout:e.timeout}:{},...e.excludeCredentials?{excludeCredentials:e.excludeCredentials.map((t)=>({...t,id:G(t.id)}))}:{},...e.authenticatorSelection?{authenticatorSelection:e.authenticatorSelection}:{},...e.attestation?{attestation:e.attestation}:{},...e.extensions?{extensions:e.extensions}:{}}}var Be=(e,t)=>fetch(e,t);class K{fetchFn;constructor(e={}){this.fetchFn=e.fetch??Be}async fetchAccount(){return(await D(await this.fetchFn("/auth/account",{credentials:"same-origin",cache:"no-store"}),Y)).account}async mutatePluginSettings(e){return(await D(await this.fetchFn("/auth/account/plugin-settings",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),Y)).account}async mutateAccount(e){return D(await this.fetchFn("/auth/account/mutations",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),_e)}async registerPasskey(){let e=await D(await this.fetchFn("/auth/account/passkeys/options",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"}),je),t=await navigator.credentials.create({publicKey:Le(e)});if(!(t instanceof PublicKeyCredential))throw Error("Passkey registration was cancelled");if(!(t.response instanceof AuthenticatorAttestationResponse))throw Error("Authenticator returned an invalid passkey response");let n=t.response,s={id:t.id,rawId:W(t.rawId),type:t.type,...t.authenticatorAttachment?{authenticatorAttachment:t.authenticatorAttachment}:{},clientExtensionResults:t.getClientExtensionResults(),response:{clientDataJSON:W(n.clientDataJSON),attestationObject:W(n.attestationObject),transports:typeof n.getTransports==="function"?n.getTransports():[]}};return(await D(await this.fetchFn("/auth/account/passkeys/verify",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),Y.extend({verified:a.literal(!0)}))).account}}function ie(e){return e.length===0?e:`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}function se(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map((t)=>t.slice(0,1).toUpperCase()).join("")}function ae(e,t){let n=t.indexOf("/");if(n<=0||n===t.length-1)return;let s=t.slice(0,n),o=t.slice(n+1);return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(s)}/${encodeURIComponent(o)}`}function F(e,t=!1){return new Date(t?e:e*1000).toISOString()}var b=f(C(),1);function _(e){return b.jsxDEV(y,{variant:e.tone==="danger"?"danger":e.tone==="primary"?"primary":"outline",type:e.type??"button",onClick:e.onClick,disabled:e.disabled,children:e.children},void 0,!1,void 0,this)}function j(e){return b.jsxDEV("div",{className:i("account-access-item",c.access),children:[b.jsxDEV(re,{density:"comfortable",title:e.kind,description:e.description,metadata:e.metadata??[]},void 0,!1,void 0,this),e.action]},void 0,!0,void 0,this)}function P(e){return b.jsxDEV("section",{className:i("account-detail-section",c.section),children:[b.jsxDEV("div",{className:"account-section-label",children:[b.jsxDEV("h3",{className:i("",c.heading,q.section),children:e.title},void 0,!1,void 0,this),e.description?b.jsxDEV("p",{className:i("",c.description),children:e.description},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),b.jsxDEV("div",{className:i("people-stack",c.stack),children:e.children},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ce(e,t){let n=Object.fromEntries(t.entries());for(let s of e)if(s.control==="checkbox")n[s.name]=t.has(s.name);else if(s.control==="number"&&typeof n[s.name]==="string"&&n[s.name]!=="")n[s.name]=Number(n[s.name]);return n}function le(e){if(e.secret)return"password";if(e.control==="url"||e.control==="number")return e.control;return"text"}var r=f(C(),1);function me(e){let{account:t,actions:n,title:s,studioPath:o}=e,g=t.role,m=t.profileEntityId?ae(o,t.profileEntityId):void 0;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV(P,{title:"Profile",children:[r.jsxDEV("div",{className:i("account-identity",c.identity),children:r.jsxDEV("div",{className:i("people-detail-person",c.person),children:[r.jsxDEV("span",{className:i("people-avatar people-avatar--large",c.avatar),children:se(s)},void 0,!1,void 0,this),r.jsxDEV("span",{className:i("",c.personCopy),children:[r.jsxDEV("span",{className:i("people-detail-name",c.name,q.secondaryDisplay),children:s},void 0,!1,void 0,this),r.jsxDEV("span",{"data-account-role":g,className:i("account-role",c.role),children:ie(g)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t.profileEntityId?r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:i("account-profile-note",c.description),children:"Managed by the Anchor profile — your account name follows the published profile."},void 0,!1,void 0,this),r.jsxDEV(j,{kind:"Anchor profile",description:s,action:m?r.jsxDEV(y,{asChild:!0,variant:"link",children:r.jsxDEV("a",{href:m,children:"Edit Anchor Profile →"},void 0,!1,void 0,this)},void 0,!1,void 0,this):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this):r.jsxDEV("form",{className:i("name-form",c.form),onSubmit:(x)=>{x.preventDefault(),n.saveName()},children:[r.jsxDEV("label",{className:i("",c.formLabel),htmlFor:"display-name",children:"Display name"},void 0,!1,void 0,this),r.jsxDEV(X,{id:"display-name",maxLength:200,autoComplete:"name",required:!0,value:n.displayName,onChange:(x)=>n.setDisplayName(x.target.value)},void 0,!1,void 0,this),r.jsxDEV(_,{type:"submit",disabled:n.busy,children:"Save name"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV("p",{className:i("",c.description),children:"Your role controls access to this brain. An administrator manages access in Administration."},void 0,!1,void 0,this),g==="admin"&&r.jsxDEV(y,{asChild:!0,variant:"outline",children:r.jsxDEV("a",{href:de(o,"admin:administration"),children:"Manage people in Administration →"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ge(e){let t=e.account.connectedChannels;return r.jsxDEV(P,{title:"Linked identities",description:"How this brain recognizes messages from you. These are your identities, not services configured for the whole brain.",children:t.length===0?r.jsxDEV("p",{className:i("people-empty",c.empty),children:"No linked identities."},void 0,!1,void 0,this):t.map((n)=>r.jsxDEV(j,{kind:n.type,description:n.label,metadata:[`Verified: ${F(n.verifiedAt,!0)}`]},`${n.type}:${n.label}`,!1,void 0,this))},void 0,!1,void 0,this)}function fe(e){let{account:t,actions:n}=e;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:i("",c.description),children:"Settings for your account only. These do not configure shared services for the brain."},void 0,!1,void 0,this),t.pluginSettings.map((s)=>r.jsxDEV(pe,{label:s.title,density:"comfortable",presentation:"disclosure",children:[r.jsxDEV("p",{className:i("account-settings-description",c.description),children:s.description??"Private settings for this account."},void 0,!1,void 0,this),r.jsxDEV("form",{className:i("name-form",c.form),onSubmit:(o)=>{o.preventDefault(),n.saveSettings(s,new FormData(o.currentTarget))},children:[s.fields.map((o)=>r.jsxDEV("label",{htmlFor:`setting-${s.id}-${o.name}`,className:i("",c.field),children:[r.jsxDEV("span",{className:i("",c.formLabel),children:o.label},void 0,!1,void 0,this),o.control==="checkbox"?r.jsxDEV(ue,{id:`setting-${s.id}-${o.name}`,name:o.name,defaultChecked:o.value===!0},void 0,!1,void 0,this):r.jsxDEV(X,{id:`setting-${s.id}-${o.name}`,name:o.name,type:le(o),required:o.required&&(!s.configured||o.secret)&&!o.set,defaultValue:o.secret?"":typeof o.value==="string"||typeof o.value==="number"?o.value:"",placeholder:o.secret&&o.set?"Stored — leave blank to keep":void 0,autoComplete:"off"},void 0,!1,void 0,this)]},o.name,!0,void 0,this)),r.jsxDEV("div",{className:i("people-inline-actions",c.inlineActions),children:[r.jsxDEV(_,{type:"submit",tone:"primary",disabled:n.busy,children:"Save settings"},void 0,!1,void 0,this),s.configured?r.jsxDEV(y,{variant:"danger",disabled:n.busy,type:"button",onClick:()=>n.removeSettings(s),children:"Remove"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},`${s.id}:${s.revision??"unset"}`,!0,void 0,this)]},s.id,!0,void 0,this))]},void 0,!0,void 0,this)}function ye(e){let{account:t,actions:n}=e,{busy:s}=n;return r.jsxDEV("div",{className:i("",c.column),children:[r.jsxDEV(P,{title:"Sign-in",description:"Passkeys used to access this account. Your final passkey is protected from revocation.",children:[t.passkeys.map((o)=>r.jsxDEV(j,{kind:o.credentialBackedUp?"Synced passkey":"Device passkey",metadata:[`Added: ${F(o.createdAt,!0)}`],action:t.passkeys.length>1?r.jsxDEV(y,{variant:"danger",disabled:s,type:"button",onClick:()=>n.revokePasskey(o.id),children:"Revoke"},void 0,!1,void 0,this):void 0},o.id,!1,void 0,this)),r.jsxDEV("div",{className:i("people-inline-actions",c.inlineActions),children:r.jsxDEV(y,{variant:"outline",disabled:s,type:"button",onClick:n.addPasskey,children:"Add passkey"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV(P,{title:"Signed-in sessions",children:t.sessions.map((o)=>r.jsxDEV(j,{kind:o.current?"This session":"Browser session",metadata:[`Started: ${F(o.createdAt)}`,...o.current?["Current browser"]:[]],action:!o.current?r.jsxDEV(y,{variant:"danger",disabled:s,type:"button",onClick:()=>n.revokeSession(o.id),children:"End"},void 0,!1,void 0,this):void 0},o.id,!1,void 0,this))},void 0,!1,void 0,this),r.jsxDEV("footer",{className:i("account-session-actions",c.footer),children:[r.jsxDEV("small",{children:"Access changes require an Admin."},void 0,!1,void 0,this),r.jsxDEV("div",{className:i("",c.actions),children:[r.jsxDEV(_,{disabled:s||t.sessions.every((o)=>o.current),onClick:n.revokeOtherSessions,children:"End other sessions"},void 0,!1,void 0,this),r.jsxDEV(_,{tone:"danger",disabled:s,onClick:n.revokeAllSessions,children:"Sign out everywhere"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var be=f(Q(),1);var p={clients:{k1xSpc:"xrvj5dj",kumcoG:"x12p5jtz",kOIVth:"x1af02g3",k7Eaqz:"xeuugli",$$css:!0},client:{k7Eaqz:"xeuugli",k1xSpc:"xrvj5dj",kfiyM8:"x10ukxgv",kOIVth:"x883omv",kmVPX3:"x1np1h16",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",kWkggS:"x18s3upu",$$css:!0},clientName:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},text:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},steps:{kogj98:"x1ghz6dp",kE3dHu:"x5tiur9",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},fields:{k1xSpc:"xrvj5dj",kumcoG:"x16lqc3j",kOIVth:"x1vtxxvk",kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",$$css:!0},field:{k1xSpc:"xjp7ctv",$$css:!0},fieldLabel:{k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},fieldValue:{kogj98:"x1ghz6dp",k7Eaqz:"xeuugli",kHjlTd:"xj0a0fe",kMwMTN:"x1ar3pfp",$$css:!0},code:{kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x12oqio5",kmVPX3:"x1nyoefi",$$css:!0},snippet:{k1xSpc:"x78zum5",kGNEyG:"x1cy8zhl",kOIVth:"x167g77z",k7Eaqz:"xeuugli",$$css:!0},snippetCode:{kUk6DE:"x98rzlu",k7Eaqz:"xeuugli",kogj98:"x1ghz6dp",kmVPX3:"x6yrr3s",kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kLWn49:"x1jjo3f5",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x1kogg8i",khDVqt:"x1sdyfia",kXHlph:"xw2csxc",$$css:!0},developer:{k7Eaqz:"xeuugli",kmVPX3:"x1d8yrva",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",$$css:!0},developerSummary:{kkrTdU:"x1ypdohk",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},developerClients:{keoZOQ:"x1hmvnq2",kumcoG:"x1mkdm3x",$$css:!0},developerHint:{k1xSpc:"x1lliihq",keoZOQ:"x1gslohp",k63SB2:"xo1l8bm",kGuDYH:"xfifm61",kMwMTN:"x1ar3pfp",$$css:!0}};function He(e){return new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Z(e){return JSON.stringify(e,null,2)}function he(e,t,n){return["Already have servers there? Add only the ",{code:`"${n}"`}," entry inside ",{code:`"${t}"`},` of ${e}.`]}function Ae(e){let t=He(e),n="Sign in with your passkey when asked.";return[{id:"claude",group:"primary",name:"Claude",note:["Desktop app and claude.ai."],steps:[["Open Settings → Connectors → Add custom connector."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when asked."]]},{id:"chatgpt",group:"primary",name:"ChatGPT",steps:[["Open Settings → Apps & Connectors → Advanced and turn on Developer mode."],["Choose Create, name it ",{code:t},", paste your brain’s address and pick OAuth."],["Sign in with your passkey when asked."]]},{id:"claude-code",group:"developer",name:"Claude Code",lead:[["Add the server in your terminal:"]],snippet:{label:"Claude Code command",code:`claude mcp add --transport http ${t} ${e}`},after:[["Then start Claude Code, run ",{code:"/mcp"},", choose ",{code:t}," and sign in with your passkey."]]},{id:"cursor",group:"developer",name:"Cursor",steps:[["Open Cursor Settings → MCP → Add new global MCP server."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when Cursor asks."]],lead:[["Or add it to ",{code:"~/.cursor/mcp.json"},":"]],snippet:{label:"Cursor configuration",code:Z({mcpServers:{[t]:{url:e}}})},after:[he("the file","mcpServers",t)]},{id:"vscode",group:"developer",name:"VS Code",steps:[["Open the Command Palette and run ",{code:"MCP: Add Server"},"."],["Choose HTTP, paste your brain’s address and name it ",{code:t},"."],["Choose Global, then sign in with your passkey when asked."]],lead:[["Or run ",{code:"MCP: Open User Configuration"}," and add:"]],snippet:{label:"VS Code configuration",code:Z({servers:{[t]:{type:"http",url:e}}})},after:[he("your user configuration","servers",t)]},{id:"other",group:"developer",name:"Any other MCP client",inlineName:"any other MCP client",note:["Look for “add MCP server”, “connector” or “integration” in the tool’s settings and fill in:"],fields:[{label:"Name",value:[{code:t}]},{label:"Type",value:["Remote server, Streamable HTTP — not stdio, not SSE"]},{label:"URL",value:[{code:e}]},{label:"Authentication",value:["OAuth. Leave API key, token, client ID and secret empty; the tool registers itself."]}],lead:[["When you connect, your browser opens “Authorize <tool>?” on your brain. Approve MCP access with your passkey. The tool then has two tools: ",{code:"chat"},", to ask your brain anything as you would in chat, and ",{code:"confirm"},", to approve changes when the brain asks."],["Tool only takes local (stdio) servers, or insists on an API key? Bridge it with ",{code:"mcp-remote"},", which handles the sign-in:"]],snippet:{label:"mcp-remote bridge configuration",code:Z({mcpServers:{[t]:{command:"npx",args:["-y","mcp-remote",e]}}})}}]}var l=f(C(),1);function L(e){return l.jsxDEV(l.Fragment,{children:e.text.map((t,n)=>typeof t==="string"?t:l.jsxDEV("code",{className:i("",p.code),children:t.code},n,!1,void 0,this))},void 0,!1,void 0,this)}function ve(e){let[t,n]=be.useState("idle"),s=async()=>{try{await navigator.clipboard.writeText(e.code),n("copied")}catch{n("unavailable")}};return l.jsxDEV("div",{className:i("ai-tools-snippet",p.snippet),children:[l.jsxDEV("pre",{className:i("",p.snippetCode),"aria-label":e.label,children:e.code},void 0,!1,void 0,this),l.jsxDEV(y,{variant:"outline",size:"sm",onClick:()=>void s(),"aria-label":`Copy ${e.label}`,children:t==="copied"?"Copied":t==="unavailable"?"Select to copy":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ke(e){let{client:t}=e;return l.jsxDEV("article",{className:i("ai-tools-client",p.client),children:[l.jsxDEV("h4",{className:i("",p.clientName),children:t.name},void 0,!1,void 0,this),t.note?l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:t.note},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,t.steps?l.jsxDEV("ol",{className:i("",p.steps),children:t.steps.map((n,s)=>l.jsxDEV("li",{children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},s,!1,void 0,this))},void 0,!1,void 0,this):null,t.fields?l.jsxDEV("dl",{className:i("",p.fields),children:t.fields.map((n)=>l.jsxDEV("div",{className:i("",p.field),children:[l.jsxDEV("dt",{className:i("",p.fieldLabel),children:n.label},void 0,!1,void 0,this),l.jsxDEV("dd",{className:i("",p.fieldValue),children:l.jsxDEV(L,{text:n.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},n.label,!0,void 0,this))},void 0,!1,void 0,this):null,t.lead?.map((n,s)=>l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},`lead-${s}`,!1,void 0,this)),t.snippet?l.jsxDEV(ve,{...t.snippet},void 0,!1,void 0,this):null,t.after?.map((n,s)=>l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},`after-${s}`,!1,void 0,this))]},void 0,!0,void 0,this)}function Fe(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function Se(e){let t=Ae(e.mcpUrl),n=t.filter((o)=>o.group==="primary"),s=t.filter((o)=>o.group==="developer");return l.jsxDEV(P,{title:"AI tools",description:"Connect AI tools you already use to this brain. A connected tool talks to the brain as you do in chat — asking, saving and updating within your access — after you sign in with your passkey.",children:[l.jsxDEV("article",{className:i("ai-tools-address",p.client),children:[l.jsxDEV("h4",{className:i("",p.clientName),children:"Your brain’s address"},void 0,!1,void 0,this),l.jsxDEV(ve,{label:"brain address",code:e.mcpUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:i("ai-tools-clients",p.clients),children:n.map((o)=>l.jsxDEV(ke,{client:o},o.id,!1,void 0,this))},void 0,!1,void 0,this),l.jsxDEV("details",{className:i("ai-tools-developer",p.developer),children:[l.jsxDEV("summary",{className:i("",p.developerSummary),children:["Developer tools and other clients",l.jsxDEV("span",{className:i("",p.developerHint),children:Fe(s.map((o)=>o.inlineName??o.name))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:i("ai-tools-clients",p.clients,p.developerClients),children:s.map((o)=>l.jsxDEV(ke,{client:o},o.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var A=f(Q(),1);var h={updateDisplayName:"updateDisplayName",revokePasskey:"revokePasskey",revokeSession:"revokeSession",revokeOtherSessions:"revokeOtherSessions",revokeAllSessions:"revokeAllSessions"};var ee={revokePasskey:{title:"Revoke this passkey?",message:"You will not be able to use this passkey again.",confirmLabel:"Revoke passkey",pending:"Revoking passkey…",complete:"Passkey revoked."},revokeSession:{title:"End this browser session?",message:"That browser will need a passkey to sign in again.",confirmLabel:"End session",pending:"Ending session…",complete:"Session ended."},revokeOtherSessions:{title:"End every other browser session?",message:"Your current browser will remain signed in.",confirmLabel:"End other sessions",pending:"Ending other sessions…",complete:"Other sessions ended."}};function Te(e){return Ce(e,"Account request failed")}function xe(e){let{client:t,initialAccount:n}=e,[s,o]=A.useState(n),[g,m]=A.useState(n?.displayName??e.initialDisplayName),[x,N]=A.useState(""),[v,S]=A.useState(!1),[T,B]=A.useState(!1),[U,R]=A.useState(null);A.useEffect(()=>{if(n)return;let d=!1;return t.fetchAccount().then((k)=>{if(d)return;o(k),m(k.displayName)}).catch((k)=>{if(d)return;S(!0),N(Te(k))}),()=>{d=!0}},[t,n]);let O=A.useCallback(async(d,k,J)=>{B(!0),S(!1),N(d);try{let E=await J();if(E)o(E),m(E.displayName);N(k)}catch(E){S(!0),N(Te(E))}finally{B(!1)}},[]),te=async(d)=>(await t.mutateAccount(d)).account,V=(d,k)=>R({title:d.title,message:d.message,confirmLabel:d.confirmLabel,action:()=>{O(d.pending,d.complete,()=>te(k))}});return{account:s,displayName:g,setDisplayName:m,status:x,error:v,busy:T,confirmation:U,cancelConfirmation:()=>R(null),confirm:()=>{if(!U)return;R(null),U.action()},saveName:()=>{O("Saving…","Display name updated.",()=>te({action:h.updateDisplayName,confirmation:h.updateDisplayName,displayName:g}))},addPasskey:()=>{O("Waiting for your authenticator…","Passkey added.",()=>t.registerPasskey())},revokePasskey:(d)=>V(ee.revokePasskey,{action:h.revokePasskey,confirmation:h.revokePasskey,credentialId:d}),revokeSession:(d)=>V(ee.revokeSession,{action:h.revokeSession,confirmation:h.revokeSession,sessionId:d}),revokeOtherSessions:()=>V(ee.revokeOtherSessions,{action:h.revokeOtherSessions,confirmation:h.revokeOtherSessions}),revokeAllSessions:()=>R({title:"Sign out everywhere?",message:"This ends every session, including this one. You will need your passkey to return.",confirmLabel:"Sign out everywhere",action:()=>{O("Signing out everywhere…","Signed out.",async()=>{await t.mutateAccount({action:h.revokeAllSessions,confirmation:h.revokeAllSessions}),window.location.assign(`/login?return_to=${encodeURIComponent(e.routePath)}`);return})}}),saveSettings:(d,k)=>{let J=ce(d.fields,k);O(`Saving ${d.title}…`,`${d.title} updated.`,()=>t.mutatePluginSettings({action:"save",definitionId:d.id,values:J}))},removeSettings:(d)=>R({title:`Remove ${d.title}?`,message:"The stored settings for this integration will be removed from your account only.",confirmLabel:"Remove settings",action:()=>{O(`Removing ${d.title}…`,`${d.title} removed.`,()=>t.mutatePluginSettings({action:"delete",definitionId:d.id}))}})}}var u=f(C(),1),qe=["profile","security","identities","settings",M];function ze(e){let t=qe.find((n)=>n===e.initialSection);if(!t||t===M&&!e.mcpUrl)return"profile";return t}function Ve(e){let t=["your profile","sign-in security","linked identities",...e.settings?["personal settings"]:[],...e.aiTools?["AI tools"]:[]];return`Your account on this brain. Manage ${`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`} here—not shared services or other people’s access.`}function Rt({bootstrap:e,initialAccount:t,client:n}){let s=we(),o=z.useMemo(()=>n??new K({fetch:s.fetch}),[n,s]),g=xe({client:o,initialAccount:t,initialDisplayName:e.displayName,routePath:e.routePath}),{account:m,status:x,error:N,busy:v,confirmation:S}=g,[T,B]=z.useState(()=>ze(e)),U=m?.displayName??e.displayName;return u.jsxDEV(u.Fragment,{children:[u.jsxDEV("div",{className:i("account-shell",c.shell,Ie.inset),children:[u.jsxDEV(Ue,{model:{access:Me("public"),title:"Your account",totals:[]}},void 0,!1,void 0,this),u.jsxDEV("p",{className:i("account-scope",c.description),children:Ve({settings:(m?.pluginSettings.length??0)>0,aiTools:Boolean(e.mcpUrl)})},void 0,!1,void 0,this),u.jsxDEV("p",{className:i(`account-status${N?" is-error":""}`,c.feedback,N&&c.feedbackError),role:"status","aria-live":"polite",children:x},void 0,!1,void 0,this),!m?u.jsxDEV("p",{className:i("account-loading",c.loading),children:"Reading your account…"},void 0,!1,void 0,this):u.jsxDEV(Pe,{className:"account-details",value:T,onValueChange:B,children:[u.jsxDEV(Oe,{"aria-label":"Account sections",className:i("account-tabs",c.tabs),children:[u.jsxDEV(w,{value:"profile",disabled:v,children:"Profile"},void 0,!1,void 0,this),u.jsxDEV(w,{value:"security",disabled:v,children:"Sign-in & sessions"},void 0,!1,void 0,this),u.jsxDEV(w,{value:"identities",disabled:v,children:"Linked identities"},void 0,!1,void 0,this),m.pluginSettings.length>0&&u.jsxDEV(w,{value:"settings",disabled:v,children:"Personal settings"},void 0,!1,void 0,this),e.mcpUrl&&u.jsxDEV(w,{value:M,disabled:v,children:"AI tools"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV(I,{value:"profile",forceMount:!0,hidden:T!=="profile",className:i("account-detail-sections",c.tabPanel),children:u.jsxDEV(me,{account:m,actions:g,title:U,studioPath:e.studioPath},void 0,!1,void 0,this)},void 0,!1,void 0,this),u.jsxDEV(I,{value:"identities",forceMount:!0,hidden:T!=="identities",className:i("",c.tabPanel),children:u.jsxDEV(ge,{account:m},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.pluginSettings.length>0&&u.jsxDEV(I,{value:"settings",forceMount:!0,hidden:T!=="settings",className:i("",c.tabPanel),children:u.jsxDEV(fe,{account:m,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),u.jsxDEV(I,{value:"security",forceMount:!0,hidden:T!=="security",className:i("",c.tabPanel),children:u.jsxDEV(ye,{account:m,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.mcpUrl&&u.jsxDEV(I,{value:M,forceMount:!0,hidden:T!==M,className:i("",c.tabPanel),children:u.jsxDEV(Se,{mcpUrl:e.mcpUrl},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S&&u.jsxDEV(Ne,{mark:"!",title:S.title,titleId:"account-confirmation-title",cancelLabel:"Cancel",confirmLabel:S.confirmLabel,confirmVariant:"danger",pending:v,onCancel:g.cancelConfirmation,onConfirm:g.confirm,children:u.jsxDEV("p",{children:S.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Rt as AccountApp};
1
+ import{a as c,b as i,c as re,d as pe}from"./main-m8wmpxz1.js";import{Gb as a,Hb as H,Ib as Ce,Kb as M,bb as C,dc as we,ec as Ie,fb as y,gb as X,gc as Me,hc as Ue,jb as ue,oc as de,qb as Ne,qc as q,sb as Pe,tb as Oe,ub as w,vb as I}from"./main-4vaeqvhy.js";import{rc as f,xc as Q}from"./main-h3ka07k3.js";var z=f(Q(),1);var $e=a.object({displayName:a.string(),role:a.enum(["admin","trusted","public"]),profileEntityId:a.string().optional(),passkeys:a.array(a.object({id:a.string(),transports:a.array(a.string()).optional(),credentialDeviceType:a.string().optional(),credentialBackedUp:a.boolean(),createdAt:a.number(),updatedAt:a.number()})),connectedChannels:a.array(a.object({type:a.string(),label:a.string(),verifiedAt:a.number()})),pluginSettings:a.array(a.object({id:a.string(),title:a.string(),description:a.string().optional(),configured:a.boolean(),revision:a.number().nullable(),fields:a.array(a.object({name:a.string(),label:a.string(),control:a.enum(["text","url","number","checkbox"]),secret:a.boolean(),required:a.boolean(),value:a.union([a.string(),a.number(),a.boolean(),a.null()]).optional(),set:a.boolean().optional()}))})),sessions:a.array(a.object({id:a.string(),current:a.boolean(),createdAt:a.number(),expiresAt:a.number()}))});function Re(e){return $e.safeParse(e).success}var ne=a.custom(Re,{message:"Invalid account response"}),Y=a.object({account:ne}),Ee=a.object({account:ne.optional(),revoked:a.object({sessions:a.number(),refreshTokens:a.number().optional()}).optional(),signedOut:a.boolean().optional()});function De(e){return Ee.safeParse(e).success}var _e=a.custom(De,{message:"Invalid account mutation response"}),je=a.custom((e)=>{if(!H(e))return!1;return typeof e.challenge==="string"&&H(e.rp)&&H(e.user)&&Array.isArray(e.pubKeyCredParams)},{message:"Invalid passkey registration options"});class oe extends Error{status;constructor(e,t){super(e);this.name="AccountApiError",this.status=t}}async function D(e,t){let n;try{n=await e.json()}catch{n={}}if(!e.ok){let s=typeof n==="object"&&n!==null&&"error"in n&&typeof n.error==="string"?n.error:"Account request failed";throw new oe(s,e.status)}return t.parse(n)}function G(e){let t=e.replaceAll("-","+").replaceAll("_","/").padEnd(Math.ceil(e.length/4)*4,"=");return Uint8Array.from(atob(t),(n)=>n.charCodeAt(0)).buffer}function W(e){let t=new Uint8Array(e),n="";for(let s of t)n+=String.fromCharCode(s);return btoa(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function Le(e){return{challenge:G(e.challenge),rp:e.rp,user:{...e.user,id:G(e.user.id)},pubKeyCredParams:e.pubKeyCredParams,...e.timeout!==void 0?{timeout:e.timeout}:{},...e.excludeCredentials?{excludeCredentials:e.excludeCredentials.map((t)=>({...t,id:G(t.id)}))}:{},...e.authenticatorSelection?{authenticatorSelection:e.authenticatorSelection}:{},...e.attestation?{attestation:e.attestation}:{},...e.extensions?{extensions:e.extensions}:{}}}var Be=(e,t)=>fetch(e,t);class K{fetchFn;constructor(e={}){this.fetchFn=e.fetch??Be}async fetchAccount(){return(await D(await this.fetchFn("/auth/account",{credentials:"same-origin",cache:"no-store"}),Y)).account}async mutatePluginSettings(e){return(await D(await this.fetchFn("/auth/account/plugin-settings",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),Y)).account}async mutateAccount(e){return D(await this.fetchFn("/auth/account/mutations",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),_e)}async registerPasskey(){let e=await D(await this.fetchFn("/auth/account/passkeys/options",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:"{}"}),je),t=await navigator.credentials.create({publicKey:Le(e)});if(!(t instanceof PublicKeyCredential))throw Error("Passkey registration was cancelled");if(!(t.response instanceof AuthenticatorAttestationResponse))throw Error("Authenticator returned an invalid passkey response");let n=t.response,s={id:t.id,rawId:W(t.rawId),type:t.type,...t.authenticatorAttachment?{authenticatorAttachment:t.authenticatorAttachment}:{},clientExtensionResults:t.getClientExtensionResults(),response:{clientDataJSON:W(n.clientDataJSON),attestationObject:W(n.attestationObject),transports:typeof n.getTransports==="function"?n.getTransports():[]}};return(await D(await this.fetchFn("/auth/account/passkeys/verify",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),Y.extend({verified:a.literal(!0)}))).account}}function ie(e){return e.length===0?e:`${e.slice(0,1).toUpperCase()}${e.slice(1)}`}function se(e){return e.split(/\s+/).filter(Boolean).slice(0,2).map((t)=>t.slice(0,1).toUpperCase()).join("")}function ae(e,t){let n=t.indexOf("/");if(n<=0||n===t.length-1)return;let s=t.slice(0,n),o=t.slice(n+1);return`${e==="/"?"":e.replace(/\/+$/,"")}/entities/${encodeURIComponent(s)}/${encodeURIComponent(o)}`}function F(e,t=!1){return new Date(t?e:e*1000).toISOString()}var b=f(C(),1);function _(e){return b.jsxDEV(y,{variant:e.tone==="danger"?"danger":e.tone==="primary"?"primary":"outline",type:e.type??"button",onClick:e.onClick,disabled:e.disabled,children:e.children},void 0,!1,void 0,this)}function j(e){return b.jsxDEV("div",{className:i("account-access-item",c.access),children:[b.jsxDEV(re,{density:"comfortable",title:e.kind,description:e.description,metadata:e.metadata??[]},void 0,!1,void 0,this),e.action]},void 0,!0,void 0,this)}function P(e){return b.jsxDEV("section",{className:i("account-detail-section",c.section),children:[b.jsxDEV("div",{className:"account-section-label",children:[b.jsxDEV("h3",{className:i("",c.heading,q.section),children:e.title},void 0,!1,void 0,this),e.description?b.jsxDEV("p",{className:i("",c.description),children:e.description},void 0,!1,void 0,this):null]},void 0,!0,void 0,this),b.jsxDEV("div",{className:i("people-stack",c.stack),children:e.children},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ce(e,t){let n=Object.fromEntries(t.entries());for(let s of e)if(s.control==="checkbox")n[s.name]=t.has(s.name);else if(s.control==="number"&&typeof n[s.name]==="string"&&n[s.name]!=="")n[s.name]=Number(n[s.name]);return n}function le(e){if(e.secret)return"password";if(e.control==="url"||e.control==="number")return e.control;return"text"}var r=f(C(),1);function me(e){let{account:t,actions:n,title:s,studioPath:o}=e,g=t.role,m=t.profileEntityId?ae(o,t.profileEntityId):void 0;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV(P,{title:"Profile",children:[r.jsxDEV("div",{className:i("account-identity",c.identity),children:r.jsxDEV("div",{className:i("people-detail-person",c.person),children:[r.jsxDEV("span",{className:i("people-avatar people-avatar--large",c.avatar),children:se(s)},void 0,!1,void 0,this),r.jsxDEV("span",{className:i("",c.personCopy),children:[r.jsxDEV("span",{className:i("people-detail-name",c.name,q.secondaryDisplay),children:s},void 0,!1,void 0,this),r.jsxDEV("span",{"data-account-role":g,className:i("account-role",c.role),children:ie(g)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),t.profileEntityId?r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:i("account-profile-note",c.description),children:"Managed by the Anchor profile — your account name follows the published profile."},void 0,!1,void 0,this),r.jsxDEV(j,{kind:"Anchor profile",description:s,action:m?r.jsxDEV(y,{asChild:!0,variant:"link",children:r.jsxDEV("a",{href:m,children:"Edit Anchor Profile →"},void 0,!1,void 0,this)},void 0,!1,void 0,this):void 0},void 0,!1,void 0,this)]},void 0,!0,void 0,this):r.jsxDEV("form",{className:i("name-form",c.form),onSubmit:(x)=>{x.preventDefault(),n.saveName()},children:[r.jsxDEV("label",{className:i("",c.formLabel),htmlFor:"display-name",children:"Display name"},void 0,!1,void 0,this),r.jsxDEV(X,{id:"display-name",maxLength:200,autoComplete:"name",required:!0,value:n.displayName,onChange:(x)=>n.setDisplayName(x.target.value)},void 0,!1,void 0,this),r.jsxDEV(_,{type:"submit",disabled:n.busy,children:"Save name"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV("p",{className:i("",c.description),children:"Your role controls access to this brain. An administrator manages access in Administration."},void 0,!1,void 0,this),g==="admin"&&r.jsxDEV(y,{asChild:!0,variant:"outline",children:r.jsxDEV("a",{href:de(o,"admin:administration"),children:"Manage people in Administration →"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ge(e){let t=e.account.connectedChannels;return r.jsxDEV(P,{title:"Linked identities",description:"How this brain recognizes messages from you. These are your identities, not services configured for the whole brain.",children:t.length===0?r.jsxDEV("p",{className:i("people-empty",c.empty),children:"No linked identities."},void 0,!1,void 0,this):t.map((n)=>r.jsxDEV(j,{kind:n.type,description:n.label,metadata:[`Verified: ${F(n.verifiedAt,!0)}`]},`${n.type}:${n.label}`,!1,void 0,this))},void 0,!1,void 0,this)}function fe(e){let{account:t,actions:n}=e;return r.jsxDEV(r.Fragment,{children:[r.jsxDEV("p",{className:i("",c.description),children:"Settings for your account only. These do not configure shared services for the brain."},void 0,!1,void 0,this),t.pluginSettings.map((s)=>r.jsxDEV(pe,{label:s.title,density:"comfortable",presentation:"disclosure",children:[r.jsxDEV("p",{className:i("account-settings-description",c.description),children:s.description??"Private settings for this account."},void 0,!1,void 0,this),r.jsxDEV("form",{className:i("name-form",c.form),onSubmit:(o)=>{o.preventDefault(),n.saveSettings(s,new FormData(o.currentTarget))},children:[s.fields.map((o)=>r.jsxDEV("label",{htmlFor:`setting-${s.id}-${o.name}`,className:i("",c.field),children:[r.jsxDEV("span",{className:i("",c.formLabel),children:o.label},void 0,!1,void 0,this),o.control==="checkbox"?r.jsxDEV(ue,{id:`setting-${s.id}-${o.name}`,name:o.name,defaultChecked:o.value===!0},void 0,!1,void 0,this):r.jsxDEV(X,{id:`setting-${s.id}-${o.name}`,name:o.name,type:le(o),required:o.required&&(!s.configured||o.secret)&&!o.set,defaultValue:o.secret?"":typeof o.value==="string"||typeof o.value==="number"?o.value:"",placeholder:o.secret&&o.set?"Stored — leave blank to keep":void 0,autoComplete:"off"},void 0,!1,void 0,this)]},o.name,!0,void 0,this)),r.jsxDEV("div",{className:i("people-inline-actions",c.inlineActions),children:[r.jsxDEV(_,{type:"submit",tone:"primary",disabled:n.busy,children:"Save settings"},void 0,!1,void 0,this),s.configured?r.jsxDEV(y,{variant:"danger",disabled:n.busy,type:"button",onClick:()=>n.removeSettings(s),children:"Remove"},void 0,!1,void 0,this):null]},void 0,!0,void 0,this)]},`${s.id}:${s.revision??"unset"}`,!0,void 0,this)]},s.id,!0,void 0,this))]},void 0,!0,void 0,this)}function ye(e){let{account:t,actions:n}=e,{busy:s}=n;return r.jsxDEV("div",{className:i("",c.column),children:[r.jsxDEV(P,{title:"Sign-in",description:"Passkeys used to access this account. Your final passkey is protected from revocation.",children:[t.passkeys.map((o)=>r.jsxDEV(j,{kind:o.credentialBackedUp?"Synced passkey":"Device passkey",metadata:[`Added: ${F(o.createdAt,!0)}`],action:t.passkeys.length>1?r.jsxDEV(y,{variant:"danger",disabled:s,type:"button",onClick:()=>n.revokePasskey(o.id),children:"Revoke"},void 0,!1,void 0,this):void 0},o.id,!1,void 0,this)),r.jsxDEV("div",{className:i("people-inline-actions",c.inlineActions),children:r.jsxDEV(y,{variant:"outline",disabled:s,type:"button",onClick:n.addPasskey,children:"Add passkey"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),r.jsxDEV(P,{title:"Signed-in sessions",children:t.sessions.map((o)=>r.jsxDEV(j,{kind:o.current?"This session":"Browser session",metadata:[`Started: ${F(o.createdAt)}`,...o.current?["Current browser"]:[]],action:!o.current?r.jsxDEV(y,{variant:"danger",disabled:s,type:"button",onClick:()=>n.revokeSession(o.id),children:"End"},void 0,!1,void 0,this):void 0},o.id,!1,void 0,this))},void 0,!1,void 0,this),r.jsxDEV("footer",{className:i("account-session-actions",c.footer),children:[r.jsxDEV("small",{children:"Access changes require an Admin."},void 0,!1,void 0,this),r.jsxDEV("div",{className:i("",c.actions),children:[r.jsxDEV(_,{disabled:s||t.sessions.every((o)=>o.current),onClick:n.revokeOtherSessions,children:"End other sessions"},void 0,!1,void 0,this),r.jsxDEV(_,{tone:"danger",disabled:s,onClick:n.revokeAllSessions,children:"Sign out everywhere"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var be=f(Q(),1);var p={clients:{k1xSpc:"xrvj5dj",kumcoG:"x12p5jtz",kOIVth:"x1af02g3",k7Eaqz:"xeuugli",$$css:!0},client:{k7Eaqz:"xeuugli",k1xSpc:"xrvj5dj",kfiyM8:"x10ukxgv",kOIVth:"x883omv",kmVPX3:"x1np1h16",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",kWkggS:"x18s3upu",$$css:!0},clientName:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},text:{kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},steps:{kogj98:"x1ghz6dp",kE3dHu:"x5tiur9",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",kLWn49:"x1dbl2gt",kMwMTN:"x1ar3pfp",$$css:!0},fields:{k1xSpc:"xrvj5dj",kumcoG:"x16lqc3j",kOIVth:"x1vtxxvk",kogj98:"x1ghz6dp",kMv6JI:"x5ddh9m",kGuDYH:"x4z9k3i",$$css:!0},field:{k1xSpc:"xjp7ctv",$$css:!0},fieldLabel:{k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},fieldValue:{kogj98:"x1ghz6dp",k7Eaqz:"xeuugli",kHjlTd:"xj0a0fe",kMwMTN:"x1ar3pfp",$$css:!0},code:{kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x12oqio5",kmVPX3:"x1nyoefi",$$css:!0},snippet:{k1xSpc:"x78zum5",kGNEyG:"x1cy8zhl",kOIVth:"x167g77z",k7Eaqz:"xeuugli",$$css:!0},snippetCode:{kUk6DE:"x98rzlu",k7Eaqz:"xeuugli",kogj98:"x1ghz6dp",kmVPX3:"x6yrr3s",kMv6JI:"xa9opjo",kGuDYH:"xfifm61",kLWn49:"x1jjo3f5",kMwMTN:"xqvuw85",kWkggS:"xbslqsl",kaIpWk:"x1kogg8i",khDVqt:"x1sdyfia",kXHlph:"xw2csxc",$$css:!0},developer:{k7Eaqz:"xeuugli",kmVPX3:"x1d8yrva",kMzoRj:"xmkeg23",ksu8eU:"x1y0btm7",kVAM5u:"xy1lt07",kaIpWk:"xur7f20",$$css:!0},developerSummary:{kkrTdU:"x1ypdohk",kMv6JI:"x5ddh9m",kGuDYH:"xif65rj",k63SB2:"x1s688f",kMwMTN:"xqvuw85",$$css:!0},developerClients:{keoZOQ:"x1hmvnq2",kumcoG:"x1mkdm3x",$$css:!0},developerHint:{k1xSpc:"x1lliihq",keoZOQ:"x1gslohp",k63SB2:"xo1l8bm",kGuDYH:"xfifm61",kMwMTN:"x1ar3pfp",$$css:!0}};function He(e){return new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Z(e){return JSON.stringify(e,null,2)}function he(e,t,n){return["Already have servers there? Add only the ",{code:`"${n}"`}," entry inside ",{code:`"${t}"`},` of ${e}.`]}function Ae(e){let t=He(e),n="Sign in with your passkey when asked.";return[{id:"claude",group:"primary",name:"Claude",note:["Desktop app and claude.ai."],steps:[["Open Settings → Connectors → Add custom connector."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when asked."]]},{id:"chatgpt",group:"primary",name:"ChatGPT",steps:[["Open Settings → Apps & Connectors → Advanced and turn on Developer mode."],["Choose Create, name it ",{code:t},", paste your brain’s address and pick OAuth."],["Sign in with your passkey when asked."]]},{id:"claude-code",group:"developer",name:"Claude Code",lead:[["Add the server in your terminal:"]],snippet:{label:"Claude Code command",code:`claude mcp add --transport http ${t} ${e}`},after:[["Then start Claude Code, run ",{code:"/mcp"},", choose ",{code:t}," and sign in with your passkey."]]},{id:"cursor",group:"developer",name:"Cursor",steps:[["Open Cursor Settings → MCP → Add new global MCP server."],["Name it ",{code:t}," and paste your brain’s address."],["Sign in with your passkey when Cursor asks."]],lead:[["Or add it to ",{code:"~/.cursor/mcp.json"},":"]],snippet:{label:"Cursor configuration",code:Z({mcpServers:{[t]:{url:e}}})},after:[he("the file","mcpServers",t)]},{id:"vscode",group:"developer",name:"VS Code",steps:[["Open the Command Palette and run ",{code:"MCP: Add Server"},"."],["Choose HTTP, paste your brain’s address and name it ",{code:t},"."],["Choose Global, then sign in with your passkey when asked."]],lead:[["Or run ",{code:"MCP: Open User Configuration"}," and add:"]],snippet:{label:"VS Code configuration",code:Z({servers:{[t]:{type:"http",url:e}}})},after:[he("your user configuration","servers",t)]},{id:"other",group:"developer",name:"Any other MCP client",inlineName:"any other MCP client",note:["Look for “add MCP server”, “connector” or “integration” in the tool’s settings and fill in:"],fields:[{label:"Name",value:[{code:t}]},{label:"Type",value:["Remote server, Streamable HTTP — not stdio, not SSE"]},{label:"URL",value:[{code:e}]},{label:"Authentication",value:["OAuth. Leave API key, token, client ID and secret empty; the tool registers itself."]}],lead:[["When you connect, your browser opens “Authorize <tool>?” on your brain. Approve MCP access with your passkey. The tool then has two tools: ",{code:"chat"},", to ask your brain anything as you would in chat, and ",{code:"confirm"},", to approve changes when the brain asks."],["Tool only takes local (stdio) servers, or insists on an API key? Bridge it with ",{code:"mcp-remote"},", which handles the sign-in:"]],snippet:{label:"mcp-remote bridge configuration",code:Z({mcpServers:{[t]:{command:"npx",args:["-y","mcp-remote",e]}}})}}]}var l=f(C(),1);function L(e){return l.jsxDEV(l.Fragment,{children:e.text.map((t,n)=>typeof t==="string"?t:l.jsxDEV("code",{className:i("",p.code),children:t.code},n,!1,void 0,this))},void 0,!1,void 0,this)}function ve(e){let[t,n]=be.useState("idle"),s=async()=>{try{await navigator.clipboard.writeText(e.code),n("copied")}catch{n("unavailable")}};return l.jsxDEV("div",{className:i("ai-tools-snippet",p.snippet),children:[l.jsxDEV("pre",{className:i("",p.snippetCode),"aria-label":e.label,children:e.code},void 0,!1,void 0,this),l.jsxDEV(y,{variant:"outline",size:"sm",onClick:()=>void s(),"aria-label":`Copy ${e.label}`,children:t==="copied"?"Copied":t==="unavailable"?"Select to copy":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ke(e){let{client:t}=e;return l.jsxDEV("article",{className:i("ai-tools-client",p.client),children:[l.jsxDEV("h4",{className:i("",p.clientName),children:t.name},void 0,!1,void 0,this),t.note?l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:t.note},void 0,!1,void 0,this)},void 0,!1,void 0,this):null,t.steps?l.jsxDEV("ol",{className:i("",p.steps),children:t.steps.map((n,s)=>l.jsxDEV("li",{children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},s,!1,void 0,this))},void 0,!1,void 0,this):null,t.fields?l.jsxDEV("dl",{className:i("",p.fields),children:t.fields.map((n)=>l.jsxDEV("div",{className:i("",p.field),children:[l.jsxDEV("dt",{className:i("",p.fieldLabel),children:n.label},void 0,!1,void 0,this),l.jsxDEV("dd",{className:i("",p.fieldValue),children:l.jsxDEV(L,{text:n.value},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},n.label,!0,void 0,this))},void 0,!1,void 0,this):null,t.lead?.map((n,s)=>l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},`lead-${s}`,!1,void 0,this)),t.snippet?l.jsxDEV(ve,{...t.snippet},void 0,!1,void 0,this):null,t.after?.map((n,s)=>l.jsxDEV("p",{className:i("",p.text),children:l.jsxDEV(L,{text:n},void 0,!1,void 0,this)},`after-${s}`,!1,void 0,this))]},void 0,!0,void 0,this)}function Fe(e){return e.length<2?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`}function Se(e){let t=Ae(e.mcpUrl),n=t.filter((o)=>o.group==="primary"),s=t.filter((o)=>o.group==="developer");return l.jsxDEV(P,{title:"AI tools",description:"Connect AI tools you already use to this brain. A connected tool talks to the brain as you do in chat — asking, saving and updating within your access — after you sign in with your passkey.",children:[l.jsxDEV("article",{className:i("ai-tools-address",p.client),children:[l.jsxDEV("h4",{className:i("",p.clientName),children:"Your brain’s address"},void 0,!1,void 0,this),l.jsxDEV(ve,{label:"brain address",code:e.mcpUrl},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:i("ai-tools-clients",p.clients),children:n.map((o)=>l.jsxDEV(ke,{client:o},o.id,!1,void 0,this))},void 0,!1,void 0,this),l.jsxDEV("details",{className:i("ai-tools-developer",p.developer),children:[l.jsxDEV("summary",{className:i("",p.developerSummary),children:["Developer tools and other clients",l.jsxDEV("span",{className:i("",p.developerHint),children:Fe(s.map((o)=>o.inlineName??o.name))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l.jsxDEV("div",{className:i("ai-tools-clients",p.clients,p.developerClients),children:s.map((o)=>l.jsxDEV(ke,{client:o},o.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var A=f(Q(),1);var h={updateDisplayName:"updateDisplayName",revokePasskey:"revokePasskey",revokeSession:"revokeSession",revokeOtherSessions:"revokeOtherSessions",revokeAllSessions:"revokeAllSessions"};var ee={revokePasskey:{title:"Revoke this passkey?",message:"You will not be able to use this passkey again.",confirmLabel:"Revoke passkey",pending:"Revoking passkey…",complete:"Passkey revoked."},revokeSession:{title:"End this browser session?",message:"That browser will need a passkey to sign in again.",confirmLabel:"End session",pending:"Ending session…",complete:"Session ended."},revokeOtherSessions:{title:"End every other browser session?",message:"Your current browser will remain signed in.",confirmLabel:"End other sessions",pending:"Ending other sessions…",complete:"Other sessions ended."}};function Te(e){return Ce(e,"Account request failed")}function xe(e){let{client:t,initialAccount:n}=e,[s,o]=A.useState(n),[g,m]=A.useState(n?.displayName??e.initialDisplayName),[x,N]=A.useState(""),[v,S]=A.useState(!1),[T,B]=A.useState(!1),[U,R]=A.useState(null);A.useEffect(()=>{if(n)return;let d=!1;return t.fetchAccount().then((k)=>{if(d)return;o(k),m(k.displayName)}).catch((k)=>{if(d)return;S(!0),N(Te(k))}),()=>{d=!0}},[t,n]);let O=A.useCallback(async(d,k,J)=>{B(!0),S(!1),N(d);try{let E=await J();if(E)o(E),m(E.displayName);N(k)}catch(E){S(!0),N(Te(E))}finally{B(!1)}},[]),te=async(d)=>(await t.mutateAccount(d)).account,V=(d,k)=>R({title:d.title,message:d.message,confirmLabel:d.confirmLabel,action:()=>{O(d.pending,d.complete,()=>te(k))}});return{account:s,displayName:g,setDisplayName:m,status:x,error:v,busy:T,confirmation:U,cancelConfirmation:()=>R(null),confirm:()=>{if(!U)return;R(null),U.action()},saveName:()=>{O("Saving…","Display name updated.",()=>te({action:h.updateDisplayName,confirmation:h.updateDisplayName,displayName:g}))},addPasskey:()=>{O("Waiting for your authenticator…","Passkey added.",()=>t.registerPasskey())},revokePasskey:(d)=>V(ee.revokePasskey,{action:h.revokePasskey,confirmation:h.revokePasskey,credentialId:d}),revokeSession:(d)=>V(ee.revokeSession,{action:h.revokeSession,confirmation:h.revokeSession,sessionId:d}),revokeOtherSessions:()=>V(ee.revokeOtherSessions,{action:h.revokeOtherSessions,confirmation:h.revokeOtherSessions}),revokeAllSessions:()=>R({title:"Sign out everywhere?",message:"This ends every session, including this one. You will need your passkey to return.",confirmLabel:"Sign out everywhere",action:()=>{O("Signing out everywhere…","Signed out.",async()=>{await t.mutateAccount({action:h.revokeAllSessions,confirmation:h.revokeAllSessions}),window.location.assign(`/login?return_to=${encodeURIComponent(e.routePath)}`);return})}}),saveSettings:(d,k)=>{let J=ce(d.fields,k);O(`Saving ${d.title}…`,`${d.title} updated.`,()=>t.mutatePluginSettings({action:"save",definitionId:d.id,values:J}))},removeSettings:(d)=>R({title:`Remove ${d.title}?`,message:"The stored settings for this integration will be removed from your account only.",confirmLabel:"Remove settings",action:()=>{O(`Removing ${d.title}…`,`${d.title} removed.`,()=>t.mutatePluginSettings({action:"delete",definitionId:d.id}))}})}}var u=f(C(),1),qe=["profile","security","identities","settings",M];function ze(e){let t=qe.find((n)=>n===e.initialSection);if(!t||t===M&&!e.mcpUrl)return"profile";return t}function Ve(e){let t=["your profile","sign-in security","linked identities",...e.settings?["personal settings"]:[],...e.aiTools?["AI tools"]:[]];return`Your account on this brain. Manage ${`${t.slice(0,-1).join(", ")} and ${t.at(-1)}`} here—not shared services or other people’s access.`}function Rt({bootstrap:e,initialAccount:t,client:n}){let s=we(),o=z.useMemo(()=>n??new K({fetch:s.fetch}),[n,s]),g=xe({client:o,initialAccount:t,initialDisplayName:e.displayName,routePath:e.routePath}),{account:m,status:x,error:N,busy:v,confirmation:S}=g,[T,B]=z.useState(()=>ze(e)),U=m?.displayName??e.displayName;return u.jsxDEV(u.Fragment,{children:[u.jsxDEV("div",{className:i("account-shell",c.shell,Ie.inset),children:[u.jsxDEV(Ue,{model:{access:Me("public"),title:"Your account",totals:[]}},void 0,!1,void 0,this),u.jsxDEV("p",{className:i("account-scope",c.description),children:Ve({settings:(m?.pluginSettings.length??0)>0,aiTools:Boolean(e.mcpUrl)})},void 0,!1,void 0,this),u.jsxDEV("p",{className:i(`account-status${N?" is-error":""}`,c.feedback,N&&c.feedbackError),role:"status","aria-live":"polite",children:x},void 0,!1,void 0,this),!m?u.jsxDEV("p",{className:i("account-loading",c.loading),children:"Reading your account…"},void 0,!1,void 0,this):u.jsxDEV(Pe,{className:"account-details",value:T,onValueChange:B,children:[u.jsxDEV(Oe,{"aria-label":"Account sections",className:i("account-tabs",c.tabs),children:[u.jsxDEV(w,{value:"profile",disabled:v,children:"Profile"},void 0,!1,void 0,this),u.jsxDEV(w,{value:"security",disabled:v,children:"Sign-in & sessions"},void 0,!1,void 0,this),u.jsxDEV(w,{value:"identities",disabled:v,children:"Linked identities"},void 0,!1,void 0,this),m.pluginSettings.length>0&&u.jsxDEV(w,{value:"settings",disabled:v,children:"Personal settings"},void 0,!1,void 0,this),e.mcpUrl&&u.jsxDEV(w,{value:M,disabled:v,children:"AI tools"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u.jsxDEV(I,{value:"profile",forceMount:!0,hidden:T!=="profile",className:i("account-detail-sections",c.tabPanel),children:u.jsxDEV(me,{account:m,actions:g,title:U,studioPath:e.studioPath},void 0,!1,void 0,this)},void 0,!1,void 0,this),u.jsxDEV(I,{value:"identities",forceMount:!0,hidden:T!=="identities",className:i("",c.tabPanel),children:u.jsxDEV(ge,{account:m},void 0,!1,void 0,this)},void 0,!1,void 0,this),m.pluginSettings.length>0&&u.jsxDEV(I,{value:"settings",forceMount:!0,hidden:T!=="settings",className:i("",c.tabPanel),children:u.jsxDEV(fe,{account:m,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),u.jsxDEV(I,{value:"security",forceMount:!0,hidden:T!=="security",className:i("",c.tabPanel),children:u.jsxDEV(ye,{account:m,actions:g},void 0,!1,void 0,this)},void 0,!1,void 0,this),e.mcpUrl&&u.jsxDEV(I,{value:M,forceMount:!0,hidden:T!==M,className:i("",c.tabPanel),children:u.jsxDEV(Se,{mcpUrl:e.mcpUrl},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),S&&u.jsxDEV(Ne,{mark:"!",title:S.title,titleId:"account-confirmation-title",cancelLabel:"Cancel",confirmLabel:S.confirmLabel,confirmVariant:"danger",pending:v,onCancel:g.cancelConfirmation,onConfirm:g.confirm,children:u.jsxDEV("p",{children:S.message},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Rt as AccountApp};
2
2
 
3
3
  //# debugId=656B20FA7276BF9264756E2164756E21