@suveren/gateway 0.3.13 → 0.3.14

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.
@@ -22,7 +22,7 @@ var Yf=Object.defineProperty;var Qf=(e,t,n)=>t in e?Yf(e,t,{enumerable:!0,config
22
22
  *
23
23
  * This source code is licensed under the MIT license found in the
24
24
  * LICENSE file in the root directory of this source tree.
25
- */(function(e){function t(A,K){var T=A.length;A.push(K);e:for(;0<T;){var P=T-1>>>1,F=A[P];if(0<a(F,K))A[P]=K,A[T]=F,T=P;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var K=A[0],T=A.pop();if(T!==K){A[0]=T;e:for(var P=0,F=A.length,X=F>>>1;P<X;){var Y=2*(P+1)-1,le=A[Y],C=Y+1,D=A[C];if(0>a(le,T))C<F&&0>a(D,le)?(A[P]=D,A[C]=T,P=C):(A[P]=le,A[Y]=T,P=Y);else if(C<F&&0>a(D,T))A[P]=D,A[C]=T,P=C;else break e}}return K}function a(A,K){var T=A.sortIndex-K.sortIndex;return T!==0?T:A.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],p=1,m=null,g=3,w=!1,x=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(A){for(var K=n(u);K!==null;){if(K.callback===null)r(u);else if(K.startTime<=A)r(u),K.sortIndex=K.expirationTime,t(c,K);else break;K=n(u)}}function S(A){if(y=!1,v(A),!x)if(n(c)!==null)x=!0,ee(E);else{var K=n(u);K!==null&&ie(S,K.startTime-A)}}function E(A,K){x=!1,y&&(y=!1,h(N),N=-1),w=!0;var T=g;try{for(v(K),m=n(c);m!==null&&(!(m.expirationTime>K)||A&&!H());){var P=m.callback;if(typeof P=="function"){m.callback=null,g=m.priorityLevel;var F=P(m.expirationTime<=K);K=e.unstable_now(),typeof F=="function"?m.callback=F:m===n(c)&&r(c),v(K)}else r(c);m=n(c)}if(m!==null)var X=!0;else{var Y=n(u);Y!==null&&ie(S,Y.startTime-K),X=!1}return X}finally{m=null,g=T,w=!1}}var z=!1,k=null,N=-1,b=5,I=-1;function H(){return!(e.unstable_now()-I<b)}function U(){if(k!==null){var A=e.unstable_now();I=A;var K=!0;try{K=k(!0,A)}finally{K?O():(z=!1,k=null)}}else z=!1}var O;if(typeof f=="function")O=function(){f(U)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,B=R.port2;R.port1.onmessage=U,O=function(){B.postMessage(null)}}else O=function(){j(U,0)};function ee(A){k=A,z||(z=!0,O())}function ie(A,K){N=j(function(){A(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){x||w||(x=!0,ee(E))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):b=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(g){case 1:case 2:case 3:var K=3;break;default:K=g}var T=g;g=K;try{return A()}finally{g=T}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,K){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var T=g;g=A;try{return K()}finally{g=T}},e.unstable_scheduleCallback=function(A,K,T){var P=e.unstable_now();switch(typeof T=="object"&&T!==null?(T=T.delay,T=typeof T=="number"&&0<T?P+T:P):T=P,A){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=T+F,A={id:p++,callback:K,priorityLevel:A,startTime:T,expirationTime:F,sortIndex:-1},T>P?(A.sortIndex=T,t(u,A),n(c)===null&&A===n(u)&&(y?(h(N),N=-1):y=!0,ie(S,T-P))):(A.sortIndex=F,t(c,A),x||w||(x=!0,ee(E))),A},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(A){var K=g;return function(){var T=g;g=K;try{return A.apply(this,arguments)}finally{g=T}}}})(du);uu.exports=du;var vp=uu.exports;/**
25
+ */(function(e){function t(A,K){var T=A.length;A.push(K);e:for(;0<T;){var P=T-1>>>1,O=A[P];if(0<a(O,K))A[P]=K,A[T]=O,T=P;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var K=A[0],T=A.pop();if(T!==K){A[0]=T;e:for(var P=0,O=A.length,X=O>>>1;P<X;){var Y=2*(P+1)-1,le=A[Y],C=Y+1,D=A[C];if(0>a(le,T))C<O&&0>a(D,le)?(A[P]=D,A[C]=T,P=C):(A[P]=le,A[Y]=T,P=Y);else if(C<O&&0>a(D,T))A[P]=D,A[C]=T,P=C;else break e}}return K}function a(A,K){var T=A.sortIndex-K.sortIndex;return T!==0?T:A.id-K.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],p=1,h=null,m=3,w=!1,x=!1,y=!1,j=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(A){for(var K=n(u);K!==null;){if(K.callback===null)r(u);else if(K.startTime<=A)r(u),K.sortIndex=K.expirationTime,t(c,K);else break;K=n(u)}}function S(A){if(y=!1,v(A),!x)if(n(c)!==null)x=!0,ee(E);else{var K=n(u);K!==null&&ie(S,K.startTime-A)}}function E(A,K){x=!1,y&&(y=!1,g(N),N=-1),w=!0;var T=m;try{for(v(K),h=n(c);h!==null&&(!(h.expirationTime>K)||A&&!H());){var P=h.callback;if(typeof P=="function"){h.callback=null,m=h.priorityLevel;var O=P(h.expirationTime<=K);K=e.unstable_now(),typeof O=="function"?h.callback=O:h===n(c)&&r(c),v(K)}else r(c);h=n(c)}if(h!==null)var X=!0;else{var Y=n(u);Y!==null&&ie(S,Y.startTime-K),X=!1}return X}finally{h=null,m=T,w=!1}}var z=!1,k=null,N=-1,b=5,I=-1;function H(){return!(e.unstable_now()-I<b)}function U(){if(k!==null){var A=e.unstable_now();I=A;var K=!0;try{K=k(!0,A)}finally{K?B():(z=!1,k=null)}}else z=!1}var B;if(typeof f=="function")B=function(){f(U)};else if(typeof MessageChannel<"u"){var R=new MessageChannel,F=R.port2;R.port1.onmessage=U,B=function(){F.postMessage(null)}}else B=function(){j(U,0)};function ee(A){k=A,z||(z=!0,B())}function ie(A,K){N=j(function(){A(e.unstable_now())},K)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(A){A.callback=null},e.unstable_continueExecution=function(){x||w||(x=!0,ee(E))},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):b=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(A){switch(m){case 1:case 2:case 3:var K=3;break;default:K=m}var T=m;m=K;try{return A()}finally{m=T}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(A,K){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var T=m;m=A;try{return K()}finally{m=T}},e.unstable_scheduleCallback=function(A,K,T){var P=e.unstable_now();switch(typeof T=="object"&&T!==null?(T=T.delay,T=typeof T=="number"&&0<T?P+T:P):T=P,A){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=T+O,A={id:p++,callback:K,priorityLevel:A,startTime:T,expirationTime:O,sortIndex:-1},T>P?(A.sortIndex=T,t(u,A),n(c)===null&&A===n(u)&&(y?(g(N),N=-1):y=!0,ie(S,T-P))):(A.sortIndex=O,t(c,A),x||w||(x=!0,ee(E))),A},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(A){var K=m;return function(){var T=m;m=K;try{return A.apply(this,arguments)}finally{m=T}}}})(du);uu.exports=du;var vp=uu.exports;/**
26
26
  * @license React
27
27
  * react-dom.production.min.js
28
28
  *
@@ -34,10 +34,10 @@ var Yf=Object.defineProperty;var Qf=(e,t,n)=>t in e?Yf(e,t,{enumerable:!0,config
34
34
  `+Do+e}var Uo=!1;function Wo(e,t){if(!e||Uo)return"";Uo=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var a=u.stack.split(`
35
35
  `),s=r.stack.split(`
36
36
  `),i=a.length-1,l=s.length-1;1<=i&&0<=l&&a[i]!==s[l];)l--;for(;1<=i&&0<=l;i--,l--)if(a[i]!==s[l]){if(i!==1||l!==1)do if(i--,l--,0>l||a[i]!==s[l]){var c=`
37
- `+a[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=l);break}}}finally{Uo=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?br(e):""}function kp(e){switch(e.tag){case 5:return br(e.type);case 16:return br("Lazy");case 13:return br("Suspense");case 19:return br("SuspenseList");case 0:case 2:case 15:return e=Wo(e.type,!1),e;case 11:return e=Wo(e.type.render,!1),e;case 1:return e=Wo(e.type,!0),e;default:return""}}function ks(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Bn:return"Fragment";case On:return"Portal";case ws:return"Profiler";case Ei:return"StrictMode";case Ss:return"Suspense";case js:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case mu:return(e.displayName||"Context")+".Consumer";case pu:return(e._context.displayName||"Context")+".Provider";case zi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ii:return t=e.displayName||null,t!==null?t:ks(e.type)||"Memo";case Yt:t=e._payload,e=e._init;try{return ks(e(t))}catch{}}return null}function Cp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ks(t);case 8:return t===Ei?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function un(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function bp(e){var t=gu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pa(e){e._valueTracker||(e._valueTracker=bp(e))}function vu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ka(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Cs(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Il(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=un(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function yu(e,t){t=t.checked,t!=null&&Ni(e,"checked",t,!1)}function bs(e,t){yu(e,t);var n=un(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ns(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ns(e,t.type,un(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Pl(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ns(e,t,n){(t!=="number"||Ka(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Nr=Array.isArray;function Xn(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+un(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Es(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return ye({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Tl(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(M(92));if(Nr(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:un(n)}}function xu(e,t){var n=un(t.value),r=un(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Rl(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function wu(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function zs(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?wu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var ma,Su=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(ma=ma||document.createElement("div"),ma.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ma.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Dr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Np=["Webkit","ms","Moz","O"];Object.keys(Pr).forEach(function(e){Np.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pr[t]=Pr[e]})});function ju(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Pr.hasOwnProperty(e)&&Pr[e]?(""+t).trim():t+"px"}function ku(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=ju(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Ep=ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Is(e,t){if(t){if(Ep[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(M(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(M(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(M(61))}if(t.style!=null&&typeof t.style!="object")throw Error(M(62))}}function Ps(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ts=null;function Pi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rs=null,qn=null,Zn=null;function _l(e){if(e=ia(e)){if(typeof Rs!="function")throw Error(M(280));var t=e.stateNode;t&&(t=bo(t),Rs(e.stateNode,e.type,t))}}function Cu(e){qn?Zn?Zn.push(e):Zn=[e]:qn=e}function bu(){if(qn){var e=qn,t=Zn;if(Zn=qn=null,_l(e),t)for(e=0;e<t.length;e++)_l(t[e])}}function Nu(e,t){return e(t)}function Eu(){}var Ho=!1;function zu(e,t,n){if(Ho)return e(t,n);Ho=!0;try{return Nu(e,t,n)}finally{Ho=!1,(qn!==null||Zn!==null)&&(Eu(),bu())}}function Ur(e,t){var n=e.stateNode;if(n===null)return null;var r=bo(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(M(231,t,typeof n));return n}var _s=!1;if(Bt)try{var vr={};Object.defineProperty(vr,"passive",{get:function(){_s=!0}}),window.addEventListener("test",vr,vr),window.removeEventListener("test",vr,vr)}catch{_s=!1}function zp(e,t,n,r,a,s,i,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Tr=!1,Ga=null,Ya=!1,As=null,Ip={onError:function(e){Tr=!0,Ga=e}};function Pp(e,t,n,r,a,s,i,l,c){Tr=!1,Ga=null,zp.apply(Ip,arguments)}function Tp(e,t,n,r,a,s,i,l,c){if(Pp.apply(this,arguments),Tr){if(Tr){var u=Ga;Tr=!1,Ga=null}else throw Error(M(198));Ya||(Ya=!0,As=u)}}function An(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Iu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Al(e){if(An(e)!==e)throw Error(M(188))}function Rp(e){var t=e.alternate;if(!t){if(t=An(e),t===null)throw Error(M(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return Al(a),e;if(s===r)return Al(a),t;s=s.sibling}throw Error(M(188))}if(n.return!==r.return)n=a,r=s;else{for(var i=!1,l=a.child;l;){if(l===n){i=!0,n=a,r=s;break}if(l===r){i=!0,r=a,n=s;break}l=l.sibling}if(!i){for(l=s.child;l;){if(l===n){i=!0,n=s,r=a;break}if(l===r){i=!0,r=s,n=a;break}l=l.sibling}if(!i)throw Error(M(189))}}if(n.alternate!==r)throw Error(M(190))}if(n.tag!==3)throw Error(M(188));return n.stateNode.current===n?e:t}function Pu(e){return e=Rp(e),e!==null?Tu(e):null}function Tu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Tu(e);if(t!==null)return t;e=e.sibling}return null}var Ru=at.unstable_scheduleCallback,$l=at.unstable_cancelCallback,_p=at.unstable_shouldYield,Ap=at.unstable_requestPaint,we=at.unstable_now,$p=at.unstable_getCurrentPriorityLevel,Ti=at.unstable_ImmediatePriority,_u=at.unstable_UserBlockingPriority,Qa=at.unstable_NormalPriority,Lp=at.unstable_LowPriority,Au=at.unstable_IdlePriority,So=null,Pt=null;function Mp(e){if(Pt&&typeof Pt.onCommitFiberRoot=="function")try{Pt.onCommitFiberRoot(So,e,void 0,(e.current.flags&128)===128)}catch{}}var St=Math.clz32?Math.clz32:Bp,Fp=Math.log,Op=Math.LN2;function Bp(e){return e>>>=0,e===0?32:31-(Fp(e)/Op|0)|0}var ha=64,ga=4194304;function Er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ja(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~a;l!==0?r=Er(l):(s&=i,s!==0&&(r=Er(s)))}else i=n&~a,i!==0?r=Er(i):s!==0&&(r=Er(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,s=t&-t,a>=s||a===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-St(t),a=1<<n,r|=e[n],t&=~a;return r}function Dp(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Up(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-St(s),l=1<<i,c=a[i];c===-1?(!(l&n)||l&r)&&(a[i]=Dp(l,t)):c<=t&&(e.expiredLanes|=l),s&=~l}}function $s(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function $u(){var e=ha;return ha<<=1,!(ha&4194240)&&(ha=64),e}function Vo(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-St(t),e[t]=n}function Wp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-St(n),s=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~s}}function Ri(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-St(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var se=0;function Lu(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Mu,_i,Fu,Ou,Bu,Ls=!1,va=[],tn=null,nn=null,rn=null,Wr=new Map,Hr=new Map,Xt=[],Hp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ll(e,t){switch(e){case"focusin":case"focusout":tn=null;break;case"dragenter":case"dragleave":nn=null;break;case"mouseover":case"mouseout":rn=null;break;case"pointerover":case"pointerout":Wr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hr.delete(t.pointerId)}}function yr(e,t,n,r,a,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[a]},t!==null&&(t=ia(t),t!==null&&_i(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Vp(e,t,n,r,a){switch(t){case"focusin":return tn=yr(tn,e,t,n,r,a),!0;case"dragenter":return nn=yr(nn,e,t,n,r,a),!0;case"mouseover":return rn=yr(rn,e,t,n,r,a),!0;case"pointerover":var s=a.pointerId;return Wr.set(s,yr(Wr.get(s)||null,e,t,n,r,a)),!0;case"gotpointercapture":return s=a.pointerId,Hr.set(s,yr(Hr.get(s)||null,e,t,n,r,a)),!0}return!1}function Du(e){var t=jn(e.target);if(t!==null){var n=An(t);if(n!==null){if(t=n.tag,t===13){if(t=Iu(n),t!==null){e.blockedOn=t,Bu(e.priority,function(){Fu(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function _a(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ms(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ts=r,n.target.dispatchEvent(r),Ts=null}else return t=ia(n),t!==null&&_i(t),e.blockedOn=n,!1;t.shift()}return!0}function Ml(e,t,n){_a(e)&&n.delete(t)}function Kp(){Ls=!1,tn!==null&&_a(tn)&&(tn=null),nn!==null&&_a(nn)&&(nn=null),rn!==null&&_a(rn)&&(rn=null),Wr.forEach(Ml),Hr.forEach(Ml)}function xr(e,t){e.blockedOn===t&&(e.blockedOn=null,Ls||(Ls=!0,at.unstable_scheduleCallback(at.unstable_NormalPriority,Kp)))}function Vr(e){function t(a){return xr(a,e)}if(0<va.length){xr(va[0],e);for(var n=1;n<va.length;n++){var r=va[n];r.blockedOn===e&&(r.blockedOn=null)}}for(tn!==null&&xr(tn,e),nn!==null&&xr(nn,e),rn!==null&&xr(rn,e),Wr.forEach(t),Hr.forEach(t),n=0;n<Xt.length;n++)r=Xt[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Xt.length&&(n=Xt[0],n.blockedOn===null);)Du(n),n.blockedOn===null&&Xt.shift()}var er=Vt.ReactCurrentBatchConfig,Xa=!0;function Gp(e,t,n,r){var a=se,s=er.transition;er.transition=null;try{se=1,Ai(e,t,n,r)}finally{se=a,er.transition=s}}function Yp(e,t,n,r){var a=se,s=er.transition;er.transition=null;try{se=4,Ai(e,t,n,r)}finally{se=a,er.transition=s}}function Ai(e,t,n,r){if(Xa){var a=Ms(e,t,n,r);if(a===null)ts(e,t,r,qa,n),Ll(e,r);else if(Vp(a,e,t,n,r))r.stopPropagation();else if(Ll(e,r),t&4&&-1<Hp.indexOf(e)){for(;a!==null;){var s=ia(a);if(s!==null&&Mu(s),s=Ms(e,t,n,r),s===null&&ts(e,t,r,qa,n),s===a)break;a=s}a!==null&&r.stopPropagation()}else ts(e,t,r,null,n)}}var qa=null;function Ms(e,t,n,r){if(qa=null,e=Pi(r),e=jn(e),e!==null)if(t=An(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Iu(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return qa=e,null}function Uu(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($p()){case Ti:return 1;case _u:return 4;case Qa:case Lp:return 16;case Au:return 536870912;default:return 16}default:return 16}}var Zt=null,$i=null,Aa=null;function Wu(){if(Aa)return Aa;var e,t=$i,n=t.length,r,a="value"in Zt?Zt.value:Zt.textContent,s=a.length;for(e=0;e<n&&t[e]===a[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===a[s-r];r++);return Aa=a.slice(e,1<r?1-r:void 0)}function $a(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ya(){return!0}function Fl(){return!1}function st(e){function t(n,r,a,s,i){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?ya:Fl,this.isPropagationStopped=Fl,this}return ye(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=ya)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ya)},persist:function(){},isPersistent:ya}),t}var dr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Li=st(dr),sa=ye({},dr,{view:0,detail:0}),Qp=st(sa),Ko,Go,wr,jo=ye({},sa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mi,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==wr&&(wr&&e.type==="mousemove"?(Ko=e.screenX-wr.screenX,Go=e.screenY-wr.screenY):Go=Ko=0,wr=e),Ko)},movementY:function(e){return"movementY"in e?e.movementY:Go}}),Ol=st(jo),Jp=ye({},jo,{dataTransfer:0}),Xp=st(Jp),qp=ye({},sa,{relatedTarget:0}),Yo=st(qp),Zp=ye({},dr,{animationName:0,elapsedTime:0,pseudoElement:0}),em=st(Zp),tm=ye({},dr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),nm=st(tm),rm=ye({},dr,{data:0}),Bl=st(rm),am={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},om={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},sm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function im(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=sm[e])?!!t[e]:!1}function Mi(){return im}var lm=ye({},sa,{key:function(e){if(e.key){var t=am[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=$a(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?om[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mi,charCode:function(e){return e.type==="keypress"?$a(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?$a(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),cm=st(lm),um=ye({},jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dl=st(um),dm=ye({},sa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mi}),fm=st(dm),pm=ye({},dr,{propertyName:0,elapsedTime:0,pseudoElement:0}),mm=st(pm),hm=ye({},jo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),gm=st(hm),vm=[9,13,27,32],Fi=Bt&&"CompositionEvent"in window,Rr=null;Bt&&"documentMode"in document&&(Rr=document.documentMode);var ym=Bt&&"TextEvent"in window&&!Rr,Hu=Bt&&(!Fi||Rr&&8<Rr&&11>=Rr),Ul=" ",Wl=!1;function Vu(e,t){switch(e){case"keyup":return vm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ku(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Dn=!1;function xm(e,t){switch(e){case"compositionend":return Ku(t);case"keypress":return t.which!==32?null:(Wl=!0,Ul);case"textInput":return e=t.data,e===Ul&&Wl?null:e;default:return null}}function wm(e,t){if(Dn)return e==="compositionend"||!Fi&&Vu(e,t)?(e=Wu(),Aa=$i=Zt=null,Dn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Hu&&t.locale!=="ko"?null:t.data;default:return null}}var Sm={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Sm[e.type]:t==="textarea"}function Gu(e,t,n,r){Cu(r),t=Za(t,"onChange"),0<t.length&&(n=new Li("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var _r=null,Kr=null;function jm(e){ad(e,0)}function ko(e){var t=Hn(e);if(vu(t))return e}function km(e,t){if(e==="change")return t}var Yu=!1;if(Bt){var Qo;if(Bt){var Jo="oninput"in document;if(!Jo){var Vl=document.createElement("div");Vl.setAttribute("oninput","return;"),Jo=typeof Vl.oninput=="function"}Qo=Jo}else Qo=!1;Yu=Qo&&(!document.documentMode||9<document.documentMode)}function Kl(){_r&&(_r.detachEvent("onpropertychange",Qu),Kr=_r=null)}function Qu(e){if(e.propertyName==="value"&&ko(Kr)){var t=[];Gu(t,Kr,e,Pi(e)),zu(jm,t)}}function Cm(e,t,n){e==="focusin"?(Kl(),_r=t,Kr=n,_r.attachEvent("onpropertychange",Qu)):e==="focusout"&&Kl()}function bm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ko(Kr)}function Nm(e,t){if(e==="click")return ko(t)}function Em(e,t){if(e==="input"||e==="change")return ko(t)}function zm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kt=typeof Object.is=="function"?Object.is:zm;function Gr(e,t){if(kt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!xs.call(t,a)||!kt(e[a],t[a]))return!1}return!0}function Gl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yl(e,t){var n=Gl(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Gl(n)}}function Ju(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ju(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xu(){for(var e=window,t=Ka();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ka(e.document)}return t}function Oi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Im(e){var t=Xu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ju(n.ownerDocument.documentElement,n)){if(r!==null&&Oi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,s=Math.min(r.start,a);r=r.end===void 0?s:Math.min(r.end,a),!e.extend&&s>r&&(a=r,r=s,s=a),a=Yl(n,s);var i=Yl(n,r);a&&i&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Pm=Bt&&"documentMode"in document&&11>=document.documentMode,Un=null,Fs=null,Ar=null,Os=!1;function Ql(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Os||Un==null||Un!==Ka(r)||(r=Un,"selectionStart"in r&&Oi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ar&&Gr(Ar,r)||(Ar=r,r=Za(Fs,"onSelect"),0<r.length&&(t=new Li("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Un)))}function xa(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Wn={animationend:xa("Animation","AnimationEnd"),animationiteration:xa("Animation","AnimationIteration"),animationstart:xa("Animation","AnimationStart"),transitionend:xa("Transition","TransitionEnd")},Xo={},qu={};Bt&&(qu=document.createElement("div").style,"AnimationEvent"in window||(delete Wn.animationend.animation,delete Wn.animationiteration.animation,delete Wn.animationstart.animation),"TransitionEvent"in window||delete Wn.transitionend.transition);function Co(e){if(Xo[e])return Xo[e];if(!Wn[e])return e;var t=Wn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in qu)return Xo[e]=t[n];return e}var Zu=Co("animationend"),ed=Co("animationiteration"),td=Co("animationstart"),nd=Co("transitionend"),rd=new Map,Jl="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function fn(e,t){rd.set(e,t),_n(t,[e])}for(var qo=0;qo<Jl.length;qo++){var Zo=Jl[qo],Tm=Zo.toLowerCase(),Rm=Zo[0].toUpperCase()+Zo.slice(1);fn(Tm,"on"+Rm)}fn(Zu,"onAnimationEnd");fn(ed,"onAnimationIteration");fn(td,"onAnimationStart");fn("dblclick","onDoubleClick");fn("focusin","onFocus");fn("focusout","onBlur");fn(nd,"onTransitionEnd");rr("onMouseEnter",["mouseout","mouseover"]);rr("onMouseLeave",["mouseout","mouseover"]);rr("onPointerEnter",["pointerout","pointerover"]);rr("onPointerLeave",["pointerout","pointerover"]);_n("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));_n("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));_n("onBeforeInput",["compositionend","keypress","textInput","paste"]);_n("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));_n("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));_n("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_m=new Set("cancel close invalid load scroll toggle".split(" ").concat(zr));function Xl(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Tp(r,t,void 0,e),e.currentTarget=null}function ad(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var i=r.length-1;0<=i;i--){var l=r[i],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==s&&a.isPropagationStopped())break e;Xl(a,l,u),s=c}else for(i=0;i<r.length;i++){if(l=r[i],c=l.instance,u=l.currentTarget,l=l.listener,c!==s&&a.isPropagationStopped())break e;Xl(a,l,u),s=c}}}if(Ya)throw e=As,Ya=!1,As=null,e}function ue(e,t){var n=t[Hs];n===void 0&&(n=t[Hs]=new Set);var r=e+"__bubble";n.has(r)||(od(t,e,2,!1),n.add(r))}function es(e,t,n){var r=0;t&&(r|=4),od(n,e,r,t)}var wa="_reactListening"+Math.random().toString(36).slice(2);function Yr(e){if(!e[wa]){e[wa]=!0,fu.forEach(function(n){n!=="selectionchange"&&(_m.has(n)||es(n,!1,e),es(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wa]||(t[wa]=!0,es("selectionchange",!1,t))}}function od(e,t,n,r){switch(Uu(t)){case 1:var a=Gp;break;case 4:a=Yp;break;default:a=Ai}n=a.bind(null,t,n,e),a=void 0,!_s||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function ts(e,t,n,r,a){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;i=i.return}for(;l!==null;){if(i=jn(l),i===null)return;if(c=i.tag,c===5||c===6){r=s=i;continue e}l=l.parentNode}}r=r.return}zu(function(){var u=s,p=Pi(n),m=[];e:{var g=rd.get(e);if(g!==void 0){var w=Li,x=e;switch(e){case"keypress":if($a(n)===0)break e;case"keydown":case"keyup":w=cm;break;case"focusin":x="focus",w=Yo;break;case"focusout":x="blur",w=Yo;break;case"beforeblur":case"afterblur":w=Yo;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":w=Ol;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":w=Xp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":w=fm;break;case Zu:case ed:case td:w=em;break;case nd:w=mm;break;case"scroll":w=Qp;break;case"wheel":w=gm;break;case"copy":case"cut":case"paste":w=nm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":w=Dl}var y=(t&4)!==0,j=!y&&e==="scroll",h=y?g!==null?g+"Capture":null:g;y=[];for(var f=u,v;f!==null;){v=f;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,h!==null&&(S=Ur(f,h),S!=null&&y.push(Qr(f,S,v)))),j)break;f=f.return}0<y.length&&(g=new w(g,x,null,n,p),m.push({event:g,listeners:y}))}}if(!(t&7)){e:{if(g=e==="mouseover"||e==="pointerover",w=e==="mouseout"||e==="pointerout",g&&n!==Ts&&(x=n.relatedTarget||n.fromElement)&&(jn(x)||x[Dt]))break e;if((w||g)&&(g=p.window===p?p:(g=p.ownerDocument)?g.defaultView||g.parentWindow:window,w?(x=n.relatedTarget||n.toElement,w=u,x=x?jn(x):null,x!==null&&(j=An(x),x!==j||x.tag!==5&&x.tag!==6)&&(x=null)):(w=null,x=u),w!==x)){if(y=Ol,S="onMouseLeave",h="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(y=Dl,S="onPointerLeave",h="onPointerEnter",f="pointer"),j=w==null?g:Hn(w),v=x==null?g:Hn(x),g=new y(S,f+"leave",w,n,p),g.target=j,g.relatedTarget=v,S=null,jn(p)===u&&(y=new y(h,f+"enter",x,n,p),y.target=v,y.relatedTarget=j,S=y),j=S,w&&x)t:{for(y=w,h=x,f=0,v=y;v;v=Fn(v))f++;for(v=0,S=h;S;S=Fn(S))v++;for(;0<f-v;)y=Fn(y),f--;for(;0<v-f;)h=Fn(h),v--;for(;f--;){if(y===h||h!==null&&y===h.alternate)break t;y=Fn(y),h=Fn(h)}y=null}else y=null;w!==null&&ql(m,g,w,y,!1),x!==null&&j!==null&&ql(m,j,x,y,!0)}}e:{if(g=u?Hn(u):window,w=g.nodeName&&g.nodeName.toLowerCase(),w==="select"||w==="input"&&g.type==="file")var E=km;else if(Hl(g))if(Yu)E=Em;else{E=bm;var z=Cm}else(w=g.nodeName)&&w.toLowerCase()==="input"&&(g.type==="checkbox"||g.type==="radio")&&(E=Nm);if(E&&(E=E(e,u))){Gu(m,E,n,p);break e}z&&z(e,g,u),e==="focusout"&&(z=g._wrapperState)&&z.controlled&&g.type==="number"&&Ns(g,"number",g.value)}switch(z=u?Hn(u):window,e){case"focusin":(Hl(z)||z.contentEditable==="true")&&(Un=z,Fs=u,Ar=null);break;case"focusout":Ar=Fs=Un=null;break;case"mousedown":Os=!0;break;case"contextmenu":case"mouseup":case"dragend":Os=!1,Ql(m,n,p);break;case"selectionchange":if(Pm)break;case"keydown":case"keyup":Ql(m,n,p)}var k;if(Fi)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Dn?Vu(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(Hu&&n.locale!=="ko"&&(Dn||N!=="onCompositionStart"?N==="onCompositionEnd"&&Dn&&(k=Wu()):(Zt=p,$i="value"in Zt?Zt.value:Zt.textContent,Dn=!0)),z=Za(u,N),0<z.length&&(N=new Bl(N,e,null,n,p),m.push({event:N,listeners:z}),k?N.data=k:(k=Ku(n),k!==null&&(N.data=k)))),(k=ym?xm(e,n):wm(e,n))&&(u=Za(u,"onBeforeInput"),0<u.length&&(p=new Bl("onBeforeInput","beforeinput",null,n,p),m.push({event:p,listeners:u}),p.data=k))}ad(m,t)})}function Qr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Za(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,s=a.stateNode;a.tag===5&&s!==null&&(a=s,s=Ur(e,n),s!=null&&r.unshift(Qr(e,s,a)),s=Ur(e,t),s!=null&&r.push(Qr(e,s,a))),e=e.return}return r}function Fn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function ql(e,t,n,r,a){for(var s=t._reactName,i=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,a?(c=Ur(n,s),c!=null&&i.unshift(Qr(n,c,l))):a||(c=Ur(n,s),c!=null&&i.push(Qr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Am=/\r\n?/g,$m=/\u0000|\uFFFD/g;function Zl(e){return(typeof e=="string"?e:""+e).replace(Am,`
38
- `).replace($m,"")}function Sa(e,t,n){if(t=Zl(t),Zl(e)!==t&&n)throw Error(M(425))}function eo(){}var Bs=null,Ds=null;function Us(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ws=typeof setTimeout=="function"?setTimeout:void 0,Lm=typeof clearTimeout=="function"?clearTimeout:void 0,ec=typeof Promise=="function"?Promise:void 0,Mm=typeof queueMicrotask=="function"?queueMicrotask:typeof ec<"u"?function(e){return ec.resolve(null).then(e).catch(Fm)}:Ws;function Fm(e){setTimeout(function(){throw e})}function ns(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),Vr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);Vr(t)}function an(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function tc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var fr=Math.random().toString(36).slice(2),It="__reactFiber$"+fr,Jr="__reactProps$"+fr,Dt="__reactContainer$"+fr,Hs="__reactEvents$"+fr,Om="__reactListeners$"+fr,Bm="__reactHandles$"+fr;function jn(e){var t=e[It];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Dt]||n[It]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=tc(e);e!==null;){if(n=e[It])return n;e=tc(e)}return t}e=n,n=e.parentNode}return null}function ia(e){return e=e[It]||e[Dt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Hn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function bo(e){return e[Jr]||null}var Vs=[],Vn=-1;function pn(e){return{current:e}}function de(e){0>Vn||(e.current=Vs[Vn],Vs[Vn]=null,Vn--)}function ce(e,t){Vn++,Vs[Vn]=e.current,e.current=t}var dn={},Fe=pn(dn),Qe=pn(!1),zn=dn;function ar(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},s;for(s in n)a[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Je(e){return e=e.childContextTypes,e!=null}function to(){de(Qe),de(Fe)}function nc(e,t,n){if(Fe.current!==dn)throw Error(M(168));ce(Fe,t),ce(Qe,n)}function sd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(M(108,Cp(e)||"Unknown",a));return ye({},n,r)}function no(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,zn=Fe.current,ce(Fe,e),ce(Qe,Qe.current),!0}function rc(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=sd(e,t,zn),r.__reactInternalMemoizedMergedChildContext=e,de(Qe),de(Fe),ce(Fe,e)):de(Qe),ce(Qe,n)}var $t=null,No=!1,rs=!1;function id(e){$t===null?$t=[e]:$t.push(e)}function Dm(e){No=!0,id(e)}function mn(){if(!rs&&$t!==null){rs=!0;var e=0,t=se;try{var n=$t;for(se=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}$t=null,No=!1}catch(a){throw $t!==null&&($t=$t.slice(e+1)),Ru(Ti,mn),a}finally{se=t,rs=!1}}return null}var Kn=[],Gn=0,ro=null,ao=0,ct=[],ut=0,In=null,Lt=1,Mt="";function xn(e,t){Kn[Gn++]=ao,Kn[Gn++]=ro,ro=e,ao=t}function ld(e,t,n){ct[ut++]=Lt,ct[ut++]=Mt,ct[ut++]=In,In=e;var r=Lt;e=Mt;var a=32-St(r)-1;r&=~(1<<a),n+=1;var s=32-St(t)+a;if(30<s){var i=a-a%5;s=(r&(1<<i)-1).toString(32),r>>=i,a-=i,Lt=1<<32-St(t)+a|n<<a|r,Mt=s+e}else Lt=1<<s|n<<a|r,Mt=e}function Bi(e){e.return!==null&&(xn(e,1),ld(e,1,0))}function Di(e){for(;e===ro;)ro=Kn[--Gn],Kn[Gn]=null,ao=Kn[--Gn],Kn[Gn]=null;for(;e===In;)In=ct[--ut],ct[ut]=null,Mt=ct[--ut],ct[ut]=null,Lt=ct[--ut],ct[ut]=null}var rt=null,nt=null,pe=!1,wt=null;function cd(e,t){var n=dt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function ac(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,rt=e,nt=an(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,rt=e,nt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=In!==null?{id:Lt,overflow:Mt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=dt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,rt=e,nt=null,!0):!1;default:return!1}}function Ks(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Gs(e){if(pe){var t=nt;if(t){var n=t;if(!ac(e,t)){if(Ks(e))throw Error(M(418));t=an(n.nextSibling);var r=rt;t&&ac(e,t)?cd(r,n):(e.flags=e.flags&-4097|2,pe=!1,rt=e)}}else{if(Ks(e))throw Error(M(418));e.flags=e.flags&-4097|2,pe=!1,rt=e}}}function oc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;rt=e}function ja(e){if(e!==rt)return!1;if(!pe)return oc(e),pe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Us(e.type,e.memoizedProps)),t&&(t=nt)){if(Ks(e))throw ud(),Error(M(418));for(;t;)cd(e,t),t=an(t.nextSibling)}if(oc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(M(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){nt=an(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}nt=null}}else nt=rt?an(e.stateNode.nextSibling):null;return!0}function ud(){for(var e=nt;e;)e=an(e.nextSibling)}function or(){nt=rt=null,pe=!1}function Ui(e){wt===null?wt=[e]:wt.push(e)}var Um=Vt.ReactCurrentBatchConfig;function Sr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(M(309));var r=n.stateNode}if(!r)throw Error(M(147,e));var a=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(i){var l=a.refs;i===null?delete l[s]:l[s]=i},t._stringRef=s,t)}if(typeof e!="string")throw Error(M(284));if(!n._owner)throw Error(M(290,e))}return e}function ka(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function sc(e){var t=e._init;return t(e._payload)}function dd(e){function t(h,f){if(e){var v=h.deletions;v===null?(h.deletions=[f],h.flags|=16):v.push(f)}}function n(h,f){if(!e)return null;for(;f!==null;)t(h,f),f=f.sibling;return null}function r(h,f){for(h=new Map;f!==null;)f.key!==null?h.set(f.key,f):h.set(f.index,f),f=f.sibling;return h}function a(h,f){return h=cn(h,f),h.index=0,h.sibling=null,h}function s(h,f,v){return h.index=v,e?(v=h.alternate,v!==null?(v=v.index,v<f?(h.flags|=2,f):v):(h.flags|=2,f)):(h.flags|=1048576,f)}function i(h){return e&&h.alternate===null&&(h.flags|=2),h}function l(h,f,v,S){return f===null||f.tag!==6?(f=us(v,h.mode,S),f.return=h,f):(f=a(f,v),f.return=h,f)}function c(h,f,v,S){var E=v.type;return E===Bn?p(h,f,v.props.children,S,v.key):f!==null&&(f.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&sc(E)===f.type)?(S=a(f,v.props),S.ref=Sr(h,f,v),S.return=h,S):(S=Ua(v.type,v.key,v.props,null,h.mode,S),S.ref=Sr(h,f,v),S.return=h,S)}function u(h,f,v,S){return f===null||f.tag!==4||f.stateNode.containerInfo!==v.containerInfo||f.stateNode.implementation!==v.implementation?(f=ds(v,h.mode,S),f.return=h,f):(f=a(f,v.children||[]),f.return=h,f)}function p(h,f,v,S,E){return f===null||f.tag!==7?(f=En(v,h.mode,S,E),f.return=h,f):(f=a(f,v),f.return=h,f)}function m(h,f,v){if(typeof f=="string"&&f!==""||typeof f=="number")return f=us(""+f,h.mode,v),f.return=h,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case fa:return v=Ua(f.type,f.key,f.props,null,h.mode,v),v.ref=Sr(h,null,f),v.return=h,v;case On:return f=ds(f,h.mode,v),f.return=h,f;case Yt:var S=f._init;return m(h,S(f._payload),v)}if(Nr(f)||gr(f))return f=En(f,h.mode,v,null),f.return=h,f;ka(h,f)}return null}function g(h,f,v,S){var E=f!==null?f.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return E!==null?null:l(h,f,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case fa:return v.key===E?c(h,f,v,S):null;case On:return v.key===E?u(h,f,v,S):null;case Yt:return E=v._init,g(h,f,E(v._payload),S)}if(Nr(v)||gr(v))return E!==null?null:p(h,f,v,S,null);ka(h,v)}return null}function w(h,f,v,S,E){if(typeof S=="string"&&S!==""||typeof S=="number")return h=h.get(v)||null,l(f,h,""+S,E);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case fa:return h=h.get(S.key===null?v:S.key)||null,c(f,h,S,E);case On:return h=h.get(S.key===null?v:S.key)||null,u(f,h,S,E);case Yt:var z=S._init;return w(h,f,v,z(S._payload),E)}if(Nr(S)||gr(S))return h=h.get(v)||null,p(f,h,S,E,null);ka(f,S)}return null}function x(h,f,v,S){for(var E=null,z=null,k=f,N=f=0,b=null;k!==null&&N<v.length;N++){k.index>N?(b=k,k=null):b=k.sibling;var I=g(h,k,v[N],S);if(I===null){k===null&&(k=b);break}e&&k&&I.alternate===null&&t(h,k),f=s(I,f,N),z===null?E=I:z.sibling=I,z=I,k=b}if(N===v.length)return n(h,k),pe&&xn(h,N),E;if(k===null){for(;N<v.length;N++)k=m(h,v[N],S),k!==null&&(f=s(k,f,N),z===null?E=k:z.sibling=k,z=k);return pe&&xn(h,N),E}for(k=r(h,k);N<v.length;N++)b=w(k,h,N,v[N],S),b!==null&&(e&&b.alternate!==null&&k.delete(b.key===null?N:b.key),f=s(b,f,N),z===null?E=b:z.sibling=b,z=b);return e&&k.forEach(function(H){return t(h,H)}),pe&&xn(h,N),E}function y(h,f,v,S){var E=gr(v);if(typeof E!="function")throw Error(M(150));if(v=E.call(v),v==null)throw Error(M(151));for(var z=E=null,k=f,N=f=0,b=null,I=v.next();k!==null&&!I.done;N++,I=v.next()){k.index>N?(b=k,k=null):b=k.sibling;var H=g(h,k,I.value,S);if(H===null){k===null&&(k=b);break}e&&k&&H.alternate===null&&t(h,k),f=s(H,f,N),z===null?E=H:z.sibling=H,z=H,k=b}if(I.done)return n(h,k),pe&&xn(h,N),E;if(k===null){for(;!I.done;N++,I=v.next())I=m(h,I.value,S),I!==null&&(f=s(I,f,N),z===null?E=I:z.sibling=I,z=I);return pe&&xn(h,N),E}for(k=r(h,k);!I.done;N++,I=v.next())I=w(k,h,N,I.value,S),I!==null&&(e&&I.alternate!==null&&k.delete(I.key===null?N:I.key),f=s(I,f,N),z===null?E=I:z.sibling=I,z=I);return e&&k.forEach(function(U){return t(h,U)}),pe&&xn(h,N),E}function j(h,f,v,S){if(typeof v=="object"&&v!==null&&v.type===Bn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case fa:e:{for(var E=v.key,z=f;z!==null;){if(z.key===E){if(E=v.type,E===Bn){if(z.tag===7){n(h,z.sibling),f=a(z,v.props.children),f.return=h,h=f;break e}}else if(z.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&sc(E)===z.type){n(h,z.sibling),f=a(z,v.props),f.ref=Sr(h,z,v),f.return=h,h=f;break e}n(h,z);break}else t(h,z);z=z.sibling}v.type===Bn?(f=En(v.props.children,h.mode,S,v.key),f.return=h,h=f):(S=Ua(v.type,v.key,v.props,null,h.mode,S),S.ref=Sr(h,f,v),S.return=h,h=S)}return i(h);case On:e:{for(z=v.key;f!==null;){if(f.key===z)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(h,f.sibling),f=a(f,v.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else t(h,f);f=f.sibling}f=ds(v,h.mode,S),f.return=h,h=f}return i(h);case Yt:return z=v._init,j(h,f,z(v._payload),S)}if(Nr(v))return x(h,f,v,S);if(gr(v))return y(h,f,v,S);ka(h,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(h,f.sibling),f=a(f,v),f.return=h,h=f):(n(h,f),f=us(v,h.mode,S),f.return=h,h=f),i(h)):n(h,f)}return j}var sr=dd(!0),fd=dd(!1),oo=pn(null),so=null,Yn=null,Wi=null;function Hi(){Wi=Yn=so=null}function Vi(e){var t=oo.current;de(oo),e._currentValue=t}function Ys(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tr(e,t){so=e,Wi=Yn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ye=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Wi!==e)if(e={context:e,memoizedValue:t,next:null},Yn===null){if(so===null)throw Error(M(308));Yn=e,so.dependencies={lanes:0,firstContext:e}}else Yn=Yn.next=e;return t}var kn=null;function Ki(e){kn===null?kn=[e]:kn.push(e)}function pd(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,Ki(t)):(n.next=a.next,a.next=n),t.interleaved=n,Ut(e,r)}function Ut(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qt=!1;function Gi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function md(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ot(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function on(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,re&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Ut(e,n)}return a=r.interleaved,a===null?(t.next=t,Ki(r)):(t.next=a.next,a.next=t),r.interleaved=t,Ut(e,n)}function La(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ri(e,n)}}function ic(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?a=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?a=s=t:s=s.next=t}else a=s=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function io(e,t,n,r){var a=e.updateQueue;Qt=!1;var s=a.firstBaseUpdate,i=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,u=c.next;c.next=null,i===null?s=u:i.next=u,i=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==i&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(s!==null){var m=a.baseState;i=0,p=u=c=null,l=s;do{var g=l.lane,w=l.eventTime;if((r&g)===g){p!==null&&(p=p.next={eventTime:w,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,y=l;switch(g=t,w=n,y.tag){case 1:if(x=y.payload,typeof x=="function"){m=x.call(w,m,g);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=y.payload,g=typeof x=="function"?x.call(w,m,g):x,g==null)break e;m=ye({},m,g);break e;case 2:Qt=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,g=a.effects,g===null?a.effects=[l]:g.push(l))}else w={eventTime:w,lane:g,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=w,c=m):p=p.next=w,i|=g;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;g=l,l=g.next,g.next=null,a.lastBaseUpdate=g,a.shared.pending=null}}while(!0);if(p===null&&(c=m),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,t=a.shared.interleaved,t!==null){a=t;do i|=a.lane,a=a.next;while(a!==t)}else s===null&&(a.shared.lanes=0);Tn|=i,e.lanes=i,e.memoizedState=m}}function lc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(M(191,a));a.call(r)}}}var la={},Tt=pn(la),Xr=pn(la),qr=pn(la);function Cn(e){if(e===la)throw Error(M(174));return e}function Yi(e,t){switch(ce(qr,t),ce(Xr,e),ce(Tt,la),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:zs(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=zs(t,e)}de(Tt),ce(Tt,t)}function ir(){de(Tt),de(Xr),de(qr)}function hd(e){Cn(qr.current);var t=Cn(Tt.current),n=zs(t,e.type);t!==n&&(ce(Xr,e),ce(Tt,n))}function Qi(e){Xr.current===e&&(de(Tt),de(Xr))}var ge=pn(0);function lo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var as=[];function Ji(){for(var e=0;e<as.length;e++)as[e]._workInProgressVersionPrimary=null;as.length=0}var Ma=Vt.ReactCurrentDispatcher,os=Vt.ReactCurrentBatchConfig,Pn=0,ve=null,Ce=null,Ee=null,co=!1,$r=!1,Zr=0,Wm=0;function $e(){throw Error(M(321))}function Xi(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!kt(e[n],t[n]))return!1;return!0}function qi(e,t,n,r,a,s){if(Pn=s,ve=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ma.current=e===null||e.memoizedState===null?Gm:Ym,e=n(r,a),$r){s=0;do{if($r=!1,Zr=0,25<=s)throw Error(M(301));s+=1,Ee=Ce=null,t.updateQueue=null,Ma.current=Qm,e=n(r,a)}while($r)}if(Ma.current=uo,t=Ce!==null&&Ce.next!==null,Pn=0,Ee=Ce=ve=null,co=!1,t)throw Error(M(300));return e}function Zi(){var e=Zr!==0;return Zr=0,e}function Et(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ee===null?ve.memoizedState=Ee=e:Ee=Ee.next=e,Ee}function mt(){if(Ce===null){var e=ve.alternate;e=e!==null?e.memoizedState:null}else e=Ce.next;var t=Ee===null?ve.memoizedState:Ee.next;if(t!==null)Ee=t,Ce=e;else{if(e===null)throw Error(M(310));Ce=e,e={memoizedState:Ce.memoizedState,baseState:Ce.baseState,baseQueue:Ce.baseQueue,queue:Ce.queue,next:null},Ee===null?ve.memoizedState=Ee=e:Ee=Ee.next=e}return Ee}function ea(e,t){return typeof t=="function"?t(e):t}function ss(e){var t=mt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=Ce,a=r.baseQueue,s=n.pending;if(s!==null){if(a!==null){var i=a.next;a.next=s.next,s.next=i}r.baseQueue=a=s,n.pending=null}if(a!==null){s=a.next,r=r.baseState;var l=i=null,c=null,u=s;do{var p=u.lane;if((Pn&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var m={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=m,i=r):c=c.next=m,ve.lanes|=p,Tn|=p}u=u.next}while(u!==null&&u!==s);c===null?i=r:c.next=l,kt(r,t.memoizedState)||(Ye=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do s=a.lane,ve.lanes|=s,Tn|=s,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function is(e){var t=mt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(a!==null){n.pending=null;var i=a=a.next;do s=e(s,i.action),i=i.next;while(i!==a);kt(s,t.memoizedState)||(Ye=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function gd(){}function vd(e,t){var n=ve,r=mt(),a=t(),s=!kt(r.memoizedState,a);if(s&&(r.memoizedState=a,Ye=!0),r=r.queue,el(wd.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||Ee!==null&&Ee.memoizedState.tag&1){if(n.flags|=2048,ta(9,xd.bind(null,n,r,a,t),void 0,null),ze===null)throw Error(M(349));Pn&30||yd(n,t,a)}return a}function yd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ve.updateQueue,t===null?(t={lastEffect:null,stores:null},ve.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function xd(e,t,n,r){t.value=n,t.getSnapshot=r,Sd(t)&&jd(e)}function wd(e,t,n){return n(function(){Sd(t)&&jd(e)})}function Sd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kt(e,n)}catch{return!0}}function jd(e){var t=Ut(e,1);t!==null&&jt(t,e,1,-1)}function cc(e){var t=Et();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ea,lastRenderedState:e},t.queue=e,e=e.dispatch=Km.bind(null,ve,e),[t.memoizedState,e]}function ta(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ve.updateQueue,t===null?(t={lastEffect:null,stores:null},ve.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function kd(){return mt().memoizedState}function Fa(e,t,n,r){var a=Et();ve.flags|=e,a.memoizedState=ta(1|t,n,void 0,r===void 0?null:r)}function Eo(e,t,n,r){var a=mt();r=r===void 0?null:r;var s=void 0;if(Ce!==null){var i=Ce.memoizedState;if(s=i.destroy,r!==null&&Xi(r,i.deps)){a.memoizedState=ta(t,n,s,r);return}}ve.flags|=e,a.memoizedState=ta(1|t,n,s,r)}function uc(e,t){return Fa(8390656,8,e,t)}function el(e,t){return Eo(2048,8,e,t)}function Cd(e,t){return Eo(4,2,e,t)}function bd(e,t){return Eo(4,4,e,t)}function Nd(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ed(e,t,n){return n=n!=null?n.concat([e]):null,Eo(4,4,Nd.bind(null,t,e),n)}function tl(){}function zd(e,t){var n=mt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Xi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Id(e,t){var n=mt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Xi(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Pd(e,t,n){return Pn&21?(kt(n,t)||(n=$u(),ve.lanes|=n,Tn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ye=!0),e.memoizedState=n)}function Hm(e,t){var n=se;se=n!==0&&4>n?n:4,e(!0);var r=os.transition;os.transition={};try{e(!1),t()}finally{se=n,os.transition=r}}function Td(){return mt().memoizedState}function Vm(e,t,n){var r=ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rd(e))_d(t,n);else if(n=pd(e,t,n,r),n!==null){var a=De();jt(n,e,r,a),Ad(n,t,r)}}function Km(e,t,n){var r=ln(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rd(e))_d(t,a);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,l=s(i,n);if(a.hasEagerState=!0,a.eagerState=l,kt(l,i)){var c=t.interleaved;c===null?(a.next=a,Ki(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=pd(e,t,a,r),n!==null&&(a=De(),jt(n,e,r,a),Ad(n,t,r))}}function Rd(e){var t=e.alternate;return e===ve||t!==null&&t===ve}function _d(e,t){$r=co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ad(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ri(e,n)}}var uo={readContext:pt,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useInsertionEffect:$e,useLayoutEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useMutableSource:$e,useSyncExternalStore:$e,useId:$e,unstable_isNewReconciler:!1},Gm={readContext:pt,useCallback:function(e,t){return Et().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:uc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fa(4194308,4,Nd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fa(4,2,e,t)},useMemo:function(e,t){var n=Et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Vm.bind(null,ve,e),[r.memoizedState,e]},useRef:function(e){var t=Et();return e={current:e},t.memoizedState=e},useState:cc,useDebugValue:tl,useDeferredValue:function(e){return Et().memoizedState=e},useTransition:function(){var e=cc(!1),t=e[0];return e=Hm.bind(null,e[1]),Et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ve,a=Et();if(pe){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),ze===null)throw Error(M(349));Pn&30||yd(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,uc(wd.bind(null,r,s,e),[e]),r.flags|=2048,ta(9,xd.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Et(),t=ze.identifierPrefix;if(pe){var n=Mt,r=Lt;n=(r&~(1<<32-St(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zr++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Wm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Ym={readContext:pt,useCallback:zd,useContext:pt,useEffect:el,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:bd,useMemo:Id,useReducer:ss,useRef:kd,useState:function(){return ss(ea)},useDebugValue:tl,useDeferredValue:function(e){var t=mt();return Pd(t,Ce.memoizedState,e)},useTransition:function(){var e=ss(ea)[0],t=mt().memoizedState;return[e,t]},useMutableSource:gd,useSyncExternalStore:vd,useId:Td,unstable_isNewReconciler:!1},Qm={readContext:pt,useCallback:zd,useContext:pt,useEffect:el,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:bd,useMemo:Id,useReducer:is,useRef:kd,useState:function(){return is(ea)},useDebugValue:tl,useDeferredValue:function(e){var t=mt();return Ce===null?t.memoizedState=e:Pd(t,Ce.memoizedState,e)},useTransition:function(){var e=is(ea)[0],t=mt().memoizedState;return[e,t]},useMutableSource:gd,useSyncExternalStore:vd,useId:Td,unstable_isNewReconciler:!1};function yt(e,t){if(e&&e.defaultProps){t=ye({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Qs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ye({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var zo={isMounted:function(e){return(e=e._reactInternals)?An(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=De(),a=ln(e),s=Ot(r,a);s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(jt(t,e,a,r),La(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=De(),a=ln(e),s=Ot(r,a);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(jt(t,e,a,r),La(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=De(),r=ln(e),a=Ot(n,r);a.tag=2,t!=null&&(a.callback=t),t=on(e,a,r),t!==null&&(jt(t,e,r,n),La(t,e,r))}};function dc(e,t,n,r,a,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):t.prototype&&t.prototype.isPureReactComponent?!Gr(n,r)||!Gr(a,s):!0}function $d(e,t,n){var r=!1,a=dn,s=t.contextType;return typeof s=="object"&&s!==null?s=pt(s):(a=Je(t)?zn:Fe.current,r=t.contextTypes,s=(r=r!=null)?ar(e,a):dn),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=zo,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=s),t}function fc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zo.enqueueReplaceState(t,t.state,null)}function Js(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Gi(e);var s=t.contextType;typeof s=="object"&&s!==null?a.context=pt(s):(s=Je(t)?zn:Fe.current,a.context=ar(e,s)),a.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(Qs(e,t,s,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&zo.enqueueReplaceState(a,a.state,null),io(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function lr(e,t){try{var n="",r=t;do n+=kp(r),r=r.return;while(r);var a=n}catch(s){a=`
37
+ `+a[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=l);break}}}finally{Uo=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?br(e):""}function kp(e){switch(e.tag){case 5:return br(e.type);case 16:return br("Lazy");case 13:return br("Suspense");case 19:return br("SuspenseList");case 0:case 2:case 15:return e=Wo(e.type,!1),e;case 11:return e=Wo(e.type.render,!1),e;case 1:return e=Wo(e.type,!0),e;default:return""}}function ks(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Bn:return"Fragment";case On:return"Portal";case ws:return"Profiler";case Ei:return"StrictMode";case Ss:return"Suspense";case js:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case mu:return(e.displayName||"Context")+".Consumer";case pu:return(e._context.displayName||"Context")+".Provider";case zi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ii:return t=e.displayName||null,t!==null?t:ks(e.type)||"Memo";case Yt:t=e._payload,e=e._init;try{return ks(e(t))}catch{}}return null}function Cp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ks(t);case 8:return t===Ei?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function un(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function gu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function bp(e){var t=gu(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var a=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(i){r=""+i,s.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pa(e){e._valueTracker||(e._valueTracker=bp(e))}function vu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=gu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ka(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Cs(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Il(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=un(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function yu(e,t){t=t.checked,t!=null&&Ni(e,"checked",t,!1)}function bs(e,t){yu(e,t);var n=un(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ns(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ns(e,t.type,un(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Pl(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ns(e,t,n){(t!=="number"||Ka(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Nr=Array.isArray;function Xn(e,t,n,r){if(e=e.options,t){t={};for(var a=0;a<n.length;a++)t["$"+n[a]]=!0;for(n=0;n<e.length;n++)a=t.hasOwnProperty("$"+e[n].value),e[n].selected!==a&&(e[n].selected=a),a&&r&&(e[n].defaultSelected=!0)}else{for(n=""+un(n),t=null,a=0;a<e.length;a++){if(e[a].value===n){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Es(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(M(91));return ye({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function Tl(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(M(92));if(Nr(n)){if(1<n.length)throw Error(M(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:un(n)}}function xu(e,t){var n=un(t.value),r=un(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Rl(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function wu(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function zs(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?wu(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var ma,Su=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(ma=ma||document.createElement("div"),ma.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ma.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Dr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Np=["Webkit","ms","Moz","O"];Object.keys(Pr).forEach(function(e){Np.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Pr[t]=Pr[e]})});function ju(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Pr.hasOwnProperty(e)&&Pr[e]?(""+t).trim():t+"px"}function ku(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,a=ju(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,a):e[n]=a}}var Ep=ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Is(e,t){if(t){if(Ep[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(M(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(M(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(M(61))}if(t.style!=null&&typeof t.style!="object")throw Error(M(62))}}function Ps(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ts=null;function Pi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rs=null,qn=null,Zn=null;function _l(e){if(e=ia(e)){if(typeof Rs!="function")throw Error(M(280));var t=e.stateNode;t&&(t=bo(t),Rs(e.stateNode,e.type,t))}}function Cu(e){qn?Zn?Zn.push(e):Zn=[e]:qn=e}function bu(){if(qn){var e=qn,t=Zn;if(Zn=qn=null,_l(e),t)for(e=0;e<t.length;e++)_l(t[e])}}function Nu(e,t){return e(t)}function Eu(){}var Ho=!1;function zu(e,t,n){if(Ho)return e(t,n);Ho=!0;try{return Nu(e,t,n)}finally{Ho=!1,(qn!==null||Zn!==null)&&(Eu(),bu())}}function Ur(e,t){var n=e.stateNode;if(n===null)return null;var r=bo(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(M(231,t,typeof n));return n}var _s=!1;if(Bt)try{var vr={};Object.defineProperty(vr,"passive",{get:function(){_s=!0}}),window.addEventListener("test",vr,vr),window.removeEventListener("test",vr,vr)}catch{_s=!1}function zp(e,t,n,r,a,s,i,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(p){this.onError(p)}}var Tr=!1,Ga=null,Ya=!1,As=null,Ip={onError:function(e){Tr=!0,Ga=e}};function Pp(e,t,n,r,a,s,i,l,c){Tr=!1,Ga=null,zp.apply(Ip,arguments)}function Tp(e,t,n,r,a,s,i,l,c){if(Pp.apply(this,arguments),Tr){if(Tr){var u=Ga;Tr=!1,Ga=null}else throw Error(M(198));Ya||(Ya=!0,As=u)}}function An(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function Iu(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Al(e){if(An(e)!==e)throw Error(M(188))}function Rp(e){var t=e.alternate;if(!t){if(t=An(e),t===null)throw Error(M(188));return t!==e?null:e}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return Al(a),e;if(s===r)return Al(a),t;s=s.sibling}throw Error(M(188))}if(n.return!==r.return)n=a,r=s;else{for(var i=!1,l=a.child;l;){if(l===n){i=!0,n=a,r=s;break}if(l===r){i=!0,r=a,n=s;break}l=l.sibling}if(!i){for(l=s.child;l;){if(l===n){i=!0,n=s,r=a;break}if(l===r){i=!0,r=s,n=a;break}l=l.sibling}if(!i)throw Error(M(189))}}if(n.alternate!==r)throw Error(M(190))}if(n.tag!==3)throw Error(M(188));return n.stateNode.current===n?e:t}function Pu(e){return e=Rp(e),e!==null?Tu(e):null}function Tu(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Tu(e);if(t!==null)return t;e=e.sibling}return null}var Ru=at.unstable_scheduleCallback,$l=at.unstable_cancelCallback,_p=at.unstable_shouldYield,Ap=at.unstable_requestPaint,we=at.unstable_now,$p=at.unstable_getCurrentPriorityLevel,Ti=at.unstable_ImmediatePriority,_u=at.unstable_UserBlockingPriority,Qa=at.unstable_NormalPriority,Lp=at.unstable_LowPriority,Au=at.unstable_IdlePriority,So=null,Pt=null;function Mp(e){if(Pt&&typeof Pt.onCommitFiberRoot=="function")try{Pt.onCommitFiberRoot(So,e,void 0,(e.current.flags&128)===128)}catch{}}var St=Math.clz32?Math.clz32:Bp,Fp=Math.log,Op=Math.LN2;function Bp(e){return e>>>=0,e===0?32:31-(Fp(e)/Op|0)|0}var ha=64,ga=4194304;function Er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ja(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~a;l!==0?r=Er(l):(s&=i,s!==0&&(r=Er(s)))}else i=n&~a,i!==0?r=Er(i):s!==0&&(r=Er(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,s=t&-t,a>=s||a===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-St(t),a=1<<n,r|=e[n],t&=~a;return r}function Dp(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Up(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,s=e.pendingLanes;0<s;){var i=31-St(s),l=1<<i,c=a[i];c===-1?(!(l&n)||l&r)&&(a[i]=Dp(l,t)):c<=t&&(e.expiredLanes|=l),s&=~l}}function $s(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function $u(){var e=ha;return ha<<=1,!(ha&4194240)&&(ha=64),e}function Vo(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-St(t),e[t]=n}function Wp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var a=31-St(n),s=1<<a;t[a]=0,r[a]=-1,e[a]=-1,n&=~s}}function Ri(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-St(n),a=1<<r;a&t|e[r]&t&&(e[r]|=t),n&=~a}}var se=0;function Lu(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var Mu,_i,Fu,Ou,Bu,Ls=!1,va=[],tn=null,nn=null,rn=null,Wr=new Map,Hr=new Map,Xt=[],Hp="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ll(e,t){switch(e){case"focusin":case"focusout":tn=null;break;case"dragenter":case"dragleave":nn=null;break;case"mouseover":case"mouseout":rn=null;break;case"pointerover":case"pointerout":Wr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Hr.delete(t.pointerId)}}function yr(e,t,n,r,a,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[a]},t!==null&&(t=ia(t),t!==null&&_i(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function Vp(e,t,n,r,a){switch(t){case"focusin":return tn=yr(tn,e,t,n,r,a),!0;case"dragenter":return nn=yr(nn,e,t,n,r,a),!0;case"mouseover":return rn=yr(rn,e,t,n,r,a),!0;case"pointerover":var s=a.pointerId;return Wr.set(s,yr(Wr.get(s)||null,e,t,n,r,a)),!0;case"gotpointercapture":return s=a.pointerId,Hr.set(s,yr(Hr.get(s)||null,e,t,n,r,a)),!0}return!1}function Du(e){var t=jn(e.target);if(t!==null){var n=An(t);if(n!==null){if(t=n.tag,t===13){if(t=Iu(n),t!==null){e.blockedOn=t,Bu(e.priority,function(){Fu(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function _a(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ms(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ts=r,n.target.dispatchEvent(r),Ts=null}else return t=ia(n),t!==null&&_i(t),e.blockedOn=n,!1;t.shift()}return!0}function Ml(e,t,n){_a(e)&&n.delete(t)}function Kp(){Ls=!1,tn!==null&&_a(tn)&&(tn=null),nn!==null&&_a(nn)&&(nn=null),rn!==null&&_a(rn)&&(rn=null),Wr.forEach(Ml),Hr.forEach(Ml)}function xr(e,t){e.blockedOn===t&&(e.blockedOn=null,Ls||(Ls=!0,at.unstable_scheduleCallback(at.unstable_NormalPriority,Kp)))}function Vr(e){function t(a){return xr(a,e)}if(0<va.length){xr(va[0],e);for(var n=1;n<va.length;n++){var r=va[n];r.blockedOn===e&&(r.blockedOn=null)}}for(tn!==null&&xr(tn,e),nn!==null&&xr(nn,e),rn!==null&&xr(rn,e),Wr.forEach(t),Hr.forEach(t),n=0;n<Xt.length;n++)r=Xt[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Xt.length&&(n=Xt[0],n.blockedOn===null);)Du(n),n.blockedOn===null&&Xt.shift()}var er=Vt.ReactCurrentBatchConfig,Xa=!0;function Gp(e,t,n,r){var a=se,s=er.transition;er.transition=null;try{se=1,Ai(e,t,n,r)}finally{se=a,er.transition=s}}function Yp(e,t,n,r){var a=se,s=er.transition;er.transition=null;try{se=4,Ai(e,t,n,r)}finally{se=a,er.transition=s}}function Ai(e,t,n,r){if(Xa){var a=Ms(e,t,n,r);if(a===null)ts(e,t,r,qa,n),Ll(e,r);else if(Vp(a,e,t,n,r))r.stopPropagation();else if(Ll(e,r),t&4&&-1<Hp.indexOf(e)){for(;a!==null;){var s=ia(a);if(s!==null&&Mu(s),s=Ms(e,t,n,r),s===null&&ts(e,t,r,qa,n),s===a)break;a=s}a!==null&&r.stopPropagation()}else ts(e,t,r,null,n)}}var qa=null;function Ms(e,t,n,r){if(qa=null,e=Pi(r),e=jn(e),e!==null)if(t=An(e),t===null)e=null;else if(n=t.tag,n===13){if(e=Iu(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return qa=e,null}function Uu(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($p()){case Ti:return 1;case _u:return 4;case Qa:case Lp:return 16;case Au:return 536870912;default:return 16}default:return 16}}var Zt=null,$i=null,Aa=null;function Wu(){if(Aa)return Aa;var e,t=$i,n=t.length,r,a="value"in Zt?Zt.value:Zt.textContent,s=a.length;for(e=0;e<n&&t[e]===a[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===a[s-r];r++);return Aa=a.slice(e,1<r?1-r:void 0)}function $a(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function ya(){return!0}function Fl(){return!1}function st(e){function t(n,r,a,s,i){this._reactName=n,this._targetInst=a,this.type=r,this.nativeEvent=s,this.target=i,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?ya:Fl,this.isPropagationStopped=Fl,this}return ye(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=ya)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ya)},persist:function(){},isPersistent:ya}),t}var dr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Li=st(dr),sa=ye({},dr,{view:0,detail:0}),Qp=st(sa),Ko,Go,wr,jo=ye({},sa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mi,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==wr&&(wr&&e.type==="mousemove"?(Ko=e.screenX-wr.screenX,Go=e.screenY-wr.screenY):Go=Ko=0,wr=e),Ko)},movementY:function(e){return"movementY"in e?e.movementY:Go}}),Ol=st(jo),Jp=ye({},jo,{dataTransfer:0}),Xp=st(Jp),qp=ye({},sa,{relatedTarget:0}),Yo=st(qp),Zp=ye({},dr,{animationName:0,elapsedTime:0,pseudoElement:0}),em=st(Zp),tm=ye({},dr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),nm=st(tm),rm=ye({},dr,{data:0}),Bl=st(rm),am={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},om={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},sm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function im(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=sm[e])?!!t[e]:!1}function Mi(){return im}var lm=ye({},sa,{key:function(e){if(e.key){var t=am[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=$a(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?om[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mi,charCode:function(e){return e.type==="keypress"?$a(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?$a(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),cm=st(lm),um=ye({},jo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Dl=st(um),dm=ye({},sa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mi}),fm=st(dm),pm=ye({},dr,{propertyName:0,elapsedTime:0,pseudoElement:0}),mm=st(pm),hm=ye({},jo,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),gm=st(hm),vm=[9,13,27,32],Fi=Bt&&"CompositionEvent"in window,Rr=null;Bt&&"documentMode"in document&&(Rr=document.documentMode);var ym=Bt&&"TextEvent"in window&&!Rr,Hu=Bt&&(!Fi||Rr&&8<Rr&&11>=Rr),Ul=" ",Wl=!1;function Vu(e,t){switch(e){case"keyup":return vm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ku(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Dn=!1;function xm(e,t){switch(e){case"compositionend":return Ku(t);case"keypress":return t.which!==32?null:(Wl=!0,Ul);case"textInput":return e=t.data,e===Ul&&Wl?null:e;default:return null}}function wm(e,t){if(Dn)return e==="compositionend"||!Fi&&Vu(e,t)?(e=Wu(),Aa=$i=Zt=null,Dn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Hu&&t.locale!=="ko"?null:t.data;default:return null}}var Sm={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Sm[e.type]:t==="textarea"}function Gu(e,t,n,r){Cu(r),t=Za(t,"onChange"),0<t.length&&(n=new Li("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var _r=null,Kr=null;function jm(e){ad(e,0)}function ko(e){var t=Hn(e);if(vu(t))return e}function km(e,t){if(e==="change")return t}var Yu=!1;if(Bt){var Qo;if(Bt){var Jo="oninput"in document;if(!Jo){var Vl=document.createElement("div");Vl.setAttribute("oninput","return;"),Jo=typeof Vl.oninput=="function"}Qo=Jo}else Qo=!1;Yu=Qo&&(!document.documentMode||9<document.documentMode)}function Kl(){_r&&(_r.detachEvent("onpropertychange",Qu),Kr=_r=null)}function Qu(e){if(e.propertyName==="value"&&ko(Kr)){var t=[];Gu(t,Kr,e,Pi(e)),zu(jm,t)}}function Cm(e,t,n){e==="focusin"?(Kl(),_r=t,Kr=n,_r.attachEvent("onpropertychange",Qu)):e==="focusout"&&Kl()}function bm(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ko(Kr)}function Nm(e,t){if(e==="click")return ko(t)}function Em(e,t){if(e==="input"||e==="change")return ko(t)}function zm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var kt=typeof Object.is=="function"?Object.is:zm;function Gr(e,t){if(kt(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var a=n[r];if(!xs.call(t,a)||!kt(e[a],t[a]))return!1}return!0}function Gl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Yl(e,t){var n=Gl(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Gl(n)}}function Ju(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ju(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xu(){for(var e=window,t=Ka();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ka(e.document)}return t}function Oi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Im(e){var t=Xu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ju(n.ownerDocument.documentElement,n)){if(r!==null&&Oi(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=n.textContent.length,s=Math.min(r.start,a);r=r.end===void 0?s:Math.min(r.end,a),!e.extend&&s>r&&(a=r,r=s,s=a),a=Yl(n,s);var i=Yl(n,r);a&&i&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var Pm=Bt&&"documentMode"in document&&11>=document.documentMode,Un=null,Fs=null,Ar=null,Os=!1;function Ql(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Os||Un==null||Un!==Ka(r)||(r=Un,"selectionStart"in r&&Oi(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ar&&Gr(Ar,r)||(Ar=r,r=Za(Fs,"onSelect"),0<r.length&&(t=new Li("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Un)))}function xa(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Wn={animationend:xa("Animation","AnimationEnd"),animationiteration:xa("Animation","AnimationIteration"),animationstart:xa("Animation","AnimationStart"),transitionend:xa("Transition","TransitionEnd")},Xo={},qu={};Bt&&(qu=document.createElement("div").style,"AnimationEvent"in window||(delete Wn.animationend.animation,delete Wn.animationiteration.animation,delete Wn.animationstart.animation),"TransitionEvent"in window||delete Wn.transitionend.transition);function Co(e){if(Xo[e])return Xo[e];if(!Wn[e])return e;var t=Wn[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in qu)return Xo[e]=t[n];return e}var Zu=Co("animationend"),ed=Co("animationiteration"),td=Co("animationstart"),nd=Co("transitionend"),rd=new Map,Jl="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function fn(e,t){rd.set(e,t),_n(t,[e])}for(var qo=0;qo<Jl.length;qo++){var Zo=Jl[qo],Tm=Zo.toLowerCase(),Rm=Zo[0].toUpperCase()+Zo.slice(1);fn(Tm,"on"+Rm)}fn(Zu,"onAnimationEnd");fn(ed,"onAnimationIteration");fn(td,"onAnimationStart");fn("dblclick","onDoubleClick");fn("focusin","onFocus");fn("focusout","onBlur");fn(nd,"onTransitionEnd");rr("onMouseEnter",["mouseout","mouseover"]);rr("onMouseLeave",["mouseout","mouseover"]);rr("onPointerEnter",["pointerout","pointerover"]);rr("onPointerLeave",["pointerout","pointerover"]);_n("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));_n("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));_n("onBeforeInput",["compositionend","keypress","textInput","paste"]);_n("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));_n("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));_n("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),_m=new Set("cancel close invalid load scroll toggle".split(" ").concat(zr));function Xl(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,Tp(r,t,void 0,e),e.currentTarget=null}function ad(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],a=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var i=r.length-1;0<=i;i--){var l=r[i],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==s&&a.isPropagationStopped())break e;Xl(a,l,u),s=c}else for(i=0;i<r.length;i++){if(l=r[i],c=l.instance,u=l.currentTarget,l=l.listener,c!==s&&a.isPropagationStopped())break e;Xl(a,l,u),s=c}}}if(Ya)throw e=As,Ya=!1,As=null,e}function ue(e,t){var n=t[Hs];n===void 0&&(n=t[Hs]=new Set);var r=e+"__bubble";n.has(r)||(od(t,e,2,!1),n.add(r))}function es(e,t,n){var r=0;t&&(r|=4),od(n,e,r,t)}var wa="_reactListening"+Math.random().toString(36).slice(2);function Yr(e){if(!e[wa]){e[wa]=!0,fu.forEach(function(n){n!=="selectionchange"&&(_m.has(n)||es(n,!1,e),es(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[wa]||(t[wa]=!0,es("selectionchange",!1,t))}}function od(e,t,n,r){switch(Uu(t)){case 1:var a=Gp;break;case 4:a=Yp;break;default:a=Ai}n=a.bind(null,t,n,e),a=void 0,!_s||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,n,{capture:!0,passive:a}):e.addEventListener(t,n,!0):a!==void 0?e.addEventListener(t,n,{passive:a}):e.addEventListener(t,n,!1)}function ts(e,t,n,r,a){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var l=r.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;i=i.return}for(;l!==null;){if(i=jn(l),i===null)return;if(c=i.tag,c===5||c===6){r=s=i;continue e}l=l.parentNode}}r=r.return}zu(function(){var u=s,p=Pi(n),h=[];e:{var m=rd.get(e);if(m!==void 0){var w=Li,x=e;switch(e){case"keypress":if($a(n)===0)break e;case"keydown":case"keyup":w=cm;break;case"focusin":x="focus",w=Yo;break;case"focusout":x="blur",w=Yo;break;case"beforeblur":case"afterblur":w=Yo;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":w=Ol;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":w=Xp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":w=fm;break;case Zu:case ed:case td:w=em;break;case nd:w=mm;break;case"scroll":w=Qp;break;case"wheel":w=gm;break;case"copy":case"cut":case"paste":w=nm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":w=Dl}var y=(t&4)!==0,j=!y&&e==="scroll",g=y?m!==null?m+"Capture":null:m;y=[];for(var f=u,v;f!==null;){v=f;var S=v.stateNode;if(v.tag===5&&S!==null&&(v=S,g!==null&&(S=Ur(f,g),S!=null&&y.push(Qr(f,S,v)))),j)break;f=f.return}0<y.length&&(m=new w(m,x,null,n,p),h.push({event:m,listeners:y}))}}if(!(t&7)){e:{if(m=e==="mouseover"||e==="pointerover",w=e==="mouseout"||e==="pointerout",m&&n!==Ts&&(x=n.relatedTarget||n.fromElement)&&(jn(x)||x[Dt]))break e;if((w||m)&&(m=p.window===p?p:(m=p.ownerDocument)?m.defaultView||m.parentWindow:window,w?(x=n.relatedTarget||n.toElement,w=u,x=x?jn(x):null,x!==null&&(j=An(x),x!==j||x.tag!==5&&x.tag!==6)&&(x=null)):(w=null,x=u),w!==x)){if(y=Ol,S="onMouseLeave",g="onMouseEnter",f="mouse",(e==="pointerout"||e==="pointerover")&&(y=Dl,S="onPointerLeave",g="onPointerEnter",f="pointer"),j=w==null?m:Hn(w),v=x==null?m:Hn(x),m=new y(S,f+"leave",w,n,p),m.target=j,m.relatedTarget=v,S=null,jn(p)===u&&(y=new y(g,f+"enter",x,n,p),y.target=v,y.relatedTarget=j,S=y),j=S,w&&x)t:{for(y=w,g=x,f=0,v=y;v;v=Fn(v))f++;for(v=0,S=g;S;S=Fn(S))v++;for(;0<f-v;)y=Fn(y),f--;for(;0<v-f;)g=Fn(g),v--;for(;f--;){if(y===g||g!==null&&y===g.alternate)break t;y=Fn(y),g=Fn(g)}y=null}else y=null;w!==null&&ql(h,m,w,y,!1),x!==null&&j!==null&&ql(h,j,x,y,!0)}}e:{if(m=u?Hn(u):window,w=m.nodeName&&m.nodeName.toLowerCase(),w==="select"||w==="input"&&m.type==="file")var E=km;else if(Hl(m))if(Yu)E=Em;else{E=bm;var z=Cm}else(w=m.nodeName)&&w.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(E=Nm);if(E&&(E=E(e,u))){Gu(h,E,n,p);break e}z&&z(e,m,u),e==="focusout"&&(z=m._wrapperState)&&z.controlled&&m.type==="number"&&Ns(m,"number",m.value)}switch(z=u?Hn(u):window,e){case"focusin":(Hl(z)||z.contentEditable==="true")&&(Un=z,Fs=u,Ar=null);break;case"focusout":Ar=Fs=Un=null;break;case"mousedown":Os=!0;break;case"contextmenu":case"mouseup":case"dragend":Os=!1,Ql(h,n,p);break;case"selectionchange":if(Pm)break;case"keydown":case"keyup":Ql(h,n,p)}var k;if(Fi)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else Dn?Vu(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(Hu&&n.locale!=="ko"&&(Dn||N!=="onCompositionStart"?N==="onCompositionEnd"&&Dn&&(k=Wu()):(Zt=p,$i="value"in Zt?Zt.value:Zt.textContent,Dn=!0)),z=Za(u,N),0<z.length&&(N=new Bl(N,e,null,n,p),h.push({event:N,listeners:z}),k?N.data=k:(k=Ku(n),k!==null&&(N.data=k)))),(k=ym?xm(e,n):wm(e,n))&&(u=Za(u,"onBeforeInput"),0<u.length&&(p=new Bl("onBeforeInput","beforeinput",null,n,p),h.push({event:p,listeners:u}),p.data=k))}ad(h,t)})}function Qr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Za(e,t){for(var n=t+"Capture",r=[];e!==null;){var a=e,s=a.stateNode;a.tag===5&&s!==null&&(a=s,s=Ur(e,n),s!=null&&r.unshift(Qr(e,s,a)),s=Ur(e,t),s!=null&&r.push(Qr(e,s,a))),e=e.return}return r}function Fn(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function ql(e,t,n,r,a){for(var s=t._reactName,i=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,a?(c=Ur(n,s),c!=null&&i.unshift(Qr(n,c,l))):a||(c=Ur(n,s),c!=null&&i.push(Qr(n,c,l)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var Am=/\r\n?/g,$m=/\u0000|\uFFFD/g;function Zl(e){return(typeof e=="string"?e:""+e).replace(Am,`
38
+ `).replace($m,"")}function Sa(e,t,n){if(t=Zl(t),Zl(e)!==t&&n)throw Error(M(425))}function eo(){}var Bs=null,Ds=null;function Us(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Ws=typeof setTimeout=="function"?setTimeout:void 0,Lm=typeof clearTimeout=="function"?clearTimeout:void 0,ec=typeof Promise=="function"?Promise:void 0,Mm=typeof queueMicrotask=="function"?queueMicrotask:typeof ec<"u"?function(e){return ec.resolve(null).then(e).catch(Fm)}:Ws;function Fm(e){setTimeout(function(){throw e})}function ns(e,t){var n=t,r=0;do{var a=n.nextSibling;if(e.removeChild(n),a&&a.nodeType===8)if(n=a.data,n==="/$"){if(r===0){e.removeChild(a),Vr(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=a}while(n);Vr(t)}function an(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function tc(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var fr=Math.random().toString(36).slice(2),It="__reactFiber$"+fr,Jr="__reactProps$"+fr,Dt="__reactContainer$"+fr,Hs="__reactEvents$"+fr,Om="__reactListeners$"+fr,Bm="__reactHandles$"+fr;function jn(e){var t=e[It];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Dt]||n[It]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=tc(e);e!==null;){if(n=e[It])return n;e=tc(e)}return t}e=n,n=e.parentNode}return null}function ia(e){return e=e[It]||e[Dt],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Hn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(M(33))}function bo(e){return e[Jr]||null}var Vs=[],Vn=-1;function pn(e){return{current:e}}function de(e){0>Vn||(e.current=Vs[Vn],Vs[Vn]=null,Vn--)}function ce(e,t){Vn++,Vs[Vn]=e.current,e.current=t}var dn={},Fe=pn(dn),Qe=pn(!1),zn=dn;function ar(e,t){var n=e.type.contextTypes;if(!n)return dn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},s;for(s in n)a[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Je(e){return e=e.childContextTypes,e!=null}function to(){de(Qe),de(Fe)}function nc(e,t,n){if(Fe.current!==dn)throw Error(M(168));ce(Fe,t),ce(Qe,n)}function sd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(M(108,Cp(e)||"Unknown",a));return ye({},n,r)}function no(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||dn,zn=Fe.current,ce(Fe,e),ce(Qe,Qe.current),!0}function rc(e,t,n){var r=e.stateNode;if(!r)throw Error(M(169));n?(e=sd(e,t,zn),r.__reactInternalMemoizedMergedChildContext=e,de(Qe),de(Fe),ce(Fe,e)):de(Qe),ce(Qe,n)}var $t=null,No=!1,rs=!1;function id(e){$t===null?$t=[e]:$t.push(e)}function Dm(e){No=!0,id(e)}function mn(){if(!rs&&$t!==null){rs=!0;var e=0,t=se;try{var n=$t;for(se=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}$t=null,No=!1}catch(a){throw $t!==null&&($t=$t.slice(e+1)),Ru(Ti,mn),a}finally{se=t,rs=!1}}return null}var Kn=[],Gn=0,ro=null,ao=0,ct=[],ut=0,In=null,Lt=1,Mt="";function xn(e,t){Kn[Gn++]=ao,Kn[Gn++]=ro,ro=e,ao=t}function ld(e,t,n){ct[ut++]=Lt,ct[ut++]=Mt,ct[ut++]=In,In=e;var r=Lt;e=Mt;var a=32-St(r)-1;r&=~(1<<a),n+=1;var s=32-St(t)+a;if(30<s){var i=a-a%5;s=(r&(1<<i)-1).toString(32),r>>=i,a-=i,Lt=1<<32-St(t)+a|n<<a|r,Mt=s+e}else Lt=1<<s|n<<a|r,Mt=e}function Bi(e){e.return!==null&&(xn(e,1),ld(e,1,0))}function Di(e){for(;e===ro;)ro=Kn[--Gn],Kn[Gn]=null,ao=Kn[--Gn],Kn[Gn]=null;for(;e===In;)In=ct[--ut],ct[ut]=null,Mt=ct[--ut],ct[ut]=null,Lt=ct[--ut],ct[ut]=null}var rt=null,nt=null,pe=!1,wt=null;function cd(e,t){var n=dt(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function ac(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,rt=e,nt=an(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,rt=e,nt=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=In!==null?{id:Lt,overflow:Mt}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=dt(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,rt=e,nt=null,!0):!1;default:return!1}}function Ks(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Gs(e){if(pe){var t=nt;if(t){var n=t;if(!ac(e,t)){if(Ks(e))throw Error(M(418));t=an(n.nextSibling);var r=rt;t&&ac(e,t)?cd(r,n):(e.flags=e.flags&-4097|2,pe=!1,rt=e)}}else{if(Ks(e))throw Error(M(418));e.flags=e.flags&-4097|2,pe=!1,rt=e}}}function oc(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;rt=e}function ja(e){if(e!==rt)return!1;if(!pe)return oc(e),pe=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Us(e.type,e.memoizedProps)),t&&(t=nt)){if(Ks(e))throw ud(),Error(M(418));for(;t;)cd(e,t),t=an(t.nextSibling)}if(oc(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(M(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){nt=an(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}nt=null}}else nt=rt?an(e.stateNode.nextSibling):null;return!0}function ud(){for(var e=nt;e;)e=an(e.nextSibling)}function or(){nt=rt=null,pe=!1}function Ui(e){wt===null?wt=[e]:wt.push(e)}var Um=Vt.ReactCurrentBatchConfig;function Sr(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(M(309));var r=n.stateNode}if(!r)throw Error(M(147,e));var a=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(i){var l=a.refs;i===null?delete l[s]:l[s]=i},t._stringRef=s,t)}if(typeof e!="string")throw Error(M(284));if(!n._owner)throw Error(M(290,e))}return e}function ka(e,t){throw e=Object.prototype.toString.call(t),Error(M(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function sc(e){var t=e._init;return t(e._payload)}function dd(e){function t(g,f){if(e){var v=g.deletions;v===null?(g.deletions=[f],g.flags|=16):v.push(f)}}function n(g,f){if(!e)return null;for(;f!==null;)t(g,f),f=f.sibling;return null}function r(g,f){for(g=new Map;f!==null;)f.key!==null?g.set(f.key,f):g.set(f.index,f),f=f.sibling;return g}function a(g,f){return g=cn(g,f),g.index=0,g.sibling=null,g}function s(g,f,v){return g.index=v,e?(v=g.alternate,v!==null?(v=v.index,v<f?(g.flags|=2,f):v):(g.flags|=2,f)):(g.flags|=1048576,f)}function i(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,f,v,S){return f===null||f.tag!==6?(f=us(v,g.mode,S),f.return=g,f):(f=a(f,v),f.return=g,f)}function c(g,f,v,S){var E=v.type;return E===Bn?p(g,f,v.props.children,S,v.key):f!==null&&(f.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&sc(E)===f.type)?(S=a(f,v.props),S.ref=Sr(g,f,v),S.return=g,S):(S=Ua(v.type,v.key,v.props,null,g.mode,S),S.ref=Sr(g,f,v),S.return=g,S)}function u(g,f,v,S){return f===null||f.tag!==4||f.stateNode.containerInfo!==v.containerInfo||f.stateNode.implementation!==v.implementation?(f=ds(v,g.mode,S),f.return=g,f):(f=a(f,v.children||[]),f.return=g,f)}function p(g,f,v,S,E){return f===null||f.tag!==7?(f=En(v,g.mode,S,E),f.return=g,f):(f=a(f,v),f.return=g,f)}function h(g,f,v){if(typeof f=="string"&&f!==""||typeof f=="number")return f=us(""+f,g.mode,v),f.return=g,f;if(typeof f=="object"&&f!==null){switch(f.$$typeof){case fa:return v=Ua(f.type,f.key,f.props,null,g.mode,v),v.ref=Sr(g,null,f),v.return=g,v;case On:return f=ds(f,g.mode,v),f.return=g,f;case Yt:var S=f._init;return h(g,S(f._payload),v)}if(Nr(f)||gr(f))return f=En(f,g.mode,v,null),f.return=g,f;ka(g,f)}return null}function m(g,f,v,S){var E=f!==null?f.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return E!==null?null:l(g,f,""+v,S);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case fa:return v.key===E?c(g,f,v,S):null;case On:return v.key===E?u(g,f,v,S):null;case Yt:return E=v._init,m(g,f,E(v._payload),S)}if(Nr(v)||gr(v))return E!==null?null:p(g,f,v,S,null);ka(g,v)}return null}function w(g,f,v,S,E){if(typeof S=="string"&&S!==""||typeof S=="number")return g=g.get(v)||null,l(f,g,""+S,E);if(typeof S=="object"&&S!==null){switch(S.$$typeof){case fa:return g=g.get(S.key===null?v:S.key)||null,c(f,g,S,E);case On:return g=g.get(S.key===null?v:S.key)||null,u(f,g,S,E);case Yt:var z=S._init;return w(g,f,v,z(S._payload),E)}if(Nr(S)||gr(S))return g=g.get(v)||null,p(f,g,S,E,null);ka(f,S)}return null}function x(g,f,v,S){for(var E=null,z=null,k=f,N=f=0,b=null;k!==null&&N<v.length;N++){k.index>N?(b=k,k=null):b=k.sibling;var I=m(g,k,v[N],S);if(I===null){k===null&&(k=b);break}e&&k&&I.alternate===null&&t(g,k),f=s(I,f,N),z===null?E=I:z.sibling=I,z=I,k=b}if(N===v.length)return n(g,k),pe&&xn(g,N),E;if(k===null){for(;N<v.length;N++)k=h(g,v[N],S),k!==null&&(f=s(k,f,N),z===null?E=k:z.sibling=k,z=k);return pe&&xn(g,N),E}for(k=r(g,k);N<v.length;N++)b=w(k,g,N,v[N],S),b!==null&&(e&&b.alternate!==null&&k.delete(b.key===null?N:b.key),f=s(b,f,N),z===null?E=b:z.sibling=b,z=b);return e&&k.forEach(function(H){return t(g,H)}),pe&&xn(g,N),E}function y(g,f,v,S){var E=gr(v);if(typeof E!="function")throw Error(M(150));if(v=E.call(v),v==null)throw Error(M(151));for(var z=E=null,k=f,N=f=0,b=null,I=v.next();k!==null&&!I.done;N++,I=v.next()){k.index>N?(b=k,k=null):b=k.sibling;var H=m(g,k,I.value,S);if(H===null){k===null&&(k=b);break}e&&k&&H.alternate===null&&t(g,k),f=s(H,f,N),z===null?E=H:z.sibling=H,z=H,k=b}if(I.done)return n(g,k),pe&&xn(g,N),E;if(k===null){for(;!I.done;N++,I=v.next())I=h(g,I.value,S),I!==null&&(f=s(I,f,N),z===null?E=I:z.sibling=I,z=I);return pe&&xn(g,N),E}for(k=r(g,k);!I.done;N++,I=v.next())I=w(k,g,N,I.value,S),I!==null&&(e&&I.alternate!==null&&k.delete(I.key===null?N:I.key),f=s(I,f,N),z===null?E=I:z.sibling=I,z=I);return e&&k.forEach(function(U){return t(g,U)}),pe&&xn(g,N),E}function j(g,f,v,S){if(typeof v=="object"&&v!==null&&v.type===Bn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case fa:e:{for(var E=v.key,z=f;z!==null;){if(z.key===E){if(E=v.type,E===Bn){if(z.tag===7){n(g,z.sibling),f=a(z,v.props.children),f.return=g,g=f;break e}}else if(z.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===Yt&&sc(E)===z.type){n(g,z.sibling),f=a(z,v.props),f.ref=Sr(g,z,v),f.return=g,g=f;break e}n(g,z);break}else t(g,z);z=z.sibling}v.type===Bn?(f=En(v.props.children,g.mode,S,v.key),f.return=g,g=f):(S=Ua(v.type,v.key,v.props,null,g.mode,S),S.ref=Sr(g,f,v),S.return=g,g=S)}return i(g);case On:e:{for(z=v.key;f!==null;){if(f.key===z)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(g,f.sibling),f=a(f,v.children||[]),f.return=g,g=f;break e}else{n(g,f);break}else t(g,f);f=f.sibling}f=ds(v,g.mode,S),f.return=g,g=f}return i(g);case Yt:return z=v._init,j(g,f,z(v._payload),S)}if(Nr(v))return x(g,f,v,S);if(gr(v))return y(g,f,v,S);ka(g,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(g,f.sibling),f=a(f,v),f.return=g,g=f):(n(g,f),f=us(v,g.mode,S),f.return=g,g=f),i(g)):n(g,f)}return j}var sr=dd(!0),fd=dd(!1),oo=pn(null),so=null,Yn=null,Wi=null;function Hi(){Wi=Yn=so=null}function Vi(e){var t=oo.current;de(oo),e._currentValue=t}function Ys(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function tr(e,t){so=e,Wi=Yn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ye=!0),e.firstContext=null)}function pt(e){var t=e._currentValue;if(Wi!==e)if(e={context:e,memoizedValue:t,next:null},Yn===null){if(so===null)throw Error(M(308));Yn=e,so.dependencies={lanes:0,firstContext:e}}else Yn=Yn.next=e;return t}var kn=null;function Ki(e){kn===null?kn=[e]:kn.push(e)}function pd(e,t,n,r){var a=t.interleaved;return a===null?(n.next=n,Ki(t)):(n.next=a.next,a.next=n),t.interleaved=n,Ut(e,r)}function Ut(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qt=!1;function Gi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function md(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ot(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function on(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,re&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,Ut(e,n)}return a=r.interleaved,a===null?(t.next=t,Ki(r)):(t.next=a.next,a.next=t),r.interleaved=t,Ut(e,n)}function La(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ri(e,n)}}function ic(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var a=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?a=s=i:s=s.next=i,n=n.next}while(n!==null);s===null?a=s=t:s=s.next=t}else a=s=t;n={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function io(e,t,n,r){var a=e.updateQueue;Qt=!1;var s=a.firstBaseUpdate,i=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,u=c.next;c.next=null,i===null?s=u:i.next=u,i=c;var p=e.alternate;p!==null&&(p=p.updateQueue,l=p.lastBaseUpdate,l!==i&&(l===null?p.firstBaseUpdate=u:l.next=u,p.lastBaseUpdate=c))}if(s!==null){var h=a.baseState;i=0,p=u=c=null,l=s;do{var m=l.lane,w=l.eventTime;if((r&m)===m){p!==null&&(p=p.next={eventTime:w,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,y=l;switch(m=t,w=n,y.tag){case 1:if(x=y.payload,typeof x=="function"){h=x.call(w,h,m);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=y.payload,m=typeof x=="function"?x.call(w,h,m):x,m==null)break e;h=ye({},h,m);break e;case 2:Qt=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,m=a.effects,m===null?a.effects=[l]:m.push(l))}else w={eventTime:w,lane:m,tag:l.tag,payload:l.payload,callback:l.callback,next:null},p===null?(u=p=w,c=h):p=p.next=w,i|=m;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;m=l,l=m.next,m.next=null,a.lastBaseUpdate=m,a.shared.pending=null}}while(!0);if(p===null&&(c=h),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=p,t=a.shared.interleaved,t!==null){a=t;do i|=a.lane,a=a.next;while(a!==t)}else s===null&&(a.shared.lanes=0);Tn|=i,e.lanes=i,e.memoizedState=h}}function lc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=n,typeof a!="function")throw Error(M(191,a));a.call(r)}}}var la={},Tt=pn(la),Xr=pn(la),qr=pn(la);function Cn(e){if(e===la)throw Error(M(174));return e}function Yi(e,t){switch(ce(qr,t),ce(Xr,e),ce(Tt,la),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:zs(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=zs(t,e)}de(Tt),ce(Tt,t)}function ir(){de(Tt),de(Xr),de(qr)}function hd(e){Cn(qr.current);var t=Cn(Tt.current),n=zs(t,e.type);t!==n&&(ce(Xr,e),ce(Tt,n))}function Qi(e){Xr.current===e&&(de(Tt),de(Xr))}var ge=pn(0);function lo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var as=[];function Ji(){for(var e=0;e<as.length;e++)as[e]._workInProgressVersionPrimary=null;as.length=0}var Ma=Vt.ReactCurrentDispatcher,os=Vt.ReactCurrentBatchConfig,Pn=0,ve=null,Ce=null,Ee=null,co=!1,$r=!1,Zr=0,Wm=0;function $e(){throw Error(M(321))}function Xi(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!kt(e[n],t[n]))return!1;return!0}function qi(e,t,n,r,a,s){if(Pn=s,ve=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ma.current=e===null||e.memoizedState===null?Gm:Ym,e=n(r,a),$r){s=0;do{if($r=!1,Zr=0,25<=s)throw Error(M(301));s+=1,Ee=Ce=null,t.updateQueue=null,Ma.current=Qm,e=n(r,a)}while($r)}if(Ma.current=uo,t=Ce!==null&&Ce.next!==null,Pn=0,Ee=Ce=ve=null,co=!1,t)throw Error(M(300));return e}function Zi(){var e=Zr!==0;return Zr=0,e}function Et(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ee===null?ve.memoizedState=Ee=e:Ee=Ee.next=e,Ee}function mt(){if(Ce===null){var e=ve.alternate;e=e!==null?e.memoizedState:null}else e=Ce.next;var t=Ee===null?ve.memoizedState:Ee.next;if(t!==null)Ee=t,Ce=e;else{if(e===null)throw Error(M(310));Ce=e,e={memoizedState:Ce.memoizedState,baseState:Ce.baseState,baseQueue:Ce.baseQueue,queue:Ce.queue,next:null},Ee===null?ve.memoizedState=Ee=e:Ee=Ee.next=e}return Ee}function ea(e,t){return typeof t=="function"?t(e):t}function ss(e){var t=mt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=Ce,a=r.baseQueue,s=n.pending;if(s!==null){if(a!==null){var i=a.next;a.next=s.next,s.next=i}r.baseQueue=a=s,n.pending=null}if(a!==null){s=a.next,r=r.baseState;var l=i=null,c=null,u=s;do{var p=u.lane;if((Pn&p)===p)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:p,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=h,i=r):c=c.next=h,ve.lanes|=p,Tn|=p}u=u.next}while(u!==null&&u!==s);c===null?i=r:c.next=l,kt(r,t.memoizedState)||(Ye=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){a=e;do s=a.lane,ve.lanes|=s,Tn|=s,a=a.next;while(a!==e)}else a===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function is(e){var t=mt(),n=t.queue;if(n===null)throw Error(M(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,s=t.memoizedState;if(a!==null){n.pending=null;var i=a=a.next;do s=e(s,i.action),i=i.next;while(i!==a);kt(s,t.memoizedState)||(Ye=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function gd(){}function vd(e,t){var n=ve,r=mt(),a=t(),s=!kt(r.memoizedState,a);if(s&&(r.memoizedState=a,Ye=!0),r=r.queue,el(wd.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||Ee!==null&&Ee.memoizedState.tag&1){if(n.flags|=2048,ta(9,xd.bind(null,n,r,a,t),void 0,null),ze===null)throw Error(M(349));Pn&30||yd(n,t,a)}return a}function yd(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ve.updateQueue,t===null?(t={lastEffect:null,stores:null},ve.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function xd(e,t,n,r){t.value=n,t.getSnapshot=r,Sd(t)&&jd(e)}function wd(e,t,n){return n(function(){Sd(t)&&jd(e)})}function Sd(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kt(e,n)}catch{return!0}}function jd(e){var t=Ut(e,1);t!==null&&jt(t,e,1,-1)}function cc(e){var t=Et();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ea,lastRenderedState:e},t.queue=e,e=e.dispatch=Km.bind(null,ve,e),[t.memoizedState,e]}function ta(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ve.updateQueue,t===null?(t={lastEffect:null,stores:null},ve.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function kd(){return mt().memoizedState}function Fa(e,t,n,r){var a=Et();ve.flags|=e,a.memoizedState=ta(1|t,n,void 0,r===void 0?null:r)}function Eo(e,t,n,r){var a=mt();r=r===void 0?null:r;var s=void 0;if(Ce!==null){var i=Ce.memoizedState;if(s=i.destroy,r!==null&&Xi(r,i.deps)){a.memoizedState=ta(t,n,s,r);return}}ve.flags|=e,a.memoizedState=ta(1|t,n,s,r)}function uc(e,t){return Fa(8390656,8,e,t)}function el(e,t){return Eo(2048,8,e,t)}function Cd(e,t){return Eo(4,2,e,t)}function bd(e,t){return Eo(4,4,e,t)}function Nd(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ed(e,t,n){return n=n!=null?n.concat([e]):null,Eo(4,4,Nd.bind(null,t,e),n)}function tl(){}function zd(e,t){var n=mt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Xi(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Id(e,t){var n=mt();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Xi(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Pd(e,t,n){return Pn&21?(kt(n,t)||(n=$u(),ve.lanes|=n,Tn|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ye=!0),e.memoizedState=n)}function Hm(e,t){var n=se;se=n!==0&&4>n?n:4,e(!0);var r=os.transition;os.transition={};try{e(!1),t()}finally{se=n,os.transition=r}}function Td(){return mt().memoizedState}function Vm(e,t,n){var r=ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rd(e))_d(t,n);else if(n=pd(e,t,n,r),n!==null){var a=De();jt(n,e,r,a),Ad(n,t,r)}}function Km(e,t,n){var r=ln(e),a={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rd(e))_d(t,a);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var i=t.lastRenderedState,l=s(i,n);if(a.hasEagerState=!0,a.eagerState=l,kt(l,i)){var c=t.interleaved;c===null?(a.next=a,Ki(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}n=pd(e,t,a,r),n!==null&&(a=De(),jt(n,e,r,a),Ad(n,t,r))}}function Rd(e){var t=e.alternate;return e===ve||t!==null&&t===ve}function _d(e,t){$r=co=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ad(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ri(e,n)}}var uo={readContext:pt,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useInsertionEffect:$e,useLayoutEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useMutableSource:$e,useSyncExternalStore:$e,useId:$e,unstable_isNewReconciler:!1},Gm={readContext:pt,useCallback:function(e,t){return Et().memoizedState=[e,t===void 0?null:t],e},useContext:pt,useEffect:uc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fa(4194308,4,Nd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fa(4,2,e,t)},useMemo:function(e,t){var n=Et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Vm.bind(null,ve,e),[r.memoizedState,e]},useRef:function(e){var t=Et();return e={current:e},t.memoizedState=e},useState:cc,useDebugValue:tl,useDeferredValue:function(e){return Et().memoizedState=e},useTransition:function(){var e=cc(!1),t=e[0];return e=Hm.bind(null,e[1]),Et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ve,a=Et();if(pe){if(n===void 0)throw Error(M(407));n=n()}else{if(n=t(),ze===null)throw Error(M(349));Pn&30||yd(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,uc(wd.bind(null,r,s,e),[e]),r.flags|=2048,ta(9,xd.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Et(),t=ze.identifierPrefix;if(pe){var n=Mt,r=Lt;n=(r&~(1<<32-St(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zr++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=Wm++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Ym={readContext:pt,useCallback:zd,useContext:pt,useEffect:el,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:bd,useMemo:Id,useReducer:ss,useRef:kd,useState:function(){return ss(ea)},useDebugValue:tl,useDeferredValue:function(e){var t=mt();return Pd(t,Ce.memoizedState,e)},useTransition:function(){var e=ss(ea)[0],t=mt().memoizedState;return[e,t]},useMutableSource:gd,useSyncExternalStore:vd,useId:Td,unstable_isNewReconciler:!1},Qm={readContext:pt,useCallback:zd,useContext:pt,useEffect:el,useImperativeHandle:Ed,useInsertionEffect:Cd,useLayoutEffect:bd,useMemo:Id,useReducer:is,useRef:kd,useState:function(){return is(ea)},useDebugValue:tl,useDeferredValue:function(e){var t=mt();return Ce===null?t.memoizedState=e:Pd(t,Ce.memoizedState,e)},useTransition:function(){var e=is(ea)[0],t=mt().memoizedState;return[e,t]},useMutableSource:gd,useSyncExternalStore:vd,useId:Td,unstable_isNewReconciler:!1};function yt(e,t){if(e&&e.defaultProps){t=ye({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Qs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:ye({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var zo={isMounted:function(e){return(e=e._reactInternals)?An(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=De(),a=ln(e),s=Ot(r,a);s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(jt(t,e,a,r),La(t,e,a))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=De(),a=ln(e),s=Ot(r,a);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=on(e,s,a),t!==null&&(jt(t,e,a,r),La(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=De(),r=ln(e),a=Ot(n,r);a.tag=2,t!=null&&(a.callback=t),t=on(e,a,r),t!==null&&(jt(t,e,r,n),La(t,e,r))}};function dc(e,t,n,r,a,s,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,i):t.prototype&&t.prototype.isPureReactComponent?!Gr(n,r)||!Gr(a,s):!0}function $d(e,t,n){var r=!1,a=dn,s=t.contextType;return typeof s=="object"&&s!==null?s=pt(s):(a=Je(t)?zn:Fe.current,r=t.contextTypes,s=(r=r!=null)?ar(e,a):dn),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=zo,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=s),t}function fc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&zo.enqueueReplaceState(t,t.state,null)}function Js(e,t,n,r){var a=e.stateNode;a.props=n,a.state=e.memoizedState,a.refs={},Gi(e);var s=t.contextType;typeof s=="object"&&s!==null?a.context=pt(s):(s=Je(t)?zn:Fe.current,a.context=ar(e,s)),a.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(Qs(e,t,s,n),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&zo.enqueueReplaceState(a,a.state,null),io(e,n,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function lr(e,t){try{var n="",r=t;do n+=kp(r),r=r.return;while(r);var a=n}catch(s){a=`
39
39
  Error generating stack: `+s.message+`
40
- `+s.stack}return{value:e,source:t,stack:a,digest:null}}function ls(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Xs(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Jm=typeof WeakMap=="function"?WeakMap:Map;function Ld(e,t,n){n=Ot(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){po||(po=!0,ii=r),Xs(e,t)},n}function Md(e,t,n){n=Ot(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){Xs(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Xs(e,t),typeof r!="function"&&(sn===null?sn=new Set([this]):sn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function pc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Jm;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=uh.bind(null,e,t,n),t.then(e,e))}function mc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function hc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ot(-1,1),t.tag=2,on(n,t,1))),n.lanes|=1),e)}var Xm=Vt.ReactCurrentOwner,Ye=!1;function Be(e,t,n,r){t.child=e===null?fd(t,null,n,r):sr(t,e.child,n,r)}function gc(e,t,n,r,a){n=n.render;var s=t.ref;return tr(t,a),r=qi(e,t,n,r,s,a),n=Zi(),e!==null&&!Ye?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Wt(e,t,a)):(pe&&n&&Bi(t),t.flags|=1,Be(e,t,r,a),t.child)}function vc(e,t,n,r,a){if(e===null){var s=n.type;return typeof s=="function"&&!cl(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,Fd(e,t,s,r,a)):(e=Ua(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&a)){var i=s.memoizedProps;if(n=n.compare,n=n!==null?n:Gr,n(i,r)&&e.ref===t.ref)return Wt(e,t,a)}return t.flags|=1,e=cn(s,r),e.ref=t.ref,e.return=t,t.child=e}function Fd(e,t,n,r,a){if(e!==null){var s=e.memoizedProps;if(Gr(s,r)&&e.ref===t.ref)if(Ye=!1,t.pendingProps=r=s,(e.lanes&a)!==0)e.flags&131072&&(Ye=!0);else return t.lanes=e.lanes,Wt(e,t,a)}return qs(e,t,n,r,a)}function Od(e,t,n){var r=t.pendingProps,a=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ce(Jn,et),et|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ce(Jn,et),et|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ce(Jn,et),et|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,ce(Jn,et),et|=r;return Be(e,t,a,n),t.child}function Bd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function qs(e,t,n,r,a){var s=Je(n)?zn:Fe.current;return s=ar(t,s),tr(t,a),n=qi(e,t,n,r,s,a),r=Zi(),e!==null&&!Ye?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Wt(e,t,a)):(pe&&r&&Bi(t),t.flags|=1,Be(e,t,n,a),t.child)}function yc(e,t,n,r,a){if(Je(n)){var s=!0;no(t)}else s=!1;if(tr(t,a),t.stateNode===null)Oa(e,t),$d(t,n,r),Js(t,n,r,a),r=!0;else if(e===null){var i=t.stateNode,l=t.memoizedProps;i.props=l;var c=i.context,u=n.contextType;typeof u=="object"&&u!==null?u=pt(u):(u=Je(n)?zn:Fe.current,u=ar(t,u));var p=n.getDerivedStateFromProps,m=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function";m||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==u)&&fc(t,i,r,u),Qt=!1;var g=t.memoizedState;i.state=g,io(t,r,i,a),c=t.memoizedState,l!==r||g!==c||Qe.current||Qt?(typeof p=="function"&&(Qs(t,n,p,r),c=t.memoizedState),(l=Qt||dc(t,n,l,r,g,c,u))?(m||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=u,r=l):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,md(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:yt(t.type,l),i.props=u,m=t.pendingProps,g=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=pt(c):(c=Je(n)?zn:Fe.current,c=ar(t,c));var w=n.getDerivedStateFromProps;(p=typeof w=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==m||g!==c)&&fc(t,i,r,c),Qt=!1,g=t.memoizedState,i.state=g,io(t,r,i,a);var x=t.memoizedState;l!==m||g!==x||Qe.current||Qt?(typeof w=="function"&&(Qs(t,n,w,r),x=t.memoizedState),(u=Qt||dc(t,n,u,r,g,x,c)||!1)?(p||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,x,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,x,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),i.props=r,i.state=x,i.context=c,r=u):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&g===e.memoizedState||(t.flags|=1024),r=!1)}return Zs(e,t,n,r,s,a)}function Zs(e,t,n,r,a,s){Bd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return a&&rc(t,n,!1),Wt(e,t,s);r=t.stateNode,Xm.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=sr(t,e.child,null,s),t.child=sr(t,null,l,s)):Be(e,t,l,s),t.memoizedState=r.state,a&&rc(t,n,!0),t.child}function Dd(e){var t=e.stateNode;t.pendingContext?nc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&nc(e,t.context,!1),Yi(e,t.containerInfo)}function xc(e,t,n,r,a){return or(),Ui(a),t.flags|=256,Be(e,t,n,r),t.child}var ei={dehydrated:null,treeContext:null,retryLane:0};function ti(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ud(e,t,n){var r=t.pendingProps,a=ge.current,s=!1,i=(t.flags&128)!==0,l;if((l=i)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ce(ge,a&1),e===null)return Gs(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,s?(r=t.mode,s=t.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=To(i,r,0,null),e=En(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=ti(n),t.memoizedState=ei,e):nl(t,i));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return qm(e,t,i,r,l,a,n);if(s){s=r.fallback,i=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=cn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?s=cn(l,s):(s=En(s,i,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,i=e.child.memoizedState,i=i===null?ti(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=ei,r}return s=e.child,e=s.sibling,r=cn(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function nl(e,t){return t=To({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ca(e,t,n,r){return r!==null&&Ui(r),sr(t,e.child,null,n),e=nl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function qm(e,t,n,r,a,s,i){if(n)return t.flags&256?(t.flags&=-257,r=ls(Error(M(422))),Ca(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,a=t.mode,r=To({mode:"visible",children:r.children},a,0,null),s=En(s,a,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&sr(t,e.child,null,i),t.child.memoizedState=ti(i),t.memoizedState=ei,s);if(!(t.mode&1))return Ca(e,t,i,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(M(419)),r=ls(s,r,void 0),Ca(e,t,i,r)}if(l=(i&e.childLanes)!==0,Ye||l){if(r=ze,r!==null){switch(i&-i){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|i)?0:a,a!==0&&a!==s.retryLane&&(s.retryLane=a,Ut(e,a),jt(r,e,a,-1))}return ll(),r=ls(Error(M(421))),Ca(e,t,i,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=dh.bind(null,e),a._reactRetry=t,null):(e=s.treeContext,nt=an(a.nextSibling),rt=t,pe=!0,wt=null,e!==null&&(ct[ut++]=Lt,ct[ut++]=Mt,ct[ut++]=In,Lt=e.id,Mt=e.overflow,In=t),t=nl(t,r.children),t.flags|=4096,t)}function wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ys(e.return,t,n)}function cs(e,t,n,r,a){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=a)}function Wd(e,t,n){var r=t.pendingProps,a=r.revealOrder,s=r.tail;if(Be(e,t,r.children,n),r=ge.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wc(e,n,t);else if(e.tag===19)wc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ce(ge,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&lo(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),cs(t,!1,a,n,s);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&lo(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}cs(t,!0,n,null,s);break;case"together":cs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Oa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Tn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(M(153));if(t.child!==null){for(e=t.child,n=cn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=cn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Zm(e,t,n){switch(t.tag){case 3:Dd(t),or();break;case 5:hd(t);break;case 1:Je(t.type)&&no(t);break;case 4:Yi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ce(oo,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ce(ge,ge.current&1),t.flags|=128,null):n&t.child.childLanes?Ud(e,t,n):(ce(ge,ge.current&1),e=Wt(e,t,n),e!==null?e.sibling:null);ce(ge,ge.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Wd(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ce(ge,ge.current),r)break;return null;case 22:case 23:return t.lanes=0,Od(e,t,n)}return Wt(e,t,n)}var Hd,ni,Vd,Kd;Hd=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};ni=function(){};Vd=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Cn(Tt.current);var s=null;switch(n){case"input":a=Cs(e,a),r=Cs(e,r),s=[];break;case"select":a=ye({},a,{value:void 0}),r=ye({},r,{value:void 0}),s=[];break;case"textarea":a=Es(e,a),r=Es(e,r),s=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=eo)}Is(n,r);var i;n=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var l=a[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Br.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(s=s||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Br.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&ue("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}};Kd=function(e,t,n,r){n!==r&&(t.flags|=4)};function jr(e,t){if(!pe)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Le(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function eh(e,t,n){var r=t.pendingProps;switch(Di(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Le(t),null;case 1:return Je(t.type)&&to(),Le(t),null;case 3:return r=t.stateNode,ir(),de(Qe),de(Fe),Ji(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ja(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,wt!==null&&(ui(wt),wt=null))),ni(e,t),Le(t),null;case 5:Qi(t);var a=Cn(qr.current);if(n=t.type,e!==null&&t.stateNode!=null)Vd(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(M(166));return Le(t),null}if(e=Cn(Tt.current),ja(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[It]=t,r[Jr]=s,e=(t.mode&1)!==0,n){case"dialog":ue("cancel",r),ue("close",r);break;case"iframe":case"object":case"embed":ue("load",r);break;case"video":case"audio":for(a=0;a<zr.length;a++)ue(zr[a],r);break;case"source":ue("error",r);break;case"img":case"image":case"link":ue("error",r),ue("load",r);break;case"details":ue("toggle",r);break;case"input":Il(r,s),ue("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},ue("invalid",r);break;case"textarea":Tl(r,s),ue("invalid",r)}Is(n,s),a=null;for(var i in s)if(s.hasOwnProperty(i)){var l=s[i];i==="children"?typeof l=="string"?r.textContent!==l&&(s.suppressHydrationWarning!==!0&&Sa(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&Sa(r.textContent,l,e),a=["children",""+l]):Br.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&ue("scroll",r)}switch(n){case"input":pa(r),Pl(r,s,!0);break;case"textarea":pa(r),Rl(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=eo)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=wu(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[It]=t,e[Jr]=r,Hd(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ps(n,r),n){case"dialog":ue("cancel",e),ue("close",e),a=r;break;case"iframe":case"object":case"embed":ue("load",e),a=r;break;case"video":case"audio":for(a=0;a<zr.length;a++)ue(zr[a],e);a=r;break;case"source":ue("error",e),a=r;break;case"img":case"image":case"link":ue("error",e),ue("load",e),a=r;break;case"details":ue("toggle",e),a=r;break;case"input":Il(e,r),a=Cs(e,r),ue("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=ye({},r,{value:void 0}),ue("invalid",e);break;case"textarea":Tl(e,r),a=Es(e,r),ue("invalid",e);break;default:a=r}Is(n,a),l=a;for(s in l)if(l.hasOwnProperty(s)){var c=l[s];s==="style"?ku(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Su(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Dr(e,c):typeof c=="number"&&Dr(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Br.hasOwnProperty(s)?c!=null&&s==="onScroll"&&ue("scroll",e):c!=null&&Ni(e,s,c,i))}switch(n){case"input":pa(e),Pl(e,r,!1);break;case"textarea":pa(e),Rl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+un(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Xn(e,!!r.multiple,s,!1):r.defaultValue!=null&&Xn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=eo)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Le(t),null;case 6:if(e&&t.stateNode!=null)Kd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=Cn(qr.current),Cn(Tt.current),ja(t)){if(r=t.stateNode,n=t.memoizedProps,r[It]=t,(s=r.nodeValue!==n)&&(e=rt,e!==null))switch(e.tag){case 3:Sa(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Sa(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[It]=t,t.stateNode=r}return Le(t),null;case 13:if(de(ge),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(pe&&nt!==null&&t.mode&1&&!(t.flags&128))ud(),or(),t.flags|=98560,s=!1;else if(s=ja(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(M(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(M(317));s[It]=t}else or(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Le(t),s=!1}else wt!==null&&(ui(wt),wt=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||ge.current&1?be===0&&(be=3):ll())),t.updateQueue!==null&&(t.flags|=4),Le(t),null);case 4:return ir(),ni(e,t),e===null&&Yr(t.stateNode.containerInfo),Le(t),null;case 10:return Vi(t.type._context),Le(t),null;case 17:return Je(t.type)&&to(),Le(t),null;case 19:if(de(ge),s=t.memoizedState,s===null)return Le(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)jr(s,!1);else{if(be!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=lo(e),i!==null){for(t.flags|=128,jr(s,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,i=s.alternate,i===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=i.childLanes,s.lanes=i.lanes,s.child=i.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=i.memoizedProps,s.memoizedState=i.memoizedState,s.updateQueue=i.updateQueue,s.type=i.type,e=i.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ce(ge,ge.current&1|2),t.child}e=e.sibling}s.tail!==null&&we()>cr&&(t.flags|=128,r=!0,jr(s,!1),t.lanes=4194304)}else{if(!r)if(e=lo(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),jr(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!pe)return Le(t),null}else 2*we()-s.renderingStartTime>cr&&n!==1073741824&&(t.flags|=128,r=!0,jr(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=we(),t.sibling=null,n=ge.current,ce(ge,r?n&1|2:n&1),t):(Le(t),null);case 22:case 23:return il(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(Le(t),t.subtreeFlags&6&&(t.flags|=8192)):Le(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function th(e,t){switch(Di(t),t.tag){case 1:return Je(t.type)&&to(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ir(),de(Qe),de(Fe),Ji(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Qi(t),null;case 13:if(de(ge),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));or()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(ge),null;case 4:return ir(),null;case 10:return Vi(t.type._context),null;case 22:case 23:return il(),null;case 24:return null;default:return null}}var ba=!1,Me=!1,nh=typeof WeakSet=="function"?WeakSet:Set,G=null;function Qn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function ri(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Sc=!1;function rh(e,t){if(Bs=Xa,e=Xu(),Oi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,l=-1,c=-1,u=0,p=0,m=e,g=null;t:for(;;){for(var w;m!==n||a!==0&&m.nodeType!==3||(l=i+a),m!==s||r!==0&&m.nodeType!==3||(c=i+r),m.nodeType===3&&(i+=m.nodeValue.length),(w=m.firstChild)!==null;)g=m,m=w;for(;;){if(m===e)break t;if(g===n&&++u===a&&(l=i),g===s&&++p===r&&(c=i),(w=m.nextSibling)!==null)break;m=g,g=m.parentNode}m=w}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ds={focusedElem:e,selectionRange:n},Xa=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var y=x.memoizedProps,j=x.memoizedState,h=t.stateNode,f=h.getSnapshotBeforeUpdate(t.elementType===t.type?y:yt(t.type,y),j);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(M(163))}}catch(S){xe(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return x=Sc,Sc=!1,x}function Lr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var s=a.destroy;a.destroy=void 0,s!==void 0&&ri(t,n,s)}a=a.next}while(a!==r)}}function Io(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ai(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gd(e){var t=e.alternate;t!==null&&(e.alternate=null,Gd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[Jr],delete t[Hs],delete t[Om],delete t[Bm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Yd(e){return e.tag===5||e.tag===3||e.tag===4}function jc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Yd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function oi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=eo));else if(r!==4&&(e=e.child,e!==null))for(oi(e,t,n),e=e.sibling;e!==null;)oi(e,t,n),e=e.sibling}function si(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(si(e,t,n),e=e.sibling;e!==null;)si(e,t,n),e=e.sibling}var Te=null,xt=!1;function Gt(e,t,n){for(n=n.child;n!==null;)Qd(e,t,n),n=n.sibling}function Qd(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(So,n)}catch{}switch(n.tag){case 5:Me||Qn(n,t);case 6:var r=Te,a=xt;Te=null,Gt(e,t,n),Te=r,xt=a,Te!==null&&(xt?(e=Te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Te.removeChild(n.stateNode));break;case 18:Te!==null&&(xt?(e=Te,n=n.stateNode,e.nodeType===8?ns(e.parentNode,n):e.nodeType===1&&ns(e,n),Vr(e)):ns(Te,n.stateNode));break;case 4:r=Te,a=xt,Te=n.stateNode.containerInfo,xt=!0,Gt(e,t,n),Te=r,xt=a;break;case 0:case 11:case 14:case 15:if(!Me&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var s=a,i=s.destroy;s=s.tag,i!==void 0&&(s&2||s&4)&&ri(n,t,i),a=a.next}while(a!==r)}Gt(e,t,n);break;case 1:if(!Me&&(Qn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){xe(n,t,l)}Gt(e,t,n);break;case 21:Gt(e,t,n);break;case 22:n.mode&1?(Me=(r=Me)||n.memoizedState!==null,Gt(e,t,n),Me=r):Gt(e,t,n);break;default:Gt(e,t,n)}}function kc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new nh),t.forEach(function(r){var a=fh.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function vt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var s=e,i=t,l=i;e:for(;l!==null;){switch(l.tag){case 5:Te=l.stateNode,xt=!1;break e;case 3:Te=l.stateNode.containerInfo,xt=!0;break e;case 4:Te=l.stateNode.containerInfo,xt=!0;break e}l=l.return}if(Te===null)throw Error(M(160));Qd(s,i,a),Te=null,xt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(u){xe(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Jd(t,e),t=t.sibling}function Jd(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(vt(t,e),Nt(e),r&4){try{Lr(3,e,e.return),Io(3,e)}catch(y){xe(e,e.return,y)}try{Lr(5,e,e.return)}catch(y){xe(e,e.return,y)}}break;case 1:vt(t,e),Nt(e),r&512&&n!==null&&Qn(n,n.return);break;case 5:if(vt(t,e),Nt(e),r&512&&n!==null&&Qn(n,n.return),e.flags&32){var a=e.stateNode;try{Dr(a,"")}catch(y){xe(e,e.return,y)}}if(r&4&&(a=e.stateNode,a!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&yu(a,s),Ps(l,i);var u=Ps(l,s);for(i=0;i<c.length;i+=2){var p=c[i],m=c[i+1];p==="style"?ku(a,m):p==="dangerouslySetInnerHTML"?Su(a,m):p==="children"?Dr(a,m):Ni(a,p,m,u)}switch(l){case"input":bs(a,s);break;case"textarea":xu(a,s);break;case"select":var g=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!s.multiple;var w=s.value;w!=null?Xn(a,!!s.multiple,w,!1):g!==!!s.multiple&&(s.defaultValue!=null?Xn(a,!!s.multiple,s.defaultValue,!0):Xn(a,!!s.multiple,s.multiple?[]:"",!1))}a[Jr]=s}catch(y){xe(e,e.return,y)}}break;case 6:if(vt(t,e),Nt(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,s=e.memoizedProps;try{a.nodeValue=s}catch(y){xe(e,e.return,y)}}break;case 3:if(vt(t,e),Nt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vr(t.containerInfo)}catch(y){xe(e,e.return,y)}break;case 4:vt(t,e),Nt(e);break;case 13:vt(t,e),Nt(e),a=e.child,a.flags&8192&&(s=a.memoizedState!==null,a.stateNode.isHidden=s,!s||a.alternate!==null&&a.alternate.memoizedState!==null||(ol=we())),r&4&&kc(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Me=(u=Me)||p,vt(t,e),Me=u):vt(t,e),Nt(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(G=e,p=e.child;p!==null;){for(m=G=p;G!==null;){switch(g=G,w=g.child,g.tag){case 0:case 11:case 14:case 15:Lr(4,g,g.return);break;case 1:Qn(g,g.return);var x=g.stateNode;if(typeof x.componentWillUnmount=="function"){r=g,n=g.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(y){xe(r,n,y)}}break;case 5:Qn(g,g.return);break;case 22:if(g.memoizedState!==null){bc(m);continue}}w!==null?(w.return=g,G=w):bc(m)}p=p.sibling}e:for(p=null,m=e;;){if(m.tag===5){if(p===null){p=m;try{a=m.stateNode,u?(s=a.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=m.stateNode,c=m.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ju("display",i))}catch(y){xe(e,e.return,y)}}}else if(m.tag===6){if(p===null)try{m.stateNode.nodeValue=u?"":m.memoizedProps}catch(y){xe(e,e.return,y)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;p===m&&(p=null),m=m.return}p===m&&(p=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:vt(t,e),Nt(e),r&4&&kc(e);break;case 21:break;default:vt(t,e),Nt(e)}}function Nt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Yd(n)){var r=n;break e}n=n.return}throw Error(M(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(Dr(a,""),r.flags&=-33);var s=jc(e);si(e,s,a);break;case 3:case 4:var i=r.stateNode.containerInfo,l=jc(e);oi(e,l,i);break;default:throw Error(M(161))}}catch(c){xe(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ah(e,t,n){G=e,Xd(e)}function Xd(e,t,n){for(var r=(e.mode&1)!==0;G!==null;){var a=G,s=a.child;if(a.tag===22&&r){var i=a.memoizedState!==null||ba;if(!i){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Me;l=ba;var u=Me;if(ba=i,(Me=c)&&!u)for(G=a;G!==null;)i=G,c=i.child,i.tag===22&&i.memoizedState!==null?Nc(a):c!==null?(c.return=i,G=c):Nc(a);for(;s!==null;)G=s,Xd(s),s=s.sibling;G=a,ba=l,Me=u}Cc(e)}else a.subtreeFlags&8772&&s!==null?(s.return=a,G=s):Cc(e)}}function Cc(e){for(;G!==null;){var t=G;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Me||Io(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Me)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:yt(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&lc(t,s,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}lc(t,i,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var m=p.dehydrated;m!==null&&Vr(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Me||t.flags&512&&ai(t)}catch(g){xe(t,t.return,g)}}if(t===e){G=null;break}if(n=t.sibling,n!==null){n.return=t.return,G=n;break}G=t.return}}function bc(e){for(;G!==null;){var t=G;if(t===e){G=null;break}var n=t.sibling;if(n!==null){n.return=t.return,G=n;break}G=t.return}}function Nc(e){for(;G!==null;){var t=G;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Io(4,t)}catch(c){xe(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){xe(t,a,c)}}var s=t.return;try{ai(t)}catch(c){xe(t,s,c)}break;case 5:var i=t.return;try{ai(t)}catch(c){xe(t,i,c)}}}catch(c){xe(t,t.return,c)}if(t===e){G=null;break}var l=t.sibling;if(l!==null){l.return=t.return,G=l;break}G=t.return}}var oh=Math.ceil,fo=Vt.ReactCurrentDispatcher,rl=Vt.ReactCurrentOwner,ft=Vt.ReactCurrentBatchConfig,re=0,ze=null,Se=null,Re=0,et=0,Jn=pn(0),be=0,na=null,Tn=0,Po=0,al=0,Mr=null,Ge=null,ol=0,cr=1/0,At=null,po=!1,ii=null,sn=null,Na=!1,en=null,mo=0,Fr=0,li=null,Ba=-1,Da=0;function De(){return re&6?we():Ba!==-1?Ba:Ba=we()}function ln(e){return e.mode&1?re&2&&Re!==0?Re&-Re:Um.transition!==null?(Da===0&&(Da=$u()),Da):(e=se,e!==0||(e=window.event,e=e===void 0?16:Uu(e.type)),e):1}function jt(e,t,n,r){if(50<Fr)throw Fr=0,li=null,Error(M(185));oa(e,n,r),(!(re&2)||e!==ze)&&(e===ze&&(!(re&2)&&(Po|=n),be===4&&qt(e,Re)),Xe(e,r),n===1&&re===0&&!(t.mode&1)&&(cr=we()+500,No&&mn()))}function Xe(e,t){var n=e.callbackNode;Up(e,t);var r=Ja(e,e===ze?Re:0);if(r===0)n!==null&&$l(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&$l(n),t===1)e.tag===0?Dm(Ec.bind(null,e)):id(Ec.bind(null,e)),Mm(function(){!(re&6)&&mn()}),n=null;else{switch(Lu(r)){case 1:n=Ti;break;case 4:n=_u;break;case 16:n=Qa;break;case 536870912:n=Au;break;default:n=Qa}n=of(n,qd.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function qd(e,t){if(Ba=-1,Da=0,re&6)throw Error(M(327));var n=e.callbackNode;if(nr()&&e.callbackNode!==n)return null;var r=Ja(e,e===ze?Re:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=ho(e,r);else{t=r;var a=re;re|=2;var s=ef();(ze!==e||Re!==t)&&(At=null,cr=we()+500,Nn(e,t));do try{lh();break}catch(l){Zd(e,l)}while(!0);Hi(),fo.current=s,re=a,Se!==null?t=0:(ze=null,Re=0,t=be)}if(t!==0){if(t===2&&(a=$s(e),a!==0&&(r=a,t=ci(e,a))),t===1)throw n=na,Nn(e,0),qt(e,r),Xe(e,we()),n;if(t===6)qt(e,r);else{if(a=e.current.alternate,!(r&30)&&!sh(a)&&(t=ho(e,r),t===2&&(s=$s(e),s!==0&&(r=s,t=ci(e,s))),t===1))throw n=na,Nn(e,0),qt(e,r),Xe(e,we()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:wn(e,Ge,At);break;case 3:if(qt(e,r),(r&130023424)===r&&(t=ol+500-we(),10<t)){if(Ja(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){De(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ws(wn.bind(null,e,Ge,At),t);break}wn(e,Ge,At);break;case 4:if(qt(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var i=31-St(r);s=1<<i,i=t[i],i>a&&(a=i),r&=~s}if(r=a,r=we()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*oh(r/1960))-r,10<r){e.timeoutHandle=Ws(wn.bind(null,e,Ge,At),r);break}wn(e,Ge,At);break;case 5:wn(e,Ge,At);break;default:throw Error(M(329))}}}return Xe(e,we()),e.callbackNode===n?qd.bind(null,e):null}function ci(e,t){var n=Mr;return e.current.memoizedState.isDehydrated&&(Nn(e,t).flags|=256),e=ho(e,t),e!==2&&(t=Ge,Ge=n,t!==null&&ui(t)),e}function ui(e){Ge===null?Ge=e:Ge.push.apply(Ge,e)}function sh(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],s=a.getSnapshot;a=a.value;try{if(!kt(s(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function qt(e,t){for(t&=~al,t&=~Po,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-St(t),r=1<<n;e[n]=-1,t&=~r}}function Ec(e){if(re&6)throw Error(M(327));nr();var t=Ja(e,0);if(!(t&1))return Xe(e,we()),null;var n=ho(e,t);if(e.tag!==0&&n===2){var r=$s(e);r!==0&&(t=r,n=ci(e,r))}if(n===1)throw n=na,Nn(e,0),qt(e,t),Xe(e,we()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,wn(e,Ge,At),Xe(e,we()),null}function sl(e,t){var n=re;re|=1;try{return e(t)}finally{re=n,re===0&&(cr=we()+500,No&&mn())}}function Rn(e){en!==null&&en.tag===0&&!(re&6)&&nr();var t=re;re|=1;var n=ft.transition,r=se;try{if(ft.transition=null,se=1,e)return e()}finally{se=r,ft.transition=n,re=t,!(re&6)&&mn()}}function il(){et=Jn.current,de(Jn)}function Nn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Lm(n)),Se!==null)for(n=Se.return;n!==null;){var r=n;switch(Di(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&to();break;case 3:ir(),de(Qe),de(Fe),Ji();break;case 5:Qi(r);break;case 4:ir();break;case 13:de(ge);break;case 19:de(ge);break;case 10:Vi(r.type._context);break;case 22:case 23:il()}n=n.return}if(ze=e,Se=e=cn(e.current,null),Re=et=t,be=0,na=null,al=Po=Tn=0,Ge=Mr=null,kn!==null){for(t=0;t<kn.length;t++)if(n=kn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,s=n.pending;if(s!==null){var i=s.next;s.next=a,r.next=i}n.pending=r}kn=null}return e}function Zd(e,t){do{var n=Se;try{if(Hi(),Ma.current=uo,co){for(var r=ve.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}co=!1}if(Pn=0,Ee=Ce=ve=null,$r=!1,Zr=0,rl.current=null,n===null||n.return===null){be=1,na=t,Se=null;break}e:{var s=e,i=n.return,l=n,c=t;if(t=Re,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,m=p.tag;if(!(p.mode&1)&&(m===0||m===11||m===15)){var g=p.alternate;g?(p.updateQueue=g.updateQueue,p.memoizedState=g.memoizedState,p.lanes=g.lanes):(p.updateQueue=null,p.memoizedState=null)}var w=mc(i);if(w!==null){w.flags&=-257,hc(w,i,l,s,t),w.mode&1&&pc(s,u,t),t=w,c=u;var x=t.updateQueue;if(x===null){var y=new Set;y.add(c),t.updateQueue=y}else x.add(c);break e}else{if(!(t&1)){pc(s,u,t),ll();break e}c=Error(M(426))}}else if(pe&&l.mode&1){var j=mc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),hc(j,i,l,s,t),Ui(lr(c,l));break e}}s=c=lr(c,l),be!==4&&(be=2),Mr===null?Mr=[s]:Mr.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var h=Ld(s,c,t);ic(s,h);break e;case 1:l=c;var f=s.type,v=s.stateNode;if(!(s.flags&128)&&(typeof f.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(sn===null||!sn.has(v)))){s.flags|=65536,t&=-t,s.lanes|=t;var S=Md(s,l,t);ic(s,S);break e}}s=s.return}while(s!==null)}nf(n)}catch(E){t=E,Se===n&&n!==null&&(Se=n=n.return);continue}break}while(!0)}function ef(){var e=fo.current;return fo.current=uo,e===null?uo:e}function ll(){(be===0||be===3||be===2)&&(be=4),ze===null||!(Tn&268435455)&&!(Po&268435455)||qt(ze,Re)}function ho(e,t){var n=re;re|=2;var r=ef();(ze!==e||Re!==t)&&(At=null,Nn(e,t));do try{ih();break}catch(a){Zd(e,a)}while(!0);if(Hi(),re=n,fo.current=r,Se!==null)throw Error(M(261));return ze=null,Re=0,be}function ih(){for(;Se!==null;)tf(Se)}function lh(){for(;Se!==null&&!_p();)tf(Se)}function tf(e){var t=af(e.alternate,e,et);e.memoizedProps=e.pendingProps,t===null?nf(e):Se=t,rl.current=null}function nf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=th(n,t),n!==null){n.flags&=32767,Se=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{be=6,Se=null;return}}else if(n=eh(n,t,et),n!==null){Se=n;return}if(t=t.sibling,t!==null){Se=t;return}Se=t=e}while(t!==null);be===0&&(be=5)}function wn(e,t,n){var r=se,a=ft.transition;try{ft.transition=null,se=1,ch(e,t,n,r)}finally{ft.transition=a,se=r}return null}function ch(e,t,n,r){do nr();while(en!==null);if(re&6)throw Error(M(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(M(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(Wp(e,s),e===ze&&(Se=ze=null,Re=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Na||(Na=!0,of(Qa,function(){return nr(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=ft.transition,ft.transition=null;var i=se;se=1;var l=re;re|=4,rl.current=null,rh(e,n),Jd(n,e),Im(Ds),Xa=!!Bs,Ds=Bs=null,e.current=n,ah(n),Ap(),re=l,se=i,ft.transition=s}else e.current=n;if(Na&&(Na=!1,en=e,mo=a),s=e.pendingLanes,s===0&&(sn=null),Mp(n.stateNode),Xe(e,we()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(po)throw po=!1,e=ii,ii=null,e;return mo&1&&e.tag!==0&&nr(),s=e.pendingLanes,s&1?e===li?Fr++:(Fr=0,li=e):Fr=0,mn(),null}function nr(){if(en!==null){var e=Lu(mo),t=ft.transition,n=se;try{if(ft.transition=null,se=16>e?16:e,en===null)var r=!1;else{if(e=en,en=null,mo=0,re&6)throw Error(M(331));var a=re;for(re|=4,G=e.current;G!==null;){var s=G,i=s.child;if(G.flags&16){var l=s.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(G=u;G!==null;){var p=G;switch(p.tag){case 0:case 11:case 15:Lr(8,p,s)}var m=p.child;if(m!==null)m.return=p,G=m;else for(;G!==null;){p=G;var g=p.sibling,w=p.return;if(Gd(p),p===u){G=null;break}if(g!==null){g.return=w,G=g;break}G=w}}}var x=s.alternate;if(x!==null){var y=x.child;if(y!==null){x.child=null;do{var j=y.sibling;y.sibling=null,y=j}while(y!==null)}}G=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,G=i;else e:for(;G!==null;){if(s=G,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Lr(9,s,s.return)}var h=s.sibling;if(h!==null){h.return=s.return,G=h;break e}G=s.return}}var f=e.current;for(G=f;G!==null;){i=G;var v=i.child;if(i.subtreeFlags&2064&&v!==null)v.return=i,G=v;else e:for(i=f;G!==null;){if(l=G,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Io(9,l)}}catch(E){xe(l,l.return,E)}if(l===i){G=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,G=S;break e}G=l.return}}if(re=a,mn(),Pt&&typeof Pt.onPostCommitFiberRoot=="function")try{Pt.onPostCommitFiberRoot(So,e)}catch{}r=!0}return r}finally{se=n,ft.transition=t}}return!1}function zc(e,t,n){t=lr(n,t),t=Ld(e,t,1),e=on(e,t,1),t=De(),e!==null&&(oa(e,1,t),Xe(e,t))}function xe(e,t,n){if(e.tag===3)zc(e,e,n);else for(;t!==null;){if(t.tag===3){zc(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(sn===null||!sn.has(r))){e=lr(n,e),e=Md(t,e,1),t=on(t,e,1),e=De(),t!==null&&(oa(t,1,e),Xe(t,e));break}}t=t.return}}function uh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=De(),e.pingedLanes|=e.suspendedLanes&n,ze===e&&(Re&n)===n&&(be===4||be===3&&(Re&130023424)===Re&&500>we()-ol?Nn(e,0):al|=n),Xe(e,t)}function rf(e,t){t===0&&(e.mode&1?(t=ga,ga<<=1,!(ga&130023424)&&(ga=4194304)):t=1);var n=De();e=Ut(e,t),e!==null&&(oa(e,t,n),Xe(e,n))}function dh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),rf(e,n)}function fh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(M(314))}r!==null&&r.delete(t),rf(e,n)}var af;af=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Qe.current)Ye=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ye=!1,Zm(e,t,n);Ye=!!(e.flags&131072)}else Ye=!1,pe&&t.flags&1048576&&ld(t,ao,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Oa(e,t),e=t.pendingProps;var a=ar(t,Fe.current);tr(t,n),a=qi(null,t,r,e,a,n);var s=Zi();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Je(r)?(s=!0,no(t)):s=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Gi(t),a.updater=zo,t.stateNode=a,a._reactInternals=t,Js(t,r,e,n),t=Zs(null,t,r,!0,s,n)):(t.tag=0,pe&&s&&Bi(t),Be(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Oa(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=mh(r),e=yt(r,e),a){case 0:t=qs(null,t,r,e,n);break e;case 1:t=yc(null,t,r,e,n);break e;case 11:t=gc(null,t,r,e,n);break e;case 14:t=vc(null,t,r,yt(r.type,e),n);break e}throw Error(M(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),qs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),yc(e,t,r,a,n);case 3:e:{if(Dd(t),e===null)throw Error(M(387));r=t.pendingProps,s=t.memoizedState,a=s.element,md(e,t),io(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){a=lr(Error(M(423)),t),t=xc(e,t,r,n,a);break e}else if(r!==a){a=lr(Error(M(424)),t),t=xc(e,t,r,n,a);break e}else for(nt=an(t.stateNode.containerInfo.firstChild),rt=t,pe=!0,wt=null,n=fd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(or(),r===a){t=Wt(e,t,n);break e}Be(e,t,r,n)}t=t.child}return t;case 5:return hd(t),e===null&&Gs(t),r=t.type,a=t.pendingProps,s=e!==null?e.memoizedProps:null,i=a.children,Us(r,a)?i=null:s!==null&&Us(r,s)&&(t.flags|=32),Bd(e,t),Be(e,t,i,n),t.child;case 6:return e===null&&Gs(t),null;case 13:return Ud(e,t,n);case 4:return Yi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=sr(t,null,r,n):Be(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),gc(e,t,r,a,n);case 7:return Be(e,t,t.pendingProps,n),t.child;case 8:return Be(e,t,t.pendingProps.children,n),t.child;case 12:return Be(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,s=t.memoizedProps,i=a.value,ce(oo,r._currentValue),r._currentValue=i,s!==null)if(kt(s.value,i)){if(s.children===a.children&&!Qe.current){t=Wt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){i=s.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=Ot(-1,n&-n),c.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ys(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(M(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Ys(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}Be(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,tr(t,n),a=pt(a),r=r(a),t.flags|=1,Be(e,t,r,n),t.child;case 14:return r=t.type,a=yt(r,t.pendingProps),a=yt(r.type,a),vc(e,t,r,a,n);case 15:return Fd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),Oa(e,t),t.tag=1,Je(r)?(e=!0,no(t)):e=!1,tr(t,n),$d(t,r,a),Js(t,r,a,n),Zs(null,t,r,!0,e,n);case 19:return Wd(e,t,n);case 22:return Od(e,t,n)}throw Error(M(156,t.tag))};function of(e,t){return Ru(e,t)}function ph(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dt(e,t,n,r){return new ph(e,t,n,r)}function cl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function mh(e){if(typeof e=="function")return cl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zi)return 11;if(e===Ii)return 14}return 2}function cn(e,t){var n=e.alternate;return n===null?(n=dt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ua(e,t,n,r,a,s){var i=2;if(r=e,typeof e=="function")cl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Bn:return En(n.children,a,s,t);case Ei:i=8,a|=8;break;case ws:return e=dt(12,n,t,a|2),e.elementType=ws,e.lanes=s,e;case Ss:return e=dt(13,n,t,a),e.elementType=Ss,e.lanes=s,e;case js:return e=dt(19,n,t,a),e.elementType=js,e.lanes=s,e;case hu:return To(n,a,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pu:i=10;break e;case mu:i=9;break e;case zi:i=11;break e;case Ii:i=14;break e;case Yt:i=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=dt(i,n,t,a),t.elementType=e,t.type=r,t.lanes=s,t}function En(e,t,n,r){return e=dt(7,e,r,t),e.lanes=n,e}function To(e,t,n,r){return e=dt(22,e,r,t),e.elementType=hu,e.lanes=n,e.stateNode={isHidden:!1},e}function us(e,t,n){return e=dt(6,e,null,t),e.lanes=n,e}function ds(e,t,n){return t=dt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function hh(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vo(0),this.expirationTimes=Vo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vo(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function ul(e,t,n,r,a,s,i,l,c){return e=new hh(e,t,n,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=dt(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gi(s),e}function gh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:On,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function sf(e){if(!e)return dn;e=e._reactInternals;e:{if(An(e)!==e||e.tag!==1)throw Error(M(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Je(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(M(171))}if(e.tag===1){var n=e.type;if(Je(n))return sd(e,n,t)}return t}function lf(e,t,n,r,a,s,i,l,c){return e=ul(n,r,!0,e,a,s,i,l,c),e.context=sf(null),n=e.current,r=De(),a=ln(n),s=Ot(r,a),s.callback=t??null,on(n,s,a),e.current.lanes=a,oa(e,a,r),Xe(e,r),e}function Ro(e,t,n,r){var a=t.current,s=De(),i=ln(a);return n=sf(n),t.context===null?t.context=n:t.pendingContext=n,t=Ot(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=on(a,t,i),e!==null&&(jt(e,a,i,s),La(e,a,i)),i}function go(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ic(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function dl(e,t){Ic(e,t),(e=e.alternate)&&Ic(e,t)}function vh(){return null}var cf=typeof reportError=="function"?reportError:function(e){console.error(e)};function fl(e){this._internalRoot=e}_o.prototype.render=fl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));Ro(e,t,null,null)};_o.prototype.unmount=fl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Rn(function(){Ro(null,e,null,null)}),t[Dt]=null}};function _o(e){this._internalRoot=e}_o.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ou();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Xt.length&&t!==0&&t<Xt[n].priority;n++);Xt.splice(n,0,e),n===0&&Du(e)}};function pl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Ao(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Pc(){}function yh(e,t,n,r,a){if(a){if(typeof r=="function"){var s=r;r=function(){var u=go(i);s.call(u)}}var i=lf(t,r,e,0,null,!1,!1,"",Pc);return e._reactRootContainer=i,e[Dt]=i.current,Yr(e.nodeType===8?e.parentNode:e),Rn(),i}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var u=go(c);l.call(u)}}var c=ul(e,0,!1,null,null,!1,!1,"",Pc);return e._reactRootContainer=c,e[Dt]=c.current,Yr(e.nodeType===8?e.parentNode:e),Rn(function(){Ro(t,c,n,r)}),c}function $o(e,t,n,r,a){var s=n._reactRootContainer;if(s){var i=s;if(typeof a=="function"){var l=a;a=function(){var c=go(i);l.call(c)}}Ro(t,i,e,a)}else i=yh(n,t,e,a,r);return go(i)}Mu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Er(t.pendingLanes);n!==0&&(Ri(t,n|1),Xe(t,we()),!(re&6)&&(cr=we()+500,mn()))}break;case 13:Rn(function(){var r=Ut(e,1);if(r!==null){var a=De();jt(r,e,1,a)}}),dl(e,1)}};_i=function(e){if(e.tag===13){var t=Ut(e,134217728);if(t!==null){var n=De();jt(t,e,134217728,n)}dl(e,134217728)}};Fu=function(e){if(e.tag===13){var t=ln(e),n=Ut(e,t);if(n!==null){var r=De();jt(n,e,t,r)}dl(e,t)}};Ou=function(){return se};Bu=function(e,t){var n=se;try{return se=e,t()}finally{se=n}};Rs=function(e,t,n){switch(t){case"input":if(bs(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=bo(r);if(!a)throw Error(M(90));vu(r),bs(r,a)}}}break;case"textarea":xu(e,n);break;case"select":t=n.value,t!=null&&Xn(e,!!n.multiple,t,!1)}};Nu=sl;Eu=Rn;var xh={usingClientEntryPoint:!1,Events:[ia,Hn,bo,Cu,bu,sl]},kr={findFiberByHostInstance:jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},wh={bundleType:kr.bundleType,version:kr.version,rendererPackageName:kr.rendererPackageName,rendererConfig:kr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Vt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Pu(e),e===null?null:e.stateNode},findFiberByHostInstance:kr.findFiberByHostInstance||vh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ea=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ea.isDisabled&&Ea.supportsFiber)try{So=Ea.inject(wh),Pt=Ea}catch{}}ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xh;ot.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!pl(t))throw Error(M(200));return gh(e,t,null,n)};ot.createRoot=function(e,t){if(!pl(e))throw Error(M(299));var n=!1,r="",a=cf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=ul(e,1,!1,null,null,n,!1,r,a),e[Dt]=t.current,Yr(e.nodeType===8?e.parentNode:e),new fl(t)};ot.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(M(188)):(e=Object.keys(e).join(","),Error(M(268,e)));return e=Pu(t),e=e===null?null:e.stateNode,e};ot.flushSync=function(e){return Rn(e)};ot.hydrate=function(e,t,n){if(!Ao(t))throw Error(M(200));return $o(null,e,t,!0,n)};ot.hydrateRoot=function(e,t,n){if(!pl(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,s="",i=cf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=lf(t,null,e,1,n??null,a,!1,s,i),e[Dt]=t.current,Yr(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new _o(t)};ot.render=function(e,t,n){if(!Ao(t))throw Error(M(200));return $o(null,e,t,!1,n)};ot.unmountComponentAtNode=function(e){if(!Ao(e))throw Error(M(40));return e._reactRootContainer?(Rn(function(){$o(null,null,e,!1,function(){e._reactRootContainer=null,e[Dt]=null})}),!0):!1};ot.unstable_batchedUpdates=sl;ot.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Ao(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return $o(e,t,n,!1,r)};ot.version="18.3.1-next-f1338f8080-20240426";function uf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uf)}catch(e){console.error(e)}}uf(),cu.exports=ot;var df=cu.exports,ff,Tc=df;ff=Tc.createRoot,Tc.hydrateRoot;/**
40
+ `+s.stack}return{value:e,source:t,stack:a,digest:null}}function ls(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Xs(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Jm=typeof WeakMap=="function"?WeakMap:Map;function Ld(e,t,n){n=Ot(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){po||(po=!0,ii=r),Xs(e,t)},n}function Md(e,t,n){n=Ot(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;n.payload=function(){return r(a)},n.callback=function(){Xs(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Xs(e,t),typeof r!="function"&&(sn===null?sn=new Set([this]):sn.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function pc(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Jm;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(n)||(a.add(n),e=uh.bind(null,e,t,n),t.then(e,e))}function mc(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function hc(e,t,n,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Ot(-1,1),t.tag=2,on(n,t,1))),n.lanes|=1),e)}var Xm=Vt.ReactCurrentOwner,Ye=!1;function Be(e,t,n,r){t.child=e===null?fd(t,null,n,r):sr(t,e.child,n,r)}function gc(e,t,n,r,a){n=n.render;var s=t.ref;return tr(t,a),r=qi(e,t,n,r,s,a),n=Zi(),e!==null&&!Ye?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Wt(e,t,a)):(pe&&n&&Bi(t),t.flags|=1,Be(e,t,r,a),t.child)}function vc(e,t,n,r,a){if(e===null){var s=n.type;return typeof s=="function"&&!cl(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,Fd(e,t,s,r,a)):(e=Ua(n.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&a)){var i=s.memoizedProps;if(n=n.compare,n=n!==null?n:Gr,n(i,r)&&e.ref===t.ref)return Wt(e,t,a)}return t.flags|=1,e=cn(s,r),e.ref=t.ref,e.return=t,t.child=e}function Fd(e,t,n,r,a){if(e!==null){var s=e.memoizedProps;if(Gr(s,r)&&e.ref===t.ref)if(Ye=!1,t.pendingProps=r=s,(e.lanes&a)!==0)e.flags&131072&&(Ye=!0);else return t.lanes=e.lanes,Wt(e,t,a)}return qs(e,t,n,r,a)}function Od(e,t,n){var r=t.pendingProps,a=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},ce(Jn,et),et|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,ce(Jn,et),et|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ce(Jn,et),et|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,ce(Jn,et),et|=r;return Be(e,t,a,n),t.child}function Bd(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function qs(e,t,n,r,a){var s=Je(n)?zn:Fe.current;return s=ar(t,s),tr(t,a),n=qi(e,t,n,r,s,a),r=Zi(),e!==null&&!Ye?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Wt(e,t,a)):(pe&&r&&Bi(t),t.flags|=1,Be(e,t,n,a),t.child)}function yc(e,t,n,r,a){if(Je(n)){var s=!0;no(t)}else s=!1;if(tr(t,a),t.stateNode===null)Oa(e,t),$d(t,n,r),Js(t,n,r,a),r=!0;else if(e===null){var i=t.stateNode,l=t.memoizedProps;i.props=l;var c=i.context,u=n.contextType;typeof u=="object"&&u!==null?u=pt(u):(u=Je(n)?zn:Fe.current,u=ar(t,u));var p=n.getDerivedStateFromProps,h=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==r||c!==u)&&fc(t,i,r,u),Qt=!1;var m=t.memoizedState;i.state=m,io(t,r,i,a),c=t.memoizedState,l!==r||m!==c||Qe.current||Qt?(typeof p=="function"&&(Qs(t,n,p,r),c=t.memoizedState),(l=Qt||dc(t,n,l,r,m,c,u))?(h||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=u,r=l):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,md(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:yt(t.type,l),i.props=u,h=t.pendingProps,m=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=pt(c):(c=Je(n)?zn:Fe.current,c=ar(t,c));var w=n.getDerivedStateFromProps;(p=typeof w=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(l!==h||m!==c)&&fc(t,i,r,c),Qt=!1,m=t.memoizedState,i.state=m,io(t,r,i,a);var x=t.memoizedState;l!==h||m!==x||Qe.current||Qt?(typeof w=="function"&&(Qs(t,n,w,r),x=t.memoizedState),(u=Qt||dc(t,n,u,r,m,x,c)||!1)?(p||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,x,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,x,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=x),i.props=r,i.state=x,i.context=c,r=u):(typeof i.componentDidUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&m===e.memoizedState||(t.flags|=1024),r=!1)}return Zs(e,t,n,r,s,a)}function Zs(e,t,n,r,a,s){Bd(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return a&&rc(t,n,!1),Wt(e,t,s);r=t.stateNode,Xm.current=t;var l=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=sr(t,e.child,null,s),t.child=sr(t,null,l,s)):Be(e,t,l,s),t.memoizedState=r.state,a&&rc(t,n,!0),t.child}function Dd(e){var t=e.stateNode;t.pendingContext?nc(e,t.pendingContext,t.pendingContext!==t.context):t.context&&nc(e,t.context,!1),Yi(e,t.containerInfo)}function xc(e,t,n,r,a){return or(),Ui(a),t.flags|=256,Be(e,t,n,r),t.child}var ei={dehydrated:null,treeContext:null,retryLane:0};function ti(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ud(e,t,n){var r=t.pendingProps,a=ge.current,s=!1,i=(t.flags&128)!==0,l;if((l=i)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),ce(ge,a&1),e===null)return Gs(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,s?(r=t.mode,s=t.child,i={mode:"hidden",children:i},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=i):s=To(i,r,0,null),e=En(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=ti(n),t.memoizedState=ei,e):nl(t,i));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return qm(e,t,i,r,l,a,n);if(s){s=r.fallback,i=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=cn(a,c),r.subtreeFlags=a.subtreeFlags&14680064),l!==null?s=cn(l,s):(s=En(s,i,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,i=e.child.memoizedState,i=i===null?ti(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},s.memoizedState=i,s.childLanes=e.childLanes&~n,t.memoizedState=ei,r}return s=e.child,e=s.sibling,r=cn(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function nl(e,t){return t=To({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Ca(e,t,n,r){return r!==null&&Ui(r),sr(t,e.child,null,n),e=nl(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function qm(e,t,n,r,a,s,i){if(n)return t.flags&256?(t.flags&=-257,r=ls(Error(M(422))),Ca(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,a=t.mode,r=To({mode:"visible",children:r.children},a,0,null),s=En(s,a,i,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&sr(t,e.child,null,i),t.child.memoizedState=ti(i),t.memoizedState=ei,s);if(!(t.mode&1))return Ca(e,t,i,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(M(419)),r=ls(s,r,void 0),Ca(e,t,i,r)}if(l=(i&e.childLanes)!==0,Ye||l){if(r=ze,r!==null){switch(i&-i){case 4:a=2;break;case 16:a=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|i)?0:a,a!==0&&a!==s.retryLane&&(s.retryLane=a,Ut(e,a),jt(r,e,a,-1))}return ll(),r=ls(Error(M(421))),Ca(e,t,i,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=dh.bind(null,e),a._reactRetry=t,null):(e=s.treeContext,nt=an(a.nextSibling),rt=t,pe=!0,wt=null,e!==null&&(ct[ut++]=Lt,ct[ut++]=Mt,ct[ut++]=In,Lt=e.id,Mt=e.overflow,In=t),t=nl(t,r.children),t.flags|=4096,t)}function wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ys(e.return,t,n)}function cs(e,t,n,r,a){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:a}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=a)}function Wd(e,t,n){var r=t.pendingProps,a=r.revealOrder,s=r.tail;if(Be(e,t,r.children,n),r=ge.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wc(e,n,t);else if(e.tag===19)wc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(ce(ge,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(n=t.child,a=null;n!==null;)e=n.alternate,e!==null&&lo(e)===null&&(a=n),n=n.sibling;n=a,n===null?(a=t.child,t.child=null):(a=n.sibling,n.sibling=null),cs(t,!1,a,n,s);break;case"backwards":for(n=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&lo(e)===null){t.child=a;break}e=a.sibling,a.sibling=n,n=a,a=e}cs(t,!0,n,null,s);break;case"together":cs(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Oa(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Wt(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Tn|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(M(153));if(t.child!==null){for(e=t.child,n=cn(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=cn(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Zm(e,t,n){switch(t.tag){case 3:Dd(t),or();break;case 5:hd(t);break;case 1:Je(t.type)&&no(t);break;case 4:Yi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;ce(oo,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(ce(ge,ge.current&1),t.flags|=128,null):n&t.child.childLanes?Ud(e,t,n):(ce(ge,ge.current&1),e=Wt(e,t,n),e!==null?e.sibling:null);ce(ge,ge.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return Wd(e,t,n);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),ce(ge,ge.current),r)break;return null;case 22:case 23:return t.lanes=0,Od(e,t,n)}return Wt(e,t,n)}var Hd,ni,Vd,Kd;Hd=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};ni=function(){};Vd=function(e,t,n,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,Cn(Tt.current);var s=null;switch(n){case"input":a=Cs(e,a),r=Cs(e,r),s=[];break;case"select":a=ye({},a,{value:void 0}),r=ye({},r,{value:void 0}),s=[];break;case"textarea":a=Es(e,a),r=Es(e,r),s=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=eo)}Is(n,r);var i;n=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var l=a[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Br.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(s=s||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Br.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&ue("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}};Kd=function(e,t,n,r){n!==r&&(t.flags|=4)};function jr(e,t){if(!pe)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Le(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)n|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function eh(e,t,n){var r=t.pendingProps;switch(Di(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Le(t),null;case 1:return Je(t.type)&&to(),Le(t),null;case 3:return r=t.stateNode,ir(),de(Qe),de(Fe),Ji(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ja(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,wt!==null&&(ui(wt),wt=null))),ni(e,t),Le(t),null;case 5:Qi(t);var a=Cn(qr.current);if(n=t.type,e!==null&&t.stateNode!=null)Vd(e,t,n,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(M(166));return Le(t),null}if(e=Cn(Tt.current),ja(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[It]=t,r[Jr]=s,e=(t.mode&1)!==0,n){case"dialog":ue("cancel",r),ue("close",r);break;case"iframe":case"object":case"embed":ue("load",r);break;case"video":case"audio":for(a=0;a<zr.length;a++)ue(zr[a],r);break;case"source":ue("error",r);break;case"img":case"image":case"link":ue("error",r),ue("load",r);break;case"details":ue("toggle",r);break;case"input":Il(r,s),ue("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},ue("invalid",r);break;case"textarea":Tl(r,s),ue("invalid",r)}Is(n,s),a=null;for(var i in s)if(s.hasOwnProperty(i)){var l=s[i];i==="children"?typeof l=="string"?r.textContent!==l&&(s.suppressHydrationWarning!==!0&&Sa(r.textContent,l,e),a=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&Sa(r.textContent,l,e),a=["children",""+l]):Br.hasOwnProperty(i)&&l!=null&&i==="onScroll"&&ue("scroll",r)}switch(n){case"input":pa(r),Pl(r,s,!0);break;case"textarea":pa(r),Rl(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=eo)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=wu(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[It]=t,e[Jr]=r,Hd(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ps(n,r),n){case"dialog":ue("cancel",e),ue("close",e),a=r;break;case"iframe":case"object":case"embed":ue("load",e),a=r;break;case"video":case"audio":for(a=0;a<zr.length;a++)ue(zr[a],e);a=r;break;case"source":ue("error",e),a=r;break;case"img":case"image":case"link":ue("error",e),ue("load",e),a=r;break;case"details":ue("toggle",e),a=r;break;case"input":Il(e,r),a=Cs(e,r),ue("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=ye({},r,{value:void 0}),ue("invalid",e);break;case"textarea":Tl(e,r),a=Es(e,r),ue("invalid",e);break;default:a=r}Is(n,a),l=a;for(s in l)if(l.hasOwnProperty(s)){var c=l[s];s==="style"?ku(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Su(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Dr(e,c):typeof c=="number"&&Dr(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(Br.hasOwnProperty(s)?c!=null&&s==="onScroll"&&ue("scroll",e):c!=null&&Ni(e,s,c,i))}switch(n){case"input":pa(e),Pl(e,r,!1);break;case"textarea":pa(e),Rl(e);break;case"option":r.value!=null&&e.setAttribute("value",""+un(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?Xn(e,!!r.multiple,s,!1):r.defaultValue!=null&&Xn(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=eo)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Le(t),null;case 6:if(e&&t.stateNode!=null)Kd(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(M(166));if(n=Cn(qr.current),Cn(Tt.current),ja(t)){if(r=t.stateNode,n=t.memoizedProps,r[It]=t,(s=r.nodeValue!==n)&&(e=rt,e!==null))switch(e.tag){case 3:Sa(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Sa(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[It]=t,t.stateNode=r}return Le(t),null;case 13:if(de(ge),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(pe&&nt!==null&&t.mode&1&&!(t.flags&128))ud(),or(),t.flags|=98560,s=!1;else if(s=ja(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(M(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(M(317));s[It]=t}else or(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Le(t),s=!1}else wt!==null&&(ui(wt),wt=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||ge.current&1?be===0&&(be=3):ll())),t.updateQueue!==null&&(t.flags|=4),Le(t),null);case 4:return ir(),ni(e,t),e===null&&Yr(t.stateNode.containerInfo),Le(t),null;case 10:return Vi(t.type._context),Le(t),null;case 17:return Je(t.type)&&to(),Le(t),null;case 19:if(de(ge),s=t.memoizedState,s===null)return Le(t),null;if(r=(t.flags&128)!==0,i=s.rendering,i===null)if(r)jr(s,!1);else{if(be!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=lo(e),i!==null){for(t.flags|=128,jr(s,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,i=s.alternate,i===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=i.childLanes,s.lanes=i.lanes,s.child=i.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=i.memoizedProps,s.memoizedState=i.memoizedState,s.updateQueue=i.updateQueue,s.type=i.type,e=i.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return ce(ge,ge.current&1|2),t.child}e=e.sibling}s.tail!==null&&we()>cr&&(t.flags|=128,r=!0,jr(s,!1),t.lanes=4194304)}else{if(!r)if(e=lo(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),jr(s,!0),s.tail===null&&s.tailMode==="hidden"&&!i.alternate&&!pe)return Le(t),null}else 2*we()-s.renderingStartTime>cr&&n!==1073741824&&(t.flags|=128,r=!0,jr(s,!1),t.lanes=4194304);s.isBackwards?(i.sibling=t.child,t.child=i):(n=s.last,n!==null?n.sibling=i:t.child=i,s.last=i)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=we(),t.sibling=null,n=ge.current,ce(ge,r?n&1|2:n&1),t):(Le(t),null);case 22:case 23:return il(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(Le(t),t.subtreeFlags&6&&(t.flags|=8192)):Le(t),null;case 24:return null;case 25:return null}throw Error(M(156,t.tag))}function th(e,t){switch(Di(t),t.tag){case 1:return Je(t.type)&&to(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ir(),de(Qe),de(Fe),Ji(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Qi(t),null;case 13:if(de(ge),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(M(340));or()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(ge),null;case 4:return ir(),null;case 10:return Vi(t.type._context),null;case 22:case 23:return il(),null;case 24:return null;default:return null}}var ba=!1,Me=!1,nh=typeof WeakSet=="function"?WeakSet:Set,G=null;function Qn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function ri(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Sc=!1;function rh(e,t){if(Bs=Xa,e=Xu(),Oi(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var i=0,l=-1,c=-1,u=0,p=0,h=e,m=null;t:for(;;){for(var w;h!==n||a!==0&&h.nodeType!==3||(l=i+a),h!==s||r!==0&&h.nodeType!==3||(c=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(w=h.firstChild)!==null;)m=h,h=w;for(;;){if(h===e)break t;if(m===n&&++u===a&&(l=i),m===s&&++p===r&&(c=i),(w=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=w}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ds={focusedElem:e,selectionRange:n},Xa=!1,G=t;G!==null;)if(t=G,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,G=e;else for(;G!==null;){t=G;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var y=x.memoizedProps,j=x.memoizedState,g=t.stateNode,f=g.getSnapshotBeforeUpdate(t.elementType===t.type?y:yt(t.type,y),j);g.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(M(163))}}catch(S){xe(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,G=e;break}G=t.return}return x=Sc,Sc=!1,x}function Lr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var s=a.destroy;a.destroy=void 0,s!==void 0&&ri(t,n,s)}a=a.next}while(a!==r)}}function Io(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ai(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gd(e){var t=e.alternate;t!==null&&(e.alternate=null,Gd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[Jr],delete t[Hs],delete t[Om],delete t[Bm])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Yd(e){return e.tag===5||e.tag===3||e.tag===4}function jc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Yd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function oi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=eo));else if(r!==4&&(e=e.child,e!==null))for(oi(e,t,n),e=e.sibling;e!==null;)oi(e,t,n),e=e.sibling}function si(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(si(e,t,n),e=e.sibling;e!==null;)si(e,t,n),e=e.sibling}var Te=null,xt=!1;function Gt(e,t,n){for(n=n.child;n!==null;)Qd(e,t,n),n=n.sibling}function Qd(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(So,n)}catch{}switch(n.tag){case 5:Me||Qn(n,t);case 6:var r=Te,a=xt;Te=null,Gt(e,t,n),Te=r,xt=a,Te!==null&&(xt?(e=Te,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Te.removeChild(n.stateNode));break;case 18:Te!==null&&(xt?(e=Te,n=n.stateNode,e.nodeType===8?ns(e.parentNode,n):e.nodeType===1&&ns(e,n),Vr(e)):ns(Te,n.stateNode));break;case 4:r=Te,a=xt,Te=n.stateNode.containerInfo,xt=!0,Gt(e,t,n),Te=r,xt=a;break;case 0:case 11:case 14:case 15:if(!Me&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var s=a,i=s.destroy;s=s.tag,i!==void 0&&(s&2||s&4)&&ri(n,t,i),a=a.next}while(a!==r)}Gt(e,t,n);break;case 1:if(!Me&&(Qn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){xe(n,t,l)}Gt(e,t,n);break;case 21:Gt(e,t,n);break;case 22:n.mode&1?(Me=(r=Me)||n.memoizedState!==null,Gt(e,t,n),Me=r):Gt(e,t,n);break;default:Gt(e,t,n)}}function kc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new nh),t.forEach(function(r){var a=fh.bind(null,e,r);n.has(r)||(n.add(r),r.then(a,a))})}}function vt(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r];try{var s=e,i=t,l=i;e:for(;l!==null;){switch(l.tag){case 5:Te=l.stateNode,xt=!1;break e;case 3:Te=l.stateNode.containerInfo,xt=!0;break e;case 4:Te=l.stateNode.containerInfo,xt=!0;break e}l=l.return}if(Te===null)throw Error(M(160));Qd(s,i,a),Te=null,xt=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(u){xe(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Jd(t,e),t=t.sibling}function Jd(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(vt(t,e),Nt(e),r&4){try{Lr(3,e,e.return),Io(3,e)}catch(y){xe(e,e.return,y)}try{Lr(5,e,e.return)}catch(y){xe(e,e.return,y)}}break;case 1:vt(t,e),Nt(e),r&512&&n!==null&&Qn(n,n.return);break;case 5:if(vt(t,e),Nt(e),r&512&&n!==null&&Qn(n,n.return),e.flags&32){var a=e.stateNode;try{Dr(a,"")}catch(y){xe(e,e.return,y)}}if(r&4&&(a=e.stateNode,a!=null)){var s=e.memoizedProps,i=n!==null?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&yu(a,s),Ps(l,i);var u=Ps(l,s);for(i=0;i<c.length;i+=2){var p=c[i],h=c[i+1];p==="style"?ku(a,h):p==="dangerouslySetInnerHTML"?Su(a,h):p==="children"?Dr(a,h):Ni(a,p,h,u)}switch(l){case"input":bs(a,s);break;case"textarea":xu(a,s);break;case"select":var m=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!s.multiple;var w=s.value;w!=null?Xn(a,!!s.multiple,w,!1):m!==!!s.multiple&&(s.defaultValue!=null?Xn(a,!!s.multiple,s.defaultValue,!0):Xn(a,!!s.multiple,s.multiple?[]:"",!1))}a[Jr]=s}catch(y){xe(e,e.return,y)}}break;case 6:if(vt(t,e),Nt(e),r&4){if(e.stateNode===null)throw Error(M(162));a=e.stateNode,s=e.memoizedProps;try{a.nodeValue=s}catch(y){xe(e,e.return,y)}}break;case 3:if(vt(t,e),Nt(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vr(t.containerInfo)}catch(y){xe(e,e.return,y)}break;case 4:vt(t,e),Nt(e);break;case 13:vt(t,e),Nt(e),a=e.child,a.flags&8192&&(s=a.memoizedState!==null,a.stateNode.isHidden=s,!s||a.alternate!==null&&a.alternate.memoizedState!==null||(ol=we())),r&4&&kc(e);break;case 22:if(p=n!==null&&n.memoizedState!==null,e.mode&1?(Me=(u=Me)||p,vt(t,e),Me=u):vt(t,e),Nt(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!p&&e.mode&1)for(G=e,p=e.child;p!==null;){for(h=G=p;G!==null;){switch(m=G,w=m.child,m.tag){case 0:case 11:case 14:case 15:Lr(4,m,m.return);break;case 1:Qn(m,m.return);var x=m.stateNode;if(typeof x.componentWillUnmount=="function"){r=m,n=m.return;try{t=r,x.props=t.memoizedProps,x.state=t.memoizedState,x.componentWillUnmount()}catch(y){xe(r,n,y)}}break;case 5:Qn(m,m.return);break;case 22:if(m.memoizedState!==null){bc(h);continue}}w!==null?(w.return=m,G=w):bc(h)}p=p.sibling}e:for(p=null,h=e;;){if(h.tag===5){if(p===null){p=h;try{a=h.stateNode,u?(s=a.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=h.stateNode,c=h.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=ju("display",i))}catch(y){xe(e,e.return,y)}}}else if(h.tag===6){if(p===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(y){xe(e,e.return,y)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;p===h&&(p=null),h=h.return}p===h&&(p=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:vt(t,e),Nt(e),r&4&&kc(e);break;case 21:break;default:vt(t,e),Nt(e)}}function Nt(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(Yd(n)){var r=n;break e}n=n.return}throw Error(M(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(Dr(a,""),r.flags&=-33);var s=jc(e);si(e,s,a);break;case 3:case 4:var i=r.stateNode.containerInfo,l=jc(e);oi(e,l,i);break;default:throw Error(M(161))}}catch(c){xe(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ah(e,t,n){G=e,Xd(e)}function Xd(e,t,n){for(var r=(e.mode&1)!==0;G!==null;){var a=G,s=a.child;if(a.tag===22&&r){var i=a.memoizedState!==null||ba;if(!i){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Me;l=ba;var u=Me;if(ba=i,(Me=c)&&!u)for(G=a;G!==null;)i=G,c=i.child,i.tag===22&&i.memoizedState!==null?Nc(a):c!==null?(c.return=i,G=c):Nc(a);for(;s!==null;)G=s,Xd(s),s=s.sibling;G=a,ba=l,Me=u}Cc(e)}else a.subtreeFlags&8772&&s!==null?(s.return=a,G=s):Cc(e)}}function Cc(e){for(;G!==null;){var t=G;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Me||Io(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Me)if(n===null)r.componentDidMount();else{var a=t.elementType===t.type?n.memoizedProps:yt(t.type,n.memoizedProps);r.componentDidUpdate(a,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&lc(t,s,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}lc(t,i,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var p=u.memoizedState;if(p!==null){var h=p.dehydrated;h!==null&&Vr(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(M(163))}Me||t.flags&512&&ai(t)}catch(m){xe(t,t.return,m)}}if(t===e){G=null;break}if(n=t.sibling,n!==null){n.return=t.return,G=n;break}G=t.return}}function bc(e){for(;G!==null;){var t=G;if(t===e){G=null;break}var n=t.sibling;if(n!==null){n.return=t.return,G=n;break}G=t.return}}function Nc(e){for(;G!==null;){var t=G;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Io(4,t)}catch(c){xe(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){xe(t,a,c)}}var s=t.return;try{ai(t)}catch(c){xe(t,s,c)}break;case 5:var i=t.return;try{ai(t)}catch(c){xe(t,i,c)}}}catch(c){xe(t,t.return,c)}if(t===e){G=null;break}var l=t.sibling;if(l!==null){l.return=t.return,G=l;break}G=t.return}}var oh=Math.ceil,fo=Vt.ReactCurrentDispatcher,rl=Vt.ReactCurrentOwner,ft=Vt.ReactCurrentBatchConfig,re=0,ze=null,Se=null,Re=0,et=0,Jn=pn(0),be=0,na=null,Tn=0,Po=0,al=0,Mr=null,Ge=null,ol=0,cr=1/0,At=null,po=!1,ii=null,sn=null,Na=!1,en=null,mo=0,Fr=0,li=null,Ba=-1,Da=0;function De(){return re&6?we():Ba!==-1?Ba:Ba=we()}function ln(e){return e.mode&1?re&2&&Re!==0?Re&-Re:Um.transition!==null?(Da===0&&(Da=$u()),Da):(e=se,e!==0||(e=window.event,e=e===void 0?16:Uu(e.type)),e):1}function jt(e,t,n,r){if(50<Fr)throw Fr=0,li=null,Error(M(185));oa(e,n,r),(!(re&2)||e!==ze)&&(e===ze&&(!(re&2)&&(Po|=n),be===4&&qt(e,Re)),Xe(e,r),n===1&&re===0&&!(t.mode&1)&&(cr=we()+500,No&&mn()))}function Xe(e,t){var n=e.callbackNode;Up(e,t);var r=Ja(e,e===ze?Re:0);if(r===0)n!==null&&$l(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&$l(n),t===1)e.tag===0?Dm(Ec.bind(null,e)):id(Ec.bind(null,e)),Mm(function(){!(re&6)&&mn()}),n=null;else{switch(Lu(r)){case 1:n=Ti;break;case 4:n=_u;break;case 16:n=Qa;break;case 536870912:n=Au;break;default:n=Qa}n=of(n,qd.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function qd(e,t){if(Ba=-1,Da=0,re&6)throw Error(M(327));var n=e.callbackNode;if(nr()&&e.callbackNode!==n)return null;var r=Ja(e,e===ze?Re:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=ho(e,r);else{t=r;var a=re;re|=2;var s=ef();(ze!==e||Re!==t)&&(At=null,cr=we()+500,Nn(e,t));do try{lh();break}catch(l){Zd(e,l)}while(!0);Hi(),fo.current=s,re=a,Se!==null?t=0:(ze=null,Re=0,t=be)}if(t!==0){if(t===2&&(a=$s(e),a!==0&&(r=a,t=ci(e,a))),t===1)throw n=na,Nn(e,0),qt(e,r),Xe(e,we()),n;if(t===6)qt(e,r);else{if(a=e.current.alternate,!(r&30)&&!sh(a)&&(t=ho(e,r),t===2&&(s=$s(e),s!==0&&(r=s,t=ci(e,s))),t===1))throw n=na,Nn(e,0),qt(e,r),Xe(e,we()),n;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(M(345));case 2:wn(e,Ge,At);break;case 3:if(qt(e,r),(r&130023424)===r&&(t=ol+500-we(),10<t)){if(Ja(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){De(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=Ws(wn.bind(null,e,Ge,At),t);break}wn(e,Ge,At);break;case 4:if(qt(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var i=31-St(r);s=1<<i,i=t[i],i>a&&(a=i),r&=~s}if(r=a,r=we()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*oh(r/1960))-r,10<r){e.timeoutHandle=Ws(wn.bind(null,e,Ge,At),r);break}wn(e,Ge,At);break;case 5:wn(e,Ge,At);break;default:throw Error(M(329))}}}return Xe(e,we()),e.callbackNode===n?qd.bind(null,e):null}function ci(e,t){var n=Mr;return e.current.memoizedState.isDehydrated&&(Nn(e,t).flags|=256),e=ho(e,t),e!==2&&(t=Ge,Ge=n,t!==null&&ui(t)),e}function ui(e){Ge===null?Ge=e:Ge.push.apply(Ge,e)}function sh(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var a=n[r],s=a.getSnapshot;a=a.value;try{if(!kt(s(),a))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function qt(e,t){for(t&=~al,t&=~Po,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-St(t),r=1<<n;e[n]=-1,t&=~r}}function Ec(e){if(re&6)throw Error(M(327));nr();var t=Ja(e,0);if(!(t&1))return Xe(e,we()),null;var n=ho(e,t);if(e.tag!==0&&n===2){var r=$s(e);r!==0&&(t=r,n=ci(e,r))}if(n===1)throw n=na,Nn(e,0),qt(e,t),Xe(e,we()),n;if(n===6)throw Error(M(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,wn(e,Ge,At),Xe(e,we()),null}function sl(e,t){var n=re;re|=1;try{return e(t)}finally{re=n,re===0&&(cr=we()+500,No&&mn())}}function Rn(e){en!==null&&en.tag===0&&!(re&6)&&nr();var t=re;re|=1;var n=ft.transition,r=se;try{if(ft.transition=null,se=1,e)return e()}finally{se=r,ft.transition=n,re=t,!(re&6)&&mn()}}function il(){et=Jn.current,de(Jn)}function Nn(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,Lm(n)),Se!==null)for(n=Se.return;n!==null;){var r=n;switch(Di(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&to();break;case 3:ir(),de(Qe),de(Fe),Ji();break;case 5:Qi(r);break;case 4:ir();break;case 13:de(ge);break;case 19:de(ge);break;case 10:Vi(r.type._context);break;case 22:case 23:il()}n=n.return}if(ze=e,Se=e=cn(e.current,null),Re=et=t,be=0,na=null,al=Po=Tn=0,Ge=Mr=null,kn!==null){for(t=0;t<kn.length;t++)if(n=kn[t],r=n.interleaved,r!==null){n.interleaved=null;var a=r.next,s=n.pending;if(s!==null){var i=s.next;s.next=a,r.next=i}n.pending=r}kn=null}return e}function Zd(e,t){do{var n=Se;try{if(Hi(),Ma.current=uo,co){for(var r=ve.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}co=!1}if(Pn=0,Ee=Ce=ve=null,$r=!1,Zr=0,rl.current=null,n===null||n.return===null){be=1,na=t,Se=null;break}e:{var s=e,i=n.return,l=n,c=t;if(t=Re,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,p=l,h=p.tag;if(!(p.mode&1)&&(h===0||h===11||h===15)){var m=p.alternate;m?(p.updateQueue=m.updateQueue,p.memoizedState=m.memoizedState,p.lanes=m.lanes):(p.updateQueue=null,p.memoizedState=null)}var w=mc(i);if(w!==null){w.flags&=-257,hc(w,i,l,s,t),w.mode&1&&pc(s,u,t),t=w,c=u;var x=t.updateQueue;if(x===null){var y=new Set;y.add(c),t.updateQueue=y}else x.add(c);break e}else{if(!(t&1)){pc(s,u,t),ll();break e}c=Error(M(426))}}else if(pe&&l.mode&1){var j=mc(i);if(j!==null){!(j.flags&65536)&&(j.flags|=256),hc(j,i,l,s,t),Ui(lr(c,l));break e}}s=c=lr(c,l),be!==4&&(be=2),Mr===null?Mr=[s]:Mr.push(s),s=i;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var g=Ld(s,c,t);ic(s,g);break e;case 1:l=c;var f=s.type,v=s.stateNode;if(!(s.flags&128)&&(typeof f.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(sn===null||!sn.has(v)))){s.flags|=65536,t&=-t,s.lanes|=t;var S=Md(s,l,t);ic(s,S);break e}}s=s.return}while(s!==null)}nf(n)}catch(E){t=E,Se===n&&n!==null&&(Se=n=n.return);continue}break}while(!0)}function ef(){var e=fo.current;return fo.current=uo,e===null?uo:e}function ll(){(be===0||be===3||be===2)&&(be=4),ze===null||!(Tn&268435455)&&!(Po&268435455)||qt(ze,Re)}function ho(e,t){var n=re;re|=2;var r=ef();(ze!==e||Re!==t)&&(At=null,Nn(e,t));do try{ih();break}catch(a){Zd(e,a)}while(!0);if(Hi(),re=n,fo.current=r,Se!==null)throw Error(M(261));return ze=null,Re=0,be}function ih(){for(;Se!==null;)tf(Se)}function lh(){for(;Se!==null&&!_p();)tf(Se)}function tf(e){var t=af(e.alternate,e,et);e.memoizedProps=e.pendingProps,t===null?nf(e):Se=t,rl.current=null}function nf(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=th(n,t),n!==null){n.flags&=32767,Se=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{be=6,Se=null;return}}else if(n=eh(n,t,et),n!==null){Se=n;return}if(t=t.sibling,t!==null){Se=t;return}Se=t=e}while(t!==null);be===0&&(be=5)}function wn(e,t,n){var r=se,a=ft.transition;try{ft.transition=null,se=1,ch(e,t,n,r)}finally{ft.transition=a,se=r}return null}function ch(e,t,n,r){do nr();while(en!==null);if(re&6)throw Error(M(327));n=e.finishedWork;var a=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(M(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(Wp(e,s),e===ze&&(Se=ze=null,Re=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Na||(Na=!0,of(Qa,function(){return nr(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=ft.transition,ft.transition=null;var i=se;se=1;var l=re;re|=4,rl.current=null,rh(e,n),Jd(n,e),Im(Ds),Xa=!!Bs,Ds=Bs=null,e.current=n,ah(n),Ap(),re=l,se=i,ft.transition=s}else e.current=n;if(Na&&(Na=!1,en=e,mo=a),s=e.pendingLanes,s===0&&(sn=null),Mp(n.stateNode),Xe(e,we()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)a=t[n],r(a.value,{componentStack:a.stack,digest:a.digest});if(po)throw po=!1,e=ii,ii=null,e;return mo&1&&e.tag!==0&&nr(),s=e.pendingLanes,s&1?e===li?Fr++:(Fr=0,li=e):Fr=0,mn(),null}function nr(){if(en!==null){var e=Lu(mo),t=ft.transition,n=se;try{if(ft.transition=null,se=16>e?16:e,en===null)var r=!1;else{if(e=en,en=null,mo=0,re&6)throw Error(M(331));var a=re;for(re|=4,G=e.current;G!==null;){var s=G,i=s.child;if(G.flags&16){var l=s.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(G=u;G!==null;){var p=G;switch(p.tag){case 0:case 11:case 15:Lr(8,p,s)}var h=p.child;if(h!==null)h.return=p,G=h;else for(;G!==null;){p=G;var m=p.sibling,w=p.return;if(Gd(p),p===u){G=null;break}if(m!==null){m.return=w,G=m;break}G=w}}}var x=s.alternate;if(x!==null){var y=x.child;if(y!==null){x.child=null;do{var j=y.sibling;y.sibling=null,y=j}while(y!==null)}}G=s}}if(s.subtreeFlags&2064&&i!==null)i.return=s,G=i;else e:for(;G!==null;){if(s=G,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Lr(9,s,s.return)}var g=s.sibling;if(g!==null){g.return=s.return,G=g;break e}G=s.return}}var f=e.current;for(G=f;G!==null;){i=G;var v=i.child;if(i.subtreeFlags&2064&&v!==null)v.return=i,G=v;else e:for(i=f;G!==null;){if(l=G,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Io(9,l)}}catch(E){xe(l,l.return,E)}if(l===i){G=null;break e}var S=l.sibling;if(S!==null){S.return=l.return,G=S;break e}G=l.return}}if(re=a,mn(),Pt&&typeof Pt.onPostCommitFiberRoot=="function")try{Pt.onPostCommitFiberRoot(So,e)}catch{}r=!0}return r}finally{se=n,ft.transition=t}}return!1}function zc(e,t,n){t=lr(n,t),t=Ld(e,t,1),e=on(e,t,1),t=De(),e!==null&&(oa(e,1,t),Xe(e,t))}function xe(e,t,n){if(e.tag===3)zc(e,e,n);else for(;t!==null;){if(t.tag===3){zc(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(sn===null||!sn.has(r))){e=lr(n,e),e=Md(t,e,1),t=on(t,e,1),e=De(),t!==null&&(oa(t,1,e),Xe(t,e));break}}t=t.return}}function uh(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=De(),e.pingedLanes|=e.suspendedLanes&n,ze===e&&(Re&n)===n&&(be===4||be===3&&(Re&130023424)===Re&&500>we()-ol?Nn(e,0):al|=n),Xe(e,t)}function rf(e,t){t===0&&(e.mode&1?(t=ga,ga<<=1,!(ga&130023424)&&(ga=4194304)):t=1);var n=De();e=Ut(e,t),e!==null&&(oa(e,t,n),Xe(e,n))}function dh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),rf(e,n)}function fh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(M(314))}r!==null&&r.delete(t),rf(e,n)}var af;af=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Qe.current)Ye=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ye=!1,Zm(e,t,n);Ye=!!(e.flags&131072)}else Ye=!1,pe&&t.flags&1048576&&ld(t,ao,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Oa(e,t),e=t.pendingProps;var a=ar(t,Fe.current);tr(t,n),a=qi(null,t,r,e,a,n);var s=Zi();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Je(r)?(s=!0,no(t)):s=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Gi(t),a.updater=zo,t.stateNode=a,a._reactInternals=t,Js(t,r,e,n),t=Zs(null,t,r,!0,s,n)):(t.tag=0,pe&&s&&Bi(t),Be(null,t,a,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Oa(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=mh(r),e=yt(r,e),a){case 0:t=qs(null,t,r,e,n);break e;case 1:t=yc(null,t,r,e,n);break e;case 11:t=gc(null,t,r,e,n);break e;case 14:t=vc(null,t,r,yt(r.type,e),n);break e}throw Error(M(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),qs(e,t,r,a,n);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),yc(e,t,r,a,n);case 3:e:{if(Dd(t),e===null)throw Error(M(387));r=t.pendingProps,s=t.memoizedState,a=s.element,md(e,t),io(t,r,null,n);var i=t.memoizedState;if(r=i.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){a=lr(Error(M(423)),t),t=xc(e,t,r,n,a);break e}else if(r!==a){a=lr(Error(M(424)),t),t=xc(e,t,r,n,a);break e}else for(nt=an(t.stateNode.containerInfo.firstChild),rt=t,pe=!0,wt=null,n=fd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(or(),r===a){t=Wt(e,t,n);break e}Be(e,t,r,n)}t=t.child}return t;case 5:return hd(t),e===null&&Gs(t),r=t.type,a=t.pendingProps,s=e!==null?e.memoizedProps:null,i=a.children,Us(r,a)?i=null:s!==null&&Us(r,s)&&(t.flags|=32),Bd(e,t),Be(e,t,i,n),t.child;case 6:return e===null&&Gs(t),null;case 13:return Ud(e,t,n);case 4:return Yi(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=sr(t,null,r,n):Be(e,t,r,n),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),gc(e,t,r,a,n);case 7:return Be(e,t,t.pendingProps,n),t.child;case 8:return Be(e,t,t.pendingProps.children,n),t.child;case 12:return Be(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,s=t.memoizedProps,i=a.value,ce(oo,r._currentValue),r._currentValue=i,s!==null)if(kt(s.value,i)){if(s.children===a.children&&!Qe.current){t=Wt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){i=s.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=Ot(-1,n&-n),c.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var p=u.pending;p===null?c.next=c:(c.next=p.next,p.next=c),u.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ys(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(s.tag===10)i=s.type===t.type?null:s.child;else if(s.tag===18){if(i=s.return,i===null)throw Error(M(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),Ys(i,n,t),i=s.sibling}else i=s.child;if(i!==null)i.return=s;else for(i=s;i!==null;){if(i===t){i=null;break}if(s=i.sibling,s!==null){s.return=i.return,i=s;break}i=i.return}s=i}Be(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,tr(t,n),a=pt(a),r=r(a),t.flags|=1,Be(e,t,r,n),t.child;case 14:return r=t.type,a=yt(r,t.pendingProps),a=yt(r.type,a),vc(e,t,r,a,n);case 15:return Fd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:yt(r,a),Oa(e,t),t.tag=1,Je(r)?(e=!0,no(t)):e=!1,tr(t,n),$d(t,r,a),Js(t,r,a,n),Zs(null,t,r,!0,e,n);case 19:return Wd(e,t,n);case 22:return Od(e,t,n)}throw Error(M(156,t.tag))};function of(e,t){return Ru(e,t)}function ph(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dt(e,t,n,r){return new ph(e,t,n,r)}function cl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function mh(e){if(typeof e=="function")return cl(e)?1:0;if(e!=null){if(e=e.$$typeof,e===zi)return 11;if(e===Ii)return 14}return 2}function cn(e,t){var n=e.alternate;return n===null?(n=dt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ua(e,t,n,r,a,s){var i=2;if(r=e,typeof e=="function")cl(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Bn:return En(n.children,a,s,t);case Ei:i=8,a|=8;break;case ws:return e=dt(12,n,t,a|2),e.elementType=ws,e.lanes=s,e;case Ss:return e=dt(13,n,t,a),e.elementType=Ss,e.lanes=s,e;case js:return e=dt(19,n,t,a),e.elementType=js,e.lanes=s,e;case hu:return To(n,a,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pu:i=10;break e;case mu:i=9;break e;case zi:i=11;break e;case Ii:i=14;break e;case Yt:i=16,r=null;break e}throw Error(M(130,e==null?e:typeof e,""))}return t=dt(i,n,t,a),t.elementType=e,t.type=r,t.lanes=s,t}function En(e,t,n,r){return e=dt(7,e,r,t),e.lanes=n,e}function To(e,t,n,r){return e=dt(22,e,r,t),e.elementType=hu,e.lanes=n,e.stateNode={isHidden:!1},e}function us(e,t,n){return e=dt(6,e,null,t),e.lanes=n,e}function ds(e,t,n){return t=dt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function hh(e,t,n,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vo(0),this.expirationTimes=Vo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vo(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function ul(e,t,n,r,a,s,i,l,c){return e=new hh(e,t,n,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=dt(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gi(s),e}function gh(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:On,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function sf(e){if(!e)return dn;e=e._reactInternals;e:{if(An(e)!==e||e.tag!==1)throw Error(M(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Je(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(M(171))}if(e.tag===1){var n=e.type;if(Je(n))return sd(e,n,t)}return t}function lf(e,t,n,r,a,s,i,l,c){return e=ul(n,r,!0,e,a,s,i,l,c),e.context=sf(null),n=e.current,r=De(),a=ln(n),s=Ot(r,a),s.callback=t??null,on(n,s,a),e.current.lanes=a,oa(e,a,r),Xe(e,r),e}function Ro(e,t,n,r){var a=t.current,s=De(),i=ln(a);return n=sf(n),t.context===null?t.context=n:t.pendingContext=n,t=Ot(s,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=on(a,t,i),e!==null&&(jt(e,a,i,s),La(e,a,i)),i}function go(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ic(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function dl(e,t){Ic(e,t),(e=e.alternate)&&Ic(e,t)}function vh(){return null}var cf=typeof reportError=="function"?reportError:function(e){console.error(e)};function fl(e){this._internalRoot=e}_o.prototype.render=fl.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(M(409));Ro(e,t,null,null)};_o.prototype.unmount=fl.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Rn(function(){Ro(null,e,null,null)}),t[Dt]=null}};function _o(e){this._internalRoot=e}_o.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ou();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Xt.length&&t!==0&&t<Xt[n].priority;n++);Xt.splice(n,0,e),n===0&&Du(e)}};function pl(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Ao(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function Pc(){}function yh(e,t,n,r,a){if(a){if(typeof r=="function"){var s=r;r=function(){var u=go(i);s.call(u)}}var i=lf(t,r,e,0,null,!1,!1,"",Pc);return e._reactRootContainer=i,e[Dt]=i.current,Yr(e.nodeType===8?e.parentNode:e),Rn(),i}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var l=r;r=function(){var u=go(c);l.call(u)}}var c=ul(e,0,!1,null,null,!1,!1,"",Pc);return e._reactRootContainer=c,e[Dt]=c.current,Yr(e.nodeType===8?e.parentNode:e),Rn(function(){Ro(t,c,n,r)}),c}function $o(e,t,n,r,a){var s=n._reactRootContainer;if(s){var i=s;if(typeof a=="function"){var l=a;a=function(){var c=go(i);l.call(c)}}Ro(t,i,e,a)}else i=yh(n,t,e,a,r);return go(i)}Mu=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Er(t.pendingLanes);n!==0&&(Ri(t,n|1),Xe(t,we()),!(re&6)&&(cr=we()+500,mn()))}break;case 13:Rn(function(){var r=Ut(e,1);if(r!==null){var a=De();jt(r,e,1,a)}}),dl(e,1)}};_i=function(e){if(e.tag===13){var t=Ut(e,134217728);if(t!==null){var n=De();jt(t,e,134217728,n)}dl(e,134217728)}};Fu=function(e){if(e.tag===13){var t=ln(e),n=Ut(e,t);if(n!==null){var r=De();jt(n,e,t,r)}dl(e,t)}};Ou=function(){return se};Bu=function(e,t){var n=se;try{return se=e,t()}finally{se=n}};Rs=function(e,t,n){switch(t){case"input":if(bs(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=bo(r);if(!a)throw Error(M(90));vu(r),bs(r,a)}}}break;case"textarea":xu(e,n);break;case"select":t=n.value,t!=null&&Xn(e,!!n.multiple,t,!1)}};Nu=sl;Eu=Rn;var xh={usingClientEntryPoint:!1,Events:[ia,Hn,bo,Cu,bu,sl]},kr={findFiberByHostInstance:jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},wh={bundleType:kr.bundleType,version:kr.version,rendererPackageName:kr.rendererPackageName,rendererConfig:kr.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Vt.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Pu(e),e===null?null:e.stateNode},findFiberByHostInstance:kr.findFiberByHostInstance||vh,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ea=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ea.isDisabled&&Ea.supportsFiber)try{So=Ea.inject(wh),Pt=Ea}catch{}}ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xh;ot.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!pl(t))throw Error(M(200));return gh(e,t,null,n)};ot.createRoot=function(e,t){if(!pl(e))throw Error(M(299));var n=!1,r="",a=cf;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=ul(e,1,!1,null,null,n,!1,r,a),e[Dt]=t.current,Yr(e.nodeType===8?e.parentNode:e),new fl(t)};ot.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(M(188)):(e=Object.keys(e).join(","),Error(M(268,e)));return e=Pu(t),e=e===null?null:e.stateNode,e};ot.flushSync=function(e){return Rn(e)};ot.hydrate=function(e,t,n){if(!Ao(t))throw Error(M(200));return $o(null,e,t,!0,n)};ot.hydrateRoot=function(e,t,n){if(!pl(e))throw Error(M(405));var r=n!=null&&n.hydratedSources||null,a=!1,s="",i=cf;if(n!=null&&(n.unstable_strictMode===!0&&(a=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=lf(t,null,e,1,n??null,a,!1,s,i),e[Dt]=t.current,Yr(e),r)for(e=0;e<r.length;e++)n=r[e],a=n._getVersion,a=a(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,a]:t.mutableSourceEagerHydrationData.push(n,a);return new _o(t)};ot.render=function(e,t,n){if(!Ao(t))throw Error(M(200));return $o(null,e,t,!1,n)};ot.unmountComponentAtNode=function(e){if(!Ao(e))throw Error(M(40));return e._reactRootContainer?(Rn(function(){$o(null,null,e,!1,function(){e._reactRootContainer=null,e[Dt]=null})}),!0):!1};ot.unstable_batchedUpdates=sl;ot.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Ao(n))throw Error(M(200));if(e==null||e._reactInternals===void 0)throw Error(M(38));return $o(e,t,n,!1,r)};ot.version="18.3.1-next-f1338f8080-20240426";function uf(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uf)}catch(e){console.error(e)}}uf(),cu.exports=ot;var df=cu.exports,ff,Tc=df;ff=Tc.createRoot,Tc.hydrateRoot;/**
41
41
  * react-router v7.13.1
42
42
  *
43
43
  * Copyright (c) Remix Software Inc.
@@ -46,27 +46,27 @@ Error generating stack: `+s.message+`
46
46
  * LICENSE.md file in the root directory of this source tree.
47
47
  *
48
48
  * @license MIT
49
- */var Rc="popstate";function _c(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Sh(e={}){function t(r,a){var u;let s=(u=a.state)==null?void 0:u.masked,{pathname:i,search:l,hash:c}=s||r.location;return di("",{pathname:i,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:ra(a)}return kh(t,n,null,e)}function me(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ht(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function jh(){return Math.random().toString(36).substring(2,10)}function Ac(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function di(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?pr(t):t,state:n,key:t&&t.key||r||jh(),unstable_mask:a}}function ra({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function pr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function kh(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,i=a.history,l="POP",c=null,u=p();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function p(){return(i.state||{idx:null}).idx}function m(){l="POP";let j=p(),h=j==null?null:j-u;u=j,c&&c({action:l,location:y.location,delta:h})}function g(j,h){l="PUSH";let f=_c(j)?j:di(y.location,j,h);u=p()+1;let v=Ac(f,u),S=y.createHref(f.unstable_mask||f);try{i.pushState(v,"",S)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;a.location.assign(S)}s&&c&&c({action:l,location:y.location,delta:1})}function w(j,h){l="REPLACE";let f=_c(j)?j:di(y.location,j,h);u=p();let v=Ac(f,u),S=y.createHref(f.unstable_mask||f);i.replaceState(v,"",S),s&&c&&c({action:l,location:y.location,delta:0})}function x(j){return Ch(j)}let y={get action(){return l},get location(){return e(a,i)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Rc,m),c=j,()=>{a.removeEventListener(Rc,m),c=null}},createHref(j){return t(a,j)},createURL:x,encodeLocation(j){let h=x(j);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:g,replace:w,go(j){return i.go(j)}};return y}function Ch(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),me(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ra(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function pf(e,t,n="/"){return bh(e,t,n,!1)}function bh(e,t,n,r){let a=typeof t=="string"?pr(t):t,s=Ht(a.pathname||"/",n);if(s==null)return null;let i=mf(e);Nh(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=Mh(s);l=$h(i[c],u,r)}return l}function mf(e,t=[],n=[],r="",a=!1){let s=(i,l,c=a,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&c)return;me(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let m=Rt([r,p.relativePath]),g=n.concat(p);i.children&&i.children.length>0&&(me(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),mf(i.children,t,g,m,c)),!(i.path==null&&!i.index)&&t.push({path:m,score:_h(m,i.index),routesMeta:g})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))s(i,l);else for(let u of hf(i.path))s(i,l,!0,u)}),t}function hf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let i=hf(r.join("/")),l=[];return l.push(...i.map(c=>c===""?s:[s,c].join("/"))),a&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Nh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ah(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Eh=/^:[\w-]+$/,zh=3,Ih=2,Ph=1,Th=10,Rh=-2,$c=e=>e==="*";function _h(e,t){let n=e.split("/"),r=n.length;return n.some($c)&&(r+=Rh),t&&(r+=Ih),n.filter(a=>!$c(a)).reduce((a,s)=>a+(Eh.test(s)?zh:s===""?Ph:Th),r)}function Ah(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function $h(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,p=s==="/"?t:t.slice(s.length)||"/",m=vo({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},p),g=c.route;if(!m&&u&&n&&!r[r.length-1].route.index&&(m=vo({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},p)),!m)return null;Object.assign(a,m.params),i.push({params:a,pathname:Rt([s,m.pathname]),pathnameBase:Dh(Rt([s,m.pathnameBase])),route:g}),m.pathnameBase!=="/"&&(s=Rt([s,m.pathnameBase]))}return i}function vo(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Lh(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let s=a[0],i=s.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((u,{paramName:p,isOptional:m},g)=>{if(p==="*"){let x=l[g]||"";i=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const w=l[g];return m&&!w?u[p]=void 0:u[p]=(w||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:i,pattern:e}}function Lh(e,t=!1,n=!0){ht(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,u,p)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let m=p.charAt(u+i.length);return m&&m!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Mh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ht(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ht(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Fh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Oh(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?pr(e):e,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=Lc(n.substring(1),"/"):s=Lc(n,t)):s=t,{pathname:s,search:Uh(r),hash:Wh(a)}}function Lc(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function fs(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Bh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ml(e){let t=Bh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Lo(e,t,n,r=!1){let a;typeof e=="string"?a=pr(e):(a={...e},me(!a.pathname||!a.pathname.includes("?"),fs("?","pathname","search",a)),me(!a.pathname||!a.pathname.includes("#"),fs("#","pathname","hash",a)),me(!a.search||!a.search.includes("#"),fs("#","search","hash",a)));let s=e===""||a.pathname==="",i=s?"/":a.pathname,l;if(i==null)l=n;else{let m=t.length-1;if(!r&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),m-=1;a.pathname=g.join("/")}l=m>=0?t[m]:"/"}let c=Oh(a,l),u=i&&i!=="/"&&i.endsWith("/"),p=(s||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}var Rt=e=>e.join("/").replace(/\/\/+/g,"/"),Dh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Uh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Wh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Hh=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Vh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Kh(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var gf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function vf(e,t){let n=e;if(typeof n!="string"||!Fh.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(gf)try{let s=new URL(window.location.href),i=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Ht(i.pathname,t);i.origin===s.origin&&l!=null?n=l+i.search+i.hash:a=!0}catch{ht(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var yf=["POST","PUT","PATCH","DELETE"];new Set(yf);var Gh=["GET",...yf];new Set(Gh);var mr=d.createContext(null);mr.displayName="DataRouter";var Mo=d.createContext(null);Mo.displayName="DataRouterState";var Yh=d.createContext(!1),xf=d.createContext({isTransitioning:!1});xf.displayName="ViewTransition";var Qh=d.createContext(new Map);Qh.displayName="Fetchers";var Jh=d.createContext(null);Jh.displayName="Await";var it=d.createContext(null);it.displayName="Navigation";var ca=d.createContext(null);ca.displayName="Location";var Ct=d.createContext({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var hl=d.createContext(null);hl.displayName="RouteError";var wf="REACT_ROUTER_ERROR",Xh="REDIRECT",qh="ROUTE_ERROR_RESPONSE";function Zh(e){if(e.startsWith(`${wf}:${Xh}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function eg(e){if(e.startsWith(`${wf}:${qh}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Hh(t.status,t.statusText,t.data)}catch{}}function tg(e,{relative:t}={}){me(hr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(it),{hash:a,pathname:s,search:i}=ua(e,{relative:t}),l=s;return n!=="/"&&(l=s==="/"?n:Rt([n,s])),r.createHref({pathname:l,search:i,hash:a})}function hr(){return d.useContext(ca)!=null}function gt(){return me(hr(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(ca).location}var Sf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jf(e){d.useContext(it).static||d.useLayoutEffect(e)}function Kt(){let{isDataRoute:e}=d.useContext(Ct);return e?gg():ng()}function ng(){me(hr(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(mr),{basename:t,navigator:n}=d.useContext(it),{matches:r}=d.useContext(Ct),{pathname:a}=gt(),s=JSON.stringify(ml(r)),i=d.useRef(!1);return jf(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(ht(i.current,Sf),!i.current)return;if(typeof c=="number"){n.go(c);return}let p=Lo(c,JSON.parse(s),a,u.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Rt([t,p.pathname])),(u.replace?n.replace:n.push)(p,u.state,u)},[t,n,s,a,e])}var rg=d.createContext(null);function ag(e){let t=d.useContext(Ct).outlet;return d.useMemo(()=>t&&d.createElement(rg.Provider,{value:e},t),[t,e])}function ua(e,{relative:t}={}){let{matches:n}=d.useContext(Ct),{pathname:r}=gt(),a=JSON.stringify(ml(n));return d.useMemo(()=>Lo(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function og(e,t){return kf(e,t)}function kf(e,t,n){var j;me(hr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=d.useContext(it),{matches:a}=d.useContext(Ct),s=a[a.length-1],i=s?s.params:{},l=s?s.pathname:"/",c=s?s.pathnameBase:"/",u=s&&s.route;{let h=u&&u.path||"";bf(l,!u||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${h}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
49
+ */var Rc="popstate";function _c(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function Sh(e={}){function t(r,a){var u;let s=(u=a.state)==null?void 0:u.masked,{pathname:i,search:l,hash:c}=s||r.location;return di("",{pathname:i,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:ra(a)}return kh(t,n,null,e)}function me(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ht(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function jh(){return Math.random().toString(36).substring(2,10)}function Ac(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function di(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?pr(t):t,state:n,key:t&&t.key||r||jh(),unstable_mask:a}}function ra({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function pr(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function kh(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,i=a.history,l="POP",c=null,u=p();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function p(){return(i.state||{idx:null}).idx}function h(){l="POP";let j=p(),g=j==null?null:j-u;u=j,c&&c({action:l,location:y.location,delta:g})}function m(j,g){l="PUSH";let f=_c(j)?j:di(y.location,j,g);u=p()+1;let v=Ac(f,u),S=y.createHref(f.unstable_mask||f);try{i.pushState(v,"",S)}catch(E){if(E instanceof DOMException&&E.name==="DataCloneError")throw E;a.location.assign(S)}s&&c&&c({action:l,location:y.location,delta:1})}function w(j,g){l="REPLACE";let f=_c(j)?j:di(y.location,j,g);u=p();let v=Ac(f,u),S=y.createHref(f.unstable_mask||f);i.replaceState(v,"",S),s&&c&&c({action:l,location:y.location,delta:0})}function x(j){return Ch(j)}let y={get action(){return l},get location(){return e(a,i)},listen(j){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(Rc,h),c=j,()=>{a.removeEventListener(Rc,h),c=null}},createHref(j){return t(a,j)},createURL:x,encodeLocation(j){let g=x(j);return{pathname:g.pathname,search:g.search,hash:g.hash}},push:m,replace:w,go(j){return i.go(j)}};return y}function Ch(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),me(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ra(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function pf(e,t,n="/"){return bh(e,t,n,!1)}function bh(e,t,n,r){let a=typeof t=="string"?pr(t):t,s=Ht(a.pathname||"/",n);if(s==null)return null;let i=mf(e);Nh(i);let l=null;for(let c=0;l==null&&c<i.length;++c){let u=Mh(s);l=$h(i[c],u,r)}return l}function mf(e,t=[],n=[],r="",a=!1){let s=(i,l,c=a,u)=>{let p={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};if(p.relativePath.startsWith("/")){if(!p.relativePath.startsWith(r)&&c)return;me(p.relativePath.startsWith(r),`Absolute route path "${p.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),p.relativePath=p.relativePath.slice(r.length)}let h=Rt([r,p.relativePath]),m=n.concat(p);i.children&&i.children.length>0&&(me(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),mf(i.children,t,m,h,c)),!(i.path==null&&!i.index)&&t.push({path:h,score:_h(h,i.index),routesMeta:m})};return e.forEach((i,l)=>{var c;if(i.path===""||!((c=i.path)!=null&&c.includes("?")))s(i,l);else for(let u of hf(i.path))s(i,l,!0,u)}),t}function hf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let i=hf(r.join("/")),l=[];return l.push(...i.map(c=>c===""?s:[s,c].join("/"))),a&&l.push(...i),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function Nh(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ah(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Eh=/^:[\w-]+$/,zh=3,Ih=2,Ph=1,Th=10,Rh=-2,$c=e=>e==="*";function _h(e,t){let n=e.split("/"),r=n.length;return n.some($c)&&(r+=Rh),t&&(r+=Ih),n.filter(a=>!$c(a)).reduce((a,s)=>a+(Eh.test(s)?zh:s===""?Ph:Th),r)}function Ah(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function $h(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",i=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,p=s==="/"?t:t.slice(s.length)||"/",h=vo({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},p),m=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=vo({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},p)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:Rt([s,h.pathname]),pathnameBase:Dh(Rt([s,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(s=Rt([s,h.pathnameBase]))}return i}function vo(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Lh(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let s=a[0],i=s.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((u,{paramName:p,isOptional:h},m)=>{if(p==="*"){let x=l[m]||"";i=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const w=l[m];return h&&!w?u[p]=void 0:u[p]=(w||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:i,pattern:e}}function Lh(e,t=!1,n=!0){ht(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,l,c,u,p)=>{if(r.push({paramName:l,isOptional:c!=null}),c){let h=p.charAt(u+i.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function Mh(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ht(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Ht(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var Fh=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Oh(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?pr(e):e,s;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?s=Lc(n.substring(1),"/"):s=Lc(n,t)):s=t,{pathname:s,search:Uh(r),hash:Wh(a)}}function Lc(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function fs(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Bh(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ml(e){let t=Bh(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Lo(e,t,n,r=!1){let a;typeof e=="string"?a=pr(e):(a={...e},me(!a.pathname||!a.pathname.includes("?"),fs("?","pathname","search",a)),me(!a.pathname||!a.pathname.includes("#"),fs("#","pathname","hash",a)),me(!a.search||!a.search.includes("#"),fs("#","search","hash",a)));let s=e===""||a.pathname==="",i=s?"/":a.pathname,l;if(i==null)l=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let m=i.split("/");for(;m[0]==="..";)m.shift(),h-=1;a.pathname=m.join("/")}l=h>=0?t[h]:"/"}let c=Oh(a,l),u=i&&i!=="/"&&i.endsWith("/"),p=(s||i===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}var Rt=e=>e.join("/").replace(/\/\/+/g,"/"),Dh=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Uh=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Wh=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Hh=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Vh(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Kh(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var gf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function vf(e,t){let n=e;if(typeof n!="string"||!Fh.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(gf)try{let s=new URL(window.location.href),i=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Ht(i.pathname,t);i.origin===s.origin&&l!=null?n=l+i.search+i.hash:a=!0}catch{ht(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var yf=["POST","PUT","PATCH","DELETE"];new Set(yf);var Gh=["GET",...yf];new Set(Gh);var mr=d.createContext(null);mr.displayName="DataRouter";var Mo=d.createContext(null);Mo.displayName="DataRouterState";var Yh=d.createContext(!1),xf=d.createContext({isTransitioning:!1});xf.displayName="ViewTransition";var Qh=d.createContext(new Map);Qh.displayName="Fetchers";var Jh=d.createContext(null);Jh.displayName="Await";var it=d.createContext(null);it.displayName="Navigation";var ca=d.createContext(null);ca.displayName="Location";var Ct=d.createContext({outlet:null,matches:[],isDataRoute:!1});Ct.displayName="Route";var hl=d.createContext(null);hl.displayName="RouteError";var wf="REACT_ROUTER_ERROR",Xh="REDIRECT",qh="ROUTE_ERROR_RESPONSE";function Zh(e){if(e.startsWith(`${wf}:${Xh}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function eg(e){if(e.startsWith(`${wf}:${qh}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Hh(t.status,t.statusText,t.data)}catch{}}function tg(e,{relative:t}={}){me(hr(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=d.useContext(it),{hash:a,pathname:s,search:i}=ua(e,{relative:t}),l=s;return n!=="/"&&(l=s==="/"?n:Rt([n,s])),r.createHref({pathname:l,search:i,hash:a})}function hr(){return d.useContext(ca)!=null}function gt(){return me(hr(),"useLocation() may be used only in the context of a <Router> component."),d.useContext(ca).location}var Sf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function jf(e){d.useContext(it).static||d.useLayoutEffect(e)}function Kt(){let{isDataRoute:e}=d.useContext(Ct);return e?gg():ng()}function ng(){me(hr(),"useNavigate() may be used only in the context of a <Router> component.");let e=d.useContext(mr),{basename:t,navigator:n}=d.useContext(it),{matches:r}=d.useContext(Ct),{pathname:a}=gt(),s=JSON.stringify(ml(r)),i=d.useRef(!1);return jf(()=>{i.current=!0}),d.useCallback((c,u={})=>{if(ht(i.current,Sf),!i.current)return;if(typeof c=="number"){n.go(c);return}let p=Lo(c,JSON.parse(s),a,u.relative==="path");e==null&&t!=="/"&&(p.pathname=p.pathname==="/"?t:Rt([t,p.pathname])),(u.replace?n.replace:n.push)(p,u.state,u)},[t,n,s,a,e])}var rg=d.createContext(null);function ag(e){let t=d.useContext(Ct).outlet;return d.useMemo(()=>t&&d.createElement(rg.Provider,{value:e},t),[t,e])}function ua(e,{relative:t}={}){let{matches:n}=d.useContext(Ct),{pathname:r}=gt(),a=JSON.stringify(ml(n));return d.useMemo(()=>Lo(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function og(e,t){return kf(e,t)}function kf(e,t,n){var j;me(hr(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=d.useContext(it),{matches:a}=d.useContext(Ct),s=a[a.length-1],i=s?s.params:{},l=s?s.pathname:"/",c=s?s.pathnameBase:"/",u=s&&s.route;{let g=u&&u.path||"";bf(l,!u||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${g}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
50
50
 
51
- Please change the parent <Route path="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let p=gt(),m;if(t){let h=typeof t=="string"?pr(t):t;me(c==="/"||((j=h.pathname)==null?void 0:j.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${h.pathname}" was given in the \`location\` prop.`),m=h}else m=p;let g=m.pathname||"/",w=g;if(c!=="/"){let h=c.replace(/^\//,"").split("/");w="/"+g.replace(/^\//,"").split("/").slice(h.length).join("/")}let x=pf(e,{pathname:w});ht(u||x!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),ht(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=ug(x&&x.map(h=>Object.assign({},h,{params:Object.assign({},i,h.params),pathname:Rt([c,r.encodeLocation?r.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?c:Rt([c,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),a,n);return t&&y?d.createElement(ca.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...m},navigationType:"POP"}},y):y}function sg(){let e=hg(),t=Vh(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:s},"ErrorBoundary")," or"," ",d.createElement("code",{style:s},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:a},n):null,i)}var ig=d.createElement(sg,null),Cf=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=eg(e.digest);n&&(e=n)}let t=e!==void 0?d.createElement(Ct.Provider,{value:this.props.routeContext},d.createElement(hl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?d.createElement(lg,{error:e},t):t}};Cf.contextType=Yh;var ps=new WeakMap;function lg({children:e,error:t}){let{basename:n}=d.useContext(it);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Zh(t.digest);if(r){let a=ps.get(t);if(a)throw a;let s=vf(r.location,n);if(gf&&!ps.get(t))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw ps.set(t,i),i}return d.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function cg({routeContext:e,match:t,children:n}){let r=d.useContext(mr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Ct.Provider,{value:e},n)}function ug(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,s=r==null?void 0:r.errors;if(s!=null){let p=a.findIndex(m=>m.route.id&&(s==null?void 0:s[m.route.id])!==void 0);me(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,p+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let p=0;p<a.length;p++){let m=a[p];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(l=p),m.route.id){let{loaderData:g,errors:w}=r,x=m.route.loader&&!g.hasOwnProperty(m.route.id)&&(!w||w[m.route.id]===void 0);if(m.route.lazy||x){n.isStatic&&(i=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=r&&c?(p,m)=>{var g,w;c(p,{location:r.location,params:((w=(g=r.matches)==null?void 0:g[0])==null?void 0:w.params)??{},unstable_pattern:Kh(r.matches),errorInfo:m})}:void 0;return a.reduceRight((p,m,g)=>{let w,x=!1,y=null,j=null;r&&(w=s&&m.route.id?s[m.route.id]:void 0,y=m.route.errorElement||ig,i&&(l<0&&g===0?(bf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,j=null):l===g&&(x=!0,j=m.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,g+1)),f=()=>{let v;return w?v=y:x?v=j:m.route.Component?v=d.createElement(m.route.Component,null):m.route.element?v=m.route.element:v=p,d.createElement(cg,{match:m,routeContext:{outlet:p,matches:h,isDataRoute:r!=null},children:v})};return r&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?d.createElement(Cf,{location:r.location,revalidation:r.revalidation,component:y,error:w,children:f(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:u}):f()},null)}function gl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function dg(e){let t=d.useContext(mr);return me(t,gl(e)),t}function fg(e){let t=d.useContext(Mo);return me(t,gl(e)),t}function pg(e){let t=d.useContext(Ct);return me(t,gl(e)),t}function vl(e){let t=pg(e),n=t.matches[t.matches.length-1];return me(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function mg(){return vl("useRouteId")}function hg(){var r;let e=d.useContext(hl),t=fg("useRouteError"),n=vl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function gg(){let{router:e}=dg("useNavigate"),t=vl("useNavigate"),n=d.useRef(!1);return jf(()=>{n.current=!0}),d.useCallback(async(a,s={})=>{ht(n.current,Sf),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...s}))},[e,t])}var Mc={};function bf(e,t,n){!t&&!Mc[e]&&(Mc[e]=!0,ht(!1,n))}d.memo(vg);function vg({routes:e,future:t,state:n,isStatic:r,onError:a}){return kf(e,void 0,{state:n,isStatic:r,onError:a})}function Jt({to:e,replace:t,state:n,relative:r}){me(hr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=d.useContext(it);ht(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=d.useContext(Ct),{pathname:i}=gt(),l=Kt(),c=Lo(e,ml(s),i,r==="path"),u=JSON.stringify(c);return d.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function yg(e){return ag(e.context)}function Ne(e){me(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function xg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:s=!1,unstable_useTransitions:i}){me(!hr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=d.useMemo(()=>({basename:l,navigator:a,static:s,unstable_useTransitions:i,future:{}}),[l,a,s,i]);typeof n=="string"&&(n=pr(n));let{pathname:u="/",search:p="",hash:m="",state:g=null,key:w="default",unstable_mask:x}=n,y=d.useMemo(()=>{let j=Ht(u,l);return j==null?null:{location:{pathname:j,search:p,hash:m,state:g,key:w,unstable_mask:x},navigationType:r}},[l,u,p,m,g,w,r,x]);return ht(y!=null,`<Router basename="${l}"> is not able to match the URL "${u}${p}${m}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:d.createElement(it.Provider,{value:c},d.createElement(ca.Provider,{children:t,value:y}))}function wg({children:e,location:t}){return og(fi(e),t)}function fi(e,t=[]){let n=[];return d.Children.forEach(e,(r,a)=>{if(!d.isValidElement(r))return;let s=[...t,a];if(r.type===d.Fragment){n.push.apply(n,fi(r.props.children,s));return}me(r.type===Ne,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),me(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=fi(r.props.children,s)),n.push(i)}),n}var Wa="get",Ha="application/x-www-form-urlencoded";function Fo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Sg(e){return Fo(e)&&e.tagName.toLowerCase()==="button"}function jg(e){return Fo(e)&&e.tagName.toLowerCase()==="form"}function kg(e){return Fo(e)&&e.tagName.toLowerCase()==="input"}function Cg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function bg(e,t){return e.button===0&&(!t||t==="_self")&&!Cg(e)}function pi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Ng(e,t){let n=pi(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(s=>{n.append(a,s)})}),n}var za=null;function Eg(){if(za===null)try{new FormData(document.createElement("form"),0),za=!1}catch{za=!0}return za}var zg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ms(e){return e!=null&&!zg.has(e)?(ht(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ha}"`),null):e}function Ig(e,t){let n,r,a,s,i;if(jg(e)){let l=e.getAttribute("action");r=l?Ht(l,t):null,n=e.getAttribute("method")||Wa,a=ms(e.getAttribute("enctype"))||Ha,s=new FormData(e)}else if(Sg(e)||kg(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?Ht(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Wa,a=ms(e.getAttribute("formenctype"))||ms(l.getAttribute("enctype"))||Ha,s=new FormData(l,e),!Eg()){let{name:u,type:p,value:m}=e;if(p==="image"){let g=u?`${u}.`:"";s.append(`${g}x`,"0"),s.append(`${g}y`,"0")}else u&&s.append(u,m)}}else{if(Fo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Wa,r=null,a=Ha,i=e}return s&&a==="text/plain"&&(i=s,s=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:s,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Pg(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Ht(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function Tg(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Rg(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function _g(e,t,n){let r=await Promise.all(e.map(async a=>{let s=t.routes[a.route.id];if(s){let i=await Tg(s,n);return i.links?i.links():[]}return[]}));return Mg(r.flat(1).filter(Rg).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Fc(e,t,n,r,a,s){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var p;return n[u].pathname!==c.pathname||((p=n[u].route.path)==null?void 0:p.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return s==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):s==="data"?t.filter((c,u)=>{var m;let p=r.routes[c.route.id];if(!p||!p.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let g=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((m=n[0])==null?void 0:m.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof g=="boolean")return g}return!0}):[]}function Ag(e,t,{includeHydrateFallback:n}={}){return $g(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let s=[a.module];return a.clientActionModule&&(s=s.concat(a.clientActionModule)),a.clientLoaderModule&&(s=s.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(s=s.concat(a.hydrateFallbackModule)),a.imports&&(s=s.concat(a.imports)),s}).flat(1))}function $g(e){return[...new Set(e)]}function Lg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Mg(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let s=JSON.stringify(Lg(a));return n.has(s)||(n.add(s),r.push({key:s,link:a})),r},[])}function Nf(){let e=d.useContext(mr);return yl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Fg(){let e=d.useContext(Mo);return yl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var xl=d.createContext(void 0);xl.displayName="FrameworkContext";function Ef(){let e=d.useContext(xl);return yl(e,"You must render this element inside a <HydratedRouter> element"),e}function Og(e,t){let n=d.useContext(xl),[r,a]=d.useState(!1),[s,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:p,onTouchStart:m}=t,g=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let y=h=>{h.forEach(f=>{i(f.isIntersecting)})},j=new IntersectionObserver(y,{threshold:.5});return g.current&&j.observe(g.current),()=>{j.disconnect()}}},[e]),d.useEffect(()=>{if(r){let y=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(y)}}},[r]);let w=()=>{a(!0)},x=()=>{a(!1),i(!1)};return n?e!=="intent"?[s,g,{}]:[s,g,{onFocus:Cr(l,w),onBlur:Cr(c,x),onMouseEnter:Cr(u,w),onMouseLeave:Cr(p,x),onTouchStart:Cr(m,w)}]:[!1,g,{}]}function Cr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Bg({page:e,...t}){let{router:n}=Nf(),r=d.useMemo(()=>pf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(Ug,{page:e,matches:r,...t}):null}function Dg(e){let{manifest:t,routeModules:n}=Ef(),[r,a]=d.useState([]);return d.useEffect(()=>{let s=!1;return _g(e,t,n).then(i=>{s||a(i)}),()=>{s=!0}},[e,t,n]),r}function Ug({page:e,matches:t,...n}){let r=gt(),{future:a,manifest:s,routeModules:i}=Ef(),{basename:l}=Nf(),{loaderData:c,matches:u}=Fg(),p=d.useMemo(()=>Fc(e,t,u,s,r,"data"),[e,t,u,s,r]),m=d.useMemo(()=>Fc(e,t,u,s,r,"assets"),[e,t,u,s,r]),g=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let y=new Set,j=!1;if(t.forEach(f=>{var S;let v=s.routes[f.route.id];!v||!v.hasLoader||(!p.some(E=>E.route.id===f.route.id)&&f.route.id in c&&((S=i[f.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?j=!0:y.add(f.route.id))}),y.size===0)return[];let h=Pg(e,l,a.unstable_trailingSlashAwareDataRequests,"data");return j&&y.size>0&&h.searchParams.set("_routes",t.filter(f=>y.has(f.route.id)).map(f=>f.route.id).join(",")),[h.pathname+h.search]},[l,a.unstable_trailingSlashAwareDataRequests,c,r,s,p,t,e,i]),w=d.useMemo(()=>Ag(m,s),[m,s]),x=Dg(m);return d.createElement(d.Fragment,null,g.map(y=>d.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),w.map(y=>d.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:j})=>d.createElement("link",{key:y,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Wg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Hg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Hg&&(window.__reactRouterVersion="7.13.1")}catch{}function Vg({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=d.useRef();a.current==null&&(a.current=Sh({window:r,v5Compat:!0}));let s=a.current,[i,l]=d.useState({action:s.action,location:s.location}),c=d.useCallback(u=>{n===!1?l(u):d.startTransition(()=>l(u))},[n]);return d.useLayoutEffect(()=>s.listen(c),[s,c]),d.createElement(xg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:s,unstable_useTransitions:n})}var zf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tt=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:s,replace:i,unstable_mask:l,state:c,target:u,to:p,preventScrollReset:m,viewTransition:g,unstable_defaultShouldRevalidate:w,...x},y){let{basename:j,navigator:h,unstable_useTransitions:f}=d.useContext(it),v=typeof p=="string"&&zf.test(p),S=vf(p,j);p=S.to;let E=tg(p,{relative:a}),z=gt(),k=null;if(l){let B=Lo(l,[],z.unstable_mask?z.unstable_mask.pathname:"/",!0);j!=="/"&&(B.pathname=B.pathname==="/"?j:Rt([j,B.pathname])),k=h.createHref(B)}let[N,b,I]=Og(r,x),H=Yg(p,{replace:i,unstable_mask:l,state:c,target:u,preventScrollReset:m,relative:a,viewTransition:g,unstable_defaultShouldRevalidate:w,unstable_useTransitions:f});function U(B){t&&t(B),B.defaultPrevented||H(B)}let O=!(S.isExternal||s),R=d.createElement("a",{...x,...I,href:(O?k:void 0)||S.absoluteURL||E,onClick:O?U:t,ref:Wg(y,b),target:u,"data-discover":!v&&n==="render"?"true":void 0});return N&&!v?d.createElement(d.Fragment,null,R,d.createElement(Bg,{page:E})):R});tt.displayName="Link";var wl=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:s,to:i,viewTransition:l,children:c,...u},p){let m=ua(i,{relative:u.relative}),g=gt(),w=d.useContext(Mo),{navigator:x,basename:y}=d.useContext(it),j=w!=null&&Zg(m)&&l===!0,h=x.encodeLocation?x.encodeLocation(m).pathname:m.pathname,f=g.pathname,v=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(f=f.toLowerCase(),v=v?v.toLowerCase():null,h=h.toLowerCase()),v&&y&&(v=Ht(v,y)||v);const S=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let E=f===h||!a&&f.startsWith(h)&&f.charAt(S)==="/",z=v!=null&&(v===h||!a&&v.startsWith(h)&&v.charAt(h.length)==="/"),k={isActive:E,isPending:z,isTransitioning:j},N=E?t:void 0,b;typeof r=="function"?b=r(k):b=[r,E?"active":null,z?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let I=typeof s=="function"?s(k):s;return d.createElement(tt,{...u,"aria-current":N,className:b,ref:p,style:I,to:i,viewTransition:l},typeof c=="function"?c(k):c)});wl.displayName="NavLink";var Kg=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:s,method:i=Wa,action:l,onSubmit:c,relative:u,preventScrollReset:p,viewTransition:m,unstable_defaultShouldRevalidate:g,...w},x)=>{let{unstable_useTransitions:y}=d.useContext(it),j=Xg(),h=qg(l,{relative:u}),f=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&zf.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let z=E.nativeEvent.submitter,k=(z==null?void 0:z.getAttribute("formmethod"))||i,N=()=>j(z||E.currentTarget,{fetcherKey:t,method:k,navigate:n,replace:a,state:s,relative:u,preventScrollReset:p,viewTransition:m,unstable_defaultShouldRevalidate:g});y&&n!==!1?d.startTransition(()=>N()):N()};return d.createElement("form",{ref:x,method:f,action:h,onSubmit:r?c:S,...w,"data-discover":!v&&e==="render"?"true":void 0})});Kg.displayName="Form";function Gg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function If(e){let t=d.useContext(mr);return me(t,Gg(e)),t}function Yg(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let p=Kt(),m=gt(),g=ua(e,{relative:i});return d.useCallback(w=>{if(bg(w,t)){w.preventDefault();let x=n!==void 0?n:ra(m)===ra(g),y=()=>p(e,{replace:x,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});u?d.startTransition(()=>y()):y()}},[m,p,g,n,r,a,t,e,s,i,l,c,u])}function Pf(e){ht(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=d.useRef(pi(e)),n=d.useRef(!1),r=gt(),a=d.useMemo(()=>Ng(r.search,n.current?null:t.current),[r.search]),s=Kt(),i=d.useCallback((l,c)=>{const u=pi(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,s("?"+u,c)},[s,a]);return[a,i]}var Qg=0,Jg=()=>`__${String(++Qg)}__`;function Xg(){let{router:e}=If("useSubmit"),{basename:t}=d.useContext(it),n=mg(),r=e.fetch,a=e.navigate;return d.useCallback(async(s,i={})=>{let{action:l,method:c,encType:u,formData:p,body:m}=Ig(s,t);if(i.navigate===!1){let g=i.fetcherKey||Jg();await r(g,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:m,formMethod:i.method||c,formEncType:i.encType||u,flushSync:i.flushSync})}else await a(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:m,formMethod:i.method||c,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,a,t,n])}function qg(e,{relative:t}={}){let{basename:n}=d.useContext(it),r=d.useContext(Ct);me(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),s={...ua(e||".",{relative:t})},i=gt();if(e==null){s.search=i.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(p=>p==="")){l.delete("index"),c.filter(m=>m).forEach(m=>l.append("index",m));let p=l.toString();s.search=p?`?${p}`:""}}return(!e||e===".")&&a.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Rt([n,s.pathname])),ra(s)}function Zg(e,{relative:t}={}){let n=d.useContext(xf);me(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=If("useViewTransitionState"),a=ua(e,{relative:t});if(!n.isTransitioning)return!1;let s=Ht(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Ht(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vo(a.pathname,i)!=null||vo(a.pathname,s)!=null}class Tf extends Error{constructor(n){super("different_account");Oo(this,"summary");this.name="DifferentAccountError",this.summary=n}}class ev{constructor(){Oo(this,"apiKey",null)}setApiKey(t){this.apiKey=t}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(t,n){return globalThis.fetch(t,{...n,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n==null?void 0:n.headers}})}async login(t,n={}){const r=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":t,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:n.confirmWipe===!0})});if(r.status===409){const s=await r.json().catch(()=>({}));if(s!=null&&s.wouldWipe)throw new Tf(s.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const s=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(s.error||`Login failed: ${r.status}`)}return(await r.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const t=await this.fetch("/api/groups");if(!t.ok)throw new Error(`Failed to fetch groups: ${t.status}`);const n=await t.json();return n.groups??n}async listProfiles(){const t=await this.fetch("/api/profiles");if(!t.ok)throw new Error(`Failed to fetch profiles: ${t.status}`);return(await t.json()).profiles}async getProfile(t){const n=await this.fetch(`/api/profiles/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch profile: ${n.status}`);return n.json()}async attest(t){const n=await this.fetch("/api/as/attest",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Attest failed: ${n.status}`)}return n.json()}async getPending(t){const n=await this.fetch(`/api/attestations/pending?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch pending: ${n.status}`);const r=await n.json();return r.pending??r}async getMyAttestations(t){const n=t?`?status=${encodeURIComponent(t)}`:"",r=await this.fetch(`/api/attestations/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).attestations??[]).map(s=>{var i,l;return{authorization_id:s.authorization_id,profile_id:s.profileId,path:s.path,title:s.title??null,sp_status:s.status??null,frame:s.bounds??s.frame??{},required_domains:s.requiredDomains??[],attested_domains:s.attestedDomains??[],missing_domains:(s.requiredDomains??[]).filter(c=>!(s.attestedDomains??[]).includes(c)),deferred_commitment_domains:s.deferredCommitmentDomains??[],approvers_frozen:s.approversFrozen??[],above_cap:s.aboveCap??!1,created_at:s.createdAt?new Date(s.createdAt*1e3).toISOString():"",earliest_expiry:(i=s.attestations)!=null&&i.length?new Date(Math.min(...s.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=s.attestations)!=null&&l.length?Math.max(0,Math.min(...s.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getMyReceipts(t){const n=new URLSearchParams;t!=null&&t.date&&n.set("date",t.date),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async getCredential(t){const n=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to check credential: ${n.status}`);return n.json()}async setCredential(t,n){const r=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save credential: ${r.status}`)}async testCredential(t){const n=await this.fetch(`/vault/test/${encodeURIComponent(t)}`,{method:"POST"});if(!n.ok)throw new Error(`Test failed: ${n.status}`);return n.json()}async aiAssist(t){const n=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error,disclaimer:"AI surfaces reality. You supply intent."}}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error}}async aiTest(t){const n=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`AI test failed: ${n.status}`);return n.json()}async getMcpHealth(){const t=await this.fetch("/mcp/health");if(!t.ok)throw new Error(`MCP server unreachable: ${t.status}`);return t.json()}async getMcpIntegrations(){const t=await this.fetch("/mcp/integrations");if(!t.ok)throw new Error(`Failed to fetch integrations: ${t.status}`);return t.json()}async getOAuthHealth(t){try{const n=await this.fetch(`/auth/oauth/${encodeURIComponent(t)}/health`);return n.ok?await n.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const t=await this.fetch("/mcp/integrations/manifests");if(!t.ok)throw new Error(`Failed to fetch manifests: ${t.status}`);return t.json()}async discoverScopeField(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/discover/${encodeURIComponent(n)}`);if(!r.ok){const a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(s.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?(await r.json()).approvers??[]:[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getProposals(t){const n=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals??[]}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed"}));throw new Error(s.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const s=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(u=>!(a.attestedDomains??a.attested_domains??[]).includes(u)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(u=>u.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(u=>u.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:s}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const s=await a.json();return{receipts:s.receipts??[],nextBefore:s.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),s=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!s.ok)throw new Error(`Failed to fetch team receipts: ${s.status}`);const i=await s.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=t.domain||"owner",s=await this.getProposals(a);let i=[];if(r==="all"){const l=[],c=new Date;for(let p=0;p<n;p++){const m=new Date(c);m.setUTCDate(c.getUTCDate()-p),l.push(m.toISOString().slice(0,10))}i=(await Promise.all(l.map(p=>this.getMyReceipts({date:p,profile:t.profile})))).flat()}return{proposals:s,receipts:i}}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const L=new ev,Rf=d.createContext(null);function tv({children:e}){const[t,n]=d.useState(null),[r,a]=d.useState("personal"),[s,i]=d.useState(null),[l,c]=d.useState(""),[u,p]=d.useState(null),[m,g]=d.useState(null),[w,x]=d.useState(!1),[y,j]=d.useState(""),h=d.useRef(!1),f=d.useRef(null),v=d.useCallback(async()=>{if(h.current)try{const N=await L.getMyTeam();if(N){const{group:b,membership:I}=N;p(b),g(I),a("team"),i(b);const H=f.current??I.domains[0]??"owner";c(H)}else p(null),g(null),a("personal")}catch{}},[]);d.useEffect(()=>{const N=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[v]);const S=d.useCallback(async(N,b={})=>{x(!0),j("");try{L.setApiKey(N),h.current=!0;const I=await L.login(N,b);n(I),f.current=I.id;const H=await L.getGroups(),U=H.find(O=>O.isPersonal)??H[0]??null;i(U),c("owner"),await v()}catch(I){throw L.clearApiKey(),h.current=!1,j(I instanceof Error?I.message:"Login failed"),I}finally{x(!1)}},[v]),E=d.useCallback(async()=>{await L.logout(),L.clearApiKey(),h.current=!1,f.current=null,n(null),i(null),c(""),p(null),g(null),a("personal"),j("")},[]),z=d.useCallback(()=>j(""),[]),k=d.useCallback((N,b)=>{i(N),c(b)},[]);return o.jsx(Rf.Provider,{value:{user:t,mode:r,group:s,domain:l,groupId:(s==null?void 0:s.id)??null,activeTeam:u,activeMembership:m,isLoading:w,error:y,login:S,logout:E,clearError:z,activeGroup:s,activeDomain:l,groups:s?[s]:[],setActiveContext:k,refreshGroups:v},children:e})}function Pe(){const e=d.useContext(Rf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const _f=d.createContext(null);function nv({children:e}){const{user:t}=Pe(),n=d.useRef(null),[r,a]=d.useState(!1),s=d.useRef(new Map),i=d.useCallback((l,c)=>{const u=s.current;return u.has(l)||u.set(l,new Set),u.get(l).add(c),()=>{var p;(p=u.get(l))==null||p.delete(c)}},[]);return d.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const l=L.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const u=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected"];for(const p of u)c.addEventListener(p,m=>{let g;try{g=JSON.parse(m.data)}catch{g=null}const w=s.current.get(p);if(w)for(const x of w)try{x(g)}catch(y){console.error(`[EventSource] handler for "${p}" threw:`,y)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),o.jsx(_f.Provider,{value:{connected:r,addListener:i},children:e})}function he(e,t){const n=d.useContext(_f);if(!n)return;const{addListener:r}=n;d.useEffect(()=>r(e,t),[e,t,r])}const Or="suveren-theme",Oc="hap-theme";function Ia(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Oc);t!==null&&localStorage.getItem(Or)===null&&localStorage.setItem(Or,t),t!==null&&localStorage.removeItem(Oc)})();function Af(){const[e,t]=d.useState(()=>{const s=localStorage.getItem(Or);return s==="light"||s==="dark"?s:"system"}),[n,r]=d.useState(()=>Ia(e));d.useEffect(()=>{const s=document.documentElement,i=Ia(e);s.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Or):localStorage.setItem(Or,e),r(Ia(e))},[e]),d.useEffect(()=>{if(e!=="system")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Ia("system"));return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e]);const a=d.useCallback(()=>{t(s=>s==="system"?"light":s==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const rv=5*60*1e3,av=2e3;function $f(){const[e,t]=d.useState(!1),[n,r]=d.useState("docker"),[a,s]=d.useState(""),[i,l]=d.useState(null),[c,u]=d.useState(!1),[p,m]=d.useState(!1),[g,w]=d.useState(!1),x=d.useRef(null);return d.useEffect(()=>{let y=!1;const j=(v=!1)=>{fetch(v?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{y||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(s(S.version),x.current===null?x.current=S.version:S.version!==x.current&&S.version!=="dev"&&u(!0)))}).catch(()=>{})};j(!0);const h=setInterval(()=>j(!1),g?av:rv),f=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",f),window.addEventListener("focus",f),()=>{y=!0,clearInterval(h),document.removeEventListener("visibilitychange",f),window.removeEventListener("focus",f)}},[g]),{updateAvailable:e&&!p,installMethod:n,version:a,latestVersion:i,serverRestarted:c,startFastPolling:()=>w(!0),dismiss:()=>m(!0)}}function ov(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Bc={system:"◑",light:"☀",dark:"☾"};function sv(){const{mode:e,group:t,domain:n}=Pe();return e==="personal"?o.jsx("span",{children:"personal"}):t?o.jsxs("span",{children:[t.name," / ",n]}):o.jsx("span",{children:n})}function Sl({onMenuToggle:e}){const{user:t,logout:n}=Pe(),{theme:r,toggle:a}=Af(),{version:s}=$f(),i=ov(s);return o.jsx("nav",{className:"top-nav",children:o.jsxs("div",{className:"top-nav-inner",children:[o.jsxs("div",{className:"logo-group",children:[o.jsx("span",{className:"logo",children:"Suveren"}),o.jsx("span",{className:"version-badge",children:"Local Gateway"})]}),o.jsx("div",{className:"nav-spacer"}),o.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"user-chip",children:[o.jsx("strong",{children:t.name}),o.jsx("span",{className:"dot"}),o.jsx(sv,{})]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Bc[r]}),o.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):o.jsxs(o.Fragment,{children:[i&&o.jsxs("span",{title:"Running gateway version",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:["v",i]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Bc[r]})]})}),t&&e&&o.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function zt(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Lf(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[zt(r,t)].push(r);return n}function Ft(e,t,n){const r=d.useRef(e);r.current=e,d.useEffect(()=>{let a=null;const s=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{s()&&r.current()},l=()=>{a===null&&(a=setInterval(i,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},u=()=>{s()?(r.current(),l()):c()};return s()&&(r.current(),l()),document.addEventListener("visibilitychange",u),()=>{c(),document.removeEventListener("visibilitychange",u)}},[t,n])}const Mf=d.createContext(null),iv=3e4;function lv({children:e}){const[t,n]=d.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0}),r=d.useRef(null),a=d.useCallback(async()=>{let c=!1;const[u,p]=await Promise.all([L.getIntegrationManifests().catch(()=>(c=!0,{manifests:[]})),L.getMcpHealth().catch(()=>null)]);n(m=>({manifests:u.manifests,integrations:(p==null?void 0:p.integrations)??m.integrations,activeSessions:(p==null?void 0:p.activeSessions)??m.activeSessions,mcpServerUp:!!p,manifestsError:c,fetchCount:m.fetchCount+1}))},[]);he("integration-changed",a),Ft(a,3e5);const s=d.useMemo(()=>{const c=new Map(t.integrations.map(g=>[g.id,g])),u=Date.now(),p=t.fetchCount>0&&t.manifests.some(g=>{const w=c.get(g.id);return w&&!w.running});p&&r.current===null?r.current=u:p||(r.current=null);const m=r.current!==null&&u-r.current<iv;return t.manifests.map(g=>{const w=c.get(g.id);let x;return t.fetchCount===0?x="loading":w!=null&&w.running?x="running":w!=null&&w.error?x="error":w&&m?x="starting":x="not-running",{id:g.id,manifest:g,integration:w,state:x}})},[t]),i=d.useMemo(()=>s.filter(c=>c.state==="not-running"||c.state==="error").length,[s]),l={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:s,attentionCount:i,activeSessions:t.activeSessions,refresh:a};return o.jsx(Mf.Provider,{value:l,children:e})}function jl(){const e=d.useContext(Mf);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const cv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Authorizations",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function uv(){const{activeDomain:e}=Pe(),[t,n]=d.useState({}),r=d.useCallback(async()=>{try{const[a,s,i,l,c]=await Promise.all([L.getCredential("ai-config").catch(()=>null),L.getMyAttestations().catch(()=>null),L.getProposals(e||"owner").catch(()=>null),L.getProposalsForApprover().catch(()=>null),L.getAgentContext().catch(()=>"")]),u={};if(a&&!a.configured&&(u.assistant=1),s){const w=Lf(s).expired.length;w>0&&(u.authorizations=w)}const p=(i==null?void 0:i.length)??0,m=(l==null?void 0:l.length)??0,g=p+m;g>0&&(u.proposals=g),(!c||!c.trim())&&(u.brief=1),n(u)}catch{}},[e]);return he("attestation-changed",r),he("proposal-added",r),he("proposal-resolved",r),he("proposal-approved",r),he("proposal-rejected",r),he("team-membership-changed",r),Ft(r,3e5,e),t}const dv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},fv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function pv(){const{mode:e,group:t,domain:n,activeTeam:r}=Pe(),a=uv(),{attentionCount:s}=jl(),i={...a};s>0&&(i.integrations=s);const l=cv.filter(g=>!g.teamOnly||e==="team"),c=d.useRef(null),[u,p]=d.useState(null),m=gt();return d.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?p(`You are now acting in team context — ${r.name}`):e==="personal"&&p("You have left the team — back to personal context"),c.current=e)},[e,r]),d.useEffect(()=>{p(null)},[m.pathname]),o.jsxs("div",{className:"sidebar",children:[o.jsx("ul",{className:"sidebar-nav",children:l.map(g=>{const w=g.statusKey?i[g.statusKey]:0;return o.jsx("li",{children:o.jsxs(wl,{to:g.to,end:g.to==="/",className:({isActive:x})=>`sidebar-item${x?" active":""}`,children:[o.jsx("span",{className:"icon",children:g.icon}),g.label,w?o.jsx("span",{style:dv,children:w}):null]})},g.to)})}),o.jsxs("div",{className:"sidebar-context",children:[o.jsx("div",{className:"ctx-label",children:"Active context"}),o.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),u&&o.jsx("div",{style:fv,role:"status","aria-live":"polite",children:u})]})}const hs="suveren:updatedTo";function mv(e){return e==="npm"?"suveren-gateway stop; npm install -g @suveren/gateway@latest && suveren-gateway start --detach":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}function hv(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const n of e)if(!n.closest(".update-overlay"))return!0;const t=document.activeElement;if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){const n=t.value;if(n&&n.trim())return!0}return!1}function Ff(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:s,dismiss:i}=$f(),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[m,g]=d.useState(()=>{try{const v=sessionStorage.getItem(hs);if(v)return sessionStorage.removeItem(hs),v}catch{}return null}),w=mv(t),x=d.useRef(null),y=v=>{try{sessionStorage.setItem(hs,v||r||"✓")}catch{}window.location.reload()};d.useEffect(()=>{if(!m)return;const v=setTimeout(()=>g(null),6e3);return()=>clearTimeout(v)},[m]),d.useEffect(()=>{if(!l||!a)return;const v=()=>hv()?!1:(y(n),!0);if(v())return;const S=setInterval(v,1500);return()=>clearInterval(S)},[l,a,n]),d.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const j=e&&!l&&!m||!!m&&!l;d.useEffect(()=>{if(!j){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const v=()=>{var z;const E=((z=x.current)==null?void 0:z.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${E}px`)};v();const S=new ResizeObserver(v);return x.current&&S.observe(x.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const h=()=>{c(!0),s()},f=async()=>{try{await navigator.clipboard.writeText(w),p(!0),setTimeout(()=>p(!1),1800)}catch{}};return o.jsxs(o.Fragment,{children:[m&&!l&&o.jsx("div",{ref:x,className:"update-banner is-live",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",m&&m!=="✓"?` — ${m} is live`:" — now live","."]}),o.jsx("button",{className:"update-banner-x",onClick:()=>g(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!m&&o.jsx("div",{ref:x,className:"update-banner",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsx("span",{className:"update-banner-text",children:"Update available."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:h,children:"Update"}),o.jsx("button",{className:"update-banner-x",onClick:i,"aria-label":"Dismiss",children:"×"})]})]})}),l&&o.jsx("div",{className:"update-overlay",children:o.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[o.jsx("div",{className:"update-spinner"}),o.jsxs("h2",{children:["Finishing the update","…"]}),o.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",o.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),o.jsxs("div",{className:"update-cmd-row",children:[o.jsx("code",{className:"update-cmd",children:w}),o.jsx("button",{className:"btn btn-sm btn-primary",onClick:f,children:u?"Copied":"Copy"})]}),o.jsxs("div",{className:"update-status",children:[o.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),o.jsxs("div",{className:"update-overlay-actions",children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>y(n),children:"Reload now"}),o.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const gv={system:"◑",light:"☀",dark:"☾"},vv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function yv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:s}=Pe(),{theme:i,toggle:l}=Af(),c=gt();return d.useEffect(()=>{t()},[c.pathname]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),o.jsxs("div",{className:"mobile-menu-panel",children:[n&&o.jsxs("div",{className:"mobile-menu-header",children:[o.jsx("strong",{children:n.name}),o.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),o.jsx("nav",{className:"mobile-menu-nav",children:vv.map(u=>o.jsxs(wl,{to:u.to,end:u.to==="/",className:({isActive:p})=>`mobile-menu-item${p?" active":""}`,onClick:t,children:[o.jsx("span",{className:"icon",children:u.icon}),u.label]},u.to))}),o.jsxs("div",{className:"mobile-menu-footer",children:[o.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[o.jsx("span",{className:"icon",children:gv[i]}),"Theme: ",i]}),o.jsx("button",{className:"mobile-menu-action",onClick:()=>{s(),t()},children:"Logout"})]})]})]}):null}function xv(){const[e,t]=d.useState(!1);return o.jsxs(lv,{children:[o.jsx(Sl,{onMenuToggle:()=>t(!e)}),o.jsx(Ff,{}),o.jsx(pv,{}),o.jsx(yv,{open:e,onClose:()=>t(!1)}),o.jsx("div",{className:"main-content",children:o.jsx("div",{className:"page-inner",children:o.jsx(yg,{})})})]})}function wv(){const[e,t]=d.useState(""),{login:n,isLoading:r,error:a,clearError:s}=Pe(),[i,l]=d.useState(null),c=async()=>{if(e.trim()){s();try{await n(e)}catch(m){if(m instanceof Tf){l(m.summary);return}}}},u=async()=>{l(null),s();try{await n(e,{confirmWipe:!0})}catch{}},p=()=>{l(null)};return o.jsxs(o.Fragment,{children:[o.jsx(Sl,{}),o.jsx(Ff,{}),o.jsxs("div",{className:"login-split",children:[o.jsx("div",{className:"login-split-left",children:o.jsxs("div",{style:{maxWidth:"28rem"},children:[o.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),o.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your receipts."})]})}),o.jsx("div",{className:"login-split-right",children:o.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),o.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage authorizations."})]}),a&&o.jsx("div",{className:"error-message",children:a}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[o.jsx("label",{className:"form-label",children:"API Key"}),o.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:m=>t(m.target.value),onKeyDown:m=>m.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),o.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),o.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),o.jsx("div",{className:"login-divider",children:"New here?"}),o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",o.jsx("br",{}),"then come back to sign in."]}),o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),o.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[o.jsxs(o.Fragment,{children:["Create an account at ",o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start authorizing agents"].map((m,g)=>o.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:g<2?"0.5rem":0},children:[o.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[g+1,"."]}),m]},g))})]})]})})]}),i&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:p,children:o.jsxs("div",{className:"card",onClick:m=>m.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[o.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",o.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsxs("li",{children:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&o.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",i.credentialIds.slice(0,5).join(", "),i.credentialIds.length>5?`, +${i.credentialIds.length-5} more`:"",")"]})]}),o.jsxs("li",{children:[i.serviceCount," configured integration",i.serviceCount===1?"":"s"]}),o.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),o.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Authorizations and receipts on the Service Provider are NOT affected — only this gateway's local state is wiped."}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:p,disabled:r,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:u,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function Sv(){const{setActiveContext:e}=Pe(),t=Kt(),[n,r]=d.useState(""),[a,s]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(!1),p=async()=>{if(n.trim()){u(!0),l("");try{const g=await L.joinGroup(n.trim());e(g,g.myDomains[0]||""),t("/")}catch(g){l(g instanceof Error?g.message:"Failed to join group")}finally{u(!1)}}},m=async()=>{if(a.trim()){u(!0),l("");try{const g=await L.createGroup(a.trim());e(g,g.myDomains[0]||""),t("/")}catch(g){l(g instanceof Error?g.message:"Failed to create group")}finally{u(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(Sl,{}),o.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:o.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),o.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"Join an existing team or create a new one to share authority across domains."})]}),i&&o.jsx("div",{className:"error-message",children:i}),o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),o.jsxs("div",{className:"invite-input-row",children:[o.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:g=>r(g.target.value),onKeyDown:g=>g.key==="Enter"&&p(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),o.jsx("button",{className:"btn btn-primary",onClick:p,disabled:c,children:"Join"})]})]}),o.jsxs("div",{className:"card",children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:g=>s(g.target.value),onKeyDown:g=>g.key==="Enter"&&m(),style:{flex:1},disabled:c}),o.jsx("button",{className:"btn btn-secondary",onClick:m,disabled:c,children:"Create"})]})]})]})})]})}const mi="suveren-setup-ai-skipped",hi="suveren-setup-agent-done",gi="suveren-setup-dismissed",jv={"hap-setup-ai-skipped":mi,"hap-setup-agent-done":hi,"hap-setup-dismissed":gi};function kv(){for(const[e,t]of Object.entries(jv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}kv();const gs={"claude-code":{label:"Claude Code",snippet:e=>JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
51
+ Please change the parent <Route path="${g}"> to <Route path="${g==="/"?"*":`${g}/*`}">.`)}let p=gt(),h;if(t){let g=typeof t=="string"?pr(t):t;me(c==="/"||((j=g.pathname)==null?void 0:j.startsWith(c)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${g.pathname}" was given in the \`location\` prop.`),h=g}else h=p;let m=h.pathname||"/",w=m;if(c!=="/"){let g=c.replace(/^\//,"").split("/");w="/"+m.replace(/^\//,"").split("/").slice(g.length).join("/")}let x=pf(e,{pathname:w});ht(u||x!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),ht(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=ug(x&&x.map(g=>Object.assign({},g,{params:Object.assign({},i,g.params),pathname:Rt([c,r.encodeLocation?r.encodeLocation(g.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?c:Rt([c,r.encodeLocation?r.encodeLocation(g.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:g.pathnameBase])})),a,n);return t&&y?d.createElement(ca.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...h},navigationType:"POP"}},y):y}function sg(){let e=hg(),t=Vh(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},s={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=d.createElement(d.Fragment,null,d.createElement("p",null,"💿 Hey developer 👋"),d.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",d.createElement("code",{style:s},"ErrorBoundary")," or"," ",d.createElement("code",{style:s},"errorElement")," prop on your route.")),d.createElement(d.Fragment,null,d.createElement("h2",null,"Unexpected Application Error!"),d.createElement("h3",{style:{fontStyle:"italic"}},t),n?d.createElement("pre",{style:a},n):null,i)}var ig=d.createElement(sg,null),Cf=class extends d.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=eg(e.digest);n&&(e=n)}let t=e!==void 0?d.createElement(Ct.Provider,{value:this.props.routeContext},d.createElement(hl.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?d.createElement(lg,{error:e},t):t}};Cf.contextType=Yh;var ps=new WeakMap;function lg({children:e,error:t}){let{basename:n}=d.useContext(it);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Zh(t.digest);if(r){let a=ps.get(t);if(a)throw a;let s=vf(r.location,n);if(gf&&!ps.get(t))if(s.isExternal||r.reloadDocument)window.location.href=s.absoluteURL||s.to;else{const i=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(s.to,{replace:r.replace}));throw ps.set(t,i),i}return d.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return e}function cg({routeContext:e,match:t,children:n}){let r=d.useContext(mr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),d.createElement(Ct.Provider,{value:e},n)}function ug(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,s=r==null?void 0:r.errors;if(s!=null){let p=a.findIndex(h=>h.route.id&&(s==null?void 0:s[h.route.id])!==void 0);me(p>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),a=a.slice(0,Math.min(a.length,p+1))}let i=!1,l=-1;if(n&&r){i=r.renderFallback;for(let p=0;p<a.length;p++){let h=a[p];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(l=p),h.route.id){let{loaderData:m,errors:w}=r,x=h.route.loader&&!m.hasOwnProperty(h.route.id)&&(!w||w[h.route.id]===void 0);if(h.route.lazy||x){n.isStatic&&(i=!0),l>=0?a=a.slice(0,l+1):a=[a[0]];break}}}}let c=n==null?void 0:n.onError,u=r&&c?(p,h)=>{var m,w;c(p,{location:r.location,params:((w=(m=r.matches)==null?void 0:m[0])==null?void 0:w.params)??{},unstable_pattern:Kh(r.matches),errorInfo:h})}:void 0;return a.reduceRight((p,h,m)=>{let w,x=!1,y=null,j=null;r&&(w=s&&h.route.id?s[h.route.id]:void 0,y=h.route.errorElement||ig,i&&(l<0&&m===0?(bf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,j=null):l===m&&(x=!0,j=h.route.hydrateFallbackElement||null)));let g=t.concat(a.slice(0,m+1)),f=()=>{let v;return w?v=y:x?v=j:h.route.Component?v=d.createElement(h.route.Component,null):h.route.element?v=h.route.element:v=p,d.createElement(cg,{match:h,routeContext:{outlet:p,matches:g,isDataRoute:r!=null},children:v})};return r&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?d.createElement(Cf,{location:r.location,revalidation:r.revalidation,component:y,error:w,children:f(),routeContext:{outlet:null,matches:g,isDataRoute:!0},onError:u}):f()},null)}function gl(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function dg(e){let t=d.useContext(mr);return me(t,gl(e)),t}function fg(e){let t=d.useContext(Mo);return me(t,gl(e)),t}function pg(e){let t=d.useContext(Ct);return me(t,gl(e)),t}function vl(e){let t=pg(e),n=t.matches[t.matches.length-1];return me(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function mg(){return vl("useRouteId")}function hg(){var r;let e=d.useContext(hl),t=fg("useRouteError"),n=vl("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function gg(){let{router:e}=dg("useNavigate"),t=vl("useNavigate"),n=d.useRef(!1);return jf(()=>{n.current=!0}),d.useCallback(async(a,s={})=>{ht(n.current,Sf),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...s}))},[e,t])}var Mc={};function bf(e,t,n){!t&&!Mc[e]&&(Mc[e]=!0,ht(!1,n))}d.memo(vg);function vg({routes:e,future:t,state:n,isStatic:r,onError:a}){return kf(e,void 0,{state:n,isStatic:r,onError:a})}function Jt({to:e,replace:t,state:n,relative:r}){me(hr(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=d.useContext(it);ht(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:s}=d.useContext(Ct),{pathname:i}=gt(),l=Kt(),c=Lo(e,ml(s),i,r==="path"),u=JSON.stringify(c);return d.useEffect(()=>{l(JSON.parse(u),{replace:t,state:n,relative:r})},[l,u,r,t,n]),null}function yg(e){return ag(e.context)}function Ne(e){me(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function xg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:s=!1,unstable_useTransitions:i}){me(!hr(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=d.useMemo(()=>({basename:l,navigator:a,static:s,unstable_useTransitions:i,future:{}}),[l,a,s,i]);typeof n=="string"&&(n=pr(n));let{pathname:u="/",search:p="",hash:h="",state:m=null,key:w="default",unstable_mask:x}=n,y=d.useMemo(()=>{let j=Ht(u,l);return j==null?null:{location:{pathname:j,search:p,hash:h,state:m,key:w,unstable_mask:x},navigationType:r}},[l,u,p,h,m,w,r,x]);return ht(y!=null,`<Router basename="${l}"> is not able to match the URL "${u}${p}${h}" because it does not start with the basename, so the <Router> won't render anything.`),y==null?null:d.createElement(it.Provider,{value:c},d.createElement(ca.Provider,{children:t,value:y}))}function wg({children:e,location:t}){return og(fi(e),t)}function fi(e,t=[]){let n=[];return d.Children.forEach(e,(r,a)=>{if(!d.isValidElement(r))return;let s=[...t,a];if(r.type===d.Fragment){n.push.apply(n,fi(r.props.children,s));return}me(r.type===Ne,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),me(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=fi(r.props.children,s)),n.push(i)}),n}var Wa="get",Ha="application/x-www-form-urlencoded";function Fo(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Sg(e){return Fo(e)&&e.tagName.toLowerCase()==="button"}function jg(e){return Fo(e)&&e.tagName.toLowerCase()==="form"}function kg(e){return Fo(e)&&e.tagName.toLowerCase()==="input"}function Cg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function bg(e,t){return e.button===0&&(!t||t==="_self")&&!Cg(e)}function pi(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(a=>[n,a]):[[n,r]])},[]))}function Ng(e,t){let n=pi(e);return t&&t.forEach((r,a)=>{n.has(a)||t.getAll(a).forEach(s=>{n.append(a,s)})}),n}var za=null;function Eg(){if(za===null)try{new FormData(document.createElement("form"),0),za=!1}catch{za=!0}return za}var zg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ms(e){return e!=null&&!zg.has(e)?(ht(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ha}"`),null):e}function Ig(e,t){let n,r,a,s,i;if(jg(e)){let l=e.getAttribute("action");r=l?Ht(l,t):null,n=e.getAttribute("method")||Wa,a=ms(e.getAttribute("enctype"))||Ha,s=new FormData(e)}else if(Sg(e)||kg(e)&&(e.type==="submit"||e.type==="image")){let l=e.form;if(l==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let c=e.getAttribute("formaction")||l.getAttribute("action");if(r=c?Ht(c,t):null,n=e.getAttribute("formmethod")||l.getAttribute("method")||Wa,a=ms(e.getAttribute("formenctype"))||ms(l.getAttribute("enctype"))||Ha,s=new FormData(l,e),!Eg()){let{name:u,type:p,value:h}=e;if(p==="image"){let m=u?`${u}.`:"";s.append(`${m}x`,"0"),s.append(`${m}y`,"0")}else u&&s.append(u,h)}}else{if(Fo(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Wa,r=null,a=Ha,i=e}return s&&a==="text/plain"&&(i=s,s=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:s,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yl(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Pg(e,t,n,r){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:a.pathname==="/"?a.pathname=`_root.${r}`:t&&Ht(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function Tg(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Rg(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function _g(e,t,n){let r=await Promise.all(e.map(async a=>{let s=t.routes[a.route.id];if(s){let i=await Tg(s,n);return i.links?i.links():[]}return[]}));return Mg(r.flat(1).filter(Rg).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function Fc(e,t,n,r,a,s){let i=(c,u)=>n[u]?c.route.id!==n[u].route.id:!0,l=(c,u)=>{var p;return n[u].pathname!==c.pathname||((p=n[u].route.path)==null?void 0:p.endsWith("*"))&&n[u].params["*"]!==c.params["*"]};return s==="assets"?t.filter((c,u)=>i(c,u)||l(c,u)):s==="data"?t.filter((c,u)=>{var h;let p=r.routes[c.route.id];if(!p||!p.hasLoader)return!1;if(i(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let m=c.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((h=n[0])==null?void 0:h.params)||{},nextUrl:new URL(e,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function Ag(e,t,{includeHydrateFallback:n}={}){return $g(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let s=[a.module];return a.clientActionModule&&(s=s.concat(a.clientActionModule)),a.clientLoaderModule&&(s=s.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(s=s.concat(a.hydrateFallbackModule)),a.imports&&(s=s.concat(a.imports)),s}).flat(1))}function $g(e){return[...new Set(e)]}function Lg(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Mg(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let s=JSON.stringify(Lg(a));return n.has(s)||(n.add(s),r.push({key:s,link:a})),r},[])}function Nf(){let e=d.useContext(mr);return yl(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Fg(){let e=d.useContext(Mo);return yl(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var xl=d.createContext(void 0);xl.displayName="FrameworkContext";function Ef(){let e=d.useContext(xl);return yl(e,"You must render this element inside a <HydratedRouter> element"),e}function Og(e,t){let n=d.useContext(xl),[r,a]=d.useState(!1),[s,i]=d.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:p,onTouchStart:h}=t,m=d.useRef(null);d.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let y=g=>{g.forEach(f=>{i(f.isIntersecting)})},j=new IntersectionObserver(y,{threshold:.5});return m.current&&j.observe(m.current),()=>{j.disconnect()}}},[e]),d.useEffect(()=>{if(r){let y=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(y)}}},[r]);let w=()=>{a(!0)},x=()=>{a(!1),i(!1)};return n?e!=="intent"?[s,m,{}]:[s,m,{onFocus:Cr(l,w),onBlur:Cr(c,x),onMouseEnter:Cr(u,w),onMouseLeave:Cr(p,x),onTouchStart:Cr(h,w)}]:[!1,m,{}]}function Cr(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Bg({page:e,...t}){let{router:n}=Nf(),r=d.useMemo(()=>pf(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?d.createElement(Ug,{page:e,matches:r,...t}):null}function Dg(e){let{manifest:t,routeModules:n}=Ef(),[r,a]=d.useState([]);return d.useEffect(()=>{let s=!1;return _g(e,t,n).then(i=>{s||a(i)}),()=>{s=!0}},[e,t,n]),r}function Ug({page:e,matches:t,...n}){let r=gt(),{future:a,manifest:s,routeModules:i}=Ef(),{basename:l}=Nf(),{loaderData:c,matches:u}=Fg(),p=d.useMemo(()=>Fc(e,t,u,s,r,"data"),[e,t,u,s,r]),h=d.useMemo(()=>Fc(e,t,u,s,r,"assets"),[e,t,u,s,r]),m=d.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let y=new Set,j=!1;if(t.forEach(f=>{var S;let v=s.routes[f.route.id];!v||!v.hasLoader||(!p.some(E=>E.route.id===f.route.id)&&f.route.id in c&&((S=i[f.route.id])!=null&&S.shouldRevalidate)||v.hasClientLoader?j=!0:y.add(f.route.id))}),y.size===0)return[];let g=Pg(e,l,a.unstable_trailingSlashAwareDataRequests,"data");return j&&y.size>0&&g.searchParams.set("_routes",t.filter(f=>y.has(f.route.id)).map(f=>f.route.id).join(",")),[g.pathname+g.search]},[l,a.unstable_trailingSlashAwareDataRequests,c,r,s,p,t,e,i]),w=d.useMemo(()=>Ag(h,s),[h,s]),x=Dg(h);return d.createElement(d.Fragment,null,m.map(y=>d.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),w.map(y=>d.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:j})=>d.createElement("link",{key:y,nonce:n.nonce,...j,crossOrigin:j.crossOrigin??n.crossOrigin})))}function Wg(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Hg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Hg&&(window.__reactRouterVersion="7.13.1")}catch{}function Vg({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=d.useRef();a.current==null&&(a.current=Sh({window:r,v5Compat:!0}));let s=a.current,[i,l]=d.useState({action:s.action,location:s.location}),c=d.useCallback(u=>{n===!1?l(u):d.startTransition(()=>l(u))},[n]);return d.useLayoutEffect(()=>s.listen(c),[s,c]),d.createElement(xg,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:s,unstable_useTransitions:n})}var zf=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,tt=d.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:s,replace:i,unstable_mask:l,state:c,target:u,to:p,preventScrollReset:h,viewTransition:m,unstable_defaultShouldRevalidate:w,...x},y){let{basename:j,navigator:g,unstable_useTransitions:f}=d.useContext(it),v=typeof p=="string"&&zf.test(p),S=vf(p,j);p=S.to;let E=tg(p,{relative:a}),z=gt(),k=null;if(l){let F=Lo(l,[],z.unstable_mask?z.unstable_mask.pathname:"/",!0);j!=="/"&&(F.pathname=F.pathname==="/"?j:Rt([j,F.pathname])),k=g.createHref(F)}let[N,b,I]=Og(r,x),H=Yg(p,{replace:i,unstable_mask:l,state:c,target:u,preventScrollReset:h,relative:a,viewTransition:m,unstable_defaultShouldRevalidate:w,unstable_useTransitions:f});function U(F){t&&t(F),F.defaultPrevented||H(F)}let B=!(S.isExternal||s),R=d.createElement("a",{...x,...I,href:(B?k:void 0)||S.absoluteURL||E,onClick:B?U:t,ref:Wg(y,b),target:u,"data-discover":!v&&n==="render"?"true":void 0});return N&&!v?d.createElement(d.Fragment,null,R,d.createElement(Bg,{page:E})):R});tt.displayName="Link";var wl=d.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:s,to:i,viewTransition:l,children:c,...u},p){let h=ua(i,{relative:u.relative}),m=gt(),w=d.useContext(Mo),{navigator:x,basename:y}=d.useContext(it),j=w!=null&&Zg(h)&&l===!0,g=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,f=m.pathname,v=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;n||(f=f.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&y&&(v=Ht(v,y)||v);const S=g!=="/"&&g.endsWith("/")?g.length-1:g.length;let E=f===g||!a&&f.startsWith(g)&&f.charAt(S)==="/",z=v!=null&&(v===g||!a&&v.startsWith(g)&&v.charAt(g.length)==="/"),k={isActive:E,isPending:z,isTransitioning:j},N=E?t:void 0,b;typeof r=="function"?b=r(k):b=[r,E?"active":null,z?"pending":null,j?"transitioning":null].filter(Boolean).join(" ");let I=typeof s=="function"?s(k):s;return d.createElement(tt,{...u,"aria-current":N,className:b,ref:p,style:I,to:i,viewTransition:l},typeof c=="function"?c(k):c)});wl.displayName="NavLink";var Kg=d.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:s,method:i=Wa,action:l,onSubmit:c,relative:u,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:m,...w},x)=>{let{unstable_useTransitions:y}=d.useContext(it),j=Xg(),g=qg(l,{relative:u}),f=i.toLowerCase()==="get"?"get":"post",v=typeof l=="string"&&zf.test(l),S=E=>{if(c&&c(E),E.defaultPrevented)return;E.preventDefault();let z=E.nativeEvent.submitter,k=(z==null?void 0:z.getAttribute("formmethod"))||i,N=()=>j(z||E.currentTarget,{fetcherKey:t,method:k,navigate:n,replace:a,state:s,relative:u,preventScrollReset:p,viewTransition:h,unstable_defaultShouldRevalidate:m});y&&n!==!1?d.startTransition(()=>N()):N()};return d.createElement("form",{ref:x,method:f,action:g,onSubmit:r?c:S,...w,"data-discover":!v&&e==="render"?"true":void 0})});Kg.displayName="Form";function Gg(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function If(e){let t=d.useContext(mr);return me(t,Gg(e)),t}function Yg(e,{target:t,replace:n,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c,unstable_useTransitions:u}={}){let p=Kt(),h=gt(),m=ua(e,{relative:i});return d.useCallback(w=>{if(bg(w,t)){w.preventDefault();let x=n!==void 0?n:ra(h)===ra(m),y=()=>p(e,{replace:x,unstable_mask:r,state:a,preventScrollReset:s,relative:i,viewTransition:l,unstable_defaultShouldRevalidate:c});u?d.startTransition(()=>y()):y()}},[h,p,m,n,r,a,t,e,s,i,l,c,u])}function Pf(e){ht(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=d.useRef(pi(e)),n=d.useRef(!1),r=gt(),a=d.useMemo(()=>Ng(r.search,n.current?null:t.current),[r.search]),s=Kt(),i=d.useCallback((l,c)=>{const u=pi(typeof l=="function"?l(new URLSearchParams(a)):l);n.current=!0,s("?"+u,c)},[s,a]);return[a,i]}var Qg=0,Jg=()=>`__${String(++Qg)}__`;function Xg(){let{router:e}=If("useSubmit"),{basename:t}=d.useContext(it),n=mg(),r=e.fetch,a=e.navigate;return d.useCallback(async(s,i={})=>{let{action:l,method:c,encType:u,formData:p,body:h}=Ig(s,t);if(i.navigate===!1){let m=i.fetcherKey||Jg();await r(m,n,i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:h,formMethod:i.method||c,formEncType:i.encType||u,flushSync:i.flushSync})}else await a(i.action||l,{unstable_defaultShouldRevalidate:i.unstable_defaultShouldRevalidate,preventScrollReset:i.preventScrollReset,formData:p,body:h,formMethod:i.method||c,formEncType:i.encType||u,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,a,t,n])}function qg(e,{relative:t}={}){let{basename:n}=d.useContext(it),r=d.useContext(Ct);me(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),s={...ua(e||".",{relative:t})},i=gt();if(e==null){s.search=i.search;let l=new URLSearchParams(s.search),c=l.getAll("index");if(c.some(p=>p==="")){l.delete("index"),c.filter(h=>h).forEach(h=>l.append("index",h));let p=l.toString();s.search=p?`?${p}`:""}}return(!e||e===".")&&a.route.index&&(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(s.pathname=s.pathname==="/"?n:Rt([n,s.pathname])),ra(s)}function Zg(e,{relative:t}={}){let n=d.useContext(xf);me(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=If("useViewTransitionState"),a=ua(e,{relative:t});if(!n.isTransitioning)return!1;let s=Ht(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Ht(n.nextLocation.pathname,r)||n.nextLocation.pathname;return vo(a.pathname,i)!=null||vo(a.pathname,s)!=null}class Tf extends Error{constructor(n){super("different_account");Oo(this,"summary");this.name="DifferentAccountError",this.summary=n}}class ev{constructor(){Oo(this,"apiKey",null)}setApiKey(t){this.apiKey=t}clearApiKey(){this.apiKey=null}getApiKey(){return this.apiKey}async fetch(t,n){return globalThis.fetch(t,{...n,headers:{"Content-Type":"application/json",...this.apiKey?{"X-API-Key":this.apiKey}:{},...n==null?void 0:n.headers}})}async login(t,n={}){const r=await this.fetch("/auth/login",{method:"POST",headers:{"X-API-Key":t,"Content-Type":"application/json"},body:JSON.stringify({confirmWipe:n.confirmWipe===!0})});if(r.status===409){const s=await r.json().catch(()=>({}));if(s!=null&&s.wouldWipe)throw new Tf(s.summary??{credentialCount:0,serviceCount:0,credentialIds:[]})}if(!r.ok){const s=await r.json().catch(()=>({error:"Invalid API key"}));throw new Error(s.error||`Login failed: ${r.status}`)}return(await r.json()).user}async logout(){await this.fetch("/auth/logout",{method:"POST"})}async getGroups(){const t=await this.fetch("/api/groups");if(!t.ok)throw new Error(`Failed to fetch groups: ${t.status}`);const n=await t.json();return n.groups??n}async listProfiles(){const t=await this.fetch("/api/profiles");if(!t.ok)throw new Error(`Failed to fetch profiles: ${t.status}`);return(await t.json()).profiles}async getProfile(t){const n=await this.fetch(`/api/profiles/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch profile: ${n.status}`);return n.json()}async attest(t){const n=await this.fetch("/api/as/attest",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Attest failed: ${n.status}`)}return n.json()}async getPending(t){const n=await this.fetch(`/api/attestations/pending?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch pending: ${n.status}`);const r=await n.json();return r.pending??r}async getMyAttestations(t){const n=t?`?status=${encodeURIComponent(t)}`:"",r=await this.fetch(`/api/attestations/mine${n}`);if(!r.ok)throw new Error(`Failed to fetch attestations: ${r.status}`);return((await r.json()).attestations??[]).map(s=>{var i,l;return{authorization_id:s.authorization_id,profile_id:s.profileId,path:s.path,title:s.title??null,sp_status:s.status??null,frame:s.bounds??s.frame??{},required_domains:s.requiredDomains??[],attested_domains:s.attestedDomains??[],missing_domains:(s.requiredDomains??[]).filter(c=>!(s.attestedDomains??[]).includes(c)),deferred_commitment_domains:s.deferredCommitmentDomains??[],approvers_frozen:s.approversFrozen??[],above_cap:s.aboveCap??!1,created_at:s.createdAt?new Date(s.createdAt*1e3).toISOString():"",earliest_expiry:(i=s.attestations)!=null&&i.length?new Date(Math.min(...s.attestations.map(c=>c.expiresAt))*1e3).toISOString():null,remaining_seconds:(l=s.attestations)!=null&&l.length?Math.max(0,Math.min(...s.attestations.map(c=>c.expiresAt))-Math.floor(Date.now()/1e3)):null}})}async getMyReceipts(t){const n=new URLSearchParams;t!=null&&t.date&&n.set("date",t.date),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);return(await a.json()).receipts??[]}async revokeAttestation(t,n){const r=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/revoke`,{method:"POST",body:JSON.stringify({reason:n??"Revoked by user"})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to revoke"}));throw new Error(a.error||`Revoke failed: ${r.status}`)}}async getAttestations(t){const n=await this.fetch(`/api/attestations?authorization_id=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch attestations: ${n.status}`);return n.json()}async getGroupById(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch group: ${n.status}`);return n.json()}async createGroup(t){const n=await this.fetch("/api/groups",{method:"POST",body:JSON.stringify({name:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Create group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:!0}}async joinGroup(t){const n=await this.fetch("/api/groups/join",{method:"POST",body:JSON.stringify({inviteCode:t})});if(!n.ok){const s=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(s.error||`Join group failed: ${n.status}`)}const r=await n.json(),a=r.group||r;return{id:a.id,name:a.name,myDomains:a.myDomains||[],isAdmin:a.isAdmin||!1}}async inviteToGroup(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/invite`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Unknown error"}));throw new Error(r.error||`Invite failed: ${n.status}`)}return n.json()}async getMyTeam(){const t=await this.fetch("/api/groups/me");if(!t.ok)return null;const n=await t.json();return n.group?{group:n.group,membership:n.membership}:null}async listUsers(){const t=await this.fetch("/api/users");return t.ok?(await t.json()).users??[]:[]}async setPubkey(t){const n=await this.fetch("/api/users/me/pubkey",{method:"PUT",body:JSON.stringify({pubkey:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to set pubkey"}));throw new Error(r.error||`setPubkey failed: ${n.status}`)}}async getPubkey(t){const n=await this.fetch(`/api/users/${encodeURIComponent(t)}/pubkey`);return n.status===404||!n.ok?null:(await n.json()).pubkey??null}async leaveTeam(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/leave`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to leave team"}));throw new Error(r.error||`Leave failed: ${n.status}`)}}async getVaultStatus(){const t=await this.fetch("/vault/status");if(!t.ok)throw new Error(`Failed to fetch vault status: ${t.status}`);return t.json()}async getCredential(t){const n=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to check credential: ${n.status}`);return n.json()}async setCredential(t,n){const r=await this.fetch(`/vault/credentials/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)});if(!r.ok)throw new Error(`Failed to save credential: ${r.status}`)}async testCredential(t){const n=await this.fetch(`/vault/test/${encodeURIComponent(t)}`,{method:"POST"});if(!n.ok)throw new Error(`Test failed: ${n.status}`);return n.json()}async aiAssist(t){const n=await this.fetch("/ai/assist",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error,disclaimer:"AI surfaces reality. You supply intent."}}async aiIntentReview(t){const n=await this.fetch("/ai/intent-review",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI request failed"}))).error}}async aiTest(t){const n=await this.fetch("/ai/test",{method:"POST",body:JSON.stringify(t??{})});if(!n.ok)throw new Error(`AI test failed: ${n.status}`);return n.json()}async getMcpHealth(){const t=await this.fetch("/mcp/health");if(!t.ok)throw new Error(`MCP server unreachable: ${t.status}`);return t.json()}async getMcpIntegrations(){const t=await this.fetch("/mcp/integrations");if(!t.ok)throw new Error(`Failed to fetch integrations: ${t.status}`);return t.json()}async getOAuthHealth(t){try{const n=await this.fetch(`/auth/oauth/${encodeURIComponent(t)}/health`);return n.ok?await n.json():{status:"unverified"}}catch{return{status:"unverified"}}}async getIntegrationManifests(){const t=await this.fetch("/mcp/integrations/manifests");if(!t.ok)throw new Error(`Failed to fetch manifests: ${t.status}`);return t.json()}async discoverScopeField(t,n){const r=await this.fetch(`/integrations/${encodeURIComponent(t)}/discover/${encodeURIComponent(n)}`);if(!r.ok){const a=await r.json().catch(()=>({error:`Discovery failed: ${r.status}`}));throw new Error(a.error)}return r.json()}async activateIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}/activate`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`Failed: ${n.status}`)}return n.json()}async removeMcpIntegration(t){const n=await this.fetch(`/mcp/integrations/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`Failed to remove integration: ${n.status}`)}async getTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`);if(r.status===404||!r.ok)return null;const a=await r.json();return(a==null?void 0:a.config)??null}async setTeamProfileConfig(t,n,r){const a=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"PUT",body:JSON.stringify(r)});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed to set profile config"}));throw new Error(s.error||`setTeamProfileConfig failed: ${a.status}`)}}async encryptIntent(t,n){const r=await this.fetch("/api/encrypt-intent",{method:"POST",body:JSON.stringify({intent:t,recipients:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Encryption failed"}));throw new Error(a.error||`encryptIntent failed: ${r.status}`)}return r.json()}async getApproversPubkeys(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}/approvers/pubkeys`);return r.ok?(await r.json()).approvers??[]:[]}async deleteTeamProfileConfig(t,n){const r=await this.fetch(`/api/groups/${encodeURIComponent(t)}/profile-config/${encodeURIComponent(n)}`,{method:"DELETE"});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed to delete profile config"}));throw new Error(a.error||`deleteTeamProfileConfig failed: ${r.status}`)}}async getProposals(t){const n=await this.fetch(`/api/proposals?domain=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals??[]}async resolveProposal(t,n,r){const a=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/resolve`,{method:"POST",body:JSON.stringify({action:n,domain:r})});if(!a.ok){const s=await a.json().catch(()=>({error:"Failed"}));throw new Error(s.error||`Failed: ${a.status}`)}return a.json()}async getProposalsForApprover(){const t=await this.fetch("/api/proposals?approver=me");if(!t.ok)throw new Error(`Failed to fetch approver proposals: ${t.status}`);return(await t.json()).proposals??[]}async approveProposal(t){const n=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/approve`,{method:"POST"});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed"}));throw new Error(r.error||`approveProposal failed: ${n.status}`)}return n.json()}async rejectProposal(t,n){const r=await this.fetch(`/api/proposals/${encodeURIComponent(t)}/reject`,{method:"POST",body:JSON.stringify({reason:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`rejectProposal failed: ${r.status}`)}return r.json()}async getAttestationIntent(t){const n=await this.fetch(`/api/authorizations/${encodeURIComponent(t)}/intent`);return n.status===404||n.status===403||!n.ok?null:n.json()}async decryptIntent(t){const n=await this.fetch("/api/decrypt-intent",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const a=await n.json().catch(()=>({error:"Decryption failed"}));throw new Error(a.error||`decryptIntent failed: ${n.status}`)}return(await n.json()).intent}async storeApprovedIntent(t,n){const r=await this.fetch("/api/approved-intents",{method:"POST",body:JSON.stringify({authorityId:t,intent:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Failed"}));throw new Error(a.error||`storeApprovedIntent failed: ${r.status}`)}}async listTeamAuthorizations(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/attestations`);if(!n.ok)throw new Error(`Failed to fetch team authorizations: ${n.status}`);return((await n.json()).items??[]).map(a=>{var l,c;const s=a.owner??{userId:""};return{authorization_id:a.authorization_id??a.authorizationId,profile_id:a.profileId??a.profile_id,path:a.path??"",title:a.title??null,sp_status:a.status??a.sp_status??null,frame:a.bounds??a.frame??{},required_domains:a.requiredDomains??a.required_domains??[],attested_domains:a.attestedDomains??a.attested_domains??[],missing_domains:(a.requiredDomains??a.required_domains??[]).filter(u=>!(a.attestedDomains??a.attested_domains??[]).includes(u)),deferred_commitment_domains:a.deferredCommitmentDomains??a.deferred_commitment_domains??[],approvers_frozen:a.approversFrozen??a.approvers_frozen??[],above_cap:a.aboveCap??a.above_cap??!1,created_at:a.createdAt?new Date(a.createdAt*1e3).toISOString():a.created_at??"",earliest_expiry:(l=a.attestations)!=null&&l.length?new Date(Math.min(...a.attestations.map(u=>u.expiresAt))*1e3).toISOString():null,remaining_seconds:(c=a.attestations)!=null&&c.length?Math.max(0,Math.min(...a.attestations.map(u=>u.expiresAt))-Math.floor(Date.now()/1e3)):null,owner:s}})}async listTeamReceipts(t){const n=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts`);if(!n.ok)throw new Error(`Failed to fetch team receipts: ${n.status}`);return(await n.json()).receipts??[]}async getMyReceiptsPage(t){const n=new URLSearchParams;t!=null&&t.before&&n.set("before",t.before),t!=null&&t.profile&&n.set("profile",t.profile),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.toString(),a=await this.fetch(`/api/receipts/mine${r?"?"+r:""}`);if(!a.ok)throw new Error(`Failed to fetch receipts: ${a.status}`);const s=await a.json();return{receipts:s.receipts??[],nextBefore:s.nextBefore??null}}async listTeamReceiptsPage(t,n){const r=new URLSearchParams;n!=null&&n.before&&r.set("before",n.before),n!=null&&n.profile&&r.set("profile",n.profile),n!=null&&n.limit&&r.set("limit",String(n.limit));const a=r.toString(),s=await this.fetch(`/api/groups/${encodeURIComponent(t)}/receipts${a?"?"+a:""}`);if(!s.ok)throw new Error(`Failed to fetch team receipts: ${s.status}`);const i=await s.json();return{receipts:i.receipts??[],nextBefore:i.nextBefore??null}}async getThread(t){const n=t.sinceDays??7,r=t.status??"pending",a=t.domain||"owner",s=await this.getProposals(a);let i=[];if(r==="all"){const l=[],c=new Date;for(let p=0;p<n;p++){const h=new Date(c);h.setUTCDate(c.getUTCDate()-p),l.push(h.toISOString().slice(0,10))}i=(await Promise.all(l.map(p=>this.getMyReceipts({date:p,profile:t.profile})))).flat()}return{proposals:s,receipts:i}}async getGateContent(t){const n=await this.fetch(`/gate-content?path=${encodeURIComponent(t)}`);if(!n.ok)throw new Error(`Failed to fetch gate content: ${n.status}`);return(await n.json()).entry??null}async resyncGates(){const t=await this.fetch("/resync-gates",{method:"POST"});if(!t.ok)throw new Error(`Failed to resync gates: ${t.status}`)}async getEnrichedAuthorizations(){const t=await this.fetch("/active-authorizations");if(!t.ok)throw new Error(`Failed to fetch authorizations: ${t.status}`);return(await t.json()).authorizations??[]}async pushGateContent(t){const n=await this.fetch("/gate-content",{method:"POST",body:JSON.stringify(t)});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to push gate content"}));throw new Error(r.error||`Push gate content failed: ${n.status}`)}}async getAgentContext(){const t=await this.fetch("/agent-brief/context");if(!t.ok)throw new Error(`Failed to fetch agent context: ${t.status}`);return(await t.json()).content}async saveAgentContext(t){const n=await this.fetch("/agent-brief/context",{method:"PUT",body:JSON.stringify({content:t})});if(!n.ok){const r=await n.json().catch(()=>({error:"Failed to save agent context"}));throw new Error(r.error||`Save failed: ${n.status}`)}}async aiChat(t){const n=await this.fetch("/ai/chat",{method:"POST",body:JSON.stringify(t)});return n.ok?n.json():{success:!1,error:(await n.json().catch(()=>({error:"AI chat failed"}))).error||`Chat failed: ${n.status}`}}async getAIPrompts(){const t=await this.fetch("/ai-prompts");if(!t.ok)throw new Error(`Failed to load AI prompts: ${t.status}`);return t.json()}async setAIPrompt(t,n){const r=await this.fetch(`/ai-prompts/${t}`,{method:"PUT",body:JSON.stringify({value:n})});if(!r.ok){const a=await r.json().catch(()=>({error:"Save failed"}));throw new Error(a.error||`Save failed: ${r.status}`)}}}const $=new ev,Rf=d.createContext(null);function tv({children:e}){const[t,n]=d.useState(null),[r,a]=d.useState("personal"),[s,i]=d.useState(null),[l,c]=d.useState(""),[u,p]=d.useState(null),[h,m]=d.useState(null),[w,x]=d.useState(!1),[y,j]=d.useState(""),g=d.useRef(!1),f=d.useRef(null),v=d.useCallback(async()=>{if(g.current)try{const N=await $.getMyTeam();if(N){const{group:b,membership:I}=N;p(b),m(I),a("team"),i(b);const H=f.current??I.domains[0]??"owner";c(H)}else p(null),m(null),a("personal")}catch{}},[]);d.useEffect(()=>{const N=()=>{document.visibilityState==="visible"&&v()};return document.addEventListener("visibilitychange",N),()=>document.removeEventListener("visibilitychange",N)},[v]);const S=d.useCallback(async(N,b={})=>{x(!0),j("");try{$.setApiKey(N),g.current=!0;const I=await $.login(N,b);n(I),f.current=I.id;const H=await $.getGroups(),U=H.find(B=>B.isPersonal)??H[0]??null;i(U),c("owner"),await v()}catch(I){throw $.clearApiKey(),g.current=!1,j(I instanceof Error?I.message:"Login failed"),I}finally{x(!1)}},[v]),E=d.useCallback(async()=>{await $.logout(),$.clearApiKey(),g.current=!1,f.current=null,n(null),i(null),c(""),p(null),m(null),a("personal"),j("")},[]),z=d.useCallback(()=>j(""),[]),k=d.useCallback((N,b)=>{i(N),c(b)},[]);return o.jsx(Rf.Provider,{value:{user:t,mode:r,group:s,domain:l,groupId:(s==null?void 0:s.id)??null,activeTeam:u,activeMembership:h,isLoading:w,error:y,login:S,logout:E,clearError:z,activeGroup:s,activeDomain:l,groups:s?[s]:[],setActiveContext:k,refreshGroups:v},children:e})}function Pe(){const e=d.useContext(Rf);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const _f=d.createContext(null);function nv({children:e}){const{user:t}=Pe(),n=d.useRef(null),[r,a]=d.useState(!1),s=d.useRef(new Map),i=d.useCallback((l,c)=>{const u=s.current;return u.has(l)||u.set(l,new Set),u.get(l).add(c),()=>{var p;(p=u.get(l))==null||p.delete(c)}},[]);return d.useEffect(()=>{if(!t){n.current&&(n.current.close(),n.current=null,a(!1));return}if(n.current)return;const l=$.getApiKey();if(!l)return;const c=new EventSource(`/events?key=${encodeURIComponent(l)}`);n.current=c,c.onopen=()=>a(!0),c.onerror=()=>a(!1);const u=["integration-changed","attestation-changed","proposal-added","proposal-resolved","team-membership-changed","action-approval-needed","action-resolved","proposal-approved","proposal-rejected"];for(const p of u)c.addEventListener(p,h=>{let m;try{m=JSON.parse(h.data)}catch{m=null}const w=s.current.get(p);if(w)for(const x of w)try{x(m)}catch(y){console.error(`[EventSource] handler for "${p}" threw:`,y)}});return()=>{c.close(),n.current=null,a(!1)}},[t]),o.jsx(_f.Provider,{value:{connected:r,addListener:i},children:e})}function he(e,t){const n=d.useContext(_f);if(!n)return;const{addListener:r}=n;d.useEffect(()=>r(e,t),[e,t,r])}const Or="suveren-theme",Oc="hap-theme";function Ia(e){return e!=="system"?e:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}(function(){const t=localStorage.getItem(Oc);t!==null&&localStorage.getItem(Or)===null&&localStorage.setItem(Or,t),t!==null&&localStorage.removeItem(Oc)})();function Af(){const[e,t]=d.useState(()=>{const s=localStorage.getItem(Or);return s==="light"||s==="dark"?s:"system"}),[n,r]=d.useState(()=>Ia(e));d.useEffect(()=>{const s=document.documentElement,i=Ia(e);s.setAttribute("data-theme",i),e==="system"?localStorage.removeItem(Or):localStorage.setItem(Or,e),r(Ia(e))},[e]),d.useEffect(()=>{if(e!=="system")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),i=()=>r(Ia("system"));return s.addEventListener("change",i),()=>s.removeEventListener("change",i)},[e]);const a=d.useCallback(()=>{t(s=>s==="system"?"light":s==="light"?"dark":"system")},[]);return{theme:e,effectiveTheme:n,toggle:a}}const rv=5*60*1e3,av=2e3;function $f(){const[e,t]=d.useState(!1),[n,r]=d.useState("docker"),[a,s]=d.useState(""),[i,l]=d.useState(null),[c,u]=d.useState(!1),[p,h]=d.useState(!1),[m,w]=d.useState(!1),x=d.useRef(null);return d.useEffect(()=>{let y=!1;const j=(v=!1)=>{fetch(v?"/health?refresh=1":"/health").then(S=>S.json()).then(S=>{y||(S.installMethod&&r(S.installMethod),typeof S.latestVersion<"u"&&l(S.latestVersion),S.updateAvailable&&t(!0),S.version&&(s(S.version),x.current===null?x.current=S.version:S.version!==x.current&&S.version!=="dev"&&u(!0)))}).catch(()=>{})};j(!0);const g=setInterval(()=>j(!1),m?av:rv),f=()=>{document.visibilityState==="visible"&&j(!1)};return document.addEventListener("visibilitychange",f),window.addEventListener("focus",f),()=>{y=!0,clearInterval(g),document.removeEventListener("visibilitychange",f),window.removeEventListener("focus",f)}},[m]),{updateAvailable:e&&!p,installMethod:n,version:a,latestVersion:i,serverRestarted:c,startFastPolling:()=>w(!0),dismiss:()=>h(!0)}}function ov(e){return e?e==="dev"?"dev":/^[0-9a-f]{40}$/i.test(e)?e.slice(0,7):e:""}const Bc={system:"◑",light:"☀",dark:"☾"};function sv(){const{mode:e,group:t,domain:n}=Pe();return e==="personal"?o.jsx("span",{children:"personal"}):t?o.jsxs("span",{children:[t.name," / ",n]}):o.jsx("span",{children:n})}function Sl({onMenuToggle:e}){const{user:t,logout:n}=Pe(),{theme:r,toggle:a}=Af(),{version:s}=$f(),i=ov(s);return o.jsx("nav",{className:"top-nav",children:o.jsxs("div",{className:"top-nav-inner",children:[o.jsxs("div",{className:"logo-group",children:[o.jsx("span",{className:"logo",children:"Suveren"}),o.jsx("span",{className:"version-badge",children:"Local Gateway"})]}),o.jsx("div",{className:"nav-spacer"}),o.jsx("div",{className:"nav-actions nav-actions-desktop",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"user-chip",children:[o.jsx("strong",{children:t.name}),o.jsx("span",{className:"dot"}),o.jsx(sv,{})]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Bc[r]}),o.jsx("button",{className:"nav-logout",onClick:n,children:"Logout"})]}):o.jsxs(o.Fragment,{children:[i&&o.jsxs("span",{title:"Running gateway version",style:{fontSize:"0.8rem",color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums"},children:["v",i]}),o.jsx("button",{className:"theme-toggle",onClick:a,title:`Theme: ${r}`,children:Bc[r]})]})}),t&&e&&o.jsx("button",{className:"mobile-menu-btn",onClick:e,"aria-label":"Menu",children:"☰"})]})})}function zt(e,t){var n;if((n=t==null?void 0:t.revokedSet)!=null&&n.has(e.authorization_id))return"revoked";switch(e.sp_status){case"revoked":return"revoked";case"expired":return"expired";case"active":return"active";case"pending":return"pending"}return e.remaining_seconds===null||e.remaining_seconds<=0?"expired":e.missing_domains.length>0?"pending":"active"}function Lf(e,t){const n={active:[],pending:[],expired:[],revoked:[]};for(const r of e)n[zt(r,t)].push(r);return n}function Ft(e,t,n){const r=d.useRef(e);r.current=e,d.useEffect(()=>{let a=null;const s=()=>typeof document>"u"?!0:document.visibilityState==="visible",i=()=>{s()&&r.current()},l=()=>{a===null&&(a=setInterval(i,t))},c=()=>{a!==null&&(clearInterval(a),a=null)},u=()=>{s()?(r.current(),l()):c()};return s()&&(r.current(),l()),document.addEventListener("visibilitychange",u),()=>{c(),document.removeEventListener("visibilitychange",u)}},[t,n])}const Mf=d.createContext(null),iv=3e4;function lv({children:e}){const[t,n]=d.useState({manifests:[],integrations:[],activeSessions:0,mcpServerUp:null,manifestsError:!1,fetchCount:0,authHealth:{}}),r=d.useRef(null),a=d.useCallback(async()=>{let c=!1;const[u,p]=await Promise.all([$.getIntegrationManifests().catch(()=>(c=!0,{manifests:[]})),$.getMcpHealth().catch(()=>null)]);n(m=>({...m,manifests:u.manifests,integrations:(p==null?void 0:p.integrations)??m.integrations,activeSessions:(p==null?void 0:p.activeSessions)??m.activeSessions,mcpServerUp:!!p,manifestsError:c,fetchCount:m.fetchCount+1}));const h=u.manifests.filter(m=>m.oauth);if(h.length>0){const m=await Promise.all(h.map(async w=>[w.id,await $.getOAuthHealth(w.id)]));n(w=>({...w,authHealth:Object.fromEntries(m)}))}},[]);he("integration-changed",a),Ft(a,3e5);const s=d.useMemo(()=>{const c=new Map(t.integrations.map(m=>[m.id,m])),u=Date.now(),p=t.fetchCount>0&&t.manifests.some(m=>{const w=c.get(m.id);return w&&!w.running});p&&r.current===null?r.current=u:p||(r.current=null);const h=r.current!==null&&u-r.current<iv;return t.manifests.map(m=>{const w=c.get(m.id);let x;t.fetchCount===0?x="loading":w!=null&&w.running?x="running":w!=null&&w.error?x="error":w&&h?x="starting":x="not-running";const y=t.authHealth[m.id];return{id:m.id,manifest:m,integration:w,state:x,authStatus:y==null?void 0:y.status,authAccount:y==null?void 0:y.account,authError:y==null?void 0:y.error}})},[t]),i=d.useMemo(()=>s.filter(c=>c.state==="not-running"||c.state==="error"||c.authStatus==="failed").length,[s]),l={loading:t.fetchCount===0,mcpServerUp:t.mcpServerUp,manifestsError:t.manifestsError,entries:s,attentionCount:i,activeSessions:t.activeSessions,refresh:a};return o.jsx(Mf.Provider,{value:l,children:e})}function jl(){const e=d.useContext(Mf);if(!e)throw new Error("useIntegrationStatus must be used inside IntegrationStatusProvider");return e}const cv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals",statusKey:"proposals"},{to:"/authorizations",icon:"☰",label:"Authorizations",statusKey:"authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief",statusKey:"brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team",teamOnly:!0},{to:"/integrations",icon:"⧗",label:"Integrations",statusKey:"integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant",statusKey:"assistant"}];function uv(){const{activeDomain:e}=Pe(),[t,n]=d.useState({}),r=d.useCallback(async()=>{try{const[a,s,i,l,c]=await Promise.all([$.getCredential("ai-config").catch(()=>null),$.getMyAttestations().catch(()=>null),$.getProposals(e||"owner").catch(()=>null),$.getProposalsForApprover().catch(()=>null),$.getAgentContext().catch(()=>"")]),u={};if(a&&!a.configured&&(u.assistant=1),s){const w=Lf(s).expired.length;w>0&&(u.authorizations=w)}const p=(i==null?void 0:i.length)??0,h=(l==null?void 0:l.length)??0,m=p+h;m>0&&(u.proposals=m),(!c||!c.trim())&&(u.brief=1),n(u)}catch{}},[e]);return he("attestation-changed",r),he("proposal-added",r),he("proposal-resolved",r),he("proposal-approved",r),he("proposal-rejected",r),he("team-membership-changed",r),Ft(r,3e5,e),t}const dv={marginLeft:"auto",minWidth:"1.25rem",height:"1.25rem",padding:"0 0.375rem",borderRadius:"0.625rem",background:"var(--warning)",color:"var(--bg-elevated)",fontSize:"0.7rem",fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},fv={position:"fixed",bottom:"1.5rem",left:"50%",transform:"translateX(-50%)",background:"var(--bg-elevated, #1e1e2e)",color:"var(--text-primary, #e2e8f0)",border:"1px solid var(--border)",borderRadius:"0.5rem",padding:"0.625rem 1rem",fontSize:"0.85rem",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",zIndex:9999,whiteSpace:"nowrap",pointerEvents:"none"};function pv(){const{mode:e,group:t,domain:n,activeTeam:r}=Pe(),a=uv(),{attentionCount:s}=jl(),i={...a};s>0&&(i.integrations=s);const l=cv.filter(m=>!m.teamOnly||e==="team"),c=d.useRef(null),[u,p]=d.useState(null),h=gt();return d.useEffect(()=>{if(c.current===null){c.current=e;return}c.current!==e&&(e==="team"&&r?p(`You are now acting in team context — ${r.name}`):e==="personal"&&p("You have left the team — back to personal context"),c.current=e)},[e,r]),d.useEffect(()=>{p(null)},[h.pathname]),o.jsxs("div",{className:"sidebar",children:[o.jsx("ul",{className:"sidebar-nav",children:l.map(m=>{const w=m.statusKey?i[m.statusKey]:0;return o.jsx("li",{children:o.jsxs(wl,{to:m.to,end:m.to==="/",className:({isActive:x})=>`sidebar-item${x?" active":""}`,children:[o.jsx("span",{className:"icon",children:m.icon}),m.label,w?o.jsx("span",{style:dv,children:w}):null]})},m.to)})}),o.jsxs("div",{className:"sidebar-context",children:[o.jsx("div",{className:"ctx-label",children:"Active context"}),o.jsx("div",{className:"ctx-value",children:e==="personal"?"personal":t?`${t.name} / ${n}`:n})]}),u&&o.jsx("div",{style:fv,role:"status","aria-live":"polite",children:u})]})}const hs="suveren:updatedTo";function mv(e){return e==="npm"?"suveren-gateway stop; npm install -g @suveren/gateway@latest && suveren-gateway start --detach":e==="dev"?"git pull && pnpm install":"docker rm -f suveren-gateway 2>/dev/null; docker ps -q --filter publish=7400 --filter publish=7430 | xargs -r docker rm -f; docker pull ghcr.io/suverenai/suveren-gateway:latest && docker run -d --name suveren-gateway -p 7400:3000 -p 7430:3030 -v $HOME/.suveren:/app/data ghcr.io/suverenai/suveren-gateway"}function hv(){const e=document.querySelectorAll('[role="dialog"], .modal-overlay, .modal');for(const n of e)if(!n.closest(".update-overlay"))return!0;const t=document.activeElement;if(t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)){const n=t.value;if(n&&n.trim())return!0}return!1}function Ff(){const{updateAvailable:e,installMethod:t,version:n,latestVersion:r,serverRestarted:a,startFastPolling:s,dismiss:i}=$f(),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[h,m]=d.useState(()=>{try{const v=sessionStorage.getItem(hs);if(v)return sessionStorage.removeItem(hs),v}catch{}return null}),w=mv(t),x=d.useRef(null),y=v=>{try{sessionStorage.setItem(hs,v||r||"✓")}catch{}window.location.reload()};d.useEffect(()=>{if(!h)return;const v=setTimeout(()=>m(null),6e3);return()=>clearTimeout(v)},[h]),d.useEffect(()=>{if(!l||!a)return;const v=()=>hv()?!1:(y(n),!0);if(v())return;const S=setInterval(v,1500);return()=>clearInterval(S)},[l,a,n]),d.useEffect(()=>(document.body.classList.toggle("is-updating",l),()=>document.body.classList.remove("is-updating")),[l]);const j=e&&!l&&!h||!!h&&!l;d.useEffect(()=>{if(!j){document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner");return}document.body.classList.add("has-update-banner");const v=()=>{var z;const E=((z=x.current)==null?void 0:z.offsetHeight)??0;document.documentElement.style.setProperty("--update-banner-h",`${E}px`)};v();const S=new ResizeObserver(v);return x.current&&S.observe(x.current),()=>{S.disconnect(),document.documentElement.style.removeProperty("--update-banner-h"),document.body.classList.remove("has-update-banner")}},[j]);const g=()=>{c(!0),s()},f=async()=>{try{await navigator.clipboard.writeText(w),p(!0),setTimeout(()=>p(!1),1800)}catch{}};return o.jsxs(o.Fragment,{children:[h&&!l&&o.jsx("div",{ref:x,className:"update-banner is-live",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsxs("span",{className:"update-banner-text",children:["✓"," You","’","re on the latest version",h&&h!=="✓"?` — ${h} is live`:" — now live","."]}),o.jsx("button",{className:"update-banner-x",onClick:()=>m(null),"aria-label":"Dismiss",children:"×"})]})}),e&&!l&&!h&&o.jsx("div",{ref:x,className:"update-banner",role:"status","aria-live":"polite",children:o.jsxs("div",{className:"update-banner-row",children:[o.jsx("span",{className:"update-banner-text",children:"Update available."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:g,children:"Update"}),o.jsx("button",{className:"update-banner-x",onClick:i,"aria-label":"Dismiss",children:"×"})]})]})}),l&&o.jsx("div",{className:"update-overlay",children:o.jsxs("div",{className:"update-overlay-card",role:"dialog","aria-modal":"true","aria-label":"Finishing the update",children:[o.jsx("div",{className:"update-spinner"}),o.jsxs("h2",{children:["Finishing the update","…"]}),o.jsxs("p",{children:["Copy this command and run it in your terminal. The gateway will restart, and"," ",o.jsx("strong",{children:"this page updates automatically"})," when it comes back ","—"," no need to refresh."]}),o.jsxs("div",{className:"update-cmd-row",children:[o.jsx("code",{className:"update-cmd",children:w}),o.jsx("button",{className:"btn btn-sm btn-primary",onClick:f,children:u?"Copied":"Copy"})]}),o.jsxs("div",{className:"update-status",children:[o.jsx("span",{className:"update-pulse"})," Waiting for the gateway to restart","…"]}),o.jsxs("div",{className:"update-overlay-actions",children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>y(n),children:"Reload now"}),o.jsx("button",{className:"btn btn-secondary",onClick:()=>c(!1),children:"Cancel"})]})]})})]})}const gv={system:"◑",light:"☀",dark:"☾"},vv=[{to:"/",icon:"□",label:"Dashboard"},{to:"/proposals",icon:"▷",label:"Pending Approvals"},{to:"/authorizations",icon:"☰",label:"Authorizations"},{to:"/agent-brief",icon:"▤",label:"Agent Brief"},{to:"/audit",icon:"▣",label:"Receipts"},{to:"/groups",icon:"◉",label:"Team"},{to:"/integrations",icon:"⧗",label:"Integrations"},{to:"/settings",icon:"⚙",label:"AI Assistant"}];function yv({open:e,onClose:t}){const{user:n,activeGroup:r,activeDomain:a,logout:s}=Pe(),{theme:i,toggle:l}=Af(),c=gt();return d.useEffect(()=>{t()},[c.pathname]),e?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mobile-menu-backdrop",onClick:t}),o.jsxs("div",{className:"mobile-menu-panel",children:[n&&o.jsxs("div",{className:"mobile-menu-header",children:[o.jsx("strong",{children:n.name}),o.jsx("span",{style:{fontSize:"0.8rem",color:"var(--text-secondary)"},children:r?`${r.name} / ${a}`:a||"personal"})]}),o.jsx("nav",{className:"mobile-menu-nav",children:vv.map(u=>o.jsxs(wl,{to:u.to,end:u.to==="/",className:({isActive:p})=>`mobile-menu-item${p?" active":""}`,onClick:t,children:[o.jsx("span",{className:"icon",children:u.icon}),u.label]},u.to))}),o.jsxs("div",{className:"mobile-menu-footer",children:[o.jsxs("button",{className:"mobile-menu-action",onClick:()=>{l()},children:[o.jsx("span",{className:"icon",children:gv[i]}),"Theme: ",i]}),o.jsx("button",{className:"mobile-menu-action",onClick:()=>{s(),t()},children:"Logout"})]})]})]}):null}function xv(){const[e,t]=d.useState(!1);return o.jsxs(lv,{children:[o.jsx(Sl,{onMenuToggle:()=>t(!e)}),o.jsx(Ff,{}),o.jsx(pv,{}),o.jsx(yv,{open:e,onClose:()=>t(!1)}),o.jsx("div",{className:"main-content",children:o.jsx("div",{className:"page-inner",children:o.jsx(yg,{})})})]})}function wv(){const[e,t]=d.useState(""),{login:n,isLoading:r,error:a,clearError:s}=Pe(),[i,l]=d.useState(null),c=async()=>{if(e.trim()){s();try{await n(e)}catch(h){if(h instanceof Tf){l(h.summary);return}}}},u=async()=>{l(null),s();try{await n(e,{confirmWipe:!0})}catch{}},p=()=>{l(null)};return o.jsxs(o.Fragment,{children:[o.jsx(Sl,{}),o.jsx(Ff,{}),o.jsxs("div",{className:"login-split",children:[o.jsx("div",{className:"login-split-left",children:o.jsxs("div",{style:{maxWidth:"28rem"},children:[o.jsx("h1",{style:{fontSize:"clamp(2.25rem, 4vw, 3.25rem)",letterSpacing:"-0.03em",lineHeight:1.1,marginBottom:"1.25rem"},children:"Your agents, your intent, your rules."}),o.jsx("p",{style:{fontSize:"1.125rem",color:"var(--text-secondary)",lineHeight:1.6,marginBottom:"3rem"},children:"The gateway runs on your machine, between your agents and the tools they use. Your signature. Your bounds. Your receipts."})]})}),o.jsx("div",{className:"login-split-right",children:o.jsxs("div",{style:{width:"100%",maxWidth:"24rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{fontSize:"1.75rem",fontWeight:700,marginBottom:"0.5rem"},children:"Sign In"}),o.jsx("div",{style:{fontSize:"0.95rem",color:"var(--text-secondary)",lineHeight:1.5},children:"Enter your API key to manage authorizations."})]}),a&&o.jsx("div",{className:"error-message",children:a}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1.5rem"},children:[o.jsx("label",{className:"form-label",children:"API Key"}),o.jsx("input",{className:"form-input",type:"password",placeholder:"hap_sk_...",value:e,onChange:h=>t(h.target.value),onKeyDown:h=>h.key==="Enter"&&c(),disabled:r,style:{padding:"0.75rem"}}),o.jsx("div",{className:"form-hint",children:"From your Suveren account."})]}),o.jsx("button",{className:"btn btn-primary btn-full btn-lg",onClick:c,disabled:r,style:{marginBottom:"2rem"},children:r?"Signing in...":"Sign In"}),o.jsx("div",{className:"login-divider",children:"New here?"}),o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",marginBottom:"1rem",lineHeight:1.5},children:["Create an account on Suveren,",o.jsx("br",{}),"then come back to sign in."]}),o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",className:"btn btn-secondary btn-full",style:{textDecoration:"none"},children:"Create Account"})]}),o.jsxs("div",{style:{paddingTop:"1.75rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"0.875rem"},children:"Getting started"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.8},children:[o.jsxs(o.Fragment,{children:["Create an account at ",o.jsx("a",{href:"https://www.suveren.ai/get-started",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--accent)"},children:"Suveren"})]}),"Join or create a team to get domain authority","Sign in here with your API key to start authorizing agents"].map((h,m)=>o.jsxs("div",{style:{display:"flex",gap:"0.625rem",alignItems:"baseline",marginBottom:m<2?"0.5rem":0},children:[o.jsxs("span",{style:{color:"var(--accent)",fontWeight:700,fontSize:"0.95rem"},children:[m+1,"."]}),h]},m))})]})]})})]}),i&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wipe-warning-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:p,children:o.jsxs("div",{className:"card",onClick:h=>h.stopPropagation(),style:{maxWidth:520,width:"100%",margin:0},children:[o.jsx("h3",{id:"wipe-warning-title",className:"card-title",style:{marginBottom:"0.5rem"},children:"Sign in with a different account?"}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["This gateway already holds data for another account. Signing in with this API key will ",o.jsx("strong",{children:"permanently wipe"})," the following local data:"]}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsxs("li",{children:[i.credentialCount," stored service credential",i.credentialCount===1?"":"s",i.credentialIds.length>0&&o.jsxs("span",{style:{color:"var(--text-tertiary)",fontSize:"0.825rem"},children:[" ","(",i.credentialIds.slice(0,5).join(", "),i.credentialIds.length>5?`, +${i.credentialIds.length-5} more`:"",")"]})]}),o.jsxs("li",{children:[i.serviceCount," configured integration",i.serviceCount===1?"":"s"]}),o.jsx("li",{children:"The local E2EE keypair (a new one will be generated for this account)"}),o.jsx("li",{children:"Any unsynchronised gate content stored locally"})]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Authorizations and receipts on the Service Provider are NOT affected — only this gateway's local state is wiped."}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-tertiary)",marginBottom:"1rem"},children:"If this isn't what you wanted, cancel and sign back in with the original API key, or use a different gateway instance for this account."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:p,disabled:r,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:u,disabled:r,children:r?"Signing in...":"Wipe local data and sign in"})]})]})})]})}function Sv(){const{setActiveContext:e}=Pe(),t=Kt(),[n,r]=d.useState(""),[a,s]=d.useState(""),[i,l]=d.useState(""),[c,u]=d.useState(!1),p=async()=>{if(n.trim()){u(!0),l("");try{const m=await $.joinGroup(n.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to join group")}finally{u(!1)}}},h=async()=>{if(a.trim()){u(!0),l("");try{const m=await $.createGroup(a.trim());e(m,m.myDomains[0]||""),t("/")}catch(m){l(m instanceof Error?m.message:"Failed to create group")}finally{u(!1)}}};return o.jsxs(o.Fragment,{children:[o.jsx(Sl,{}),o.jsx("div",{className:"main-content no-sidebar",style:{marginTop:"var(--nav-height)"},children:o.jsxs("div",{style:{maxWidth:"30rem",margin:"3rem auto",padding:"0 1rem"},children:[o.jsxs("div",{style:{textAlign:"center",marginBottom:"2.5rem"},children:[o.jsx("h2",{style:{fontSize:"1.5rem",marginBottom:"0.5rem"},children:"Join Your Team"}),o.jsx("p",{style:{fontSize:"0.9rem",color:"var(--text-secondary)",lineHeight:1.6},children:"Join an existing team or create a new one to share authority across domains."})]}),i&&o.jsx("div",{className:"error-message",children:i}),o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Join an existing group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Ask your team admin for an invite code."}),o.jsxs("div",{className:"invite-input-row",children:[o.jsx("input",{className:"form-input",placeholder:"Paste invite code...",value:n,onChange:m=>r(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem"},disabled:c}),o.jsx("button",{className:"btn btn-primary",onClick:p,disabled:c,children:"Join"})]})]}),o.jsxs("div",{className:"card",children:[o.jsx("h4",{style:{fontSize:"0.95rem",marginBottom:"0.25rem"},children:"Create a new group"}),o.jsx("p",{style:{fontSize:"0.825rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Start a new team and invite members. Assign domains after creation."}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("input",{className:"form-input",placeholder:"Group name (e.g., Acme Corp)",value:a,onChange:m=>s(m.target.value),onKeyDown:m=>m.key==="Enter"&&h(),style:{flex:1},disabled:c}),o.jsx("button",{className:"btn btn-secondary",onClick:h,disabled:c,children:"Create"})]})]})]})})]})}const mi="suveren-setup-ai-skipped",hi="suveren-setup-agent-done",gi="suveren-setup-dismissed",jv={"hap-setup-ai-skipped":mi,"hap-setup-agent-done":hi,"hap-setup-dismissed":gi};function kv(){for(const[e,t]of Object.entries(jv)){const n=localStorage.getItem(e);n!==null&&localStorage.getItem(t)===null&&localStorage.setItem(t,n),n!==null&&localStorage.removeItem(e)}}kv();const gs={"claude-code":{label:"Claude Code",snippet:e=>JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)},"claude-desktop":{label:"Claude Desktop",snippet:e=>`Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
52
52
 
53
53
  ${JSON.stringify({mcpServers:{"suveren-gateway":{url:`${e}/sse`}}},null,2)}`},other:{label:"Other",snippet:e=>`Streamable HTTP: POST ${e}/mcp
54
54
  SSE transport: GET ${e}/sse
55
- Health check: GET ${e}/health`}};function Cv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[s,i]=d.useState(()=>localStorage.getItem(mi)==="true"),[l,c]=d.useState(()=>localStorage.getItem(hi)==="true"),[u,p]=d.useState(()=>localStorage.getItem(gi)==="true"),[m,g]=d.useState(null),[w,x]=d.useState("claude-code"),[y,j]=d.useState(!1),h=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":s?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Authorize your agent",to:"/agent/new",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],f=h.filter(b=>b.status==="done"||b.status==="skipped").length,v=f===h.length,S=d.useCallback(()=>{localStorage.setItem(mi,"true"),i(!0)},[]),E=d.useCallback(()=>{localStorage.setItem(hi,"true"),c(!0),g(null)},[]),z=d.useCallback(()=>{localStorage.setItem(gi,"true"),p(!0)},[]),k=d.useCallback(async b=>{try{await navigator.clipboard.writeText(b),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(u||v)return null;const N=h.findIndex(b=>b.status==="pending");return o.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[o.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),o.jsx("button",{onClick:z,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:h.map((b,I)=>{const H=I===N,U=b.status==="done"||b.status==="skipped"?"●":"○",O=b.status==="done"?"var(--success)":b.status==="skipped"?"var(--text-tertiary)":H?"var(--accent)":"var(--text-tertiary)";return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:H?"0.75rem":"0.25rem 0",borderRadius:H?"0.5rem":void 0,background:H?"var(--accent-subtle)":void 0},children:[o.jsx("span",{style:{color:O,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:U}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[b.to&&b.status==="pending"?o.jsx(tt,{to:b.to,style:{fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:b.label}):b.status==="pending"&&I===3?o.jsx("button",{onClick:()=>g(m===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)"},children:b.label}):o.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:b.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:b.label}),b.optional&&b.status==="pending"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),b.status==="skipped"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),b.detail&&b.status==="pending"&&H&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:b.detail})]}),b.optional&&b.status==="pending"&&o.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),b.to&&b.status==="pending"&&o.jsx(tt,{to:b.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),I===3&&m===3&&o.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),o.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),o.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(gs).map(([R,B])=>o.jsx("button",{onClick:()=>x(R),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:w===R?600:400,background:w===R?"var(--accent-subtle)":"transparent",color:w===R?"var(--accent)":"var(--text-secondary)",border:`1px solid ${w===R?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:B.label},R))}),o.jsx("pre",{style:{fontFamily:"monospace",fontSize:"0.78rem",lineHeight:1.6,padding:"0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",overflow:"auto",whiteSpace:"pre-wrap",margin:0,marginBottom:"0.75rem"},children:gs[w].snippet(a)}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(gs[w].snippet(a)),children:y?"Copied":"Copy"}),o.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Done"})]})]})]},I)})}),o.jsxs("div",{style:{marginTop:"1.25rem"},children:[o.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${f/h.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),o.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[f," of ",h.length," complete"]})]})]})}function bn({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return o.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function vs(){return o.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[o.jsx(bn,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[o.jsx(bn,{variant:"line",style:{width:"35%"}}),o.jsx(bn,{variant:"line-sm",style:{width:"65%"}})]})]})}const bv=30*60;function ys(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Nv(){var R;const{domain:e}=Pe(),[t,n]=d.useState([]),[r,a]=d.useState([]),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(!1),[m,g]=d.useState(!1),[w,x]=d.useState(!1),{entries:y,activeSessions:j,loading:h}=jl(),f=!h,v=d.useCallback(()=>{L.getMyAttestations().then(B=>{n(B),p(!0)}).catch(()=>p(!0)),L.getProposals(e||"owner").then(B=>{a(B),g(!0)}).catch(()=>g(!0)),L.getProposalsForApprover().then(B=>i(B)).catch(()=>i([])),L.getCredential("ai-config").then(B=>{c(B.configured),x(!0)}).catch(()=>x(!0))},[e]);he("attestation-changed",v),he("proposal-added",v),he("proposal-resolved",v),he("proposal-approved",v),he("proposal-rejected",v),Ft(v,3e5,e);const S=u&&m&&w&&f,E=Lf(t),z=E.active,k=E.expired,N=z.filter(B=>B.remaining_seconds!==null&&B.remaining_seconds<=bv),b=r.filter(B=>B.status==="pending"),I=y.filter(B=>B.state==="running"),H=y.filter(B=>B.state==="starting"),U=y.filter(B=>B.state==="not-running"||B.state==="error"),O=[];for(const B of s)O.push({label:"Approval needed",detail:`${B.tool} — above-cap action under ${ys(B.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const B of b)O.push({label:"Approval pending",detail:`${B.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const B of N){const ee=Math.ceil((B.remaining_seconds??0)/60);O.push({label:"Expiring soon",detail:`${B.title??ys(B.profile_id)} — ${ee} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const B of k)O.push({label:"Expired",detail:B.title??ys(B.profile_id),to:"/authorizations",color:"var(--danger)"});for(const B of U)O.push({label:B.state==="error"?"Integration error":"Integration stopped",detail:B.state==="error"&&((R=B.integration)!=null&&R.error)?`${B.manifest.name}: ${B.integration.error}`:`${B.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const B of H)O.push({label:"Integration starting",detail:`${B.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});return l||O.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsx("h1",{className:"page-title",children:"Dashboard"})}),S&&o.jsx(Cv,{aiConfigured:l,hasRunningIntegration:I.length>0,hasActiveAuth:z.length>0,hasAgentConnected:j>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[o.jsx(tt,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--success)":"var(--text-tertiary)"},children:z.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),o.jsx(tt,{to:"/proposals",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[m?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:b.length>0?"var(--warning)":"var(--text-tertiary)"},children:b.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),o.jsx(tt,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:k.length>0?"var(--danger)":"var(--text-tertiary)"},children:k.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),o.jsx(tt,{to:"/integrations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[f?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),O.length>0?o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:O.map((B,ee)=>o.jsx(tt,{to:B.to,style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[o.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:B.color,flexShrink:0}}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:B.label}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B.detail})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},ee))}):S?o.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:o.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[o.jsx(vs,{}),o.jsx(vs,{}),o.jsx(vs,{})]})]})}const Ev=["Scope & Limits","Intent","Authorize"];function Of({currentStep:e,onStepClick:t}){const n=Kt();return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:Ev.map((r,a)=>{const s=a+2,i=s<e,l=s===e;return o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[a>0&&o.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[o.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(s):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":a+1}),o.jsx("span",{className:"step-label-text",style:{fontSize:"0.6rem",marginTop:"0.3rem",color:l?"var(--accent)":i?"var(--text-secondary)":"var(--text-tertiary)",fontWeight:l?600:400,textAlign:"center"},children:r})]})]},s)})}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const Dc=40;function Ie(e,t){if(t)return t.slice(0,Dc);const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),s=a>=0?r.slice(0,a):r;return(s.charAt(0).toUpperCase()+s.slice(1)).slice(0,Dc)}function zv({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return o.jsxs("div",{className:"context-strip",children:[n&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"context-strip-label",children:"Team:"}),o.jsxs("span",{children:[o.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&o.jsxs("span",{children:[o.jsx("strong",{children:"Profile:"})," ",Ie(e)]}),t&&o.jsxs("span",{children:[o.jsx("strong",{children:"Bounds:"})," ",t]}),a&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function Iv({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:s}){const[i,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState(!0);d.useEffect(()=>{let x=!1;return L.discoverScopeField(e,t).then(y=>{var j;x||(l(y.options),m(!1),(j=y.options)!=null&&j.length&&(s==null||s(Object.fromEntries(y.options.map(h=>[h.value,h.label])))))}).catch(y=>{x||(u(y instanceof Error?y.message:String(y)),m(!1))}),()=>{x=!0}},[e,t]);const g=new Set(n.split(",").map(x=>x.trim()).filter(Boolean)),w=x=>{const y=new Set(g);y.has(x)?y.delete(x):y.add(x),r(Array.from(y).join(","))};return p?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!i?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",c??"no response","). Enter values manually, separated by commas."]}),o.jsx("input",{className:"form-input",type:"text",value:n,onChange:x=>r(x.target.value),disabled:a})]}):i.length===0?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:i.map(x=>{const y=x.extras??{},j=typeof y.access=="string"?y.access:void 0,h=j==="reader",f=y.primary===!0;return o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:h?"var(--text-tertiary)":"var(--text-primary)",cursor:a||h?"not-allowed":"pointer"},title:h?"Read-only — you can authorize list/read but not writes":void 0,children:[o.jsx("input",{type:"checkbox",checked:g.has(String(x.value)),onChange:()=>w(String(x.value)),disabled:a||h}),o.jsx("span",{children:x.label||x.value}),f&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),j&&o.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",j]})]},x.value)})})}function Pv(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Tv(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Rv(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function _v(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Uc(e,t){const n=e.trim();return n?t==="email"?n.includes("@")&&n.indexOf(".",n.indexOf("@"))>-1:t==="domain"?n.includes(".")&&!n.includes("@"):!0:!1}function Av(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function $v(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Lv(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Mv(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function Fv({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:s}){const i=$v(s),l=Lv(s),c=Av(s),u=Mv(t,s),p=t===""?null:Number(t),m=()=>{const w=t===""?0:Number(t),x=w%i,y=x===0?w+i:w+(i-x);n(String(y))},g=()=>{const w=t===""?0:Number(t);if(w<=0)return;const x=w%i,y=x===0?w-i:w-x;n(String(Math.max(0,y)))};return o.jsxs("div",{className:"bounded-input",children:[o.jsxs("div",{className:"bounded-input-field",children:[o.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:g,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),o.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:a??"0",onChange:w=>n(w.target.value),onFocus:w=>w.target.select(),disabled:r}),o.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:m,disabled:r,"aria-label":"Increase",children:"+"}),c&&o.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&o.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(w=>o.jsx("button",{type:"button",className:`preset-chip${p===w.value?" preset-chip-selected":""}`,onClick:()=>n(String(w.value)),children:w.label},w.value))}),u&&o.jsxs("div",{className:"bounded-input-echo",children:["≈ ",u]})]})}function Wc({htmlFor:e,label:t,description:n}){const[r,a]=d.useState(!1);return o.jsxs("div",{className:"field-label-with-tip",children:[o.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(s=>!s),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&o.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Ov({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:s}){const[i,l]=d.useState(""),[c,u]=d.useState(!1),p=d.useRef(null),m=t?t.split(",").map(h=>h.trim()).filter(Boolean):[],g=h=>{const f=h.trim();if(!f)return;if(!Uc(f,a)){u(!0);return}u(!1);const v=m.includes(f)?m:[...m,f];n(v.join(",")),l("")},w=h=>{const f=m.filter((v,S)=>S!==h);n(f.join(","))},x=h=>{h.key==="Enter"||h.key===","||h.key==="Tab"?i.trim()&&(h.preventDefault(),g(i)):h.key==="Backspace"&&!i&&m.length>0&&w(m.length-1)},y=h=>{const f=h.clipboardData.getData("text");if(f.includes(",")){h.preventDefault();const S=f.split(",").map(z=>z.trim()).filter(Boolean).filter(z=>Uc(z,a)),E=[...new Set([...m,...S])];n(E.join(",")),l(""),u(!1)}},j=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return o.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var h;return(h=p.current)==null?void 0:h.focus()},children:[m.map((h,f)=>o.jsxs("span",{className:"tag-pill",children:[h,!r&&o.jsx("button",{type:"button",className:"tag-remove",onClick:v=>{v.stopPropagation(),w(f)},"aria-label":`Remove ${h}`,children:"×"})]},h)),!r&&o.jsx("input",{ref:p,id:e,className:"tag-input-field",type:"text",value:i,onChange:h=>{l(h.target.value),u(!1)},onKeyDown:x,onPaste:y,onBlur:()=>{i.trim()&&g(i)},placeholder:m.length===0?s??j:""})]})}function Bv({id:e,options:t,value:n,onChange:r,disabled:a}){const s=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],i=l=>{const c=s.includes(l)?s.filter(u=>u!==l):[...s,l];r(c.join(","))};return o.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>o.jsxs("label",{className:`checkbox-pill${s.includes(l)?" checkbox-pill-selected":""}`,children:[o.jsx("input",{type:"checkbox",checked:s.includes(l),onChange:()=>i(l),disabled:a}),o.jsx("span",{children:l})]},l))})}function Hc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:s,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const u=Tv(e,t),p=`${a}-field-${e}`,m=o.jsx(o.Fragment,{children:_v(t)?o.jsx(Bv,{id:p,options:t.enum,value:n,onChange:g=>r(e,g),disabled:s}):(()=>{const g=t.boundType;return(g==null?void 0:g.kind)==="enum"&&Array.isArray(g.values)})()?o.jsxs("select",{id:p,className:"form-select",value:n,onChange:g=>r(e,g.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(g=>o.jsx("option",{value:g,children:g},g))]}):"enum"in t&&t.enum?o.jsxs("select",{id:p,className:"form-select",value:n,onChange:g=>r(e,g.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.enum.map(g=>o.jsx("option",{value:g,children:g},g))]}):t.type==="number"?o.jsx(Fv,{id:p,value:n,onChange:g=>r(e,g),disabled:s,unit:t.unit}):Rv(t)?o.jsx(Ov,{id:p,value:n,onChange:g=>r(e,g),disabled:s,format:t.format}):l?o.jsx(Iv,{integrationId:l,field:e,value:n,onChange:g=>r(e,g),disabled:s,onLabels:g=>c==null?void 0:c(e,g)}):o.jsx("input",{id:p,className:"form-input",type:"text",value:n,onChange:g=>r(e,g.target.value),disabled:s})});return i?o.jsxs("div",{className:"bounds-field-row",children:[o.jsx("div",{className:"bounds-field-label",children:o.jsx(Wc,{htmlFor:p,label:u,description:t.description})}),o.jsx("div",{className:"bounds-field-input",children:m})]},`${a}-${e}`):o.jsxs("div",{className:"form-group",children:[o.jsx(Wc,{htmlFor:p,label:u,description:t.description}),m]},`${a}-${e}`)}function Dv(e,t){if(!t)return"no-config";const n=t.caps,r=Array.isArray(t.approvers)&&t.approvers.length>0;if(!(n&&Object.keys(n).length>0))return r?"approvers-dormant":"no-config";let s=!1;for(const[i,l]of Object.entries(n)){const c=e[i];if(c===""||c===void 0)continue;const u=Number(c);if(!isNaN(u)&&u>l){s=!0;break}}return s?r?"above-approvers":"hard-ceiling":"within-cap"}function Uv(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const s=e[r];if(s===""||s===void 0)continue;const i=Number(s);!isNaN(i)&&i>a&&n.add(r)}return n}function Wv({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:s,initialFrame:i,profileConfig:l,approverNames:c,adminName:u}){const p=e.boundsSchema??e.frameSchema,m=e.contextSchema,g=p?Object.entries(p.fields).filter(([T])=>!(T==="profile"||T==="path")):[],w=m&&m.keyOrder.length>0?Object.entries(m.fields):[],x=a??i??{},y=s??{},j={};for(const[T]of g)j[T]=x[T]!==void 0?String(x[T]):"";const h={};for(const[T]of w)h[T]=y[T]!==void 0?String(y[T]):"";const[f,v]=d.useState(j),[S,E]=d.useState(h),[z,k]=d.useState({}),[N,b]=d.useState(null);d.useEffect(()=>{const T=Pv(e.id);L.getIntegrationManifests().then(({manifests:P})=>{const F=P.find(X=>X.profile===T&&X.contextDiscovery&&Object.keys(X.contextDiscovery).length>0);b(F??null)}).catch(()=>b(null))},[e.id]);const I=Dv(f,l),H=Uv(f,l==null?void 0:l.caps),U=(T,P)=>{v(F=>({...F,[T]:P}))},O=(T,P)=>{E(F=>({...F,[T]:P}))},R=()=>{const T={profile:e.id};for(const[F,X]of g)X.type==="number"?T[F]=f[F]===""?0:Number(f[F]):T[F]=f[F];const P={};for(const[F,X]of w)X.type==="number"?P[F]=S[F]===""?0:Number(S[F]):P[F]=S[F];return[T,P]},B=()=>{const[T,P]=R();t(T,P,z)},ee=()=>{const T=(l==null?void 0:l.caps)??{},P={...f};for(const Y of H)T[Y]!==void 0&&(P[Y]=String(T[Y]));v(P);const F={profile:e.id};for(const[Y,le]of g)if(le.type==="number"){const C=P[Y]??"";F[Y]=C===""?0:Number(C)}else F[Y]=P[Y]??"";const X={};for(const[Y,le]of w)le.type==="number"?X[Y]=S[Y]===""?0:Number(S[Y]):X[Y]=S[Y];t(F,X,z)},ie=T=>{const P=l==null?void 0:l.caps;if(!P||P[T]===void 0)return null;const F=P[T],X=H.has(T);return I==="hard-ceiling"&&X?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," — exceeds team ceiling"]}):I==="above-approvers"&&X?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," — above cap"]}):o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",F," ok"]})},A=()=>{var T;if(I==="no-config")return null;if(I==="approvers-dormant"){const P=c&&c.length>0?c.join(", "):"the configured approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",P]}),o.jsxs("div",{children:["No caps are set on this profile, so ",P," won't gate any action under this authority. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(I==="within-cap")return o.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:o.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(I==="above-approvers"){const P=c&&c.length>0?c.join(", "):"the required approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),o.jsxs("div",{children:[o.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",P,". Within-cap actions run per the mode you choose."]})]})}if(I==="hard-ceiling"){const P=Array.from(H)[0],F=P?(T=l==null?void 0:l.caps)==null?void 0:T[P]:void 0,X=u??"the team admin";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",F??"the configured limit",". Lower your bound or ask ",X," to add an approver path above the cap."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ee,children:"Save below cap"}),n&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},K=I==="hard-ceiling";return o.jsxs("div",{children:[w.length>0&&o.jsxs("div",{className:"context-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🛡"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the SP"})]})]}),w.map(([T,P])=>{var X;const F=!!((X=N==null?void 0:N.contextDiscovery)!=null&&X[T]);return o.jsx(Hc,{fieldKey:T,fieldDef:P,value:S[T],onChange:O,prefix:"context",readOnly:r,discoveryIntegrationId:F?N.id:void 0,onLabels:(Y,le)=>k(C=>({...C,[Y]:le}))},`context-${T}`)})]}),g.length>0&&o.jsxs("div",{className:"bounds-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🔒"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Limits"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Service Provider"})]})]}),o.jsx("div",{className:"bounds-fields-grid",children:g.map(([T,P])=>{var F;return o.jsxs("div",{style:{display:"contents"},children:[o.jsx(Hc,{fieldKey:T,fieldDef:P,value:f[T],onChange:U,prefix:"bounds",readOnly:r,twoColumn:!0}),I!=="no-config"&&((F=l==null?void 0:l.caps)==null?void 0:F[T])!==void 0&&o.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:ie(T)})]},`bounds-${T}`)})}),A()]}),o.jsx("button",{className:"btn btn-primary",onClick:B,disabled:K,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Hv(e){var n;const t=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Vv(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Kv="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function yo({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:s}){const[i,l]=d.useState([{role:"assistant",content:r??Kv}]),[c,u]=d.useState(""),[p,m]=d.useState(!1),[g,w]=d.useState(null),x=d.useRef(null);d.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[i,p]);const y=async()=>{const h=c.trim();if(!h||p)return;const f=[...i,{role:"user",content:h}];l(f),u(""),w(null),m(!0);try{const v=await L.aiChat({target:e,currentText:t,messages:f.filter((S,E)=>!(E===0&&S.role==="assistant"))});v.success&&v.reply?l(S=>[...S,{role:"assistant",content:v.reply}]):w(v.error??"AI returned no reply")}catch(v){w(v instanceof Error?v.message:"Chat failed")}finally{m(!1)}},j=h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),y())};return o.jsxs("div",{className:"intent-chat",children:[o.jsx("h3",{className:"card-title",children:s??"AI Assistant"}),o.jsxs("div",{ref:x,className:"chat-messages",children:[i.map((h,f)=>{const v=h.role==="assistant"?Hv(h.content):null,S=v?Vv(h.content):h.content;return o.jsx("div",{className:`chat-msg ${h.role}`,children:o.jsxs("div",{className:"chat-msg-body",children:[S&&o.jsx("div",{className:"chat-msg-prose",children:S}),v!==null&&o.jsxs(o.Fragment,{children:[o.jsx("pre",{className:"chat-fenced-block",children:v}),o.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(v),children:"Apply this draft"})]})]})},f)}),p&&o.jsx("div",{className:"chat-msg assistant",children:o.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),g&&o.jsx("div",{className:"error-message",children:g}),o.jsxs("div",{className:"chat-composer",children:[o.jsxs("div",{className:"chat-composer-pill",children:[o.jsx("textarea",{className:"chat-input",value:c,onChange:h=>u(h.target.value),onKeyDown:j,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:p}),o.jsx("button",{type:"button",className:"chat-send-btn",onClick:y,disabled:p||!c.trim(),"aria-label":"Send",children:"↑"})]}),o.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Bf({open:e,onClose:t,children:n,ariaLabel:r}){const a=d.useRef(null),s=d.useRef(null);return d.useEffect(()=>{var l;if(!e)return;s.current=document.activeElement,document.body.style.overflow="hidden";const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",s.current instanceof HTMLElement&&s.current.focus()}},[e,t]),df.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),o.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[o.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),o.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function Gv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yv(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const u of[c.scope,...c.scope.split(",").map(p=>p.trim())]){const p=u.toLowerCase();u&&!a.has(p)&&(a.add(p),r.push(u))}r.sort((c,u)=>u.length-c.length);const s=c=>{const u=c.toLowerCase();return t.filter(p=>{var m,g;return((m=p.scope)==null?void 0:m.toLowerCase())===u||((g=p.scope)==null?void 0:g.split(",").map(w=>w.trim().toLowerCase()).includes(u))})},i=["\\[\\d+\\]",...r.map(Gv)],l=new RegExp(`(${i.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const u=/^\[(\d+)\]$/.exec(c);if(u){const p=t[Number(u[1])-1];if(p){const m=p.scope&&p.scope!=="all (unscoped)"?p.scope:"all recipients",g=n?`${n}: ${m}`:m;return{text:c,label:g,matched:[p]}}}else if(r.some(p=>p.toLowerCase()===c.toLowerCase())){const p=s(c);if(p.length>0)return{text:c,label:c,matched:p}}return{text:c,label:c,matched:null}})}const Vc=`Why — What's the situation? Why does this need to happen?
55
+ Health check: GET ${e}/health`}};function Cv({aiConfigured:e,hasRunningIntegration:t,hasActiveAuth:n,hasAgentConnected:r,mcpEndpoint:a}){const[s,i]=d.useState(()=>localStorage.getItem(mi)==="true"),[l,c]=d.useState(()=>localStorage.getItem(hi)==="true"),[u,p]=d.useState(()=>localStorage.getItem(gi)==="true"),[h,m]=d.useState(null),[w,x]=d.useState("claude-code"),[y,j]=d.useState(!1),g=[{label:"AI Assistant",detail:"A trusted AI helps you think through authorizations — surfacing risks and asking the right questions.",to:"/settings",status:e?"done":s?"skipped":"pending",optional:!0},{label:"Connect a service",to:"/integrations",status:t?"done":"pending"},{label:"Authorize your agent",to:"/agent/new",status:n?"done":"pending"},{label:"Connect your agent",status:r||l?"done":"pending"}],f=g.filter(b=>b.status==="done"||b.status==="skipped").length,v=f===g.length,S=d.useCallback(()=>{localStorage.setItem(mi,"true"),i(!0)},[]),E=d.useCallback(()=>{localStorage.setItem(hi,"true"),c(!0),m(null)},[]),z=d.useCallback(()=>{localStorage.setItem(gi,"true"),p(!0)},[]),k=d.useCallback(async b=>{try{await navigator.clipboard.writeText(b),j(!0),setTimeout(()=>j(!1),2e3)}catch{}},[]);if(u||v)return null;const N=g.findIndex(b=>b.status==="pending");return o.jsxs("div",{style:{border:"2px solid var(--accent)",borderRadius:"0.75rem",padding:"1.5rem",marginBottom:"1.5rem",background:"var(--bg-elevated)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"1.25rem"},children:[o.jsx("h2",{style:{fontSize:"1.1rem",fontWeight:700,margin:0},children:"Get Started"}),o.jsx("button",{onClick:z,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"1.1rem",padding:"0 0.25rem",lineHeight:1},title:"Hide setup guide",children:"×"})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:g.map((b,I)=>{const H=I===N,U=b.status==="done"||b.status==="skipped"?"●":"○",B=b.status==="done"?"var(--success)":b.status==="skipped"?"var(--text-tertiary)":H?"var(--accent)":"var(--text-tertiary)";return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:H?"0.75rem":"0.25rem 0",borderRadius:H?"0.5rem":void 0,background:H?"var(--accent-subtle)":void 0},children:[o.jsx("span",{style:{color:B,fontSize:"0.75rem",marginTop:"0.2rem",flexShrink:0},children:U}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[b.to&&b.status==="pending"?o.jsx(tt,{to:b.to,style:{fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)",textDecoration:"none"},children:b.label}):b.status==="pending"&&I===3?o.jsx("button",{onClick:()=>m(h===3?null:3),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"0.9rem",fontWeight:H?600:500,color:H?"var(--accent)":"var(--text-primary)"},children:b.label}):o.jsx("span",{style:{fontSize:"0.9rem",fontWeight:500,color:b.status==="done"?"var(--text-secondary)":"var(--text-tertiary)"},children:b.label}),b.optional&&b.status==="pending"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontStyle:"italic"},children:"optional"}),b.status==="skipped"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:"skipped"})]}),b.detail&&b.status==="pending"&&H&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.25rem",lineHeight:1.5},children:b.detail})]}),b.optional&&b.status==="pending"&&o.jsx("button",{onClick:S,style:{background:"none",border:"none",color:"var(--text-tertiary)",cursor:"pointer",fontSize:"0.75rem",padding:"0.125rem 0.5rem",flexShrink:0},children:"Skip"}),b.to&&b.status==="pending"&&o.jsx(tt,{to:b.to,style:{color:"var(--text-tertiary)",textDecoration:"none",fontSize:"0.8rem",flexShrink:0},children:"›"})]}),I===3&&h===3&&o.jsxs("div",{style:{marginTop:"0.75rem",marginLeft:"1.5rem",padding:"1rem",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,marginBottom:"0.75rem",color:"var(--text-primary)"},children:"MCP Endpoint"}),o.jsx("div",{style:{fontFamily:"monospace",fontSize:"0.85rem",padding:"0.5rem 0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",marginBottom:"1rem",wordBreak:"break-all"},children:a}),o.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"0.75rem"},children:Object.entries(gs).map(([R,F])=>o.jsx("button",{onClick:()=>x(R),style:{padding:"0.375rem 0.75rem",fontSize:"0.75rem",fontWeight:w===R?600:400,background:w===R?"var(--accent-subtle)":"transparent",color:w===R?"var(--accent)":"var(--text-secondary)",border:`1px solid ${w===R?"var(--accent)":"var(--border)"}`,borderRadius:"0.375rem",cursor:"pointer"},children:F.label},R))}),o.jsx("pre",{style:{fontFamily:"monospace",fontSize:"0.78rem",lineHeight:1.6,padding:"0.75rem",background:"var(--bg-elevated)",border:"1px solid var(--border)",borderRadius:"0.375rem",overflow:"auto",whiteSpace:"pre-wrap",margin:0,marginBottom:"0.75rem"},children:gs[w].snippet(a)}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>k(gs[w].snippet(a)),children:y?"Copied":"Copy"}),o.jsx("button",{className:"btn btn-primary btn-sm",onClick:E,children:"Done"})]})]})]},I)})}),o.jsxs("div",{style:{marginTop:"1.25rem"},children:[o.jsx("div",{style:{height:"4px",background:"var(--border)",borderRadius:"2px",overflow:"hidden"},children:o.jsx("div",{style:{height:"100%",width:`${f/g.length*100}%`,background:"var(--accent)",borderRadius:"2px",transition:"width 0.3s ease"}})}),o.jsxs("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.375rem"},children:[f," of ",g.length," complete"]})]})]})}function bn({variant:e="base",style:t,className:n,...r}){const a=e==="title"?"skeleton skeleton-title":e==="line"?"skeleton skeleton-line":e==="line-sm"?"skeleton skeleton-line-sm":"skeleton";return o.jsx("span",{className:`${a}${n?` ${n}`:""}`,style:t,role:"status","aria-busy":"true","aria-label":r["aria-label"]??"Loading"})}function vs(){return o.jsxs("div",{className:"skeleton-card",role:"status","aria-busy":"true","aria-label":"Loading",children:[o.jsx(bn,{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",flexShrink:0}}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.35rem"},children:[o.jsx(bn,{variant:"line",style:{width:"35%"}}),o.jsx(bn,{variant:"line-sm",style:{width:"65%"}})]})]})}const bv=30*60;function ys(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Nv(){var R;const{domain:e}=Pe(),[t,n]=d.useState([]),[r,a]=d.useState([]),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(!1),[h,m]=d.useState(!1),[w,x]=d.useState(!1),{entries:y,activeSessions:j,loading:g}=jl(),f=!g,v=d.useCallback(()=>{$.getMyAttestations().then(F=>{n(F),p(!0)}).catch(()=>p(!0)),$.getProposals(e||"owner").then(F=>{a(F),m(!0)}).catch(()=>m(!0)),$.getProposalsForApprover().then(F=>i(F)).catch(()=>i([])),$.getCredential("ai-config").then(F=>{c(F.configured),x(!0)}).catch(()=>x(!0))},[e]);he("attestation-changed",v),he("proposal-added",v),he("proposal-resolved",v),he("proposal-approved",v),he("proposal-rejected",v),Ft(v,3e5,e);const S=u&&h&&w&&f,E=Lf(t),z=E.active,k=E.expired,N=z.filter(F=>F.remaining_seconds!==null&&F.remaining_seconds<=bv),b=r.filter(F=>F.status==="pending"),I=y.filter(F=>F.state==="running"),H=y.filter(F=>F.state==="starting"),U=y.filter(F=>F.state==="not-running"||F.state==="error"),B=[];for(const F of s)B.push({label:"Approval needed",detail:`${F.tool} — above-cap action under ${ys(F.profileId)}`,to:"/proposals",color:"var(--warning)"});for(const F of b)B.push({label:"Approval pending",detail:`${F.tool} awaiting your approval`,to:"/proposals",color:"var(--warning)"});for(const F of N){const ee=Math.ceil((F.remaining_seconds??0)/60);B.push({label:"Expiring soon",detail:`${F.title??ys(F.profile_id)} — ${ee} min remaining`,to:"/authorizations",color:"var(--warning)"})}for(const F of k)B.push({label:"Expired",detail:F.title??ys(F.profile_id),to:"/authorizations",color:"var(--danger)"});for(const F of U)B.push({label:F.state==="error"?"Integration error":"Integration stopped",detail:F.state==="error"&&((R=F.integration)!=null&&R.error)?`${F.manifest.name}: ${F.integration.error}`:`${F.manifest.name} is not running`,to:"/integrations",color:"var(--danger)"});for(const F of H)B.push({label:"Integration starting",detail:`${F.manifest.name} is coming up…`,to:"/integrations",color:"var(--warning)"});for(const F of y)F.authStatus==="failed"&&F.state!=="not-running"&&F.state!=="error"&&B.push({label:"Reconnect needed",detail:`${F.manifest.name}: authorization expired — reconnect to restore access`,to:"/integrations",color:"var(--danger)"});return l||B.push({label:"AI Assistant",detail:"Not configured — needed for gate advisory",to:"/settings",color:"var(--text-tertiary)"}),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsx("h1",{className:"page-title",children:"Dashboard"})}),S&&o.jsx(Cv,{aiConfigured:l,hasRunningIntegration:I.length>0,hasActiveAuth:z.length>0,hasAgentConnected:j>0,mcpEndpoint:`http://localhost:${window.location.port==="3400"?"3430":"7430"}`}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(8rem, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[o.jsx(tt,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:z.length>0?"var(--success)":"var(--text-tertiary)"},children:z.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Active"})]})}),o.jsx(tt,{to:"/proposals",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[h?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:b.length>0?"var(--warning)":"var(--text-tertiary)"},children:b.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Pending Approvals"})]})}),o.jsx(tt,{to:"/authorizations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[u?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:k.length>0?"var(--danger)":"var(--text-tertiary)"},children:k.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Expired"})]})}),o.jsx(tt,{to:"/integrations",style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"1rem",textAlign:"center"},children:[f?o.jsx("div",{style:{fontSize:"1.5rem",fontWeight:700,color:I.length>0?"var(--success)":"var(--text-tertiary)"},children:I.length}):o.jsx(bn,{variant:"title"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Integrations Running"})]})})]}),B.length>0?o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:B.map((F,ee)=>o.jsx(tt,{to:F.to,style:{textDecoration:"none"},children:o.jsxs("div",{className:"card",style:{padding:"0.75rem 1rem",display:"flex",alignItems:"center",gap:"0.75rem"},children:[o.jsx("span",{style:{width:"0.5rem",height:"0.5rem",borderRadius:"50%",background:F.color,flexShrink:0}}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:"var(--text-primary)"},children:F.label}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:F.detail})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:"›"})]})},ee))}):S?o.jsx("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:o.jsx("div",{style:{fontSize:"0.9rem",color:"var(--text-secondary)"},children:"All clear. Nothing needs your attention."})}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[o.jsx(vs,{}),o.jsx(vs,{}),o.jsx(vs,{})]})]})}const Ev=["Scope & Limits","Intent","Authorize"];function Of({currentStep:e,onStepClick:t}){const n=Kt();return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",marginBottom:"2.5rem"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",flex:1,overflow:"hidden"},children:Ev.map((r,a)=>{const s=a+2,i=s<e,l=s===e;return o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[a>0&&o.jsx("div",{style:{width:"1.5rem",height:"2px",background:i?"var(--accent)":"var(--border)",flexShrink:1}}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[o.jsx("div",{className:`step-circle${i?" completed":""}${l?" current":""}`,onClick:i&&t?()=>t(s):void 0,style:i&&t?{cursor:"pointer"}:void 0,children:i?"✓":a+1}),o.jsx("span",{className:"step-label-text",style:{fontSize:"0.6rem",marginTop:"0.3rem",color:l?"var(--accent)":i?"var(--text-secondary)":"var(--text-tertiary)",fontWeight:l?600:400,textAlign:"center"},children:r})]})]},s)})}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>n("/agent/new"),style:{flexShrink:0,fontSize:"0.8rem",marginTop:"0.15rem"},children:"Cancel"})]})}const Dc=40;function Ie(e,t){if(t)return t.slice(0,Dc);const n=e.lastIndexOf("/"),r=n>=0?e.slice(n+1):e,a=r.indexOf("@"),s=a>=0?r.slice(0,a):r;return(s.charAt(0).toUpperCase()+s.slice(1)).slice(0,Dc)}function zv({profileId:e,bounds:t,groupName:n,domain:r,onSwitch:a}){return o.jsxs("div",{className:"context-strip",children:[n&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"context-strip-label",children:"Team:"}),o.jsxs("span",{children:[o.jsx("strong",{children:n}),r?` / ${r}`:""]})]}),e&&o.jsxs("span",{children:[o.jsx("strong",{children:"Profile:"})," ",Ie(e)]}),t&&o.jsxs("span",{children:[o.jsx("strong",{children:"Bounds:"})," ",t]}),a&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginLeft:"auto",padding:"0.2rem 0.5rem",fontSize:"0.7rem"},onClick:a,children:"Switch"})]})}function Iv({integrationId:e,field:t,value:n,onChange:r,disabled:a,onLabels:s}){const[i,l]=d.useState(null),[c,u]=d.useState(null),[p,h]=d.useState(!0);d.useEffect(()=>{let x=!1;return $.discoverScopeField(e,t).then(y=>{var j;x||(l(y.options),h(!1),(j=y.options)!=null&&j.length&&(s==null||s(Object.fromEntries(y.options.map(g=>[g.value,g.label])))))}).catch(y=>{x||(u(y instanceof Error?y.message:String(y)),h(!1))}),()=>{x=!0}},[e,t]);const m=new Set(n.split(",").map(x=>x.trim()).filter(Boolean)),w=x=>{const y=new Set(m);y.has(x)?y.delete(x):y.add(x),r(Array.from(y).join(","))};return p?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["Loading options from ",e,"…"]}):c||!i?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--warning)",marginBottom:"0.5rem"},children:["Couldn't fetch options (",c??"no response","). Enter values manually, separated by commas."]}),o.jsx("input",{className:"form-input",type:"text",value:n,onChange:x=>r(x.target.value),disabled:a})]}):i.length===0?o.jsxs("p",{className:"hint-text",style:{color:"var(--text-tertiary)"},children:["No options available from ",e," for this field."]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.25rem"},children:i.map(x=>{const y=x.extras??{},j=typeof y.access=="string"?y.access:void 0,g=j==="reader",f=y.primary===!0;return o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.875rem",color:g?"var(--text-tertiary)":"var(--text-primary)",cursor:a||g?"not-allowed":"pointer"},title:g?"Read-only — you can authorize list/read but not writes":void 0,children:[o.jsx("input",{type:"checkbox",checked:m.has(String(x.value)),onChange:()=>w(String(x.value)),disabled:a||g}),o.jsx("span",{children:x.label||x.value}),f&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"primary"}),j&&o.jsxs("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["· ",j]})]},x.value)})})}function Pv(e){return e.replace(/@.*$/,"").split("/").pop()??e}function Tv(e,t){return t.displayName?t.displayName:e.replace(/_/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function Rv(e){return e.type==="string"&&(e.format==="email"||e.format==="domain")}function _v(e){var t;return!!(e.enum&&((t=e.constraint)!=null&&t.enforceable.includes("subset")))}function Uc(e,t){const n=e.trim();return n?t==="email"?n.includes("@")&&n.indexOf(".",n.indexOf("@"))>-1:t==="domain"?n.includes(".")&&!n.includes("@"):!0:!1}function Av(e){return!e||e==="count"?"":e==="minutes"?"min":e==="hours"?"hr":e==="days"?"days":e==="percent"?"%":e.startsWith("currency:")?e.slice(9):e}function $v(e){return e?e==="minutes"?15:e==="percent"?5:e.startsWith("currency:")?10:1:1}function Lv(e){return e?e==="minutes"?[{value:15,label:"15m"},{value:30,label:"30m"},{value:60,label:"1h"},{value:120,label:"2h"},{value:240,label:"4h"}]:e==="hours"?[{value:1,label:"1h"},{value:4,label:"4h"},{value:8,label:"8h"},{value:24,label:"1d"}]:e==="days"?[{value:1,label:"1d"},{value:7,label:"1w"},{value:30,label:"1mo"},{value:90,label:"3mo"}]:e==="percent"?[{value:10,label:"10%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:100,label:"100%"}]:e.startsWith("currency:")?[{value:10,label:"10"},{value:50,label:"50"},{value:100,label:"100"},{value:500,label:"500"},{value:1e3,label:"1k"}]:[]:[]}function Mv(e,t){if(!e||!t)return"";const n=Number(e);if(!Number.isFinite(n)||n<=0)return"";if(t==="minutes"&&n>=60){const r=Math.floor(n/60),a=n%60;return a===0?`${r} hour${r!==1?"s":""}`:`${r}h ${a}m`}if(t==="hours"&&n>=24&&n%24===0){const r=n/24;return`${r} day${r!==1?"s":""}`}if(t==="days"){if(n>=30&&n%30===0)return`${n/30} month${n/30!==1?"s":""}`;if(n>=7&&n%7===0)return`${n/7} week${n/7!==1?"s":""}`}return""}function Fv({id:e,value:t,onChange:n,disabled:r,placeholder:a,unit:s}){const i=$v(s),l=Lv(s),c=Av(s),u=Mv(t,s),p=t===""?null:Number(t),h=()=>{const w=t===""?0:Number(t),x=w%i,y=x===0?w+i:w+(i-x);n(String(y))},m=()=>{const w=t===""?0:Number(t);if(w<=0)return;const x=w%i,y=x===0?w-i:w-x;n(String(Math.max(0,y)))};return o.jsxs("div",{className:"bounded-input",children:[o.jsxs("div",{className:"bounded-input-field",children:[o.jsx("button",{type:"button",className:"stepper-btn stepper-decrement",onClick:m,disabled:r||t===""||Number(t)<=0,"aria-label":"Decrease",children:"−"}),o.jsx("input",{id:e,className:"stepper-input",type:"number",min:0,step:i,value:t,placeholder:a??"0",onChange:w=>n(w.target.value),onFocus:w=>w.target.select(),disabled:r}),o.jsx("button",{type:"button",className:"stepper-btn stepper-increment",onClick:h,disabled:r,"aria-label":"Increase",children:"+"}),c&&o.jsx("span",{className:"bounded-input-unit","aria-hidden":"true",children:c})]}),l.length>0&&!r&&o.jsx("div",{className:"bounded-input-presets",role:"group","aria-label":"Quick presets",children:l.map(w=>o.jsx("button",{type:"button",className:`preset-chip${p===w.value?" preset-chip-selected":""}`,onClick:()=>n(String(w.value)),children:w.label},w.value))}),u&&o.jsxs("div",{className:"bounded-input-echo",children:["≈ ",u]})]})}function Wc({htmlFor:e,label:t,description:n}){const[r,a]=d.useState(!1);return o.jsxs("div",{className:"field-label-with-tip",children:[o.jsx("label",{className:"form-label",htmlFor:e,children:t}),n&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"field-tip-trigger","aria-label":`What does "${t}" mean?`,"aria-expanded":r,onClick:()=>a(s=>!s),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onBlur:()=>a(!1),children:"i"}),r&&o.jsx("div",{className:"field-tip-bubble",role:"tooltip",children:n})]})]})}function Ov({id:e,value:t,onChange:n,disabled:r,format:a,placeholder:s}){const[i,l]=d.useState(""),[c,u]=d.useState(!1),p=d.useRef(null),h=t?t.split(",").map(g=>g.trim()).filter(Boolean):[],m=g=>{const f=g.trim();if(!f)return;if(!Uc(f,a)){u(!0);return}u(!1);const v=h.includes(f)?h:[...h,f];n(v.join(",")),l("")},w=g=>{const f=h.filter((v,S)=>S!==g);n(f.join(","))},x=g=>{g.key==="Enter"||g.key===","||g.key==="Tab"?i.trim()&&(g.preventDefault(),m(i)):g.key==="Backspace"&&!i&&h.length>0&&w(h.length-1)},y=g=>{const f=g.clipboardData.getData("text");if(f.includes(",")){g.preventDefault();const S=f.split(",").map(z=>z.trim()).filter(Boolean).filter(z=>Uc(z,a)),E=[...new Set([...h,...S])];n(E.join(",")),l(""),u(!1)}},j=a==="email"?"Type email and press Enter...":"Type domain and press Enter...";return o.jsxs("div",{className:`tag-input${c?" tag-input-invalid":""}`,onClick:()=>{var g;return(g=p.current)==null?void 0:g.focus()},children:[h.map((g,f)=>o.jsxs("span",{className:"tag-pill",children:[g,!r&&o.jsx("button",{type:"button",className:"tag-remove",onClick:v=>{v.stopPropagation(),w(f)},"aria-label":`Remove ${g}`,children:"×"})]},g)),!r&&o.jsx("input",{ref:p,id:e,className:"tag-input-field",type:"text",value:i,onChange:g=>{l(g.target.value),u(!1)},onKeyDown:x,onPaste:y,onBlur:()=>{i.trim()&&m(i)},placeholder:h.length===0?s??j:""})]})}function Bv({id:e,options:t,value:n,onChange:r,disabled:a}){const s=n?n.split(",").map(l=>l.trim()).filter(Boolean):[],i=l=>{const c=s.includes(l)?s.filter(u=>u!==l):[...s,l];r(c.join(","))};return o.jsx("div",{className:"checkbox-group",id:e,children:t.map(l=>o.jsxs("label",{className:`checkbox-pill${s.includes(l)?" checkbox-pill-selected":""}`,children:[o.jsx("input",{type:"checkbox",checked:s.includes(l),onChange:()=>i(l),disabled:a}),o.jsx("span",{children:l})]},l))})}function Hc({fieldKey:e,fieldDef:t,value:n,onChange:r,prefix:a,readOnly:s,twoColumn:i,discoveryIntegrationId:l,onLabels:c}){const u=Tv(e,t),p=`${a}-field-${e}`,h=o.jsx(o.Fragment,{children:_v(t)?o.jsx(Bv,{id:p,options:t.enum,value:n,onChange:m=>r(e,m),disabled:s}):(()=>{const m=t.boundType;return(m==null?void 0:m.kind)==="enum"&&Array.isArray(m.values)})()?o.jsxs("select",{id:p,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.boundType.values.map(m=>o.jsx("option",{value:m,children:m},m))]}):"enum"in t&&t.enum?o.jsxs("select",{id:p,className:"form-select",value:n,onChange:m=>r(e,m.target.value),disabled:s,children:[o.jsx("option",{value:"",children:"Select..."}),t.enum.map(m=>o.jsx("option",{value:m,children:m},m))]}):t.type==="number"?o.jsx(Fv,{id:p,value:n,onChange:m=>r(e,m),disabled:s,unit:t.unit}):Rv(t)?o.jsx(Ov,{id:p,value:n,onChange:m=>r(e,m),disabled:s,format:t.format}):l?o.jsx(Iv,{integrationId:l,field:e,value:n,onChange:m=>r(e,m),disabled:s,onLabels:m=>c==null?void 0:c(e,m)}):o.jsx("input",{id:p,className:"form-input",type:"text",value:n,onChange:m=>r(e,m.target.value),disabled:s})});return i?o.jsxs("div",{className:"bounds-field-row",children:[o.jsx("div",{className:"bounds-field-label",children:o.jsx(Wc,{htmlFor:p,label:u,description:t.description})}),o.jsx("div",{className:"bounds-field-input",children:h})]},`${a}-${e}`):o.jsxs("div",{className:"form-group",children:[o.jsx(Wc,{htmlFor:p,label:u,description:t.description}),h]},`${a}-${e}`)}function Dv(e,t){if(!t)return"no-config";const n=t.caps,r=Array.isArray(t.approvers)&&t.approvers.length>0;if(!(n&&Object.keys(n).length>0))return r?"approvers-dormant":"no-config";let s=!1;for(const[i,l]of Object.entries(n)){const c=e[i];if(c===""||c===void 0)continue;const u=Number(c);if(!isNaN(u)&&u>l){s=!0;break}}return s?r?"above-approvers":"hard-ceiling":"within-cap"}function Uv(e,t){const n=new Set;if(!t)return n;for(const[r,a]of Object.entries(t)){const s=e[r];if(s===""||s===void 0)continue;const i=Number(s);!isNaN(i)&&i>a&&n.add(r)}return n}function Wv({profile:e,onConfirm:t,onCancel:n,readOnly:r,initialBounds:a,initialContext:s,initialFrame:i,profileConfig:l,approverNames:c,adminName:u}){const p=e.boundsSchema??e.frameSchema,h=e.contextSchema,m=p?Object.entries(p.fields).filter(([T])=>!(T==="profile"||T==="path")):[],w=h&&h.keyOrder.length>0?Object.entries(h.fields):[],x=a??i??{},y=s??{},j={};for(const[T]of m)j[T]=x[T]!==void 0?String(x[T]):"";const g={};for(const[T]of w)g[T]=y[T]!==void 0?String(y[T]):"";const[f,v]=d.useState(j),[S,E]=d.useState(g),[z,k]=d.useState({}),[N,b]=d.useState(null);d.useEffect(()=>{const T=Pv(e.id);$.getIntegrationManifests().then(({manifests:P})=>{const O=P.find(X=>X.profile===T&&X.contextDiscovery&&Object.keys(X.contextDiscovery).length>0);b(O??null)}).catch(()=>b(null))},[e.id]);const I=Dv(f,l),H=Uv(f,l==null?void 0:l.caps),U=(T,P)=>{v(O=>({...O,[T]:P}))},B=(T,P)=>{E(O=>({...O,[T]:P}))},R=()=>{const T={profile:e.id};for(const[O,X]of m)X.type==="number"?T[O]=f[O]===""?0:Number(f[O]):T[O]=f[O];const P={};for(const[O,X]of w)X.type==="number"?P[O]=S[O]===""?0:Number(S[O]):P[O]=S[O];return[T,P]},F=()=>{const[T,P]=R();t(T,P,z)},ee=()=>{const T=(l==null?void 0:l.caps)??{},P={...f};for(const Y of H)T[Y]!==void 0&&(P[Y]=String(T[Y]));v(P);const O={profile:e.id};for(const[Y,le]of m)if(le.type==="number"){const C=P[Y]??"";O[Y]=C===""?0:Number(C)}else O[Y]=P[Y]??"";const X={};for(const[Y,le]of w)le.type==="number"?X[Y]=S[Y]===""?0:Number(S[Y]):X[Y]=S[Y];t(O,X,z)},ie=T=>{const P=l==null?void 0:l.caps;if(!P||P[T]===void 0)return null;const O=P[T],X=H.has(T);return I==="hard-ceiling"&&X?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--danger)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — exceeds team ceiling"]}):I==="above-approvers"&&X?o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--warning)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," — above cap"]}):o.jsxs("span",{style:{fontSize:"0.72rem",color:"var(--success)",marginLeft:"0.5rem",whiteSpace:"nowrap"},children:["Cap: ",O," ok"]})},A=()=>{var T;if(I==="no-config")return null;if(I==="approvers-dormant"){const P=c&&c.length>0?c.join(", "):"the configured approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--accent)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--accent)",marginBottom:"0.25rem"},children:["Profile approvers: ",P]}),o.jsxs("div",{children:["No caps are set on this profile, so ",P," won't gate any action under this authority. Your intent will still be encrypted and shared with them as an accountability record — they can read what you authorised, even though they aren't reviewing individual actions."]})]})}if(I==="within-cap")return o.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--border)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:o.jsx("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:"Within all team caps — your responsibility."})});if(I==="above-approvers"){const P=c&&c.length>0?c.join(", "):"the required approvers";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--warning)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.25rem"},children:"Above team cap."}),o.jsxs("div",{children:[o.jsx("strong",{children:"Over-cap actions"})," will require approval from you and ",P,". Within-cap actions run per the mode you choose."]})]})}if(I==="hard-ceiling"){const P=Array.from(H)[0],O=P?(T=l==null?void 0:l.caps)==null?void 0:T[P]:void 0,X=u??"the team admin";return o.jsxs("div",{style:{marginTop:"0.75rem",padding:"0.75rem 1rem",border:"1px solid var(--danger)",borderRadius:"0.375rem",background:"var(--bg-elevated)",fontSize:"0.82rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--danger)",marginBottom:"0.25rem"},children:"Hard team ceiling."}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:["Team policy caps this at ",O??"the configured limit",". Lower your bound or ask ",X," to add an approver path above the cap."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ee,children:"Save below cap"}),n&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:n,children:"Cancel"})]})]})}return null},K=I==="hard-ceiling";return o.jsxs("div",{children:[w.length>0&&o.jsxs("div",{className:"context-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🛡"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Allowed scope"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Encrypted on your device, never sent to the SP"})]})]}),w.map(([T,P])=>{var X;const O=!!((X=N==null?void 0:N.contextDiscovery)!=null&&X[T]);return o.jsx(Hc,{fieldKey:T,fieldDef:P,value:S[T],onChange:B,prefix:"context",readOnly:r,discoveryIntegrationId:O?N.id:void 0,onLabels:(Y,le)=>k(C=>({...C,[Y]:le}))},`context-${T}`)})]}),m.length>0&&o.jsxs("div",{className:"bounds-section",children:[o.jsxs("div",{className:"bounds-section-header",children:[o.jsx("span",{className:"bounds-section-icon",children:"🔒"}),o.jsxs("div",{children:[o.jsx("div",{className:"bounds-section-title",children:"Limits"}),o.jsx("div",{className:"bounds-section-subtitle",children:"Enforced by the Service Provider"})]})]}),o.jsx("div",{className:"bounds-fields-grid",children:m.map(([T,P])=>{var O;return o.jsxs("div",{style:{display:"contents"},children:[o.jsx(Hc,{fieldKey:T,fieldDef:P,value:f[T],onChange:U,prefix:"bounds",readOnly:r,twoColumn:!0}),I!=="no-config"&&((O=l==null?void 0:l.caps)==null?void 0:O[T])!==void 0&&o.jsx("div",{style:{gridColumn:"2 / 3",display:"flex",alignItems:"center",paddingBottom:"0.5rem"},children:ie(T)})]},`bounds-${T}`)})}),A()]}),o.jsx("button",{className:"btn btn-primary",onClick:F,disabled:K,style:{marginTop:"0.5rem"},children:r?"Next: Gates":"Next: Problem Statement"})]})}function Hv(e){var n;const t=e.match(/```(?:markdown|md)?\s*\n([\s\S]*?)```/);return((n=t==null?void 0:t[1])==null?void 0:n.trim())??null}function Vv(e){return e.replace(/```(?:markdown|md)?\s*\n[\s\S]*?```/,"").trim()}const Kv="Tell me what your agent should do — I'll help shape it. Or ask me to draft a full intent and we'll iterate.";function yo({target:e,currentText:t,onApply:n,greeting:r,placeholder:a,title:s}){const[i,l]=d.useState([{role:"assistant",content:r??Kv}]),[c,u]=d.useState(""),[p,h]=d.useState(!1),[m,w]=d.useState(null),x=d.useRef(null);d.useEffect(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[i,p]);const y=async()=>{const g=c.trim();if(!g||p)return;const f=[...i,{role:"user",content:g}];l(f),u(""),w(null),h(!0);try{const v=await $.aiChat({target:e,currentText:t,messages:f.filter((S,E)=>!(E===0&&S.role==="assistant"))});v.success&&v.reply?l(S=>[...S,{role:"assistant",content:v.reply}]):w(v.error??"AI returned no reply")}catch(v){w(v instanceof Error?v.message:"Chat failed")}finally{h(!1)}},j=g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),y())};return o.jsxs("div",{className:"intent-chat",children:[o.jsx("h3",{className:"card-title",children:s??"AI Assistant"}),o.jsxs("div",{ref:x,className:"chat-messages",children:[i.map((g,f)=>{const v=g.role==="assistant"?Hv(g.content):null,S=v?Vv(g.content):g.content;return o.jsx("div",{className:`chat-msg ${g.role}`,children:o.jsxs("div",{className:"chat-msg-body",children:[S&&o.jsx("div",{className:"chat-msg-prose",children:S}),v!==null&&o.jsxs(o.Fragment,{children:[o.jsx("pre",{className:"chat-fenced-block",children:v}),o.jsx("button",{type:"button",className:"btn btn-primary btn-sm chat-apply-btn",onClick:()=>n(v),children:"Apply this draft"})]})]})},f)}),p&&o.jsx("div",{className:"chat-msg assistant",children:o.jsx("div",{className:"chat-msg-body chat-msg-thinking",children:"Thinking…"})})]}),m&&o.jsx("div",{className:"error-message",children:m}),o.jsxs("div",{className:"chat-composer",children:[o.jsxs("div",{className:"chat-composer-pill",children:[o.jsx("textarea",{className:"chat-input",value:c,onChange:g=>u(g.target.value),onKeyDown:j,placeholder:a??"Ask for help articulating the intent…",rows:1,disabled:p}),o.jsx("button",{type:"button",className:"chat-send-btn",onClick:y,disabled:p||!c.trim(),"aria-label":"Send",children:"↑"})]}),o.jsx("div",{className:"chat-composer-hint",children:"Enter to send · Shift+Enter for newline"})]})]})}function Bf({open:e,onClose:t,children:n,ariaLabel:r}){const a=d.useRef(null),s=d.useRef(null);return d.useEffect(()=>{var l;if(!e)return;s.current=document.activeElement,document.body.style.overflow="hidden";const i=c=>{c.key==="Escape"&&t()};return document.addEventListener("keydown",i),(l=a.current)==null||l.focus(),()=>{document.removeEventListener("keydown",i),document.body.style.overflow="",s.current instanceof HTMLElement&&s.current.focus()}},[e,t]),df.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`bottom-sheet-backdrop${e?" is-open":""}`,onClick:t,"aria-hidden":"true"}),o.jsxs("aside",{ref:a,className:`bottom-sheet${e?" is-open":""}`,role:"dialog","aria-modal":"true","aria-label":r,tabIndex:-1,children:[o.jsx("div",{className:"bottom-sheet-handle","aria-hidden":"true"}),o.jsx("button",{type:"button",className:"bottom-sheet-close",onClick:t,"aria-label":"Close",children:"×"}),n]})]}),document.body)}function Gv(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yv(e,t,n){if(t.length===0)return[{text:e,label:e,matched:null}];const r=[],a=new Set;for(const c of t)if(!(!c.scope||c.scope==="all (unscoped)"))for(const u of[c.scope,...c.scope.split(",").map(p=>p.trim())]){const p=u.toLowerCase();u&&!a.has(p)&&(a.add(p),r.push(u))}r.sort((c,u)=>u.length-c.length);const s=c=>{const u=c.toLowerCase();return t.filter(p=>{var h,m;return((h=p.scope)==null?void 0:h.toLowerCase())===u||((m=p.scope)==null?void 0:m.split(",").map(w=>w.trim().toLowerCase()).includes(u))})},i=["\\[\\d+\\]",...r.map(Gv)],l=new RegExp(`(${i.join("|")})`,"gi");return e.split(l).filter(c=>c!=="").map(c=>{const u=/^\[(\d+)\]$/.exec(c);if(u){const p=t[Number(u[1])-1];if(p){const h=p.scope&&p.scope!=="all (unscoped)"?p.scope:"all recipients",m=n?`${n}: ${h}`:h;return{text:c,label:m,matched:[p]}}}else if(r.some(p=>p.toLowerCase()===c.toLowerCase())){const p=s(c);if(p.length>0)return{text:c,label:c,matched:p}}return{text:c,label:c,matched:null}})}const Vc=`Why — What's the situation? Why does this need to happen?
56
56
 
57
57
  Goal — What should the agent try to achieve?
58
58
 
59
- Watch out — What should the agent avoid or be careful about?`;function Qv(e,t,n,r){return Yv(e,t,r).map((a,s)=>{if(!a.matched)return o.jsx("span",{children:a.text},s);const i=a.matched;return o.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},s)})}function Jv(){var q;const e=Kt(),[t]=Pf(),n=Number(t.get("step"))||2,[r,a]=d.useState(null),[s,i]=d.useState(null),[l,c]=d.useState(n),[u,p]=d.useState(null),[m,g]=d.useState(null),[w,x]=d.useState({}),[y,j]=d.useState(Vc),[h,f]=d.useState(!1),[v,S]=d.useState(!0),[E,z]=d.useState(null),[k,N]=d.useState([]),[b,I]=d.useState(void 0),[H,U]=d.useState(!1),[O,R]=d.useState(null),[B,ee]=d.useState(null),[ie,A]=d.useState(null),[K,T]=d.useState([]),[P,F]=d.useState(null);d.useEffect(()=>{var Ve;const Q=sessionStorage.getItem("agentAuth");if(!Q){e("/agent/new");return}const fe=JSON.parse(Q);a(fe);const He=sessionStorage.getItem("agentGate");if(He){const je=JSON.parse(He);je.bounds&&p(je.bounds),je.context&&g(je.context),(Ve=je.gateContent)!=null&&Ve.intent&&j(je.gateContent.intent)}L.getProfile(fe.profileId).then(je=>i(je)).catch(()=>e("/agent/new")).finally(()=>S(!1)),fe.groupId&&Promise.all([L.getTeamProfileConfig(fe.groupId,fe.profileId).catch(()=>null),L.getGroupById(fe.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([je,hn,qe])=>{if(z(je),je){const _t=new Map;for(const ae of qe){const W=ae.name&&ae.email?`${ae.name} (${ae.email})`:ae.name||ae.email||ae.id;_t.set(ae.id,W)}const $n=(hn==null?void 0:hn.members)??[];for(const ae of $n){const W=ae.userId??ae.id;W&&(ae.name&&ae.email?_t.set(W,`${ae.name} (${ae.email})`):ae.name&&_t.set(W,ae.name))}const Ln=(je.approvers??[]).map(ae=>_t.get(ae)??ae);N(Ln);const bt=$n.find(ae=>ae.role==="admin");if(bt){const ae=bt.userId??bt.id;ae&&I(_t.get(ae)??bt.name)}}})},[e]);const X=u?Object.entries(u).filter(([Q])=>Q!=="profile"&&Q!=="path").map(([Q,fe])=>`${Q} = ${fe}`).join(", "):"",Y=(Q,fe,He)=>{p(Q),g(fe),He&&x(He),c(3)},le=y.trim()!==Vc.trim()&&y.trim()!=="",C=Q=>{le&&!confirm("Replace your current intent with the AI draft?")||j(Q)},D=()=>{const Q=s==null?void 0:s.ttl,fe={intent:y},He=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...He,bounds:u,context:m,contextLabels:w,gateContent:fe,ttlConfig:Q})),e("/agent/review")},_=async()=>{if(r){U(!0),R(null),ee(null),A(null),T([]),F(null);try{const Q=await L.aiIntentReview({profileId:r.profileId,newIntent:y,context:m??void 0});T(Q.grants??[]),Q.success?Q.review?R(Q.review):ee(Q.note??"No other authorizations on this profile to compare against."):A(Q.error??"Check failed.")}catch(Q){A(Q instanceof Error?Q.message:"Check failed.")}finally{U(!1)}}},V=Q=>{j(Q),(O||B||ie)&&(R(null),ee(null),A(null),T([]),F(null))};return v||!r||!s?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):o.jsxs(o.Fragment,{children:[o.jsx(Of,{currentStep:l,onStepClick:Q=>{Q>=2&&c(Q)}}),o.jsx(zv,{profileId:r.profileId,bounds:X||void 0,groupName:r.groupName,domain:r.domain}),l===2&&o.jsx("div",{className:"card",children:o.jsx(Wv,{profile:s,onConfirm:Y,onCancel:()=>e("/agent/new"),initialBounds:u||void 0,initialContext:m||void 0,profileConfig:E,approverNames:k,adminName:b})}),l===3&&o.jsxs("div",{className:"intent-layout",children:[o.jsx("div",{className:"card intent-pane chat tool",children:o.jsx(yo,{target:{kind:"intent",profileId:r.profileId,bounds:X||void 0},currentText:y,onApply:C})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsx("h3",{className:"card-title",children:"What should your agent know?"}),o.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),o.jsx("textarea",{className:"intent-textarea",value:y,onChange:Q=>V(Q.target.value)}),o.jsxs("div",{className:"char-counter",children:[y.length," / 2000"]})]}),o.jsxs("div",{style:{marginTop:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:_,disabled:H||!le,children:H?"Checking…":"Check against my other grants"}),ie&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),o.jsx("div",{className:"hint-body",children:ie})]}),B&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsx("div",{className:"hint-body",children:B})]}),O&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),o.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Qv(O,K,F,Ie(r.profileId))}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),o.jsxs("div",{className:"intent-footer",children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),o.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:D,disabled:!le,children:"Continue to Review"})]}),(((q=E==null?void 0:E.approvers)==null?void 0:q.length)??0)>0&&o.jsxs("div",{className:"hint-box",role:"note",children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsxs("div",{className:"hint-head",children:["Visible to ",k.length>0?k.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",k.length>0?k.join(", "):"this profile's required approvers",". Only they can decrypt it — your Service Provider cannot. Each approver stores a copy as their accountability record."]})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>f(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),o.jsx(Bf,{open:h,onClose:()=>f(!1),ariaLabel:"Intent assistant",children:o.jsx(yo,{target:{kind:"intent",profileId:r.profileId,bounds:X||void 0},currentText:y,onApply:Q=>{C(Q),f(!1)}})}),P&&o.jsx("div",{className:"modal-backdrop",onClick:Q=>Q.target===Q.currentTarget&&F(null),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:P.length>1?`Existing authorizations (${P.length})`:"Existing authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>F(null),children:"×"})]}),o.jsx("div",{className:"modal-body",children:P.map((Q,fe)=>{var He;return o.jsxs("div",{style:{marginBottom:fe<P.length-1?"1rem":0,paddingBottom:fe<P.length-1?"1rem":0,borderBottom:fe<P.length-1?"1px solid var(--border)":"none"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),o.jsx("div",{style:{marginBottom:"0.75rem"},children:Q.scope}),o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),o.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((He=Q.intent)==null?void 0:He.trim())||"(no intent recorded)"}),Object.entries(Q.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(Q.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").map(([Ve,je])=>`${Ve}: ${je}`).join(" · ")})]})]},fe)})})]})})]})]})}function Xv(e){return e.normalize("NFC").replace(/\r\n?/g,`
59
+ Watch out — What should the agent avoid or be careful about?`;function Qv(e,t,n,r){return Yv(e,t,r).map((a,s)=>{if(!a.matched)return o.jsx("span",{children:a.text},s);const i=a.matched;return o.jsx("button",{type:"button",onClick:()=>n(i),style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"var(--accent)",textDecoration:"underline",font:"inherit"},children:a.label},s)})}function Jv(){var q;const e=Kt(),[t]=Pf(),n=Number(t.get("step"))||2,[r,a]=d.useState(null),[s,i]=d.useState(null),[l,c]=d.useState(n),[u,p]=d.useState(null),[h,m]=d.useState(null),[w,x]=d.useState({}),[y,j]=d.useState(Vc),[g,f]=d.useState(!1),[v,S]=d.useState(!0),[E,z]=d.useState(null),[k,N]=d.useState([]),[b,I]=d.useState(void 0),[H,U]=d.useState(!1),[B,R]=d.useState(null),[F,ee]=d.useState(null),[ie,A]=d.useState(null),[K,T]=d.useState([]),[P,O]=d.useState(null);d.useEffect(()=>{var Ve;const Q=sessionStorage.getItem("agentAuth");if(!Q){e("/agent/new");return}const fe=JSON.parse(Q);a(fe);const He=sessionStorage.getItem("agentGate");if(He){const je=JSON.parse(He);je.bounds&&p(je.bounds),je.context&&m(je.context),(Ve=je.gateContent)!=null&&Ve.intent&&j(je.gateContent.intent)}$.getProfile(fe.profileId).then(je=>i(je)).catch(()=>e("/agent/new")).finally(()=>S(!1)),fe.groupId&&Promise.all([$.getTeamProfileConfig(fe.groupId,fe.profileId).catch(()=>null),$.getGroupById(fe.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([je,hn,qe])=>{if(z(je),je){const _t=new Map;for(const ae of qe){const W=ae.name&&ae.email?`${ae.name} (${ae.email})`:ae.name||ae.email||ae.id;_t.set(ae.id,W)}const $n=(hn==null?void 0:hn.members)??[];for(const ae of $n){const W=ae.userId??ae.id;W&&(ae.name&&ae.email?_t.set(W,`${ae.name} (${ae.email})`):ae.name&&_t.set(W,ae.name))}const Ln=(je.approvers??[]).map(ae=>_t.get(ae)??ae);N(Ln);const bt=$n.find(ae=>ae.role==="admin");if(bt){const ae=bt.userId??bt.id;ae&&I(_t.get(ae)??bt.name)}}})},[e]);const X=u?Object.entries(u).filter(([Q])=>Q!=="profile"&&Q!=="path").map(([Q,fe])=>`${Q} = ${fe}`).join(", "):"",Y=(Q,fe,He)=>{p(Q),m(fe),He&&x(He),c(3)},le=y.trim()!==Vc.trim()&&y.trim()!=="",C=Q=>{le&&!confirm("Replace your current intent with the AI draft?")||j(Q)},D=()=>{const Q=s==null?void 0:s.ttl,fe={intent:y},He=JSON.parse(sessionStorage.getItem("agentGate")??"{}");sessionStorage.setItem("agentGate",JSON.stringify({...He,bounds:u,context:h,contextLabels:w,gateContent:fe,ttlConfig:Q})),e("/agent/review")},_=async()=>{if(r){U(!0),R(null),ee(null),A(null),T([]),O(null);try{const Q=await $.aiIntentReview({profileId:r.profileId,newIntent:y,context:h??void 0});T(Q.grants??[]),Q.success?Q.review?R(Q.review):ee(Q.note??"No other authorizations on this profile to compare against."):A(Q.error??"Check failed.")}catch(Q){A(Q instanceof Error?Q.message:"Check failed.")}finally{U(!1)}}},V=Q=>{j(Q),(B||F||ie)&&(R(null),ee(null),A(null),T([]),O(null))};return v||!r||!s?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):o.jsxs(o.Fragment,{children:[o.jsx(Of,{currentStep:l,onStepClick:Q=>{Q>=2&&c(Q)}}),o.jsx(zv,{profileId:r.profileId,bounds:X||void 0,groupName:r.groupName,domain:r.domain}),l===2&&o.jsx("div",{className:"card",children:o.jsx(Wv,{profile:s,onConfirm:Y,onCancel:()=>e("/agent/new"),initialBounds:u||void 0,initialContext:h||void 0,profileConfig:E,approverNames:k,adminName:b})}),l===3&&o.jsxs("div",{className:"intent-layout",children:[o.jsx("div",{className:"card intent-pane chat tool",children:o.jsx(yo,{target:{kind:"intent",profileId:r.profileId,bounds:X||void 0},currentText:y,onApply:C})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsx("h3",{className:"card-title",children:"What should your agent know?"}),o.jsxs("div",{className:"field-editable",style:{marginBottom:0},children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Intent — your words, signed with the grant"]}),o.jsx("textarea",{className:"intent-textarea",value:y,onChange:Q=>V(Q.target.value)}),o.jsxs("div",{className:"char-counter",children:[y.length," / 2000"]})]}),o.jsxs("div",{style:{marginTop:"0.5rem"},children:[o.jsx("button",{type:"button",className:"btn btn-ghost",style:{fontSize:"0.8rem",padding:"0.4rem 0.75rem"},onClick:_,disabled:H||!le,children:H?"Checking…":"Check against my other grants"}),ie&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem",borderLeftColor:"var(--danger)"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"!"}),o.jsx("div",{className:"hint-body",children:ie})]}),F&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsx("div",{className:"hint-body",children:F})]}),B&&o.jsxs("div",{className:"hint-box",role:"note",style:{marginTop:"0.5rem"},children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsx("div",{className:"hint-head",children:"Intent review (advisory)"}),o.jsx("div",{style:{whiteSpace:"pre-wrap"},children:Qv(B,K,O,Ie(r.profileId))}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.4rem"},children:"Checked with your configured assistant. AI surfaces reality — you decide."})]})]})]}),o.jsxs("div",{className:"intent-footer",children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(2),children:"Back"}),o.jsx("button",{className:"btn btn-primary intent-continue-btn",onClick:D,disabled:!le,children:"Continue to Review"})]}),(((q=E==null?void 0:E.approvers)==null?void 0:q.length)??0)>0&&o.jsxs("div",{className:"hint-box",role:"note",children:[o.jsx("span",{className:"hint-icon","aria-hidden":"true",children:"i"}),o.jsxs("div",{className:"hint-body",children:[o.jsxs("div",{className:"hint-head",children:["Visible to ",k.length>0?k.join(", "):"the configured approvers"]}),"Your intent will be encrypted and shared with"," ",k.length>0?k.join(", "):"this profile's required approvers",". Only they can decrypt it — your Service Provider cannot. Each approver stores a copy as their accountability record."]})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>f(!0),"aria-label":"Open intent assistant",children:"Get help with intent"}),o.jsx(Bf,{open:g,onClose:()=>f(!1),ariaLabel:"Intent assistant",children:o.jsx(yo,{target:{kind:"intent",profileId:r.profileId,bounds:X||void 0},currentText:y,onApply:Q=>{C(Q),f(!1)}})}),P&&o.jsx("div",{className:"modal-backdrop",onClick:Q=>Q.target===Q.currentTarget&&O(null),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:P.length>1?`Existing authorizations (${P.length})`:"Existing authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>O(null),children:"×"})]}),o.jsx("div",{className:"modal-body",children:P.map((Q,fe)=>{var He;return o.jsxs("div",{style:{marginBottom:fe<P.length-1?"1rem":0,paddingBottom:fe<P.length-1?"1rem":0,borderBottom:fe<P.length-1?"1px solid var(--border)":"none"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Scope"}),o.jsx("div",{style:{marginBottom:"0.75rem"},children:Q.scope}),o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Intent"}),o.jsx("div",{style:{whiteSpace:"pre-wrap",marginBottom:"0.75rem"},children:((He=Q.intent)==null?void 0:He.trim())||"(no intent recorded)"}),Object.entries(Q.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Limits"}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)"},children:Object.entries(Q.bounds).filter(([Ve])=>Ve!=="profile"&&Ve!=="path").map(([Ve,je])=>`${Ve}: ${je}`).join(" · ")})]})]},fe)})})]})})]})]})}function Xv(e){return e.normalize("NFC").replace(/\r\n?/g,`
60
60
  `).split(`
61
61
  `).map(a=>a.replace(/[ \t]+$/,"")).join(`
62
62
  `).replace(/\n+$/,"")}async function vi(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}async function Va(e,t){const n=t.boundsSchema??t.frameSchema;if(!n)throw new Error("Profile has no boundsSchema or frameSchema");const a=n.keyOrder.map(i=>`${i}=${String(e[i])}`).join(`
63
63
  `);return`sha256:${await vi(a)}`}async function Df(e,t){if(!t.contextSchema||t.contextSchema.keyOrder.length===0)return`sha256:${await vi("")}`;const r=t.contextSchema.keyOrder.map(s=>`${s}=${String(e[s])}`).join(`
64
- `);return`sha256:${await vi(r)}`}async function xo(e){const t=new TextEncoder().encode(Xv(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}`}function Uf(e,t){if(!e.authorization_id)throw new Error("Attest result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??t.boundsHash,contextHash:t.contextHash,context:t.context,...t.contextLabels&&Object.keys(t.contextLabels).length>0?{contextLabels:t.contextLabels}:{},gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function Kc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function qv(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Zv(e,t,n){for(const r of e){const a=Kc(t[r]),s=Kc(n[r]);if(!(a.size===0||s.size===0)&&!qv(a,s))return!1}return!0}function ey(e){return e.length>24?`${e.slice(0,10)}…`:e}function Wf(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(s=>s.trim()).filter(Boolean).map(s=>{const i=r==null?void 0:r[s];return i?`${i} (${ey(s)})`:s}).join(", ")}function ty(){var bt,ae,W;const e=Kt(),{user:t,mode:n,domain:r}=Pe(),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState("per-action"),[g,w]=d.useState(1800),[x,y]=d.useState(86400),[j,h]=d.useState(""),[f,v]=d.useState("hours"),[S,E]=d.useState(""),[z,k]=d.useState(!0),[N,b]=d.useState(!1),[I,H]=d.useState(""),[U,O]=d.useState(null),[R,B]=d.useState([]),[ee,ie]=d.useState(!1),[A,K]=d.useState([]),[T,P]=d.useState(0);d.useEffect(()=>{var gn;const $=sessionStorage.getItem("agentAuth"),J=sessionStorage.getItem("agentGate");if(!$||!J){e("/agent/new");return}const te=JSON.parse($),Z=JSON.parse(J),Oe={bounds:Z.bounds??{},context:Z.context??{},contextLabels:Z.contextLabels??void 0,gateContent:Z.gateContent};s(te),l(Oe),Z.ttlConfig&&(w(Z.ttlConfig.default??1800),y(Z.ttlConfig.max??86400)),Z.templateMode==="automatic"?m("immediate"):Z.templateMode==="review"&&m("per-action");const Mn=((gn=Z.ttlConfig)==null?void 0:gn.max)??86400;if(typeof Z.templateTtl=="number"&&Z.templateTtl>0){const ke=Math.min(Z.templateTtl,Mn);w(ke),[3600,86400,604800,2592e3,31536e3].includes(ke)||(ke%86400===0?(h(String(ke/86400)),v("days")):(h(String(Math.max(1,Math.round(ke/3600)))),v("hours")))}L.getProfile(te.profileId).then(ke=>{var lt;if(u(ke),!S){const Ze=ke.name??((lt=te.profileId.split("/").pop())==null?void 0:lt.replace(/@.*$/,""))??"",Ae=[];if(Oe.context&&ke.contextSchema)for(const Ke of ke.contextSchema.keyOrder){const oe=Oe.context[Ke];if(oe!==void 0&&oe!==""){const yn=String(oe).split(",").map(Gf=>Gf.trim()).filter(Boolean);Ae.push(yn.join(", "))}}const vn=Ae.length>0?`${Ze}: ${Ae.join(" · ")}`:Ze;E(vn)}}).catch(()=>{}),te.groupId?Promise.all([L.getTeamProfileConfig(te.groupId,te.profileId).catch(()=>null),L.getGroupById(te.groupId).catch(()=>null),L.listUsers().catch(()=>[])]).then(([ke,lt,Ze])=>{if(O(ke),ke){const Ae=new Map;for(const oe of Ze){const yn=oe.name&&oe.email?`${oe.name} (${oe.email})`:oe.name||oe.email||oe.id;Ae.set(oe.id,yn)}const vn=(lt==null?void 0:lt.members)??[];for(const oe of vn){const yn=oe.userId??oe.id;yn&&(oe.name&&oe.email?Ae.set(yn,`${oe.name} (${oe.email})`):oe.name&&Ae.set(yn,oe.name))}const Ke=(ke.approvers??[]).map(oe=>Ae.get(oe)??oe);B(Ke)}}).finally(()=>{ie(!0)}):ie(!0)},[e]),d.useEffect(()=>{if(!(a!=null&&a.profileId))return;const $=a.profileId,J=sessionStorage.getItem("agentEditReplaces");L.getEnrichedAuthorizations().then(te=>{const Z=te.filter(Oe=>Oe.profileId===$&&Oe.authorizationId!==J).map(Oe=>({authorizationId:Oe.authorizationId,bounds:Oe.bounds,context:Oe.context??{},intent:Oe.intent}));K(Z)}).catch(()=>K([]))},[a==null?void 0:a.profileId]),d.useEffect(()=>{if(!i||!c||A.length===0){P(0);return}let $=!1;return(async()=>{const J=await Va(i.bounds,c),te=await Promise.all(A.map(Z=>Va(Z.bounds,c).catch(()=>null)));$||P(te.filter(Z=>Z===J).length)})().catch(()=>{$||P(0)}),()=>{$=!0}},[i,c,A]);const F=async()=>{if(!(!a||!i||!c||!t)){if(!a.groupId){H("No active group; cannot create authorization.");return}b(!0),H("");try{const $=r||a.domain||"owner",J=await Va(i.bounds,c),te=await Df(i.context,c),[Z,Oe]=await Promise.all([xo(i.gateContent.intent),xo(JSON.stringify({profile:a.profileId,domain:$,group:a.groupId}))]);let Mn,gn,ke,lt;if(a.isTeam){const Ke=await L.getApproversPubkeys(a.groupId,a.profileId);if(Ke.length>0){const oe=await L.encryptIntent(i.gateContent.intent,Ke);Mn=oe.intentCiphertext,gn=oe.encryptedKeys,ke=oe.approversFrozen,lt=oe.intentDisclosureHash}}const Ze=`authz_${crypto.randomUUID()}`,Ae=sessionStorage.getItem("agentEditReplaces")||void 0,vn=await L.attest({authorization_id:Ze,replaces:Ae,profile_id:a.profileId,bounds:i.bounds,bounds_hash:J,context_hash:te,domain:$,did:t.did,gate_content_hashes:{intent:Z},execution_context_hash:Oe,group_id:a.groupId,ttl:g,commitment_mode:p==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:Mn,encrypted_keys:gn,approvers_frozen:ke,intent_disclosure_hash:lt,disclose_identity:z});try{await L.pushGateContent(Uf(vn,{boundsHash:J,contextHash:te,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(Ke){try{await L.revokeAttestation(Ze,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${Ke instanceof Error?Ke.message:"Unknown error"})`)}if(Ae)try{await L.revokeAttestation(Ae,`Replaced by ${Ze} (edit)`),L.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Ze)}`)}catch($){H($ instanceof Error?$.message:"Attestation failed")}finally{b(!1)}}};if(!a||!i)return o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const X=Object.entries(i.bounds).filter(([$])=>$!=="profile"&&$!=="path"),Y=Object.entries(i.context),C=((U==null?void 0:U.caps)!=null?Object.keys(U.caps):[]).length!==0,D=R.length>0?R.join(", "):((U==null?void 0:U.approvers)??[]).join(", "),_=C?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${D}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",V=C?`Over-cap actions will be reviewed by you and ${D}. Within-cap actions run per the mode you chose above.`:`Approvers ${D} can read your intent but won't gate any action — no caps configured on this profile.`,q=!!((bt=U==null?void 0:U.approvers)!=null&&bt.length),Q=g>x,fe={flex:1,padding:"0.75rem",border:p==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},He={flex:1,padding:"0.75rem",border:p==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ve=((ae=c==null?void 0:c.contextSchema)==null?void 0:ae.keyOrder)??[],je=A.filter($=>Zv(Ve,i.context,$.context)),hn=je.length>0,qe=Ie(a.profileId),_t=$=>{const J=Object.values($).map(te=>String(te).trim()).filter(Boolean);return J.length>0?J.join(", "):"all (unscoped)"},$n=je.map($=>_t($.context)).join("; "),Ln=`This grant's scope overlaps an existing grant on ${qe} (scoped to: ${$n}). When two grants cover the same actions, the agent may act under either — the more permissive limits effectively apply. Confirm this is intended before authorizing.`;return o.jsxs(o.Fragment,{children:[o.jsx(Of,{currentStep:4,onStepClick:$=>{$<=3&&e(`/agent/gate?step=${$}`)}}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your authorization details before signing."}),I&&o.jsx("div",{className:"error-message",children:I}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Title"]}),o.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Ie(a.profileId)}: daily operations`,value:S,onChange:$=>E($.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this authorization on your dashboard."})]}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),o.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[o.jsxs("button",{onClick:()=>m("per-action"),style:He,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),o.jsxs("button",{onClick:()=>m("immediate"),style:fe,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]})]}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Duration"]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter($=>$.seconds<=x).map($=>o.jsx("button",{onClick:()=>{w($.seconds),h("")},style:{padding:"0.5rem 0.85rem",border:g===$.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:g===$.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:$.label},$.seconds)),o.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[o.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:j,onChange:$=>{h($.target.value);const J=parseInt($.target.value,10);if(J>0){const te=f==="days"?J*86400:J*3600;w(Math.min(te,x))}}}),o.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:f,onChange:$=>{v($.target.value);const J=parseInt(j,10);if(J>0){const te=$.target.value==="days"?J*86400:J*3600;w(Math.min(te,x))}},children:[o.jsx("option",{value:"hours",children:"hours"}),o.jsx("option",{value:"days",children:"days"})]})]}),Q&&o.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",x>=86400?`${Math.floor(x/86400)} days`:`${Math.floor(x/3600)} hours`]})]})]}),o.jsx("div",{className:"field-editable",children:o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:z,onChange:$=>k($.target.checked),style:{marginTop:"0.15rem"}}),o.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this authority",o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:'Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.'})]})]})}),o.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),o.jsxs("div",{className:"info-block",children:[o.jsxs("div",{className:"info-head",children:[o.jsx("span",{className:"info-title",children:"Intent"}),o.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=3"),children:"edit in step 3"})]}),o.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i.gateContent.intent})]}),(!!X.length||!!Y.length)&&o.jsxs("div",{className:"info-block",children:[o.jsxs("div",{className:"info-head",children:[o.jsx("span",{className:"info-title",children:"Scope & Limits"}),o.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=2"),children:"edit in step 2"})]}),o.jsxs("dl",{className:"info-kv",children:[Y.map(([$,J])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:$}),o.jsx("dd",{children:Wf($,J,i.contextLabels)})]},$)),X.map(([$,J])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:$}),o.jsx("dd",{children:String(J)})]},$))]})]}),o.jsxs("div",{className:"info-block",children:[o.jsx("div",{className:"info-head",children:o.jsx("span",{className:"info-title",children:"Authority"})}),o.jsxs("dl",{className:"info-kv",children:[o.jsx("dt",{children:"Profile"}),o.jsxs("dd",{children:[Ie(a.profileId),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),a.groupName&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Team"}),o.jsx("dd",{children:a.groupName})]}),a.groupId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Approvers"}),o.jsx("dd",{children:ee?(((W=U==null?void 0:U.approvers)==null?void 0:W.length)??0)===0?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"No approvers configured for this profile in this team. Your intent stays on your gateway."})]}):o.jsxs(o.Fragment,{children:[D,o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:_})]}):o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),T>0?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),o.jsxs("div",{children:[T===1?`An active grant on ${qe} already has exactly these limits.`:`${T} active grants on ${qe} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",o.jsx("strong",{children:"Extend"})," on the Authorizations page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,hn?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),o.jsx("div",{children:Ln})]})]}):null,o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/agent/gate"),children:"Back"}),o.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:F,disabled:N||!S.trim(),children:N?"Signing...":p==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),o.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:q?"block":"none"},children:V})]})]})}const ny={card:"💳",mail:"✉️"};function ry({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var le;const[s,i]=d.useState({}),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[m,g]=d.useState({}),[w,x]=d.useState(!1),[y,j]=d.useState(null),[h,f]=d.useState(!1),[v,S]=d.useState(!1),[E,z]=d.useState(!1),[k,N]=d.useState(!1),[b,I]=d.useState({});d.useEffect(()=>{let C=!1;return L.getCredential(e.id).then(D=>{var _;if(!(C||!D.configured)){if(c(!0),p(!0),D.fields){const V={};for(const q of e.credentials.fields)D.fields[q.key]!=null&&(V[q.key]=D.fields[q.key]);g(V)}if(e.oauth){const V=((_=D.fieldNames)==null?void 0:_.includes(e.oauth.tokenStorage))??!1;x(V),V&&L.getOAuthHealth(e.id).then(q=>{C||j(q)})}}}).catch(()=>{}),()=>{C=!0}},[e.id,e.oauth]);const H=!!e.oauth||e.credentials.fields.some(C=>!C.optional),U=e.oauth?w:l,O=!H||U,R=n==="starting"?"starting":O?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!w?"needs-oauth":"unconfigured",B=async()=>{if(e.credentials.fields.some(D=>{var _;return(_=s[D.key])==null?void 0:_.trim()})){f(!0);try{await L.setCredential(e.id,s),c(!0),i({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await A())}catch{a(`Failed to save ${e.name} credentials`)}finally{f(!1)}}},ee=async()=>{if(e.credentials.fields.some(D=>{var _;return(_=s[D.key])==null?void 0:_.trim()})){f(!0);try{await L.setCredential(e.id,s),i({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(N(!1),a(`${e.name} credentials updated — restarting...`),await A())}catch{a(`Failed to update ${e.name} credentials`)}finally{f(!1)}}},ie=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const C=setInterval(async()=>{var D;try{const _=await L.getCredential(e.id);_.configured&&e.oauth&&((D=_.fieldNames)!=null&&D.includes(e.oauth.tokenStorage))&&(x(!0),N(!1),j(null),clearInterval(C),a(`${e.name} connected — starting integration...`),L.getOAuthHealth(e.id).then(j).catch(()=>{}),await A())}catch{}},2e3);setTimeout(()=>clearInterval(C),12e4)},A=async()=>{z(!0);try{const C=await L.activateIntegration(e.id);C.warning?a(C.warning):a(`${e.name} integration started with ${C.tools.length} tools`),r()}catch(C){a(`Failed to start ${e.name}: ${C instanceof Error?C.message:"Unknown error"}`)}finally{z(!1)}},K=async()=>{try{await L.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},T=ny[e.icon]??"🔧",P=R==="running"?{c:"int-chip-ok",t:"Running"}:R==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},F=e.oauth&&w&&(y==null?void 0:y.status)==="failed",X=H?F?{c:"int-chip-bad",t:"Auth failed"}:U?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},Y=C=>C.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[o.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:T}),o.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),o.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[R!=="unconfigured"&&R!=="needs-oauth"&&o.jsxs("span",{className:`int-chip ${P.c}`,children:[o.jsx("span",{className:"int-dot"}),P.t]}),o.jsxs("span",{className:`int-chip ${X.c}`,children:[o.jsx("span",{className:"int-dot"}),X.t]})]})]}),e.oauth&&w&&o.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?o.jsxs(o.Fragment,{children:["Connected as ",o.jsx("b",{children:y.account})]}):o.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),F&&!k&&o.jsxs("div",{style:{marginTop:"0.7rem"},children:[o.jsxs("div",{className:"status-banner status-banner-error",style:{marginBottom:"0.6rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Authentication failed",y!=null&&y.error?` — ${y.error}`:"",". Reconnect to restore access."]})]}),o.jsxs("button",{className:"btn btn-primary btn-sm",onClick:ie,children:["Reconnect ",e.name]})]}),o.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[o.jsx("summary",{children:"Details"}),o.jsxs("div",{className:"int-meta",children:[o.jsx("span",{className:"int-k",children:"What"}),o.jsx("span",{children:e.description}),e.profile&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Profile"}),o.jsx("span",{children:e.profile})]}),e.oauth&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Scopes"}),o.jsx("span",{children:((le=e.oauth.scopes)==null?void 0:le.join(", "))||"—"})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Tools"}),o.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(R!=="running"||F)&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{onClick:()=>S(!v),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[o.jsx("span",{style:{transition:"transform 0.2s",transform:v?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),v&&o.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((C,D)=>o.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[o.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:D+1}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:C.title}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[Y(C.description),C.link&&o.jsxs(o.Fragment,{children:[" ",o.jsxs("a",{href:C.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},D))})]}),R==="starting"&&o.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[o.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),k&&o.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),u&&o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Your current values are filled in below (secret hidden — click ","“","show","”","). Edit them, then",e.oauth?" Save and Connect to re-link the account.":" Save to apply."]}),e.credentials.fields.map(C=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[o.jsx("label",{className:"form-label",children:C.label}),C.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:b[C.key]?"text":"password",placeholder:C.placeholder,value:s[C.key]||"",onChange:D=>i(_=>({..._,[C.key]:D.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>I(D=>({...D,[C.key]:!D[C.key]})),children:b[C.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:C.placeholder,value:s[C.key]||"",onChange:D=>i(_=>({..._,[C.key]:D.target.value}))})]},C.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary btn-sm",onClick:ee,disabled:h,children:h?"Saving…":"Save"}),e.oauth&&o.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:ie,children:["Connect ",e.name]}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{N(!1),i({})},children:"Cancel"})]})]}),!k&&R==="running"&&t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[o.jsx(tt,{to:"/agent/new",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Authorize agent"}),(e.credentials.fields.length>0||e.oauth)&&o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{i({...m}),N(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Change credentials"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:K,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),o.jsx("div",{style:{display:"none"},children:o.jsx(tt,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),R==="unconfigured"&&(()=>{const C=e.credentials.fields.every(V=>V.optional),D=e.credentials.fields.some(V=>!V.optional),_=e.credentials.fields.some(V=>{var q;return(q=s[V.key])==null?void 0:q.trim()});return o.jsxs(o.Fragment,{children:[u&&o.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[o.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",o.jsx("button",{onClick:()=>{c(!0),e.oauth&&x(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(V=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:V.label}),V.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:b[V.key]?"text":"password",placeholder:V.placeholder,value:s[V.key]||"",onChange:q=>i(Q=>({...Q,[V.key]:q.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>I(q=>({...q,[V.key]:!q[V.key]})),children:b[V.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:V.placeholder,value:s[V.key]||"",onChange:q=>i(Q=>({...Q,[V.key]:q.target.value}))})]},V.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[_&&o.jsx("button",{className:"btn btn-primary",onClick:B,disabled:h||D&&!e.credentials.fields.filter(V=>!V.optional).every(V=>{var q;return(q=s[V.key])==null?void 0:q.trim()}),children:h?"Saving...":"Save & Encrypt"}),C&&!_&&o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),R==="needs-oauth"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsxs("button",{className:"btn btn-primary",onClick:ie,children:["Connect ",e.name," Account"]}),o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),R==="ready"&&!t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),x(!1)},children:"Change Credentials"})]})]}),R==="ready"&&t&&!t.running&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[o.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":"Start"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:K,children:"Disable"})]})]})]})}function ay(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=jl(),[s,i]=d.useState(""),l=d.useCallback(c=>{i(c),setTimeout(()=>i(""),5e3)},[]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Integrations"}),o.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),s&&o.jsx("div",{className:"alert alert-success",children:s}),e?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):o.jsxs(o.Fragment,{children:[r.map(c=>o.jsx(ry,{manifest:c.manifest,integration:c.integration,state:c.state,onStatusChange:a,onSuccess:l},c.id)),r.length===0&&(n?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",o.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):o.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."}))]})]})}function oy(){var H,U,O;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Pe(),[a,s]=d.useState(null),[i,l]=d.useState(!1),[c,u]=d.useState(""),[p,m]=d.useState(""),[g,w]=d.useState(!1),[x,y]=d.useState(""),[j,h]=d.useState("");d.useEffect(()=>{fetch("/health").then(R=>R.json()).then(R=>{typeof R.spUrl=="string"&&h(R.spUrl)}).catch(()=>{})},[]),d.useEffect(()=>{if(!e){s(null);return}L.getGroupById(e.id).then(R=>{const B=R.group??R,ee=R.members??[],ie=R.isAdmin??!1,A=ee.map(K=>{const T=K.userId||K.id||"",P=K.role||(ie&&T===B.createdBy?"admin":"member");return{id:T,name:K.name||T.slice(0,8)||"Member",email:K.email||"",domains:K.domains||[],role:P,isAdmin:P==="admin"||ie&&T===B.createdBy}});s({id:B.id,name:B.name,members:A})}).catch(()=>s(null))},[e==null?void 0:e.id]);const f=(a==null?void 0:a.members.filter(R=>R.isAdmin))??[],v=(e==null?void 0:e.isAdmin)===!0&&f.length<=1&&f.some(R=>R.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",E=x.trim()===S&&!i,z=()=>{y(""),w(!0)},k=()=>{w(!1),y("")},N=async()=>{if(!(!e||!E)){l(!0),u("");try{await L.leaveTeam(e.id),await n(),m("You have left the team."),s(null),k()}catch(R){u(R instanceof Error?R.message:"Failed to leave team")}finally{l(!1)}}},b=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,I=j?`${j}/dashboard/groups`:void 0;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Team"}),o.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Service Provider dashboard."})]})}),c&&o.jsx("div",{className:"error-message",children:c}),p&&o.jsx("div",{className:"alert alert-success",children:p}),e?o.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{className:"card-header",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"card-title",children:e.name}),o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((H=a==null?void 0:a.members)==null?void 0:H.length)??0," ",(((U=a==null?void 0:a.members)==null?void 0:U.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),o.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(O=a==null?void 0:a.members)==null?void 0:O.map(R=>o.jsxs("div",{className:"member-row",children:[o.jsx("div",{className:"member-avatar",children:R.name.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase()}),o.jsxs("div",{className:"member-info",children:[o.jsx("div",{className:"member-name",children:R.name}),o.jsx("div",{className:"member-email",children:R.email})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:R.role})]},R.id)),o.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[b&&o.jsx("a",{className:"btn btn-secondary btn-sm",href:b,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),o.jsx("span",{title:v?"You are the only admin. Transfer admin to another member in your Service Provider dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:z,disabled:i||v,children:"Leave team"})})]})]}):o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[o.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every authorization you create here is in your personal context. You can join an existing team or create a new one in your Service Provider dashboard."}),I&&o.jsx("a",{className:"btn btn-primary btn-sm",href:I,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),g&&e&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:k,children:o.jsxs("div",{className:"card",onClick:R=>R.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[o.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",S,"?"]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsx("li",{children:"Revoke all authorizations you created in this team's context"}),o.jsx("li",{children:"Reject any pending action proposals you authored"}),o.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",o.jsx("strong",{children:"personal"})," authorizations are not affected."]}),o.jsxs("div",{className:"form-group",children:[o.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",o.jsx("code",{children:S})," to confirm:"]}),o.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:x,onChange:R=>y(R.target.value),placeholder:S,disabled:i,autoFocus:!0})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:k,disabled:i,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:N,disabled:!E,children:i?"Leaving...":"Leave team"})]})]})})]})}function sy({onDismiss:e}){const t=Kt(),{group:n,groupId:r,domain:a}=Pe(),[s,i]=d.useState([]),[l,c]=d.useState([]),[u,p]=d.useState([]),[m,g]=d.useState(!0),[w,x]=d.useState({}),[y,j]=d.useState(null);d.useEffect(()=>{Promise.all([L.listProfiles().catch(()=>[]),L.getIntegrationManifests().then(k=>k.manifests??[]).catch(()=>[]),L.getMcpHealth().then(k=>k.integrations??[]).catch(()=>[])]).then(async([k,N,b])=>{if(i(k),c(N),p(b),r){const I=await Promise.all(k.map(U=>L.getTeamProfileConfig(r,U.id).catch(()=>null))),H={};k.forEach((U,O)=>{const R=I[O];R&&(H[U.id]=R)}),x(H)}}).finally(()=>g(!1))},[r]);const h=new Map,f=new Map;for(const k of l)k.profile&&h.set(k.profile,k);for(const k of u){const N=l.find(b=>b.id===k.id);N!=null&&N.profile&&f.set(N.profile,k)}const v=s.filter(k=>{const N=k.id.replace(/@.*$/,"").split("/").pop()??k.id;return h.has(N)}),S=k=>k in w,E=(k,N)=>{if(!r){console.error("No active group when creating authorization");return}const b=S(k);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:k,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:b})),N?sessionStorage.setItem("agentGate",JSON.stringify({bounds:N.bounds,context:N.context,gateContent:{intent:N.intent},ttlConfig:{max:N.ttl},templateMode:N.mode,templateTtl:N.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},z=k=>{if(!r)return;const N=k.replace(/@.*$/,"").split("/").pop()??k,b=h.get(N);b!=null&&b.templates&&b.templates.length>0?j({profileId:k,manifest:b}):E(k)};if(y){const k=y.manifest.templates??[];return o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),o.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",y.manifest.name," authorization"]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),o.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(k.length,3)}, 1fr)`},children:k.map(N=>o.jsxs("button",{className:"template-card",onClick:()=>E(y.profileId,N),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[o.jsx("span",{className:`template-mode template-mode-${N.mode==="automatic"?"auto":"review"}`,children:N.mode==="automatic"?"Auto":"Review"}),o.jsx("span",{className:"template-risk","data-risk":N.risk,children:N.risk})]}),o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:N.name}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:N.description}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:N.tags.map(b=>o.jsx("span",{className:"template-tag",children:b},b))})]},N.name))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),o.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),o.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>E(y.profileId),children:"Custom — define your own limits and scope"})]})}return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:`
64
+ `);return`sha256:${await vi(r)}`}async function xo(e){const t=new TextEncoder().encode(Xv(e)),n=await crypto.subtle.digest("SHA-256",t);return`sha256:${Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join("")}`}function Uf(e,t){if(!e.authorization_id)throw new Error("Attest result lacks authorization_id — the Authority Server predates per-ceremony identity. Update the Authority Server (lockstep deploy).");return{authorizationId:e.authorization_id,boundsHash:e.bounds_hash??t.boundsHash,contextHash:t.contextHash,context:t.context,...t.contextLabels&&Object.keys(t.contextLabels).length>0?{contextLabels:t.contextLabels}:{},gateContent:t.gateContent,...t.path?{path:t.path}:{}}}function Kc(e){return e==null?new Set:new Set(String(e).split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}function qv(e,t){for(const n of e)if(t.has(n))return!0;return!1}function Zv(e,t,n){for(const r of e){const a=Kc(t[r]),s=Kc(n[r]);if(!(a.size===0||s.size===0)&&!qv(a,s))return!1}return!0}function ey(e){return e.length>24?`${e.slice(0,10)}…`:e}function Wf(e,t,n){const r=n==null?void 0:n[e];return String(t).split(",").map(s=>s.trim()).filter(Boolean).map(s=>{const i=r==null?void 0:r[s];return i?`${i} (${ey(s)})`:s}).join(", ")}function ty(){var bt,ae,W;const e=Kt(),{user:t,mode:n,domain:r}=Pe(),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,h]=d.useState("per-action"),[m,w]=d.useState(1800),[x,y]=d.useState(86400),[j,g]=d.useState(""),[f,v]=d.useState("hours"),[S,E]=d.useState(""),[z,k]=d.useState(!0),[N,b]=d.useState(!1),[I,H]=d.useState(""),[U,B]=d.useState(null),[R,F]=d.useState([]),[ee,ie]=d.useState(!1),[A,K]=d.useState([]),[T,P]=d.useState(0);d.useEffect(()=>{var gn;const L=sessionStorage.getItem("agentAuth"),J=sessionStorage.getItem("agentGate");if(!L||!J){e("/agent/new");return}const te=JSON.parse(L),Z=JSON.parse(J),Oe={bounds:Z.bounds??{},context:Z.context??{},contextLabels:Z.contextLabels??void 0,gateContent:Z.gateContent};s(te),l(Oe),Z.ttlConfig&&(w(Z.ttlConfig.default??1800),y(Z.ttlConfig.max??86400)),Z.templateMode==="automatic"?h("immediate"):Z.templateMode==="review"&&h("per-action");const Mn=((gn=Z.ttlConfig)==null?void 0:gn.max)??86400;if(typeof Z.templateTtl=="number"&&Z.templateTtl>0){const ke=Math.min(Z.templateTtl,Mn);w(ke),[3600,86400,604800,2592e3,31536e3].includes(ke)||(ke%86400===0?(g(String(ke/86400)),v("days")):(g(String(Math.max(1,Math.round(ke/3600)))),v("hours")))}$.getProfile(te.profileId).then(ke=>{var lt;if(u(ke),!S){const Ze=ke.name??((lt=te.profileId.split("/").pop())==null?void 0:lt.replace(/@.*$/,""))??"",Ae=[];if(Oe.context&&ke.contextSchema)for(const Ke of ke.contextSchema.keyOrder){const oe=Oe.context[Ke];if(oe!==void 0&&oe!==""){const yn=String(oe).split(",").map(Gf=>Gf.trim()).filter(Boolean);Ae.push(yn.join(", "))}}const vn=Ae.length>0?`${Ze}: ${Ae.join(" · ")}`:Ze;E(vn)}}).catch(()=>{}),te.groupId?Promise.all([$.getTeamProfileConfig(te.groupId,te.profileId).catch(()=>null),$.getGroupById(te.groupId).catch(()=>null),$.listUsers().catch(()=>[])]).then(([ke,lt,Ze])=>{if(B(ke),ke){const Ae=new Map;for(const oe of Ze){const yn=oe.name&&oe.email?`${oe.name} (${oe.email})`:oe.name||oe.email||oe.id;Ae.set(oe.id,yn)}const vn=(lt==null?void 0:lt.members)??[];for(const oe of vn){const yn=oe.userId??oe.id;yn&&(oe.name&&oe.email?Ae.set(yn,`${oe.name} (${oe.email})`):oe.name&&Ae.set(yn,oe.name))}const Ke=(ke.approvers??[]).map(oe=>Ae.get(oe)??oe);F(Ke)}}).finally(()=>{ie(!0)}):ie(!0)},[e]),d.useEffect(()=>{if(!(a!=null&&a.profileId))return;const L=a.profileId,J=sessionStorage.getItem("agentEditReplaces");$.getEnrichedAuthorizations().then(te=>{const Z=te.filter(Oe=>Oe.profileId===L&&Oe.authorizationId!==J).map(Oe=>({authorizationId:Oe.authorizationId,bounds:Oe.bounds,context:Oe.context??{},intent:Oe.intent}));K(Z)}).catch(()=>K([]))},[a==null?void 0:a.profileId]),d.useEffect(()=>{if(!i||!c||A.length===0){P(0);return}let L=!1;return(async()=>{const J=await Va(i.bounds,c),te=await Promise.all(A.map(Z=>Va(Z.bounds,c).catch(()=>null)));L||P(te.filter(Z=>Z===J).length)})().catch(()=>{L||P(0)}),()=>{L=!0}},[i,c,A]);const O=async()=>{if(!(!a||!i||!c||!t)){if(!a.groupId){H("No active group; cannot create authorization.");return}b(!0),H("");try{const L=r||a.domain||"owner",J=await Va(i.bounds,c),te=await Df(i.context,c),[Z,Oe]=await Promise.all([xo(i.gateContent.intent),xo(JSON.stringify({profile:a.profileId,domain:L,group:a.groupId}))]);let Mn,gn,ke,lt;if(a.isTeam){const Ke=await $.getApproversPubkeys(a.groupId,a.profileId);if(Ke.length>0){const oe=await $.encryptIntent(i.gateContent.intent,Ke);Mn=oe.intentCiphertext,gn=oe.encryptedKeys,ke=oe.approversFrozen,lt=oe.intentDisclosureHash}}const Ze=`authz_${crypto.randomUUID()}`,Ae=sessionStorage.getItem("agentEditReplaces")||void 0,vn=await $.attest({authorization_id:Ze,replaces:Ae,profile_id:a.profileId,bounds:i.bounds,bounds_hash:J,context_hash:te,domain:L,did:t.did,gate_content_hashes:{intent:Z},execution_context_hash:Oe,group_id:a.groupId,ttl:m,commitment_mode:p==="per-action"?"review":"automatic",title:S.trim(),intent_ciphertext:Mn,encrypted_keys:gn,approvers_frozen:ke,intent_disclosure_hash:lt,disclose_identity:z});try{await $.pushGateContent(Uf(vn,{boundsHash:J,contextHash:te,context:i.context,contextLabels:i.contextLabels,gateContent:i.gateContent}))}catch(Ke){try{await $.revokeAttestation(Ze,"Auto-revoked: gate content push failed")}catch{}throw new Error(`Authorization signed but gate content delivery failed. The attestation was revoked. Please try again. (${Ke instanceof Error?Ke.message:"Unknown error"})`)}if(Ae)try{await $.revokeAttestation(Ae,`Replaced by ${Ze} (edit)`),$.resyncGates().catch(()=>{})}catch{}sessionStorage.removeItem("agentAuth"),sessionStorage.removeItem("agentGate"),sessionStorage.removeItem("agentEditReplaces"),e(`/authorizations?highlight=${encodeURIComponent(Ze)}`)}catch(L){H(L instanceof Error?L.message:"Attestation failed")}finally{b(!1)}}};if(!a||!i)return o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."});const X=Object.entries(i.bounds).filter(([L])=>L!=="profile"&&L!=="path"),Y=Object.entries(i.context),C=((U==null?void 0:U.caps)!=null?Object.keys(U.caps):[]).length!==0,D=R.length>0?R.join(", "):((U==null?void 0:U.approvers)??[]).join(", "),_=C?`Within-cap actions run per the mode you choose above. Over-cap actions will require approval from you and ${D}, regardless of your mode.`:"No caps set — they won't gate any action, but your intent is encrypted and shared with them as an accountability record.",V=C?`Over-cap actions will be reviewed by you and ${D}. Within-cap actions run per the mode you chose above.`:`Approvers ${D} can read your intent but won't gate any action — no caps configured on this profile.`,q=!!((bt=U==null?void 0:U.approvers)!=null&&bt.length),Q=m>x,fe={flex:1,padding:"0.75rem",border:p==="immediate"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="immediate"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},He={flex:1,padding:"0.75rem",border:p==="per-action"?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"var(--radius)",background:p==="per-action"?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},Ve=((ae=c==null?void 0:c.contextSchema)==null?void 0:ae.keyOrder)??[],je=A.filter(L=>Zv(Ve,i.context,L.context)),hn=je.length>0,qe=Ie(a.profileId),_t=L=>{const J=Object.values(L).map(te=>String(te).trim()).filter(Boolean);return J.length>0?J.join(", "):"all (unscoped)"},$n=je.map(L=>_t(L.context)).join("; "),Ln=`This grant's scope overlaps an existing grant on ${qe} (scoped to: ${$n}). When two grants cover the same actions, the agent may act under either — the more permissive limits effectively apply. Confirm this is intended before authorizing.`;return o.jsxs(o.Fragment,{children:[o.jsx(Of,{currentStep:4,onStepClick:L=>{L<=3&&e(`/agent/gate?step=${L}`)}}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",style:{marginBottom:"0.25rem"},children:"Review & Commit"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1.5rem"},children:"Review your authorization details before signing."}),I&&o.jsx("div",{className:"error-message",children:I}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Title"]}),o.jsx("input",{type:"text",className:"form-input",placeholder:`e.g. ${Ie(a.profileId)}: daily operations`,value:S,onChange:L=>E(L.target.value),maxLength:80,style:{fontSize:"0.9rem"}}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"A short name to identify this authorization on your dashboard."})]}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Commitment"]}),o.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[o.jsxs("button",{onClick:()=>h("per-action"),style:He,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Review Each Action"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"You review and approve each action before it executes."})]}),o.jsxs("button",{onClick:()=>h("immediate"),style:fe,children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.85rem",marginBottom:"0.25rem",color:"var(--text-primary)"},children:"Automatic"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)"},children:"Agent acts freely within your limits."})]})]})]}),o.jsxs("div",{className:"field-editable",children:[o.jsxs("div",{className:"field-label",children:[o.jsx("span",{className:"pen",children:"✎"})," Duration"]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[[{label:"1 hour",seconds:3600},{label:"24 hours",seconds:86400},{label:"7 days",seconds:604800},{label:"30 days",seconds:2592e3},{label:"1 year",seconds:31536e3}].filter(L=>L.seconds<=x).map(L=>o.jsx("button",{onClick:()=>{w(L.seconds),g("")},style:{padding:"0.5rem 0.85rem",border:m===L.seconds?"2px solid var(--accent)":"1px solid var(--border)",borderRadius:"0.375rem",background:m===L.seconds?"var(--accent-subtle)":"var(--bg-elevated)",cursor:"pointer",fontSize:"0.85rem",fontFamily:"inherit",color:"var(--text-primary)"},children:L.label},L.seconds)),o.jsxs("div",{style:{display:"flex",gap:"0.375rem",alignItems:"center"},children:[o.jsx("input",{type:"number",className:"form-input",style:{width:"5rem",padding:"0.45rem 0.6rem",fontSize:"0.85rem"},placeholder:"Custom",value:j,onChange:L=>{g(L.target.value);const J=parseInt(L.target.value,10);if(J>0){const te=f==="days"?J*86400:J*3600;w(Math.min(te,x))}}}),o.jsxs("select",{className:"form-input",style:{padding:"0.45rem 0.5rem",fontSize:"0.85rem"},value:f,onChange:L=>{v(L.target.value);const J=parseInt(j,10);if(J>0){const te=L.target.value==="days"?J*86400:J*3600;w(Math.min(te,x))}},children:[o.jsx("option",{value:"hours",children:"hours"}),o.jsx("option",{value:"days",children:"days"})]})]}),Q&&o.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--danger)"},children:["Maximum: ",x>=86400?`${Math.floor(x/86400)} days`:`${Math.floor(x/3600)} hours`]})]})]}),o.jsx("div",{className:"field-editable",children:o.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.5rem",cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:z,onChange:L=>k(L.target.checked),style:{marginTop:"0.15rem"}}),o.jsxs("span",{style:{fontSize:"0.8rem"},children:["Show my verified name on actions under this authority",o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",marginTop:"0.15rem"},children:'Adds "verified by Suveren" with your name to outgoing content. Takes effect only if your identity is verified; otherwise actions stay pseudonymous.'})]})]})}),o.jsx("div",{className:"info-section-label",children:"What you are signing — set in previous steps"}),o.jsxs("div",{className:"info-block",children:[o.jsxs("div",{className:"info-head",children:[o.jsx("span",{className:"info-title",children:"Intent"}),o.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=3"),children:"edit in step 3"})]}),o.jsx("div",{style:{whiteSpace:"pre-wrap"},children:i.gateContent.intent})]}),(!!X.length||!!Y.length)&&o.jsxs("div",{className:"info-block",children:[o.jsxs("div",{className:"info-head",children:[o.jsx("span",{className:"info-title",children:"Scope & Limits"}),o.jsx("button",{className:"info-edit",onClick:()=>e("/agent/gate?step=2"),children:"edit in step 2"})]}),o.jsxs("dl",{className:"info-kv",children:[Y.map(([L,J])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:L}),o.jsx("dd",{children:Wf(L,J,i.contextLabels)})]},L)),X.map(([L,J])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:L}),o.jsx("dd",{children:String(J)})]},L))]})]}),o.jsxs("div",{className:"info-block",children:[o.jsx("div",{className:"info-head",children:o.jsx("span",{className:"info-title",children:"Authority"})}),o.jsxs("dl",{className:"info-kv",children:[o.jsx("dt",{children:"Profile"}),o.jsxs("dd",{children:[Ie(a.profileId),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:a.profileId})]}),a.groupName&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Team"}),o.jsx("dd",{children:a.groupName})]}),a.groupId&&o.jsxs(o.Fragment,{children:[o.jsx("dt",{children:"Approvers"}),o.jsx("dd",{children:ee?(((W=U==null?void 0:U.approvers)==null?void 0:W.length)??0)===0?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"None — solo authorization"}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:"No approvers configured for this profile in this team. Your intent stays on your gateway."})]}):o.jsxs(o.Fragment,{children:[D,o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:_})]}):o.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Loading…"})})]})]})]}),T>0?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Identical limits to an existing grant"}),o.jsxs("div",{children:[T===1?`An active grant on ${qe} already has exactly these limits.`:`${T} active grants on ${qe} already have exactly these limits.`," ","If you meant to give the existing grant more time, use ",o.jsx("strong",{children:"Extend"})," on the Authorizations page instead — authorizing here creates a separate, independent grant with its own intent and usage counters."]})]})]}):null,hn?o.jsxs("div",{style:{display:"flex",gap:"0.625rem",padding:"0.75rem 0.875rem",marginBottom:"1.25rem",border:"1px solid var(--warning)",borderLeft:"3px solid var(--warning)",borderRadius:"0.5rem",background:"var(--bg-elevated)",fontSize:"0.82rem",color:"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{color:"var(--warning)",fontWeight:700},children:"⚠"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--warning)",marginBottom:"0.2rem"},children:"Overlapping scope"}),o.jsx("div",{children:Ln})]})]}):null,o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:()=>e("/agent/gate"),children:"Back"}),o.jsx("button",{className:"btn btn-primary btn-lg",style:{flex:1},onClick:O,disabled:N||!S.trim(),children:N?"Signing...":p==="immediate"?"Authorize":"Authorize (Review Mode)"})]}),o.jsx("div",{style:{marginTop:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)",textAlign:"center",display:q?"block":"none"},children:V})]})]})}const ny={card:"💳",mail:"✉️"};function ry({manifest:e,integration:t,state:n,onStatusChange:r,onSuccess:a}){var le;const[s,i]=d.useState({}),[l,c]=d.useState(!1),[u,p]=d.useState(!1),[h,m]=d.useState({}),[w,x]=d.useState(!1),[y,j]=d.useState(null),[g,f]=d.useState(!1),[v,S]=d.useState(!1),[E,z]=d.useState(!1),[k,N]=d.useState(!1),[b,I]=d.useState({});d.useEffect(()=>{let C=!1;return $.getCredential(e.id).then(D=>{var _;if(!(C||!D.configured)){if(c(!0),p(!0),D.fields){const V={};for(const q of e.credentials.fields)D.fields[q.key]!=null&&(V[q.key]=D.fields[q.key]);m(V)}if(e.oauth){const V=((_=D.fieldNames)==null?void 0:_.includes(e.oauth.tokenStorage))??!1;x(V),V&&$.getOAuthHealth(e.id).then(q=>{C||j(q)})}}}).catch(()=>{}),()=>{C=!0}},[e.id,e.oauth]);const H=!!e.oauth||e.credentials.fields.some(C=>!C.optional),U=e.oauth?w:l,B=!H||U,R=n==="starting"?"starting":B?t!=null&&t.running?"running":!l&&e.credentials.fields.length>0?"unconfigured":"ready":e.oauth&&l&&!w?"needs-oauth":"unconfigured",F=async()=>{if(e.credentials.fields.some(D=>{var _;return(_=s[D.key])==null?void 0:_.trim()})){f(!0);try{await $.setCredential(e.id,s),c(!0),i({}),e.oauth?a(`${e.name} credentials saved!`):(a(`${e.name} credentials saved — starting integration...`),await A())}catch{a(`Failed to save ${e.name} credentials`)}finally{f(!1)}}},ee=async()=>{if(e.credentials.fields.some(D=>{var _;return(_=s[D.key])==null?void 0:_.trim()})){f(!0);try{await $.setCredential(e.id,s),i({}),c(!0),e.oauth?a(`${e.name} credentials saved — now click Connect.`):(N(!1),a(`${e.name} credentials updated — restarting...`),await A())}catch{a(`Failed to update ${e.name} credentials`)}finally{f(!1)}}},ie=()=>{window.open(`/auth/oauth/${e.id}/start`,"_blank","width=600,height=700");const C=setInterval(async()=>{var D;try{const _=await $.getCredential(e.id);_.configured&&e.oauth&&((D=_.fieldNames)!=null&&D.includes(e.oauth.tokenStorage))&&(x(!0),N(!1),j(null),clearInterval(C),a(`${e.name} connected — starting integration...`),$.getOAuthHealth(e.id).then(j).catch(()=>{}),await A())}catch{}},2e3);setTimeout(()=>clearInterval(C),12e4)},A=async()=>{z(!0);try{const C=await $.activateIntegration(e.id);C.warning?a(C.warning):a(`${e.name} integration started with ${C.tools.length} tools`),r()}catch(C){a(`Failed to start ${e.name}: ${C instanceof Error?C.message:"Unknown error"}`)}finally{z(!1)}},K=async()=>{try{await $.removeMcpIntegration(e.id),a(`${e.name} integration removed`),r()}catch{a(`Failed to remove ${e.name}`)}},T=ny[e.icon]??"🔧",P=R==="running"?{c:"int-chip-ok",t:"Running"}:R==="starting"?{c:"int-chip-idle",t:"Starting"}:t&&!t.running&&t.error?{c:"int-chip-bad",t:"Crashed"}:{c:"int-chip-idle",t:"Stopped"},O=e.oauth&&w&&(y==null?void 0:y.status)==="failed",X=H?O?{c:"int-chip-bad",t:"Auth failed"}:U?{c:"int-chip-ok",t:"Auth OK"}:{c:"int-chip-idle",t:"Not set up"}:{c:"int-chip-idle",t:"No auth"},Y=C=>C.replace(/https?:\/\/[^\s)]+\/auth\/oauth\/[a-z-]+\/callback/gi,`${window.location.origin}/auth/oauth/${e.id}/callback`);return o.jsxs("div",{className:"card",style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem"},children:[o.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1.2},children:T}),o.jsx("h3",{className:"card-title",style:{margin:0,flex:1,alignSelf:"center"},children:e.name}),o.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap",justifyContent:"flex-end"},children:[R!=="unconfigured"&&R!=="needs-oauth"&&o.jsxs("span",{className:`int-chip ${P.c}`,children:[o.jsx("span",{className:"int-dot"}),P.t]}),o.jsxs("span",{className:`int-chip ${X.c}`,children:[o.jsx("span",{className:"int-dot"}),X.t]})]})]}),e.oauth&&w&&o.jsx("div",{className:"int-account",style:{marginTop:"0.7rem"},children:y!=null&&y.account?o.jsxs(o.Fragment,{children:["Connected as ",o.jsx("b",{children:y.account})]}):o.jsx("span",{className:"int-none",children:"Account not recorded — reconnect to capture which account is used"})}),O&&!k&&o.jsxs("div",{style:{marginTop:"0.7rem"},children:[o.jsxs("div",{className:"status-banner status-banner-error",style:{marginBottom:"0.6rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Authentication failed",y!=null&&y.error?` — ${y.error}`:"",". Reconnect to restore access."]})]}),o.jsxs("button",{className:"btn btn-primary btn-sm",onClick:ie,children:["Reconnect ",e.name]})]}),o.jsxs("details",{className:"int-details",style:{marginTop:"0.85rem",marginBottom:"1.25rem"},children:[o.jsx("summary",{children:"Details"}),o.jsxs("div",{className:"int-meta",children:[o.jsx("span",{className:"int-k",children:"What"}),o.jsx("span",{children:e.description}),e.profile&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Profile"}),o.jsx("span",{children:e.profile})]}),e.oauth&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Scopes"}),o.jsx("span",{children:((le=e.oauth.scopes)==null?void 0:le.join(", "))||"—"})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"int-k",children:"Tools"}),o.jsxs("span",{children:[t.toolCount," gated"]})]})]})]}),e.setupGuide&&e.setupGuide.length>0&&(R!=="running"||O)&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{onClick:()=>S(!v),style:{background:"none",border:"none",padding:0,fontSize:"0.8rem",color:"var(--accent)",cursor:"pointer",display:"flex",alignItems:"center",gap:"0.375rem"},children:[o.jsx("span",{style:{transition:"transform 0.2s",transform:v?"rotate(90deg)":"rotate(0deg)",display:"inline-block"},children:"▶"}),"How to set up ",e.name]}),v&&o.jsx("div",{style:{marginTop:"0.75rem",paddingLeft:"0.25rem"},children:e.setupGuide.map((C,D)=>o.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"0.75rem"},children:[o.jsx("div",{style:{width:"1.5rem",height:"1.5rem",borderRadius:"50%",background:"var(--border)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.7rem",fontWeight:700,flexShrink:0,marginTop:"0.1rem"},children:D+1}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.125rem"},children:C.title}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",lineHeight:1.5},children:[Y(C.description),C.link&&o.jsxs(o.Fragment,{children:[" ",o.jsxs("a",{href:C.link,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"0.8rem"},children:["Open ","↗"]})]})]})]})]},D))})]}),R==="starting"&&o.jsxs("div",{className:"service-status",style:{color:"var(--warning)"},children:[o.jsx("span",{className:"service-status-dot",style:{background:"var(--warning)"}}),"Starting…"]}),k&&o.jsxs("div",{style:{marginTop:"0.7rem",paddingTop:"0.85rem",borderTop:"1px solid var(--border)"},children:[o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,marginBottom:"0.5rem"},children:"Change credentials"}),u&&o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-muted)",marginBottom:"0.6rem"},children:["Your current values are filled in below (secret hidden — click ","“","show","”","). Edit them, then",e.oauth?" Save and Connect to re-link the account.":" Save to apply."]}),e.credentials.fields.map(C=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.6rem"},children:[o.jsx("label",{className:"form-label",children:C.label}),C.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:b[C.key]?"text":"password",placeholder:C.placeholder,value:s[C.key]||"",onChange:D=>i(_=>({..._,[C.key]:D.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>I(D=>({...D,[C.key]:!D[C.key]})),children:b[C.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:C.placeholder,value:s[C.key]||"",onChange:D=>i(_=>({..._,[C.key]:D.target.value}))})]},C.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary btn-sm",onClick:ee,disabled:g,children:g?"Saving…":"Save"}),e.oauth&&o.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:ie,children:["Connect ",e.name]}),o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>{N(!1),i({})},children:"Cancel"})]})]}),!k&&R==="running"&&t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[o.jsx(tt,{to:"/agent/new",className:"btn btn-primary btn-sm",style:{textDecoration:"none"},children:"Authorize agent"}),(e.credentials.fields.length>0||e.oauth)&&o.jsx("button",{className:"btn btn-sm btn-secondary",onClick:()=>{i({...h}),N(!0)},title:"Re-enter client ID / secret (e.g. a new OAuth client).",children:"Change credentials"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{className:"btn btn-sm btn-ghost",style:{color:"var(--danger)"},onClick:K,title:"Stops the subprocess and removes the integration from the registry. It will NOT auto-start on next gateway restart. Re-enable with Install.",children:"Disable"})]}),o.jsx("div",{style:{display:"none"},children:o.jsx(tt,{to:"/agent/new",className:"btn btn-ghost btn-sm",style:{textDecoration:"none",display:"block",textAlign:"center"},children:"Authorize your agent"})})]}),R==="unconfigured"&&(()=>{const C=e.credentials.fields.every(V=>V.optional),D=e.credentials.fields.some(V=>!V.optional),_=e.credentials.fields.some(V=>{var q;return(q=s[V.key])==null?void 0:q.trim()});return o.jsxs(o.Fragment,{children:[u&&o.jsxs("div",{className:"alert",style:{fontSize:"0.8rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.5rem 0.75rem",marginBottom:"0.75rem",color:"var(--text-secondary)"},children:[o.jsx("strong",{style:{color:"var(--text-primary)"},children:"Credentials on file."})," ","Existing values are encrypted in the vault and not shown. Enter new values below to replace them, or"," ",o.jsx("button",{onClick:()=>{c(!0),e.oauth&&x(!0)},style:{background:"none",border:"none",padding:0,color:"var(--accent)",cursor:"pointer",textDecoration:"underline"},children:"keep existing"}),"."]}),e.oauth&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Step 1 of 2 — enter credentials, then connect your account."}),e.setupHint&&!u&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:e.setupHint}),e.credentials.fields.map(V=>o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:V.label}),V.type==="password"?o.jsxs("div",{className:"cred-field",children:[o.jsx("input",{className:"form-input",type:b[V.key]?"text":"password",placeholder:V.placeholder,value:s[V.key]||"",onChange:q=>i(Q=>({...Q,[V.key]:q.target.value}))}),o.jsx("button",{className:"cred-toggle",onClick:()=>I(q=>({...q,[V.key]:!q[V.key]})),children:b[V.key]?"hide":"show"})]}):o.jsx("input",{className:"form-input",type:"text",placeholder:V.placeholder,value:s[V.key]||"",onChange:q=>i(Q=>({...Q,[V.key]:q.target.value}))})]},V.key)),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[_&&o.jsx("button",{className:"btn btn-primary",onClick:F,disabled:g||D&&!e.credentials.fields.filter(V=>!V.optional).every(V=>{var q;return(q=s[V.key])==null?void 0:q.trim()}),children:g?"Saving...":"Save & Encrypt"}),C&&!_&&o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":`Activate ${e.name}`})]})]})})(),R==="needs-oauth"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.25rem"},children:["✓"," Step 1 done — credentials saved"]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:["Step 2: connect your ",e.name," account to authorize access."]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsxs("button",{className:"btn btn-primary",onClick:ie,children:["Connect ",e.name," Account"]}),o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Change Credentials"})]})]}),R==="ready"&&!t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--success)",marginBottom:"0.75rem"},children:["✓"," ",e.oauth?`${e.name} account connected`:"Credentials configured"]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":`Start ${e.name} Integration`}),!e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>c(!1),children:"Update Credentials"}),e.oauth&&o.jsx("button",{className:"btn btn-ghost",onClick:()=>{c(!1),x(!1)},children:"Change Credentials"})]})]}),R==="ready"&&t&&!t.running&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"service-status service-status-error",style:{marginBottom:"0.75rem"},children:[o.jsx("span",{className:"service-status-dot"}),"Not running"]}),t.error&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--danger)",marginBottom:"0.75rem"},children:t.error}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:A,disabled:E,children:E?"Starting...":"Start"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:K,children:"Disable"})]})]})]})}function ay(){const{loading:e,mcpServerUp:t,manifestsError:n,entries:r,refresh:a}=jl(),[s,i]=d.useState(""),l=d.useCallback(c=>{i(c),setTimeout(()=>i(""),5e3)},[]);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Integrations"}),o.jsx("p",{className:"page-subtitle",children:"Connect external services and manage MCP integrations."})]}),s&&o.jsx("div",{className:"alert alert-success",children:s}),e?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading integrations..."}):t===!1?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsx("span",{className:"status-banner-text",children:"MCP server is not reachable. Make sure it is running."})]}):o.jsxs(o.Fragment,{children:[r.map(c=>o.jsx(ry,{manifest:c.manifest,integration:c.integration,state:c.state,onStatusChange:a,onSuccess:l},c.id)),r.length===0&&(n?o.jsxs("div",{className:"status-banner status-banner-error",children:[o.jsx("span",{className:"status-banner-icon",children:"!"}),o.jsxs("span",{className:"status-banner-text",children:["Couldn't load integrations — the gateway can't reach its MCP server (or you're signed out). Check the control-plane's"," ",o.jsx("code",{children:"SUVEREN_MCP_INTERNAL_URL"})," (dev MCP is :3431), then refresh."]})]}):o.jsx("p",{style:{color:"var(--text-tertiary)",textAlign:"center",marginTop:"2rem"},children:"No integrations available yet."}))]})]})}function oy(){var H,U,B;const{activeTeam:e,activeMembership:t,refreshGroups:n,user:r}=Pe(),[a,s]=d.useState(null),[i,l]=d.useState(!1),[c,u]=d.useState(""),[p,h]=d.useState(""),[m,w]=d.useState(!1),[x,y]=d.useState(""),[j,g]=d.useState("");d.useEffect(()=>{fetch("/health").then(R=>R.json()).then(R=>{typeof R.spUrl=="string"&&g(R.spUrl)}).catch(()=>{})},[]),d.useEffect(()=>{if(!e){s(null);return}$.getGroupById(e.id).then(R=>{const F=R.group??R,ee=R.members??[],ie=R.isAdmin??!1,A=ee.map(K=>{const T=K.userId||K.id||"",P=K.role||(ie&&T===F.createdBy?"admin":"member");return{id:T,name:K.name||T.slice(0,8)||"Member",email:K.email||"",domains:K.domains||[],role:P,isAdmin:P==="admin"||ie&&T===F.createdBy}});s({id:F.id,name:F.name,members:A})}).catch(()=>s(null))},[e==null?void 0:e.id]);const f=(a==null?void 0:a.members.filter(R=>R.isAdmin))??[],v=(e==null?void 0:e.isAdmin)===!0&&f.length<=1&&f.some(R=>R.id===(r==null?void 0:r.id)),S=(e==null?void 0:e.name)??"",E=x.trim()===S&&!i,z=()=>{y(""),w(!0)},k=()=>{w(!1),y("")},N=async()=>{if(!(!e||!E)){l(!0),u("");try{await $.leaveTeam(e.id),await n(),h("You have left the team."),s(null),k()}catch(R){u(R instanceof Error?R.message:"Failed to leave team")}finally{l(!1)}}},b=e&&j?`${j}/dashboard/groups/${e.id}`:void 0,I=j?`${j}/dashboard/groups`:void 0;return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"page-header",children:o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Team"}),o.jsx("p",{className:"page-subtitle",children:"Your current team context. Team management lives in your Service Provider dashboard."})]})}),c&&o.jsx("div",{className:"error-message",children:c}),p&&o.jsx("div",{className:"alert alert-success",children:p}),e?o.jsxs("div",{className:"card",style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{className:"card-header",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"card-title",children:e.name}),o.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.125rem"},children:[((H=a==null?void 0:a.members)==null?void 0:H.length)??0," ",(((U=a==null?void 0:a.members)==null?void 0:U.length)??0)===1?"member":"members",e.isAdmin&&" · You are admin"]})]}),o.jsx("span",{className:"status-badge status-active",children:"Active"})]}),(B=a==null?void 0:a.members)==null?void 0:B.map(R=>o.jsxs("div",{className:"member-row",children:[o.jsx("div",{className:"member-avatar",children:R.name.split(" ").map(F=>F[0]).join("").slice(0,2).toUpperCase()}),o.jsxs("div",{className:"member-info",children:[o.jsx("div",{className:"member-name",children:R.name}),o.jsx("div",{className:"member-email",children:R.email})]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:R.role})]},R.id)),o.jsxs("div",{style:{marginTop:"1.25rem",paddingTop:"1rem",borderTop:"1px solid var(--border)",display:"flex",alignItems:"center",gap:"0.75rem",flexWrap:"wrap"},children:[b&&o.jsx("a",{className:"btn btn-secondary btn-sm",href:b,target:"_blank",rel:"noopener noreferrer",children:"Manage this team in your Service Provider →"}),o.jsx("span",{title:v?"You are the only admin. Transfer admin to another member in your Service Provider dashboard before leaving.":void 0,style:{marginLeft:"auto"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--text-tertiary)"},onClick:z,disabled:i||v,children:"Leave team"})})]})]}):o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem 1.5rem"},children:[o.jsx("h3",{style:{margin:"0 0 0.5rem 0",fontSize:"1rem"},children:"You are working solo."}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",maxWidth:480,marginLeft:"auto",marginRight:"auto"},children:"Every authorization you create here is in your personal context. You can join an existing team or create a new one in your Service Provider dashboard."}),I&&o.jsx("a",{className:"btn btn-primary btn-sm",href:I,target:"_blank",rel:"noopener noreferrer",children:"Open Service Provider dashboard →"})]}),m&&e&&o.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"leave-team-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"1rem"},onClick:k,children:o.jsxs("div",{className:"card",onClick:R=>R.stopPropagation(),style:{maxWidth:480,width:"100%",margin:0},children:[o.jsxs("h3",{id:"leave-team-title",className:"card-title",style:{marginBottom:"0.5rem"},children:["Leave ",S,"?"]}),o.jsx("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"0.75rem"},children:"Leaving will:"}),o.jsxs("ul",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem",paddingLeft:"1.25rem",lineHeight:1.6},children:[o.jsx("li",{children:"Revoke all authorizations you created in this team's context"}),o.jsx("li",{children:"Reject any pending action proposals you authored"}),o.jsx("li",{children:"Disable your membership — rejoining requires admin reactivation"})]}),o.jsxs("p",{style:{fontSize:"0.875rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:["Your ",o.jsx("strong",{children:"personal"})," authorizations are not affected."]}),o.jsxs("div",{className:"form-group",children:[o.jsxs("label",{htmlFor:"leave-confirm-input",style:{fontSize:"0.825rem",display:"block",marginBottom:"0.375rem"},children:["Type ",o.jsx("code",{children:S})," to confirm:"]}),o.jsx("input",{id:"leave-confirm-input",className:"form-input",type:"text",value:x,onChange:R=>y(R.target.value),placeholder:S,disabled:i,autoFocus:!0})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"flex-end",marginTop:"1rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:k,disabled:i,children:"Cancel"}),o.jsx("button",{className:"btn btn-secondary",style:{color:"var(--danger, #e53e3e)"},onClick:N,disabled:!E,children:i?"Leaving...":"Leave team"})]})]})})]})}function sy({onDismiss:e}){const t=Kt(),{group:n,groupId:r,domain:a}=Pe(),[s,i]=d.useState([]),[l,c]=d.useState([]),[u,p]=d.useState([]),[h,m]=d.useState(!0),[w,x]=d.useState({}),[y,j]=d.useState(null);d.useEffect(()=>{Promise.all([$.listProfiles().catch(()=>[]),$.getIntegrationManifests().then(k=>k.manifests??[]).catch(()=>[]),$.getMcpHealth().then(k=>k.integrations??[]).catch(()=>[])]).then(async([k,N,b])=>{if(i(k),c(N),p(b),r){const I=await Promise.all(k.map(U=>$.getTeamProfileConfig(r,U.id).catch(()=>null))),H={};k.forEach((U,B)=>{const R=I[B];R&&(H[U.id]=R)}),x(H)}}).finally(()=>m(!1))},[r]);const g=new Map,f=new Map;for(const k of l)k.profile&&g.set(k.profile,k);for(const k of u){const N=l.find(b=>b.id===k.id);N!=null&&N.profile&&f.set(N.profile,k)}const v=s.filter(k=>{const N=k.id.replace(/@.*$/,"").split("/").pop()??k.id;return g.has(N)}),S=k=>k in w,E=(k,N)=>{if(!r){console.error("No active group when creating authorization");return}const b=S(k);sessionStorage.setItem("agentAuth",JSON.stringify({profileId:k,groupId:r,groupName:(n==null?void 0:n.name)??null,domain:a,isTeam:b})),N?sessionStorage.setItem("agentGate",JSON.stringify({bounds:N.bounds,context:N.context,gateContent:{intent:N.intent},ttlConfig:{max:N.ttl},templateMode:N.mode,templateTtl:N.ttl})):sessionStorage.removeItem("agentGate"),j(null),e==null||e(),t("/agent/gate")},z=k=>{if(!r)return;const N=k.replace(/@.*$/,"").split("/").pop()??k,b=g.get(N);b!=null&&b.templates&&b.templates.length>0?j({profileId:k,manifest:b}):E(k)};if(y){const k=y.manifest.templates??[];return o.jsxs(o.Fragment,{children:[o.jsx("button",{className:"btn btn-ghost btn-sm",style:{marginBottom:"1rem"},onClick:()=>j(null),children:"← Back to profiles"}),o.jsxs("h3",{style:{margin:"0 0 0.25rem 0",fontSize:"1rem"},children:["Set up ",y.manifest.name," authorization"]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginTop:"0.5rem",marginBottom:"0.75rem",fontWeight:600},children:"Quick start"}),o.jsx("div",{style:{display:"grid",gap:"0.75rem",gridTemplateColumns:`repeat(${Math.min(k.length,3)}, 1fr)`},children:k.map(N=>o.jsxs("button",{className:"template-card",onClick:()=>E(y.profileId,N),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.375rem"},children:[o.jsx("span",{className:`template-mode template-mode-${N.mode==="automatic"?"auto":"review"}`,children:N.mode==="automatic"?"Auto":"Review"}),o.jsx("span",{className:"template-risk","data-risk":N.risk,children:N.risk})]}),o.jsx("div",{style:{fontSize:"0.85rem",fontWeight:600,color:"var(--text-primary)",marginBottom:"0.25rem"},children:N.name}),o.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-secondary)",lineHeight:1.45,marginBottom:"0.5rem"},children:N.description}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.3rem"},children:N.tags.map(b=>o.jsx("span",{className:"template-tag",children:b},b))})]},N.name))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",margin:"1.5rem 0"},children:[o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}}),o.jsx("span",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"or"}),o.jsx("div",{style:{flex:1,height:"1px",background:"var(--border)"}})]}),o.jsx("button",{className:"btn btn-primary",style:{width:"100%",textAlign:"center",padding:"0.75rem"},onClick:()=>E(y.profileId),children:"Custom — define your own limits and scope"})]})}return o.jsxs(o.Fragment,{children:[o.jsx("style",{children:`
65
65
  .profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; align-items: stretch; }
66
66
  .profile-grid .card { display: flex; flex-direction: column; height: 100%; margin-top: 0 !important; }
67
67
  @media (max-width: 900px) { .profile-grid { grid-template-columns: repeat(2, 1fr); } }
68
68
  @media (max-width: 560px) { .profile-grid { grid-template-columns: 1fr; } }
69
- `}),m?o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):v.length===0?o.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[o.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),o.jsx(tt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):o.jsx("div",{className:"profile-grid",children:v.map(k=>{const N=S(k.id),b=k.id.replace(/@.*$/,"").split("/").pop()??k.id,I=h.get(b),H=f.get(b),U=(H==null?void 0:H.running)===!0;return o.jsxs("div",{className:"card",style:U?void 0:{opacity:.7},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[o.jsx("h3",{className:"card-title",style:{margin:0},children:Ie(k.id,k.name)}),N?o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"})]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:k.description}),U?o.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>z(k.id),children:"Authorize"}):o.jsxs(tt,{to:`/integrations?setup=${(I==null?void 0:I.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(I==null?void 0:I.name)??"integration"]})]},k.id)})})]})}const iy={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function ly({status:e,label:t}){return o.jsx("span",{className:`status-badge status-${e}`,children:t||iy[e]})}function cy({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return o.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const Sn=86400,Ir=3600,Pa=60,uy=30*Sn;function dy(e){if(e<=0)return"Expired";if(e>90*Sn){const t=Math.floor(e/uy);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Sn){const t=Math.floor(e/Sn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Sn){const t=Math.floor(e/Sn),n=Math.floor(e%Sn/Ir);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Ir){const t=Math.floor(e/Ir),n=Math.floor(e%Ir/Pa);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Pa){const t=Math.floor(e/Pa),n=Math.floor(e%Pa);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function fy({expiresAt:e}){const[t,n]=d.useState(()=>e-Date.now()/1e3),r=t<2*Ir;d.useEffect(()=>{const s=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(s)},[e,r]);const a=t<300;return o.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:dy(t)})}function Hf({icon:e,title:t,text:n,children:r}){return o.jsxs("div",{className:"empty-state",children:[e&&o.jsx("div",{className:"empty-state-icon",children:e}),o.jsx("div",{className:"empty-state-title",children:t}),n&&o.jsx("div",{className:"empty-state-text",children:n}),r]})}function py(e){const t=Math.floor(e/86400);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/3600);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.ceil(e/60);return`${r} minute${r===1?"":"s"}`}const my=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function hy({item:e,onClose:t,onSuccess:n}){var h;const{user:r,activeDomain:a,groupId:s}=Pe(),i=e.remaining_seconds??0,l=my.filter(f=>f.seconds>i),c=((h=l[0])==null?void 0:h.seconds)??2592e3,[u,p]=d.useState(c),[m,g]=d.useState(!1),[w,x]=d.useState(""),y=Object.entries(e.frame).filter(([f])=>f!=="profile"&&f!=="path"),j=async()=>{var f;if(r){g(!0),x("");try{const v=e.authorization_id,S=await L.getGateContent(v);if(!S)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const E=await L.getProfile(e.profile_id),z=e.frame,k=S.context??{},N=e.attested_domains[0]||a||"owner",b=await Va(z,E),I=await Df(k,E),[H,U]=await Promise.all([xo(S.gateContent.intent),xo(JSON.stringify({profile:e.profile_id,path:e.path,domain:N}))]);if(!s)throw new Error("No active group; cannot extend authorization.");const O=(((f=e.deferred_commitment_domains)==null?void 0:f.length)??0)>0?"review":"automatic",R=await L.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:z,bounds_hash:b,context_hash:I,domain:N,did:r.did,gate_content_hashes:{intent:H},execution_context_hash:U,group_id:s,commitment_mode:O,ttl:u});await L.pushGateContent(Uf(R,{boundsHash:b,contextHash:I,context:k,path:e.path,gateContent:S.gateContent})),n()}catch(v){x(v instanceof Error?v.message:"Extension failed")}finally{g(!1)}}};return o.jsx("div",{className:"modal-backdrop",onClick:f=>f.target===f.currentTarget&&t(),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:"Extend Authorization"}),o.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Ie(e.profile_id)," / ",e.path]}),y.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:y.map(([f,v])=>`${f}=${v}`).join(" · ")})]}),o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),i>0&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",py(i),". Only longer durations are shown."]}),o.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:l.length===0?o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This authorization is already on the longest available duration. Nothing to extend."}):l.map(f=>o.jsx("button",{className:`btn ${u===f.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(f.seconds),style:{minWidth:"3.5rem"},children:f.label},f.seconds))})]}),o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, context, and gate content will be re-attested with a new TTL (measured from now)."}),w&&o.jsx("div",{className:"error-message",children:w})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:m,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:j,disabled:m,children:m?"Extending...":"Extend"})]})]})})}function gy(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const s=zt(r,{revokedSet:t}),i=zt(a,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[s]!==l[i]?l[s]-l[i]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function vy({item:e,revokedSet:t,expandedHash:n,gateCache:r,gateLoading:a,copiedHash:s,revokingHash:i,copyingHash:l,profileConfigCache:c,mode:u,ownerLabel:p,isAdmin:m,onExpand:g,onCopyHash:w,onCopy:x,onRevoke:y,onExtend:j,highlightHash:h}){var T;const f=zt(e,{revokedSet:t}),v=n===e.authorization_id,S=r[e.authorization_id],E=f==="active"||f==="pending"||f==="expired",z=Object.entries(e.frame).filter(([P])=>P!=="profile"&&P!=="path"),k=c.get(e.profile_id)??null,N=(((T=k==null?void 0:k.approvers)==null?void 0:T.length)??0)>0,b=new Map;if(k!=null&&k.caps&&u==="team")for(const[P,F]of z){const X=k.caps[P];X!==void 0&&Number(F)>X&&b.set(P,{authorized:Number(F),cap:X})}const I=b.size>0,H=e.approvers_frozen??[],U=(k==null?void 0:k.approvers)??[],O=u==="team"&&H.length>0&&U.length>0&&(H.length!==U.length||H.some(P=>!U.includes(P))||U.some(P=>!H.includes(P))),R=Array.from(b.entries()).map(([P,F])=>`${P}: ${F.authorized} (cap ${F.cap})`).join(", "),B=Array.from(b.entries()).map(([P,F])=>`${P}: ${F.authorized} → ${F.cap}`).join(", "),ee=I?N?b.size===1?`Above team cap: ${R} — actions require approval`:`Above team cap (${b.size}): ${R} — actions require approval`:b.size===1?`Reduced by hard cap: ${B}`:`Reduced by hard cap (${b.size}): ${B}`:"",ie=I?N?"Above-cap actions under this authority require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this authorization to reissue within the cap.":void 0,A=Ie(e.profile_id),K=h!=null&&e.authorization_id===h;return o.jsxs("div",{className:`card${K?" card-highlight":""}`,style:{marginBottom:0},children:[p&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",o.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:p})]}),o.jsxs("div",{className:"auth-card-header",children:[o.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:A}),e.title&&o.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),o.jsx(ly,{status:f}),f==="active"&&e.earliest_expiry&&o.jsx(fy,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),f==="expired"&&o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:new Date(e.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(P=>o.jsx(cy,{domain:P,attested:e.attested_domains.includes(P)},P)),e.deferred_commitment_domains.length>0&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),I&&o.jsx("span",{title:ie,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:N?"var(--accent-subtle)":"var(--danger-subtle)",color:N?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:ee}),O&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>x(e),disabled:l===e.authorization_id,title:"The approver list for this profile has changed since this authority was created. Copy to reissue with the current approvers.",children:l===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),z.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:z.map(([P,F],X)=>{const Y=b.get(P);return o.jsxs("span",{children:[X>0&&" · ",Y?N?o.jsxs("span",{title:`Team cap on ${P} is ${Y.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${Y.authorized}.`,children:[o.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[P,"=",String(F)]}),o.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",Y.cap]})]}):o.jsxs("span",{title:`Team cap on ${P} is ${Y.cap} with no approvers configured (hard cap). Authorized for ${Y.authorized}; effective ${Y.cap}.`,children:[o.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[P,"=",String(F)]}),o.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",Y.cap]})]}):o.jsxs("span",{children:[P,"=",String(F)]})]},P)})}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>g(e),children:v?"▲ Hide Details":"▼ Details"})}),v&&o.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[z.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),o.jsx("dl",{className:"review-grid",children:z.map(([P,F])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:P}),o.jsx("dd",{children:String(F)})]},P))})]}),(S==null?void 0:S.context)&&Object.keys(S.context).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),o.jsx("dl",{className:"review-grid",children:Object.entries(S.context).map(([P,F])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:P}),o.jsx("dd",{title:String(F),children:Wf(P,F,S.contextLabels)})]},P))})]}),o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),a===e.authorization_id?o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):S?o.jsx("div",{className:"gate-content-block",children:o.jsx("div",{className:"gate-content-item",children:o.jsx("div",{className:"gate-content-text",children:S.gateContent.intent})})}):o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>w(e.authorization_id),children:s===e.authorization_id?"copied":"copy"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!p&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e),disabled:l===e.authorization_id,title:"Start a new authorization pre-filled with these bounds, context, and intent",children:l===e.authorization_id?"Copying…":"⧉ Copy"}),!p&&(f==="active"||f==="pending")&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e,{asEdit:!0}),disabled:l===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new authorization revokes this one",children:"✎ Edit"}),!p&&E&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e),children:"↻ Extend"}),p&&m&&f!=="revoked"?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>y(e.authorization_id,p,A),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):!p&&(f==="active"||f==="pending")?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>y(e.authorization_id),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function yy(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[a,s]=d.useState([]),[i,l]=d.useState(!1),[c,u]=d.useState("mine"),[p,m]=d.useState("active"),[g,w]=d.useState(null),[x,y]=d.useState(null),[j,h]=Pf(),[f,v]=d.useState(()=>j.get("new")==="1"),[S,E]=d.useState(()=>j.get("highlight")),[z,k]=d.useState(null),[N,b]=d.useState({}),[I,H]=d.useState(null),[U,O]=d.useState(null),[R,B]=d.useState(null),[ee,ie]=d.useState(new Set),[A,K]=d.useState(null),[T,P]=d.useState(null),F=Kt(),{group:X,groupId:Y,domain:le,mode:C,activeTeam:D}=Pe(),_=(D==null?void 0:D.isAdmin)===!0,[V,q]=d.useState(()=>new Map),Q=d.useCallback(()=>{r(!0),L.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),fe=d.useCallback(()=>{Y&&(l(!0),L.listTeamAuthorizations(Y).then(s).catch(()=>{}).finally(()=>l(!1)))},[Y]);he("attestation-changed",()=>{Q(),_&&Y&&fe()}),d.useEffect(()=>{if(!S)return;j.get("highlight")&&(j.delete("highlight"),h(j,{replace:!0}));const W=window.setTimeout(()=>E(null),3e3);return()=>window.clearTimeout(W)},[]),Ft(Q,3e5),d.useEffect(()=>{c==="team"&&_&&Y&&a.length===0&&!i&&fe()},[c,_,Y,a.length,i,fe]),d.useEffect(()=>{if(C!=="team"||!Y)return;const W=c==="mine"?e:a;if(W.length===0)return;const $=[...new Set(W.map(J=>J.profile_id))].filter(J=>!V.has(J));if($.length!==0){q(J=>{const te=new Map(J);for(const Z of $)te.set(Z,null);return te});for(const J of $)L.getTeamProfileConfig(Y,J).then(te=>{q(Z=>new Map(Z).set(J,te))}).catch(()=>{})}},[e,a,c,Y,C,V]);const He=async W=>{if(z===W.authorization_id){k(null);return}k(W.authorization_id);const $=W.authorization_id;if(!($ in N)){H(W.authorization_id);try{const J=await L.getGateContent($);b(te=>({...te,[$]:J}))}catch{b(J=>({...J,[$]:null}))}finally{H(null)}}},Ve=W=>{navigator.clipboard.writeText(W).then(()=>{B(W),setTimeout(()=>B(null),2e3)})},je=async(W,$)=>{var J;if(!Y){alert("No active group; cannot copy authorization.");return}P(W.authorization_id);try{const te=W.authorization_id;let Z=N[te]??null;te in N||(Z=await L.getGateContent(te),b(Ke=>({...Ke,[te]:Z})));const Oe=Object.fromEntries(Object.entries(W.frame).filter(([Ke])=>Ke!=="profile"&&Ke!=="path")),Mn=(Z==null?void 0:Z.context)??{},gn=((J=Z==null?void 0:Z.gateContent)==null?void 0:J.intent)??"",ke=W.deferred_commitment_domains.length>0?"review":"automatic",lt=W.attested_domains[0]||le||"owner",Ze=Date.parse(W.created_at),Ae=W.earliest_expiry?Date.parse(W.earliest_expiry):NaN,vn=Number.isFinite(Ze)&&Number.isFinite(Ae)&&Ae>Ze?Math.round((Ae-Ze)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:W.profile_id,groupId:Y,groupName:(X==null?void 0:X.name)??null,domain:lt})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Oe,context:Mn,gateContent:{intent:gn},templateMode:ke,templateTtl:vn})),$!=null&&$.asEdit?sessionStorage.setItem("agentEditReplaces",W.authorization_id):sessionStorage.removeItem("agentEditReplaces"),F("/agent/gate")}catch(te){alert(te instanceof Error?te.message:"Failed to copy authorization")}finally{P(null)}},hn=async(W,$,J)=>{const te=$&&J?`Revoke ${$}'s ${J} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(te)){K(W);try{await L.revokeAttestation(W),ie(Z=>new Set(Z).add(W)),L.resyncGates().catch(()=>{}),$&&Y&&fe()}catch(Z){alert(Z instanceof Error?Z.message:"Failed to revoke authorization")}finally{K(null)}}},qe=c==="mine"?e:a,_t=c==="mine"?n:i,$n={active:qe.filter(W=>zt(W,{revokedSet:ee})==="active").length,pending:qe.filter(W=>zt(W,{revokedSet:ee})==="pending").length,expired:qe.filter(W=>zt(W,{revokedSet:ee})==="expired").length,revoked:qe.filter(W=>zt(W,{revokedSet:ee})==="revoked").length},Ln=(()=>{const W=new Map;for(const $ of qe){if(zt($,{revokedSet:ee})!==p)continue;const J=W.get($.profile_id)??{count:0,review:!1};J.count+=1,$.deferred_commitment_domains.length>0&&(J.review=!0),W.set($.profile_id,J)}return Array.from(W.entries()).map(([$,J])=>({profileId:$,...J})).sort(($,J)=>Ie($.profileId).localeCompare(Ie(J.profileId)))})(),bt=gy(qe.filter(W=>{if(zt(W,{revokedSet:ee})!==p||g!==null&&W.profile_id!==g)return!1;if(x!==null){const $=W.deferred_commitment_domains.length>0;if(x==="review"&&!$||x==="auto"&&$)return!1}return!0}),ee,S),ae={revokedSet:ee,expandedHash:z,gateCache:N,gateLoading:I,copiedHash:R,revokingHash:A,copyingHash:T,profileConfigCache:V,mode:C,activeDomain:le,group:X,groupId:Y,onExpand:He,onCopyHash:Ve,onCopy:je,onRevoke:hn,onExtend:O,highlightHash:S};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Authorizations"}),o.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),o.jsx("button",{className:"btn btn-primary",onClick:()=>v(!0),children:"+ New authorization"})]}),f&&o.jsx("div",{className:"modal-backdrop",onClick:()=>{v(!1),j.get("new")&&(j.delete("new"),h(j,{replace:!0}))},children:o.jsxs("div",{className:"modal",onClick:W=>W.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h2",{className:"modal-title",children:"New authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>{v(!1),j.get("new")&&(j.delete("new"),h(j,{replace:!0}))},children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),o.jsx(sy,{onDismiss:()=>v(!1)})]})]})}),_&&o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[o.jsx("button",{className:`nav-tab${c==="mine"?" active":""}`,onClick:()=>{u("mine"),m("active"),w(null),y(null),k(null)},children:"Mine"}),o.jsx("button",{className:`nav-tab${c==="team"?" active":""}`,onClick:()=>{u("team"),m("active"),w(null),y(null),k(null)},children:"Team"})]}),o.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(W=>o.jsxs("button",{className:`nav-tab${p===W?" active":""}`,onClick:()=>{m(W),w(null),y(null)},children:[W.charAt(0).toUpperCase()+W.slice(1)," (",$n[W],")"]},W))}),Ln.length>0&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Ln.map(W=>{const $=g===W.profileId;return o.jsx("button",{className:`btn btn-sm ${$?"btn-primary":"btn-secondary"}`,onClick:()=>w($?null:W.profileId),children:Ie(W.profileId)},W.profileId)}),o.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(W=>{const $=x===W;return o.jsx("button",{className:`btn btn-sm ${$?"btn-primary":"btn-secondary"}`,onClick:()=>y($?null:W),children:W==="auto"?"Auto":"Review"},W)})]}),_t&&qe.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):bt.length===0?o.jsx(Hf,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:bt.map(W=>{const $=c==="team"?W:null,J=$!=null&&$.owner?$.owner.name??$.owner.email??$.owner.userId:void 0;return o.jsx(vy,{item:W,ownerLabel:J,isAdmin:_,...ae},W.authorization_id)})}),U&&o.jsx(hy,{item:U,onClose:()=>O(null),onSuccess:()=>{O(null),Q()}})]})}function Vf({profileId:e}){return o.jsx("span",{className:"profile-badge",children:Ie(e)})}function xy(e){return new Date(e*1e3).toLocaleString()}function wy(e,t){if(t==="all")return!0;const n=t==="1d"?1:t==="7d"?7:30,r=Math.floor(Date.now()/1e3)-n*86400;return e.timestamp>=r}function Sy(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Ie(e.profileId).toLowerCase().includes(n)||e.path.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||e.attestationHash.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||JSON.stringify(e.executionContext).toLowerCase().includes(n)}function Gc(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function jy(){const{activeTeam:e,groupId:t}=Pe(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=d.useState("mine"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState({}),[m,g]=d.useState(new Set),[w,x]=d.useState(""),[y,j]=d.useState(new Set),[h,f]=d.useState(new Set),[v,S]=d.useState("all"),[E,z]=d.useState(!1),[k,N]=d.useState(null),[b,I]=d.useState(!1),[H,U]=d.useState(!1),O=d.useRef(""),R=d.useCallback(C=>r==="team"&&n&&t?L.listTeamReceiptsPage(t,{before:C,limit:200}):L.getMyReceiptsPage({before:C,limit:200}),[r,n,t]),B=d.useCallback(()=>{const C=r==="team"?`team:${t}`:"mine",D=O.current!==C;O.current=C,c(!0),U(!1),R().then(_=>{i(V=>D?_.receipts:Gc(V,_.receipts)),N(V=>D?_.nextBefore:V??_.nextBefore)}).catch(()=>{D&&i([]),U(!0)}).finally(()=>c(!1))},[R,r,t]),ee=d.useCallback(()=>{!k||b||(I(!0),U(!1),R(k).then(C=>{i(D=>Gc(D,C.receipts)),N(C.nextBefore)}).catch(()=>U(!0)).finally(()=>I(!1)))},[k,b,R]);Ft(B,12e4),d.useEffect(()=>{r!=="team"||Object.keys(u).length>0||L.listUsers().then(C=>{const D={};for(const _ of C)D[_.id]={name:_.name,email:_.email};p(D)}).catch(()=>{})},[r,u]);const ie=d.useMemo(()=>{const C=new Set;for(const D of s)C.add(Ie(D.profileId));return[...C].sort()},[s]),A=d.useMemo(()=>{const C=new Set;for(const D of s)C.add(D.action);return[...C].sort()},[s]),K=d.useMemo(()=>{if(r!=="team")return[];const C=new Set;for(const D of s)D.userId&&C.add(D.userId);return[...C].map(D=>{var _;return{id:D,label:(_=u[D])!=null&&_.name?`${u[D].name} (${u[D].email})`:D}}).sort((D,_)=>D.label.localeCompare(_.label))},[r,s,u]),T=d.useMemo(()=>s.filter(C=>!(!Sy(C,w)||y.size>0&&!y.has(Ie(C.profileId))||h.size>0&&!h.has(C.action)||m.size>0&&C.userId&&!m.has(C.userId)||!wy(C,v))),[s,w,y,h,m,v]),P=y.size>0||h.size>0||m.size>0||v!=="all";function F(C){j(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function X(C){f(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function Y(C){g(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function le(){j(new Set),f(new Set),g(new Set),S("all"),x("")}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Receipts"}),o.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),n&&o.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(C=>o.jsx("button",{onClick:()=>a(C),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===C?"2px solid var(--accent)":"2px solid transparent",color:r===C?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===C?600:500},children:C==="mine"?"Mine":"Team"},C))}),o.jsxs("div",{className:"search-filter-bar",children:[o.jsxs("div",{className:"search-input-wrap",children:[o.jsx("span",{className:"search-icon",children:"⌕"}),o.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:w,onChange:C=>x(C.target.value)}),w&&o.jsx("button",{className:"search-clear",onClick:()=>x(""),children:"×"})]}),o.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>z(!E),children:["Filters",P?` (${y.size+h.size+(v!=="all"?1:0)})`:""]})]}),E&&o.jsxs("div",{className:"filter-panel",children:[ie.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Profile"}),o.jsx("div",{className:"filter-chips",children:ie.map(C=>o.jsx("button",{className:`filter-chip${y.has(C)?" selected":""}`,onClick:()=>F(C),children:C},C))})]}),A.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Action"}),o.jsx("div",{className:"filter-chips",children:A.map(C=>o.jsx("button",{className:`filter-chip${h.has(C)?" selected":""}`,onClick:()=>X(C),children:C},C))})]}),r==="team"&&K.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Owner"}),o.jsx("div",{className:"filter-chips",children:K.map(C=>o.jsx("button",{className:`filter-chip${m.has(C.id)?" selected":""}`,onClick:()=>Y(C.id),children:C.label},C.id))})]}),o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Time range"}),o.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([C,D])=>o.jsx("button",{className:`filter-chip${v===C?" selected":""}`,onClick:()=>S(C),children:D},C))})]})]}),P&&o.jsxs("div",{className:"active-filters",children:[[...y].map(C=>o.jsxs("span",{className:"active-chip",onClick:()=>F(C),children:[C," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)),[...h].map(C=>o.jsxs("span",{className:"active-chip",onClick:()=>X(C),children:[C," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)),[...m].map(C=>{const D=u[C],_=D?D.name:C;return o.jsxs("span",{className:"active-chip",onClick:()=>Y(C),children:[_," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)}),v!=="all"&&o.jsxs("span",{className:"active-chip",onClick:()=>S("all"),children:[v==="1d"?"Today":v==="7d"?"7 days":"30 days"," ",o.jsx("span",{className:"chip-remove",children:"×"})]}),o.jsx("button",{className:"clear-filters",onClick:le,children:"Clear all"})]}),H&&o.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:o.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load receipts — your session may have expired. Try signing out and back in."})}),l&&s.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):T.length===0?o.jsx(Hf,{icon:"⌕",title:s.length===0?"No receipts in the last 30 days":"No matching receipts",text:s.length===0?"Execution receipts appear here after an agent uses an authorized tool. Older receipts can be loaded below.":"Try adjusting your search or filters."}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:T.length===s.length?`${s.length} receipt${s.length!==1?"s":""}`:`${T.length} of ${s.length} receipts`}),o.jsx("div",{className:"timeline",children:T.map(C=>{var D;return o.jsx("div",{className:"timeline-event",children:o.jsxs("div",{className:"card",style:{marginBottom:0},children:[o.jsxs("div",{className:"auth-card-header",children:[o.jsx(Vf,{profileId:C.profileId}),o.jsx("span",{className:"auth-card-path",children:C.path}),o.jsx("span",{className:"receipt-action",children:C.action}),o.jsx("span",{className:"auth-card-time",children:xy(C.timestamp)})]}),r==="team"&&C.userId&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner:"," ",o.jsx("span",{style:{color:"var(--text-secondary)"},children:(D=u[C.userId])!=null&&D.name?`${u[C.userId].name} (${u[C.userId].email})`:C.userId})]}),Object.keys(C.executionContext).length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:Object.entries(C.executionContext).map(([_,V])=>`${_}=${V}`).join(" · ")}),o.jsxs("div",{style:{display:"flex",gap:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:[o.jsxs("span",{children:["Daily: ",C.cumulativeState.daily.count," calls, $",C.cumulativeState.daily.amount]}),o.jsxs("span",{children:["Monthly: ",C.cumulativeState.monthly.count," calls, $",C.cumulativeState.monthly.amount]})]}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all",marginTop:"0.375rem"},children:C.attestationHash})]})},C.id)})})]}),k&&o.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:ee,disabled:b,children:b?"Loading…":"Load older"})})]})}const Yc={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}};function ky(){const[e,t]=d.useState(""),[n,r]=d.useState("openrouter"),[a,s]=d.useState("openai-compatible"),[i,l]=d.useState("https://openrouter.ai/api/v1"),[c,u]=d.useState("google/gemma-4-31b-it"),[p,m]=d.useState(""),[g,w]=d.useState(!1),[x,y]=d.useState(!1),[j,h]=d.useState(!1),[f,v]=d.useState(null),S=d.useCallback(b=>{t(b),setTimeout(()=>t(""),3e3)},[]),E=d.useCallback(async()=>{try{const b=await L.getCredential("ai-config");if(w(b.configured),b.configured&&b.fields){b.fields.provider&&s(b.fields.provider),b.fields.endpoint&&l(b.fields.endpoint),b.fields.model&&u(b.fields.model);const I=b.fields.endpoint??"";I.includes("openai.com")?r("openai"):I.includes("groq.com")?r("groq"):I.includes("together.xyz")?r("together"):I.includes("openrouter.ai")?r("openrouter"):r("ollama")}}catch{}},[]);d.useEffect(()=>{E()},[E]);const z=b=>{r(b);const I=Yc[b];I&&(s(I.provider),l(I.endpoint),u(I.models[0]))},k=async()=>{y(!0);try{await L.setCredential("ai-config",{provider:a,endpoint:i,model:c,...p?{apiKey:p}:{}}),w(!0),S("AI configuration saved!")}catch{S("Failed to save AI config")}finally{y(!1)}},N=async()=>{h(!0),v(null);try{const b=await L.aiTest(p?{provider:a,endpoint:i,model:c,apiKey:p}:{});v(b.ok?`OK: ${b.message}`:`Failed: ${b.message}`)}catch(b){v(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{h(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"AI Assistant"}),o.jsx("p",{className:"page-subtitle",children:"Advisory AI to help you think through intent when authorizing agents."})]}),e&&o.jsx("div",{className:"alert alert-success",children:e}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",children:"Configuration"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through authorizations. Keys are encrypted in your vault."}),g&&o.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"✓"}),o.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Provider Preset"}),o.jsxs("select",{className:"form-input",value:n,onChange:b=>z(b.target.value),children:[o.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),o.jsx("option",{value:"ollama",children:"Ollama (local)"}),o.jsx("option",{value:"openai",children:"OpenAI"}),o.jsx("option",{value:"groq",children:"Groq"}),o.jsx("option",{value:"together",children:"Together"})]})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Model"}),(()=>{var H;const b=((H=Yc[n])==null?void 0:H.models)??[],I=b.includes(c);return o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"form-input",value:I?c:"__custom__",onChange:U=>{U.target.value==="__custom__"?u(""):u(U.target.value)},style:{marginBottom:I?void 0:"0.375rem"},children:[b.map(U=>o.jsx("option",{value:U,children:U},U)),o.jsx("option",{value:"__custom__",children:"Custom model..."})]}),!I&&o.jsx("input",{className:"form-input",value:c,onChange:U=>u(U.target.value),placeholder:"Enter model name"})]})})()]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1rem"},children:[o.jsx("label",{className:"form-label",children:"API Key (if required)"}),o.jsx("input",{className:"form-input",type:"password",value:p,onChange:b=>m(b.target.value),placeholder:g?"••••••••••••••••":"sk-... (not needed for Ollama)"})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-primary",onClick:k,disabled:x,children:x?"Saving...":"Save & Encrypt"}),g&&o.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:j,children:j?"Testing...":"Test Connection"})]}),f&&o.jsx("div",{className:`alert ${f.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:f})]}),o.jsx(Cy,{}),o.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[o.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,marginBottom:"1rem"},children:"Security"}),o.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"Every tool call verified against your authorization bounds"}),o.jsx("li",{children:"Credentials never exposed to agents through MCP"}),o.jsx("li",{children:"Every action produces a signed receipt"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),o.jsx("li",{children:"For best security, run agents in sandboxed environments"}),o.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]})]})}function Cy(){const[e,t]=d.useState(null),[n,r]=d.useState({intent:"",context:""}),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,m]=d.useState(!1),g=d.useCallback(async()=>{if(!p)try{const y=await L.getAIPrompts();t(y),r({intent:y.intent.current,context:y.context.current}),m(!0)}catch(y){l(y instanceof Error?y.message:"Failed to load prompts")}},[p]),w=async y=>{if(e){s(y),l(null);try{const j=n[y],h=j.trim()===e[y].default.trim()?"":j;await L.setAIPrompt(y,h);const f=await L.getAIPrompts();t(f),r({intent:f.intent.current,context:f.context.current}),u(y),setTimeout(()=>u(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{s(null)}}},x=async y=>{if(confirm(`Revert ${y} prompt to the built-in default?`)){s(y),l(null);try{await L.setAIPrompt(y,"");const j=await L.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){l(j instanceof Error?j.message:"Revert failed")}finally{s(null)}}};return o.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:y=>{y.currentTarget.open&&g()},children:[o.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-authorization) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),i&&o.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!p&&!i&&o.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&o.jsxs(o.Fragment,{children:[o.jsx(Qc,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:y=>r(j=>({...j,intent:y})),onSave:()=>w("intent"),onRevert:()=>x("intent"),saving:a==="intent",justSaved:c==="intent"}),o.jsx(Qc,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:n.context,onChange:y=>r(j=>({...j,context:y})),onSave:()=>w("context"),onRevert:()=>x("context"),saving:a==="context",justSaved:c==="context"})]})]})}function Qc({kind:e,label:t,description:n,state:r,draft:a,onChange:s,onSave:i,onRevert:l,saving:c,justSaved:u}){const p=a!==r.current;return o.jsxs("section",{style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),o.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),o.jsx("textarea",{className:"form-textarea",value:a,onChange:m=>s(m.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${t} system prompt`}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:i,disabled:c||!p,children:c?"Saving…":"Save"}),r.overridden&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:l,disabled:c,title:"Discard the override and use the built-in default",children:"Revert to default"}),u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),p&&!c&&!u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),o.jsxs("details",{style:{marginTop:"0.5rem"},children:[o.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),o.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:r.default})]}),o.jsx("span",{style:{display:"none"},children:e})]})}function by(e){return e.proposalId?"review":"automatic"}function Jc(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,s=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||s.push({kind:"proposal",id:i.id,sortTimestamp:i.createdAt,commitmentMode:"review",profileId:i.profileId,proposal:i});if(r==="all")for(const i of t){const l=by(i);!a&&l==="automatic"||n.profile&&i.profileId!==n.profile||s.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:l,profileId:i.profileId,receipt:i})}return s.sort((i,l)=>l.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?s.slice(0,n.limit):s}function Kf(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),s=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${a}h`:a>0?i=`expires in ${a}h ${s}m`:i=`expires in ${Math.max(1,s)}m`,{label:i,urgent:n<2*3600,expired:!1}}const Ny={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Ey={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function zy(e){const t=Date.now()-e*1e3,n=t/36e5;return n<48?n<1?`${Math.max(1,Math.round(t/6e4))}m ago`:`${Math.round(n)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Iy(e){return e.split("__").pop()??e}function Py(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Ty=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),Ry=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function _y(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:Ry.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function yi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>yi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xc({item:e,onApprove:t,onReject:n,resolving:r}){const a=e.kind==="proposal",s=a?e.proposal.status:"executed",i=a?e.proposal.tool:e.receipt.action,l=Iy(i),c=Py(i),u=a?e.proposal.toolArgs:null,p=a?e.proposal.executionContext:e.receipt.executionContext,m=a?null:e.receipt.cumulativeState,g=u?Object.entries(u).filter(([x])=>!Ty.has(x)):[],w=Object.entries(p??{});return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[o.jsx(Vf,{profileId:e.profileId}),o.jsx("code",{style:{fontSize:"0.85rem"},children:l}),e.commitmentMode==="automatic"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[a&&s==="pending"&&(()=>{const x=Kf(e.proposal.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:x.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:x.urgent?600:400,whiteSpace:"nowrap"},children:x.label})})(),o.jsx("span",{className:`status-badge ${Ey[s]}`,children:Ny[s]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:zy(e.sortTimestamp)})]})]}),c&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[o.jsx("span",{children:"⚠"}),o.jsx("span",{children:"Irreversible action"})]}),a&&typeof(u==null?void 0:u._imagePreview)=="string"&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),o.jsx("img",{src:u._imagePreview,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),a&&g.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:g.map(([x,y])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:x}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:_y(x,y)?o.jsx("img",{src:y,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:x,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:j=>{const h=j.currentTarget,f=h.parentElement;if(!f)return;h.style.display="none";const v=document.createElement("span");v.textContent=y,v.style.color="var(--text-tertiary)",f.appendChild(v)}}):yi(y)})]},x))})]}),w.length>0&&o.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:w.map(([x,y])=>`${x}=${yi(y)}`).join(" · ")}),m&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",m.daily.count," action",m.daily.count===1?"":"s",m.daily.amount>0?`, ${m.daily.amount}`:""," · ","this month: ",m.monthly.count,m.monthly.amount>0?`, ${m.monthly.amount}`:""]}),a&&s==="pending"&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[a?"Proposal":"Receipt",": ",e.id]})]})}const Ay=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function xi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>xi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $y(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Ly({proposal:e,currentUserId:t,onAction:n,onMessage:r}){const[a,s]=d.useState(!1),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,m]=d.useState(!1),[g,w]=d.useState(null),[x,y]=d.useState(!1),j=e.tool.split("__").pop()??e.tool,h=Object.entries(e.toolArgs).filter(([O])=>!Ay.has(O)),f=Object.entries(e.executionContext),v=e.pendingApprovers??[],S=e.approvedBy??{},E=Object.keys(S).length,z=v.filter(O=>!(O in S)).length,k=t in S,N=async()=>{if(c===null){m(!0),w(null);try{const O=await L.getAttestationIntent(e.authorizationId);if(!O){w("Intent not available or you are not an authorized approver.");return}const R=await L.decryptIntent({intentCiphertext:O.intentCiphertext,encryptedKey:O.encryptedKey,approverId:t});u(R)}catch(O){w(O instanceof Error?O.message:"Failed to decrypt intent")}finally{m(!1)}}},b=async()=>{x?y(!1):(y(!0),await N())},I=async()=>{s(!0),r("");try{await L.approveProposal(e.id);try{if(c===null){const O=await L.getAttestationIntent(e.authorizationId);if(O){const R=await L.decryptIntent({intentCiphertext:O.intentCiphertext,encryptedKey:O.encryptedKey,approverId:t});u(R),await L.storeApprovedIntent(e.authorizationId,R)}}else await L.storeApprovedIntent(e.authorizationId,c)}catch{}r(`Approved. ${z-1>0?`${z-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(O){r(O instanceof Error?O.message:"Approval failed")}finally{s(!1)}},H=async()=>{const O=prompt("Rejection reason (optional):");if(O!==null){l(!0),r("");try{await L.rejectProposal(e.id,O||void 0),r("Action rejected."),n()}catch(R){r(R instanceof Error?R.message:"Rejection failed")}finally{l(!1)}}},U=a||i;return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ie(e.profileId)}),o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const O=Kf(e.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:O.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:O.urgent?600:400,whiteSpace:"nowrap"},children:O.label})})(),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:$y(e.createdAt)})]})]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[E," of ",v.length," approver",v.length===1?"":"s"," signed off",v.map(O=>{const R=O in S;return o.jsxs("span",{style:{marginLeft:"0.5rem",color:R?"var(--success, green)":"var(--text-tertiary)"},children:[R?"✓":"○"," ",O===t?"You":O]},O)})]}),o.jsxs("div",{style:{marginBottom:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),o.jsx("code",{style:{fontSize:"0.85rem"},children:j})]}),h.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:h.map(([O,R])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:O}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:xi(R)})]},O))})]}),f.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:f.map(([O,R])=>`${O}=${xi(R)}`).join(" · ")}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:b,disabled:p,children:[x?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),x&&o.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:g?o.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:g}):c!==null?o.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:c}):o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this authority."})})]}),!k&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:I,disabled:U,children:a?"Approving...":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:H,disabled:U,children:i?"Rejecting...":"Reject"})]}),k&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function My(){const{domain:e,user:t}=Pe(),n=(t==null?void 0:t.id)??"",[r,a]=d.useState("awaiting-me"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(""),m=d.useCallback(async()=>{try{const _=await L.getProposalsForApprover();i(_)}catch{}finally{c(!1)}},[]);he("proposal-added",m),he("proposal-approved",m),he("proposal-rejected",m),he("proposal-resolved",m),Ft(m,3e4);const[g,w]=d.useState([]),x=d.useCallback(async()=>{try{const _=await L.getProposals(e||"owner");w(_)}catch{}},[e]);he("proposal-added",x),he("proposal-approved",x),he("proposal-rejected",x),he("proposal-resolved",x),Ft(x,3e4,e);const y=d.useMemo(()=>g.filter(_=>{var V;return _.status==="pending"&&(((V=_.pendingApprovers)==null?void 0:V.length)??0)===0}),[g]),j=d.useMemo(()=>Jc(y,[],{status:"pending"}),[y]),[h,f]=d.useState([]),v=d.useCallback(async()=>{if(n)try{const V=(await L.getProposals(e||"owner")).filter(q=>q.status==="pending"&&q.pendingApprovers&&q.pendingApprovers.includes(n)&&q.approvedBy&&n in q.approvedBy);f(V)}catch{}},[n,e]);he("proposal-approved",v),he("proposal-rejected",v),Ft(v,3e4,`${n}:${e}`),d.useEffect(()=>{m(),x(),v()},[]);const[S,E]=d.useState([]),[z,k]=d.useState([]),[N,b]=d.useState(!0),[I,H]=d.useState(null),[U,O]=d.useState(""),[R,B]=d.useState("pending"),[ee,ie]=d.useState(null),[A,K]=d.useState(!1),T=d.useCallback(async()=>{try{const{proposals:_,receipts:V}=await L.getThread({domain:e,status:R,sinceDays:7});E(_),k(V)}catch{}finally{b(!1)}},[e,R]);Ft(T,3e4,`${e}:${R}`);const P=async(_,V)=>{H(_),O("");try{const q=e||"owner",Q=await L.resolveProposal(_,V,q);O(V==="commit"?`Action approved. Status: ${Q.status}`:"Action rejected."),await Promise.all([T(),x()])}catch(q){O(q instanceof Error?q.message:"Failed")}finally{H(null)}},F=d.useMemo(()=>{const _=new Set;for(const V of S)_.add(V.profileId);for(const V of z)_.add(V.profileId);return Array.from(_).sort()},[S,z]),X=d.useMemo(()=>Jc(S,z,{status:R,profile:ee??void 0,includeAutonomous:A}),[S,z,R,ee,A]),Y=d.useCallback(()=>{m(),v()},[m,v]),le=d.useMemo(()=>{const _=new Set,V=[];for(const q of h)_.has(q.id)||(_.add(q.id),V.push(q));return V.sort((q,Q)=>Q.createdAt-q.createdAt)},[h]),C=s.length+j.length,D=le.length;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Pending Approvals"}),o.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[o.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",C>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:C})]}),o.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",D>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:D})]}),o.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),T()},children:"All"})]}),r==="awaiting-me"&&o.jsx(o.Fragment,{children:l&&C===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):C===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(u||U)&&o.jsx("div",{className:"alert alert-success",children:u||U}),j.map(_=>o.jsx(Xc,{item:_,onApprove:V=>P(V,"commit"),onReject:V=>P(V,"reject"),resolving:I===_.id},_.id)),s.map(_=>o.jsx(Ly,{proposal:_,currentUserId:n,onAction:Y,onMessage:p},_.id))]})}),r==="awaiting-others"&&o.jsx(o.Fragment,{children:le.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:le.map(_=>o.jsx(Oy,{proposal:_,currentUserId:n,onCancel:async()=>{try{await L.rejectProposal(_.id,"cancelled by creator"),v(),x()}catch(V){alert(V instanceof Error?V.message:"Cancel failed")}}},_.id))})}),r==="all"&&o.jsxs(o.Fragment,{children:[U&&o.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:U}),o.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[o.jsx("button",{className:`filter-chip ${R==="pending"?"selected":""}`,onClick:()=>B("pending"),children:"Pending"}),o.jsx("button",{className:`filter-chip ${R==="all"?"selected":""}`,onClick:()=>B("all"),children:"All"}),F.length>0&&o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),F.map(_=>o.jsx("button",{className:`filter-chip ${ee===_?"selected":""}`,onClick:()=>ie(ee===_?null:_),children:Ie(_)},_)),R==="all"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),o.jsxs("button",{className:`filter-chip ${A?"selected":""}`,onClick:()=>K(!A),title:"Include actions executed without human review (automatic commitment mode)",children:[A?"✓ ":"","Autonomous actions"]})]})]}),N&&X.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):X.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:R==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R==="pending"?"Your agents are operating within their authorizations. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:X.map(_=>o.jsx(Xc,{item:_,onApprove:V=>P(V,"commit"),onReject:V=>P(V,"reject"),resolving:I===_.id},_.id))})]})]})}function Fy(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Oy({proposal:e,currentUserId:t,onCancel:n}){var u;const[r,a]=d.useState(!1),s=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(p=>!(p in(e.approvedBy??{}))),l=(((u=e.pendingApprovers)==null?void 0:u.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}};return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ie(e.profileId)}),l&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Fy(e.createdAt)})]}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:o.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[s.map(p=>o.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:p===t?"You approved":`${p} approved`},p)),i.map(p=>o.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",p===t?"you":p]},p))]}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const By=`# Agent Brief
69
+ `}),h?o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem"},children:"Loading..."}):v.length===0?o.jsxs("div",{className:"card",style:{padding:"2rem",textAlign:"center"},children:[o.jsx("p",{style:{color:"var(--text-secondary)",fontSize:"0.9rem",marginBottom:"1rem"},children:"No integrations set up yet. Connect a service first."}),o.jsx(tt,{to:"/integrations",className:"btn btn-primary btn-sm",onClick:()=>e==null?void 0:e(),children:"Go to Integrations"})]}):o.jsx("div",{className:"profile-grid",children:v.map(k=>{const N=S(k.id),b=k.id.replace(/@.*$/,"").split("/").pop()??k.id,I=g.get(b),H=f.get(b),U=(H==null?void 0:H.running)===!0;return o.jsxs("div",{className:"card",style:U?void 0:{opacity:.7},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.125rem"},children:[o.jsx("h3",{className:"card-title",style:{margin:0},children:Ie(k.id,k.name)}),N?o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Team"}):o.jsx("span",{style:{fontSize:"0.6rem",padding:"0.1rem 0.35rem",borderRadius:"0.2rem",background:"var(--bg-main)",color:"var(--text-tertiary)",fontWeight:600,border:"1px solid var(--border)"},children:"Personal"})]}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"1rem",flex:1},children:k.description}),U?o.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>z(k.id),children:"Authorize"}):o.jsxs(tt,{to:`/integrations?setup=${(I==null?void 0:I.id)??""}`,className:"btn btn-secondary btn-sm",style:{textDecoration:"none",textAlign:"center"},onClick:()=>e==null?void 0:e(),children:["Set up ",(I==null?void 0:I.name)??"integration"]})]},k.id)})})]})}const iy={active:"Active",pending:"Pending",expired:"Expired",revoked:"Revoked"};function ly({status:e,label:t}){return o.jsx("span",{className:`status-badge status-${e}`,children:t||iy[e]})}function cy({domain:e,attested:t}){const n=t===!0?"domain-attested":t===!1?"domain-missing":"";return o.jsx("span",{className:`domain-badge ${n}`,style:{fontSize:"0.75rem"},children:e})}const Sn=86400,Ir=3600,Pa=60,uy=30*Sn;function dy(e){if(e<=0)return"Expired";if(e>90*Sn){const t=Math.floor(e/uy);return`${t} ${t===1?"month":"months"} remaining`}if(e>7*Sn){const t=Math.floor(e/Sn);return`${t} ${t===1?"day":"days"} remaining`}if(e>=2*Sn){const t=Math.floor(e/Sn),n=Math.floor(e%Sn/Ir);return`${t} ${t===1?"day":"days"} ${n}h remaining`}if(e>=2*Ir){const t=Math.floor(e/Ir),n=Math.floor(e%Ir/Pa);return`${t}h ${String(n).padStart(2,"0")}m remaining`}if(e>=Pa){const t=Math.floor(e/Pa),n=Math.floor(e%Pa);return`${t}m ${String(n).padStart(2,"0")}s remaining`}return`${Math.floor(e)}s remaining`}function fy({expiresAt:e}){const[t,n]=d.useState(()=>e-Date.now()/1e3),r=t<2*Ir;d.useEffect(()=>{const s=setInterval(()=>n(e-Date.now()/1e3),r?1e3:6e4);return()=>clearInterval(s)},[e,r]);const a=t<300;return o.jsx("span",{className:`ttl-badge ${a?"ttl-warn":"ttl-ok"}`,children:dy(t)})}function Hf({icon:e,title:t,text:n,children:r}){return o.jsxs("div",{className:"empty-state",children:[e&&o.jsx("div",{className:"empty-state-icon",children:e}),o.jsx("div",{className:"empty-state-title",children:t}),n&&o.jsx("div",{className:"empty-state-text",children:n}),r]})}function py(e){const t=Math.floor(e/86400);if(t>=1)return`${t} day${t===1?"":"s"}`;const n=Math.floor(e/3600);if(n>=1)return`${n} hour${n===1?"":"s"}`;const r=Math.ceil(e/60);return`${r} minute${r===1?"":"s"}`}const my=[{label:"30m",seconds:1800},{label:"1h",seconds:3600},{label:"2h",seconds:7200},{label:"4h",seconds:14400},{label:"8h",seconds:28800},{label:"24h",seconds:86400},{label:"7d",seconds:604800},{label:"30d",seconds:2592e3},{label:"1y",seconds:31536e3}];function hy({item:e,onClose:t,onSuccess:n}){var g;const{user:r,activeDomain:a,groupId:s}=Pe(),i=e.remaining_seconds??0,l=my.filter(f=>f.seconds>i),c=((g=l[0])==null?void 0:g.seconds)??2592e3,[u,p]=d.useState(c),[h,m]=d.useState(!1),[w,x]=d.useState(""),y=Object.entries(e.frame).filter(([f])=>f!=="profile"&&f!=="path"),j=async()=>{var f;if(r){m(!0),x("");try{const v=e.authorization_id,S=await $.getGateContent(v);if(!S)throw new Error("Gate content not found locally. The MCP server may have restarted. Please re-authorize through the full wizard instead.");const E=await $.getProfile(e.profile_id),z=e.frame,k=S.context??{},N=e.attested_domains[0]||a||"owner",b=await Va(z,E),I=await Df(k,E),[H,U]=await Promise.all([xo(S.gateContent.intent),xo(JSON.stringify({profile:e.profile_id,path:e.path,domain:N}))]);if(!s)throw new Error("No active group; cannot extend authorization.");const B=(((f=e.deferred_commitment_domains)==null?void 0:f.length)??0)>0?"review":"automatic",R=await $.attest({authorization_id:e.authorization_id,renew:!0,profile_id:e.profile_id,bounds:z,bounds_hash:b,context_hash:I,domain:N,did:r.did,gate_content_hashes:{intent:H},execution_context_hash:U,group_id:s,commitment_mode:B,ttl:u});await $.pushGateContent(Uf(R,{boundsHash:b,contextHash:I,context:k,path:e.path,gateContent:S.gateContent})),n()}catch(v){x(v instanceof Error?v.message:"Extension failed")}finally{m(!1)}}};return o.jsx("div",{className:"modal-backdrop",onClick:f=>f.target===f.currentTarget&&t(),children:o.jsxs("div",{className:"modal",children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h3",{className:"modal-title",children:"Extend Authorization"}),o.jsx("button",{className:"modal-close",onClick:t,children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsxs("div",{style:{fontWeight:600,marginBottom:"0.25rem"},children:[Ie(e.profile_id)," / ",e.path]}),y.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:y.map(([f,v])=>`${f}=${v}`).join(" · ")})]}),o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.5rem"},children:"New duration"}),i>0&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["Currently valid for ",py(i),". Only longer durations are shown."]}),o.jsx("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap"},children:l.length===0?o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"This authorization is already on the longest available duration. Nothing to extend."}):l.map(f=>o.jsx("button",{className:`btn ${u===f.seconds?"btn-primary":"btn-secondary"}`,onClick:()=>p(f.seconds),style:{minWidth:"3.5rem"},children:f.label},f.seconds))})]}),o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"Same bounds, context, and gate content will be re-attested with a new TTL (measured from now)."}),w&&o.jsx("div",{className:"error-message",children:w})]}),o.jsxs("div",{className:"modal-footer",children:[o.jsx("button",{className:"btn btn-secondary",onClick:t,disabled:h,children:"Cancel"}),o.jsx("button",{className:"btn btn-primary",onClick:j,disabled:h,children:h?"Extending...":"Extend"})]})]})})}function gy(e,t,n){return[...e].sort((r,a)=>{if(n){if(r.authorization_id===n&&a.authorization_id!==n)return-1;if(a.authorization_id===n&&r.authorization_id!==n)return 1}const s=zt(r,{revokedSet:t}),i=zt(a,{revokedSet:t}),l={active:0,pending:1,expired:2,revoked:3};return l[s]!==l[i]?l[s]-l[i]:new Date(a.created_at).getTime()-new Date(r.created_at).getTime()})}function vy({item:e,revokedSet:t,expandedHash:n,gateCache:r,gateLoading:a,copiedHash:s,revokingHash:i,copyingHash:l,profileConfigCache:c,mode:u,ownerLabel:p,isAdmin:h,onExpand:m,onCopyHash:w,onCopy:x,onRevoke:y,onExtend:j,highlightHash:g}){var T;const f=zt(e,{revokedSet:t}),v=n===e.authorization_id,S=r[e.authorization_id],E=f==="active"||f==="pending"||f==="expired",z=Object.entries(e.frame).filter(([P])=>P!=="profile"&&P!=="path"),k=c.get(e.profile_id)??null,N=(((T=k==null?void 0:k.approvers)==null?void 0:T.length)??0)>0,b=new Map;if(k!=null&&k.caps&&u==="team")for(const[P,O]of z){const X=k.caps[P];X!==void 0&&Number(O)>X&&b.set(P,{authorized:Number(O),cap:X})}const I=b.size>0,H=e.approvers_frozen??[],U=(k==null?void 0:k.approvers)??[],B=u==="team"&&H.length>0&&U.length>0&&(H.length!==U.length||H.some(P=>!U.includes(P))||U.some(P=>!H.includes(P))),R=Array.from(b.entries()).map(([P,O])=>`${P}: ${O.authorized} (cap ${O.cap})`).join(", "),F=Array.from(b.entries()).map(([P,O])=>`${P}: ${O.authorized} → ${O.cap}`).join(", "),ee=I?N?b.size===1?`Above team cap: ${R} — actions require approval`:`Above team cap (${b.size}): ${R} — actions require approval`:b.size===1?`Reduced by hard cap: ${F}`:`Reduced by hard cap (${b.size}): ${F}`:"",ie=I?N?"Above-cap actions under this authority require per-action approval from the profile's approvers. Bounds remain authorized at their original values.":"No approvers are configured for this profile, so the team cap is a hard ceiling. Bounds above the cap are effectively reduced to the cap. Ask the admin to raise the cap or add approvers, or copy this authorization to reissue within the cap.":void 0,A=Ie(e.profile_id),K=g!=null&&e.authorization_id===g;return o.jsxs("div",{className:`card${K?" card-highlight":""}`,style:{marginBottom:0},children:[p&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner: ",o.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:p})]}),o.jsxs("div",{className:"auth-card-header",children:[o.jsx("span",{style:{fontWeight:700,fontSize:"1rem",color:"var(--text-primary)",letterSpacing:"0.01em"},children:A}),e.title&&o.jsx("span",{style:{fontWeight:500,fontSize:"0.85rem",color:"var(--text-secondary)"},children:e.title}),o.jsx(ly,{status:f}),f==="active"&&e.earliest_expiry&&o.jsx(fy,{expiresAt:new Date(e.earliest_expiry).getTime()/1e3}),f==="expired"&&o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:new Date(e.created_at).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem",alignItems:"center"},children:[e.required_domains.map(P=>o.jsx(cy,{domain:P,attested:e.attested_domains.includes(P)},P)),e.deferred_commitment_domains.length>0&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Review Mode"}),I&&o.jsx("span",{title:ie,style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:N?"var(--accent-subtle)":"var(--danger-subtle)",color:N?"var(--accent)":"var(--danger)",fontWeight:600,cursor:"help"},children:ee}),B&&o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.65rem",padding:"0.15rem 0.5rem",borderRadius:"0.25rem",background:"var(--warning-subtle, rgba(234,179,8,0.12))",color:"var(--warning, #ca8a04)",fontWeight:600,border:"1px solid var(--warning-border, rgba(234,179,8,0.3))",cursor:"pointer",lineHeight:1.4},onClick:()=>x(e),disabled:l===e.authorization_id,title:"The approver list for this profile has changed since this authority was created. Copy to reissue with the current approvers.",children:l===e.authorization_id?"Copying...":"Approver list updated · Copy with new approvers"})]}),z.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:z.map(([P,O],X)=>{const Y=b.get(P);return o.jsxs("span",{children:[X>0&&" · ",Y?N?o.jsxs("span",{title:`Team cap on ${P} is ${Y.cap}. Actions exceeding the cap require per-action approval. Bound remains authorized at ${Y.authorized}.`,children:[o.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[P,"=",String(O)]}),o.jsxs("span",{style:{color:"var(--accent)",marginLeft:"0.25rem",fontWeight:600},children:["↑ approval at ",Y.cap]})]}):o.jsxs("span",{title:`Team cap on ${P} is ${Y.cap} with no approvers configured (hard cap). Authorized for ${Y.authorized}; effective ${Y.cap}.`,children:[o.jsxs("span",{style:{textDecoration:"line-through",color:"var(--text-tertiary)"},children:[P,"=",String(O)]}),o.jsxs("span",{style:{color:"var(--danger)",marginLeft:"0.25rem",fontWeight:600},children:["→"," ",Y.cap]})]}):o.jsxs("span",{children:[P,"=",String(O)]})]},P)})}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",onClick:()=>m(e),children:v?"▲ Hide Details":"▼ Details"})}),v&&o.jsxs("div",{style:{borderTop:"1px solid var(--border)",marginTop:"0.75rem",paddingTop:"0.75rem"},children:[z.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Bounds"}),o.jsx("dl",{className:"review-grid",children:z.map(([P,O])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:P}),o.jsx("dd",{children:String(O)})]},P))})]}),(S==null?void 0:S.context)&&Object.keys(S.context).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Context"}),o.jsx("dl",{className:"review-grid",children:Object.entries(S.context).map(([P,O])=>o.jsxs("span",{style:{display:"contents"},children:[o.jsx("dt",{children:P}),o.jsx("dd",{title:String(O),children:Wf(P,O,S.contextLabels)})]},P))})]}),o.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginTop:"1rem",marginBottom:"0.25rem"},children:"Intent"}),a===e.authorization_id?o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Loading gate content..."}):S?o.jsx("div",{className:"gate-content-block",children:o.jsx("div",{className:"gate-content-item",children:o.jsx("div",{className:"gate-content-text",children:S.gateContent.intent})})}):o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Gate content not available."}),o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginTop:"1rem"},children:["Created: ",new Date(e.created_at).toLocaleString(),e.earliest_expiry&&` · Expires: ${new Date(e.earliest_expiry).toLocaleString()}`]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all"},children:e.authorization_id}),o.jsx("button",{className:"btn btn-ghost btn-sm",style:{fontSize:"0.7rem",padding:"0.125rem 0.375rem"},onClick:()=>w(e.authorization_id),children:s===e.authorization_id?"copied":"copy"})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.75rem"},children:[!p&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e),disabled:l===e.authorization_id,title:"Start a new authorization pre-filled with these bounds, context, and intent",children:l===e.authorization_id?"Copying…":"⧉ Copy"}),!p&&(f==="active"||f==="pending")&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>x(e,{asEdit:!0}),disabled:l===e.authorization_id,title:"Adjust intent, bounds, or scope: opens the ceremony pre-filled; signing the new authorization revokes this one",children:"✎ Edit"}),!p&&E&&o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>j(e),children:"↻ Extend"}),p&&h&&f!=="revoked"?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>y(e.authorization_id,p,A),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):!p&&(f==="active"||f==="pending")?o.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>y(e.authorization_id),disabled:i===e.authorization_id,children:i===e.authorization_id?"Revoking…":"Revoke"}):null]})]})]},e.authorization_id)}function yy(){const[e,t]=d.useState([]),[n,r]=d.useState(!0),[a,s]=d.useState([]),[i,l]=d.useState(!1),[c,u]=d.useState("mine"),[p,h]=d.useState("active"),[m,w]=d.useState(null),[x,y]=d.useState(null),[j,g]=Pf(),[f,v]=d.useState(()=>j.get("new")==="1"),[S,E]=d.useState(()=>j.get("highlight")),[z,k]=d.useState(null),[N,b]=d.useState({}),[I,H]=d.useState(null),[U,B]=d.useState(null),[R,F]=d.useState(null),[ee,ie]=d.useState(new Set),[A,K]=d.useState(null),[T,P]=d.useState(null),O=Kt(),{group:X,groupId:Y,domain:le,mode:C,activeTeam:D}=Pe(),_=(D==null?void 0:D.isAdmin)===!0,[V,q]=d.useState(()=>new Map),Q=d.useCallback(()=>{r(!0),$.getMyAttestations().then(t).catch(()=>{}).finally(()=>r(!1))},[]),fe=d.useCallback(()=>{Y&&(l(!0),$.listTeamAuthorizations(Y).then(s).catch(()=>{}).finally(()=>l(!1)))},[Y]);he("attestation-changed",()=>{Q(),_&&Y&&fe()}),d.useEffect(()=>{if(!S)return;j.get("highlight")&&(j.delete("highlight"),g(j,{replace:!0}));const W=window.setTimeout(()=>E(null),3e3);return()=>window.clearTimeout(W)},[]),Ft(Q,3e5),d.useEffect(()=>{c==="team"&&_&&Y&&a.length===0&&!i&&fe()},[c,_,Y,a.length,i,fe]),d.useEffect(()=>{if(C!=="team"||!Y)return;const W=c==="mine"?e:a;if(W.length===0)return;const L=[...new Set(W.map(J=>J.profile_id))].filter(J=>!V.has(J));if(L.length!==0){q(J=>{const te=new Map(J);for(const Z of L)te.set(Z,null);return te});for(const J of L)$.getTeamProfileConfig(Y,J).then(te=>{q(Z=>new Map(Z).set(J,te))}).catch(()=>{})}},[e,a,c,Y,C,V]);const He=async W=>{if(z===W.authorization_id){k(null);return}k(W.authorization_id);const L=W.authorization_id;if(!(L in N)){H(W.authorization_id);try{const J=await $.getGateContent(L);b(te=>({...te,[L]:J}))}catch{b(J=>({...J,[L]:null}))}finally{H(null)}}},Ve=W=>{navigator.clipboard.writeText(W).then(()=>{F(W),setTimeout(()=>F(null),2e3)})},je=async(W,L)=>{var J;if(!Y){alert("No active group; cannot copy authorization.");return}P(W.authorization_id);try{const te=W.authorization_id;let Z=N[te]??null;te in N||(Z=await $.getGateContent(te),b(Ke=>({...Ke,[te]:Z})));const Oe=Object.fromEntries(Object.entries(W.frame).filter(([Ke])=>Ke!=="profile"&&Ke!=="path")),Mn=(Z==null?void 0:Z.context)??{},gn=((J=Z==null?void 0:Z.gateContent)==null?void 0:J.intent)??"",ke=W.deferred_commitment_domains.length>0?"review":"automatic",lt=W.attested_domains[0]||le||"owner",Ze=Date.parse(W.created_at),Ae=W.earliest_expiry?Date.parse(W.earliest_expiry):NaN,vn=Number.isFinite(Ze)&&Number.isFinite(Ae)&&Ae>Ze?Math.round((Ae-Ze)/1e3):void 0;sessionStorage.setItem("agentAuth",JSON.stringify({profileId:W.profile_id,groupId:Y,groupName:(X==null?void 0:X.name)??null,domain:lt})),sessionStorage.setItem("agentGate",JSON.stringify({bounds:Oe,context:Mn,gateContent:{intent:gn},templateMode:ke,templateTtl:vn})),L!=null&&L.asEdit?sessionStorage.setItem("agentEditReplaces",W.authorization_id):sessionStorage.removeItem("agentEditReplaces"),O("/agent/gate")}catch(te){alert(te instanceof Error?te.message:"Failed to copy authorization")}finally{P(null)}},hn=async(W,L,J)=>{const te=L&&J?`Revoke ${L}'s ${J} authorization? This cannot be undone.`:"Revoke this authorization? The agent will no longer be able to execute actions under this attestation.";if(confirm(te)){K(W);try{await $.revokeAttestation(W),ie(Z=>new Set(Z).add(W)),$.resyncGates().catch(()=>{}),L&&Y&&fe()}catch(Z){alert(Z instanceof Error?Z.message:"Failed to revoke authorization")}finally{K(null)}}},qe=c==="mine"?e:a,_t=c==="mine"?n:i,$n={active:qe.filter(W=>zt(W,{revokedSet:ee})==="active").length,pending:qe.filter(W=>zt(W,{revokedSet:ee})==="pending").length,expired:qe.filter(W=>zt(W,{revokedSet:ee})==="expired").length,revoked:qe.filter(W=>zt(W,{revokedSet:ee})==="revoked").length},Ln=(()=>{const W=new Map;for(const L of qe){if(zt(L,{revokedSet:ee})!==p)continue;const J=W.get(L.profile_id)??{count:0,review:!1};J.count+=1,L.deferred_commitment_domains.length>0&&(J.review=!0),W.set(L.profile_id,J)}return Array.from(W.entries()).map(([L,J])=>({profileId:L,...J})).sort((L,J)=>Ie(L.profileId).localeCompare(Ie(J.profileId)))})(),bt=gy(qe.filter(W=>{if(zt(W,{revokedSet:ee})!==p||m!==null&&W.profile_id!==m)return!1;if(x!==null){const L=W.deferred_commitment_domains.length>0;if(x==="review"&&!L||x==="auto"&&L)return!1}return!0}),ee,S),ae={revokedSet:ee,expandedHash:z,gateCache:N,gateLoading:I,copiedHash:R,revokingHash:A,copyingHash:T,profileConfigCache:V,mode:C,activeDomain:le,group:X,groupId:Y,onExpand:He,onCopyHash:Ve,onCopy:je,onRevoke:hn,onExtend:B,highlightHash:S};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("h1",{className:"page-title",children:"Authorizations"}),o.jsx("p",{className:"page-subtitle",children:"Active, pending, and expired agent authorizations."})]}),o.jsx("button",{className:"btn btn-primary",onClick:()=>v(!0),children:"+ New authorization"})]}),f&&o.jsx("div",{className:"modal-backdrop",onClick:()=>{v(!1),j.get("new")&&(j.delete("new"),g(j,{replace:!0}))},children:o.jsxs("div",{className:"modal",onClick:W=>W.stopPropagation(),style:{maxWidth:"960px",width:"90vw"},children:[o.jsxs("div",{className:"modal-header",children:[o.jsx("h2",{className:"modal-title",children:"New authorization"}),o.jsx("button",{className:"modal-close",onClick:()=>{v(!1),j.get("new")&&(j.delete("new"),g(j,{replace:!0}))},children:"×"})]}),o.jsxs("div",{className:"modal-body",children:[o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.9rem",marginTop:0,marginBottom:"1rem"},children:"What should your agent be able to do? Pick a profile, set limits, then authorize."}),o.jsx(sy,{onDismiss:()=>v(!1)})]})]})}),_&&o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"0.5rem"},children:[o.jsx("button",{className:`nav-tab${c==="mine"?" active":""}`,onClick:()=>{u("mine"),h("active"),w(null),y(null),k(null)},children:"Mine"}),o.jsx("button",{className:`nav-tab${c==="team"?" active":""}`,onClick:()=>{u("team"),h("active"),w(null),y(null),k(null)},children:"Team"})]}),o.jsx("div",{className:"nav-tabs",children:["active","pending","expired","revoked"].map(W=>o.jsxs("button",{className:`nav-tab${p===W?" active":""}`,onClick:()=>{h(W),w(null),y(null)},children:[W.charAt(0).toUpperCase()+W.slice(1)," (",$n[W],")"]},W))}),Ln.length>0&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center",marginTop:"-0.25rem",marginBottom:"1rem"},children:[Ln.map(W=>{const L=m===W.profileId;return o.jsx("button",{className:`btn btn-sm ${L?"btn-primary":"btn-secondary"}`,onClick:()=>w(L?null:W.profileId),children:Ie(W.profileId)},W.profileId)}),o.jsx("span",{"aria-hidden":"true",style:{color:"var(--border)",fontSize:"1.1rem",padding:"0 0.25rem",userSelect:"none"},children:"|"}),["auto","review"].map(W=>{const L=x===W;return o.jsx("button",{className:`btn btn-sm ${L?"btn-primary":"btn-secondary"}`,onClick:()=>y(L?null:W),children:W==="auto"?"Auto":"Review"},W)})]}),_t&&qe.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):bt.length===0?o.jsx(Hf,{icon:"☰",title:"No authorizations",text:`No ${p} authorizations found.`}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:bt.map(W=>{const L=c==="team"?W:null,J=L!=null&&L.owner?L.owner.name??L.owner.email??L.owner.userId:void 0;return o.jsx(vy,{item:W,ownerLabel:J,isAdmin:_,...ae},W.authorization_id)})}),U&&o.jsx(hy,{item:U,onClose:()=>B(null),onSuccess:()=>{B(null),Q()}})]})}function Vf({profileId:e}){return o.jsx("span",{className:"profile-badge",children:Ie(e)})}function xy(e){return new Date(e*1e3).toLocaleString()}function wy(e,t){if(t==="all")return!0;const n=t==="1d"?1:t==="7d"?7:30,r=Math.floor(Date.now()/1e3)-n*86400;return e.timestamp>=r}function Sy(e,t){if(!t)return!0;const n=t.toLowerCase();return e.profileId.toLowerCase().includes(n)||Ie(e.profileId).toLowerCase().includes(n)||e.path.toLowerCase().includes(n)||e.action.toLowerCase().includes(n)||e.attestationHash.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||JSON.stringify(e.executionContext).toLowerCase().includes(n)}function Gc(e,t){const n=new Map(e.map(r=>[r.id,r]));for(const r of t)n.set(r.id,r);return[...n.values()].sort((r,a)=>a.timestamp-r.timestamp)}function jy(){const{activeTeam:e,groupId:t}=Pe(),n=(e==null?void 0:e.isAdmin)===!0,[r,a]=d.useState("mine"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState({}),[h,m]=d.useState(new Set),[w,x]=d.useState(""),[y,j]=d.useState(new Set),[g,f]=d.useState(new Set),[v,S]=d.useState("all"),[E,z]=d.useState(!1),[k,N]=d.useState(null),[b,I]=d.useState(!1),[H,U]=d.useState(!1),B=d.useRef(""),R=d.useCallback(C=>r==="team"&&n&&t?$.listTeamReceiptsPage(t,{before:C,limit:200}):$.getMyReceiptsPage({before:C,limit:200}),[r,n,t]),F=d.useCallback(()=>{const C=r==="team"?`team:${t}`:"mine",D=B.current!==C;B.current=C,c(!0),U(!1),R().then(_=>{i(V=>D?_.receipts:Gc(V,_.receipts)),N(V=>D?_.nextBefore:V??_.nextBefore)}).catch(()=>{D&&i([]),U(!0)}).finally(()=>c(!1))},[R,r,t]),ee=d.useCallback(()=>{!k||b||(I(!0),U(!1),R(k).then(C=>{i(D=>Gc(D,C.receipts)),N(C.nextBefore)}).catch(()=>U(!0)).finally(()=>I(!1)))},[k,b,R]);Ft(F,12e4),d.useEffect(()=>{r!=="team"||Object.keys(u).length>0||$.listUsers().then(C=>{const D={};for(const _ of C)D[_.id]={name:_.name,email:_.email};p(D)}).catch(()=>{})},[r,u]);const ie=d.useMemo(()=>{const C=new Set;for(const D of s)C.add(Ie(D.profileId));return[...C].sort()},[s]),A=d.useMemo(()=>{const C=new Set;for(const D of s)C.add(D.action);return[...C].sort()},[s]),K=d.useMemo(()=>{if(r!=="team")return[];const C=new Set;for(const D of s)D.userId&&C.add(D.userId);return[...C].map(D=>{var _;return{id:D,label:(_=u[D])!=null&&_.name?`${u[D].name} (${u[D].email})`:D}}).sort((D,_)=>D.label.localeCompare(_.label))},[r,s,u]),T=d.useMemo(()=>s.filter(C=>!(!Sy(C,w)||y.size>0&&!y.has(Ie(C.profileId))||g.size>0&&!g.has(C.action)||h.size>0&&C.userId&&!h.has(C.userId)||!wy(C,v))),[s,w,y,g,h,v]),P=y.size>0||g.size>0||h.size>0||v!=="all";function O(C){j(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function X(C){f(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function Y(C){m(D=>{const _=new Set(D);return _.has(C)?_.delete(C):_.add(C),_})}function le(){j(new Set),f(new Set),m(new Set),S("all"),x("")}return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Receipts"}),o.jsx("p",{className:"page-subtitle",children:"Execution history for agent actions."})]}),n&&o.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",borderBottom:"1px solid var(--border)"},children:["mine","team"].map(C=>o.jsx("button",{onClick:()=>a(C),className:"btn btn-ghost",style:{borderRadius:0,padding:"0.5rem 0.875rem",borderBottom:r===C?"2px solid var(--accent)":"2px solid transparent",color:r===C?"var(--text-primary)":"var(--text-tertiary)",fontWeight:r===C?600:500},children:C==="mine"?"Mine":"Team"},C))}),o.jsxs("div",{className:"search-filter-bar",children:[o.jsxs("div",{className:"search-input-wrap",children:[o.jsx("span",{className:"search-icon",children:"⌕"}),o.jsx("input",{type:"text",className:"form-input search-input",placeholder:"Search by profile, action, path, or hash\\u2026",value:w,onChange:C=>x(C.target.value)}),w&&o.jsx("button",{className:"search-clear",onClick:()=>x(""),children:"×"})]}),o.jsxs("button",{className:`btn btn-sm btn-secondary${E?" active":""}`,onClick:()=>z(!E),children:["Filters",P?` (${y.size+g.size+(v!=="all"?1:0)})`:""]})]}),E&&o.jsxs("div",{className:"filter-panel",children:[ie.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Profile"}),o.jsx("div",{className:"filter-chips",children:ie.map(C=>o.jsx("button",{className:`filter-chip${y.has(C)?" selected":""}`,onClick:()=>O(C),children:C},C))})]}),A.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Action"}),o.jsx("div",{className:"filter-chips",children:A.map(C=>o.jsx("button",{className:`filter-chip${g.has(C)?" selected":""}`,onClick:()=>X(C),children:C},C))})]}),r==="team"&&K.length>1&&o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Owner"}),o.jsx("div",{className:"filter-chips",children:K.map(C=>o.jsx("button",{className:`filter-chip${h.has(C.id)?" selected":""}`,onClick:()=>Y(C.id),children:C.label},C.id))})]}),o.jsxs("div",{className:"filter-section",children:[o.jsx("div",{className:"filter-label",children:"Time range"}),o.jsx("div",{className:"filter-chips",children:[["1d","Today"],["7d","7 days"],["30d","30 days"],["all","All time"]].map(([C,D])=>o.jsx("button",{className:`filter-chip${v===C?" selected":""}`,onClick:()=>S(C),children:D},C))})]})]}),P&&o.jsxs("div",{className:"active-filters",children:[[...y].map(C=>o.jsxs("span",{className:"active-chip",onClick:()=>O(C),children:[C," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)),[...g].map(C=>o.jsxs("span",{className:"active-chip",onClick:()=>X(C),children:[C," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)),[...h].map(C=>{const D=u[C],_=D?D.name:C;return o.jsxs("span",{className:"active-chip",onClick:()=>Y(C),children:[_," ",o.jsx("span",{className:"chip-remove",children:"×"})]},C)}),v!=="all"&&o.jsxs("span",{className:"active-chip",onClick:()=>S("all"),children:[v==="1d"?"Today":v==="7d"?"7 days":"30 days"," ",o.jsx("span",{className:"chip-remove",children:"×"})]}),o.jsx("button",{className:"clear-filters",onClick:le,children:"Clear all"})]}),H&&o.jsx("div",{className:"card",style:{borderColor:"var(--danger, #c0392b)",marginBottom:"0.75rem"},children:o.jsx("span",{style:{color:"var(--danger, #c0392b)",fontSize:"0.85rem"},children:"Couldn’t load receipts — your session may have expired. Try signing out and back in."})}),l&&s.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):T.length===0?o.jsx(Hf,{icon:"⌕",title:s.length===0?"No receipts in the last 30 days":"No matching receipts",text:s.length===0?"Execution receipts appear here after an agent uses an authorized tool. Older receipts can be loaded below.":"Try adjusting your search or filters."}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.75rem"},children:T.length===s.length?`${s.length} receipt${s.length!==1?"s":""}`:`${T.length} of ${s.length} receipts`}),o.jsx("div",{className:"timeline",children:T.map(C=>{var D;return o.jsx("div",{className:"timeline-event",children:o.jsxs("div",{className:"card",style:{marginBottom:0},children:[o.jsxs("div",{className:"auth-card-header",children:[o.jsx(Vf,{profileId:C.profileId}),o.jsx("span",{className:"auth-card-path",children:C.path}),o.jsx("span",{className:"receipt-action",children:C.action}),o.jsx("span",{className:"auth-card-time",children:xy(C.timestamp)})]}),r==="team"&&C.userId&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:["Owner:"," ",o.jsx("span",{style:{color:"var(--text-secondary)"},children:(D=u[C.userId])!=null&&D.name?`${u[C.userId].name} (${u[C.userId].email})`:C.userId})]}),Object.keys(C.executionContext).length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.375rem"},children:Object.entries(C.executionContext).map(([_,V])=>`${_}=${V}`).join(" · ")}),o.jsxs("div",{style:{display:"flex",gap:"1rem",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:[o.jsxs("span",{children:["Daily: ",C.cumulativeState.daily.count," calls, $",C.cumulativeState.daily.amount]}),o.jsxs("span",{children:["Monthly: ",C.cumulativeState.monthly.count," calls, $",C.cumulativeState.monthly.amount]})]}),o.jsx("div",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",fontFamily:"'SF Mono', Monaco, monospace",wordBreak:"break-all",marginTop:"0.375rem"},children:C.attestationHash})]})},C.id)})})]}),k&&o.jsx("div",{style:{textAlign:"center",marginTop:"1rem"},children:o.jsx("button",{className:"btn btn-secondary btn-sm",onClick:ee,disabled:b,children:b?"Loading…":"Load older"})})]})}const Yc={ollama:{provider:"ollama",endpoint:"http://localhost:11434",models:["gemma4:e4b","gemma4:e2b","gemma4:26b","gemma4:31b","llama3.2","llama3.1","mistral","qwen2.5"]},openrouter:{provider:"openai-compatible",endpoint:"https://openrouter.ai/api/v1",models:["google/gemma-4-31b-it","qwen/qwen3.6-plus:free","stepfun/step-3.5-flash:free","google/gemini-2.5-flash","openai/gpt-4o-mini","anthropic/claude-haiku-4"]},openai:{provider:"openai-compatible",endpoint:"https://api.openai.com/v1",models:["gpt-4o-mini","gpt-4o","o3-mini"]},groq:{provider:"openai-compatible",endpoint:"https://api.groq.com/openai/v1",models:["llama-3.1-8b-instant","llama-3.3-70b-versatile","gemma2-9b-it"]},together:{provider:"openai-compatible",endpoint:"https://api.together.xyz/v1",models:["meta-llama/Llama-3-8b-chat-hf","meta-llama/Llama-3-70b-chat-hf"]}};function ky(){const[e,t]=d.useState(""),[n,r]=d.useState("openrouter"),[a,s]=d.useState("openai-compatible"),[i,l]=d.useState("https://openrouter.ai/api/v1"),[c,u]=d.useState("google/gemma-4-31b-it"),[p,h]=d.useState(""),[m,w]=d.useState(!1),[x,y]=d.useState(!1),[j,g]=d.useState(!1),[f,v]=d.useState(null),S=d.useCallback(b=>{t(b),setTimeout(()=>t(""),3e3)},[]),E=d.useCallback(async()=>{try{const b=await $.getCredential("ai-config");if(w(b.configured),b.configured&&b.fields){b.fields.provider&&s(b.fields.provider),b.fields.endpoint&&l(b.fields.endpoint),b.fields.model&&u(b.fields.model);const I=b.fields.endpoint??"";I.includes("openai.com")?r("openai"):I.includes("groq.com")?r("groq"):I.includes("together.xyz")?r("together"):I.includes("openrouter.ai")?r("openrouter"):r("ollama")}}catch{}},[]);d.useEffect(()=>{E()},[E]);const z=b=>{r(b);const I=Yc[b];I&&(s(I.provider),l(I.endpoint),u(I.models[0]))},k=async()=>{y(!0);try{await $.setCredential("ai-config",{provider:a,endpoint:i,model:c,...p?{apiKey:p}:{}}),w(!0),S("AI configuration saved!")}catch{S("Failed to save AI config")}finally{y(!1)}},N=async()=>{g(!0),v(null);try{const b=await $.aiTest(p?{provider:a,endpoint:i,model:c,apiKey:p}:{});v(b.ok?`OK: ${b.message}`:`Failed: ${b.message}`)}catch(b){v(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{g(!1)}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"AI Assistant"}),o.jsx("p",{className:"page-subtitle",children:"Advisory AI to help you think through intent when authorizing agents."})]}),e&&o.jsx("div",{className:"alert alert-success",children:e}),o.jsxs("div",{className:"card",children:[o.jsx("h3",{className:"card-title",children:"Configuration"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"1rem"},children:"Connect a trusted AI model that has access to your intent — problem, objective, and tradeoffs — to help you think through authorizations. Keys are encrypted in your vault."}),m&&o.jsxs("div",{className:"status-banner status-banner-success",style:{marginBottom:"1rem",fontSize:"0.8rem"},children:[o.jsx("span",{className:"status-banner-icon",children:"✓"}),o.jsx("span",{className:"status-banner-text",children:"AI configured"})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Provider Preset"}),o.jsxs("select",{className:"form-input",value:n,onChange:b=>z(b.target.value),children:[o.jsx("option",{value:"openrouter",children:"OpenRouter (recommended)"}),o.jsx("option",{value:"ollama",children:"Ollama (local)"}),o.jsx("option",{value:"openai",children:"OpenAI"}),o.jsx("option",{value:"groq",children:"Groq"}),o.jsx("option",{value:"together",children:"Together"})]})]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"0.75rem"},children:[o.jsx("label",{className:"form-label",children:"Model"}),(()=>{var H;const b=((H=Yc[n])==null?void 0:H.models)??[],I=b.includes(c);return o.jsxs(o.Fragment,{children:[o.jsxs("select",{className:"form-input",value:I?c:"__custom__",onChange:U=>{U.target.value==="__custom__"?u(""):u(U.target.value)},style:{marginBottom:I?void 0:"0.375rem"},children:[b.map(U=>o.jsx("option",{value:U,children:U},U)),o.jsx("option",{value:"__custom__",children:"Custom model..."})]}),!I&&o.jsx("input",{className:"form-input",value:c,onChange:U=>u(U.target.value),placeholder:"Enter model name"})]})})()]}),o.jsxs("div",{className:"form-group",style:{marginBottom:"1rem"},children:[o.jsx("label",{className:"form-label",children:"API Key (if required)"}),o.jsx("input",{className:"form-input",type:"password",value:p,onChange:b=>h(b.target.value),placeholder:m?"••••••••••••••••":"sk-... (not needed for Ollama)"})]}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[o.jsx("button",{className:"btn btn-primary",onClick:k,disabled:x,children:x?"Saving...":"Save & Encrypt"}),m&&o.jsx("button",{className:"btn btn-ghost",onClick:N,disabled:j,children:j?"Testing...":"Test Connection"})]}),f&&o.jsx("div",{className:`alert ${f.startsWith("OK")?"alert-success":"alert-error"}`,style:{marginTop:"0.75rem"},children:f})]}),o.jsx(Cy,{}),o.jsxs("div",{className:"card",style:{padding:"1.5rem",marginTop:"2rem"},children:[o.jsx("h2",{style:{fontSize:"1rem",fontWeight:700,marginBottom:"1rem"},children:"Security"}),o.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",lineHeight:1.7},children:[o.jsxs("div",{style:{marginBottom:"1rem"},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"What the gateway protects"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"Every tool call verified against your authorization bounds"}),o.jsx("li",{children:"Credentials never exposed to agents through MCP"}),o.jsx("li",{children:"Every action produces a signed receipt"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",marginBottom:"0.375rem"},children:"Your responsibility"}),o.jsxs("ul",{style:{margin:0,paddingLeft:"1.25rem"},children:[o.jsx("li",{children:"If your AI agent has full access to your computer, it could bypass the gateway"}),o.jsx("li",{children:"For best security, run agents in sandboxed environments"}),o.jsx("li",{children:"The gateway secures what agents do through tools — not what they do on your machine"})]})]})]})]})]})}function Cy(){const[e,t]=d.useState(null),[n,r]=d.useState({intent:"",context:""}),[a,s]=d.useState(null),[i,l]=d.useState(null),[c,u]=d.useState(null),[p,h]=d.useState(!1),m=d.useCallback(async()=>{if(!p)try{const y=await $.getAIPrompts();t(y),r({intent:y.intent.current,context:y.context.current}),h(!0)}catch(y){l(y instanceof Error?y.message:"Failed to load prompts")}},[p]),w=async y=>{if(e){s(y),l(null);try{const j=n[y],g=j.trim()===e[y].default.trim()?"":j;await $.setAIPrompt(y,g);const f=await $.getAIPrompts();t(f),r({intent:f.intent.current,context:f.context.current}),u(y),setTimeout(()=>u(null),2e3)}catch(j){l(j instanceof Error?j.message:"Save failed")}finally{s(null)}}},x=async y=>{if(confirm(`Revert ${y} prompt to the built-in default?`)){s(y),l(null);try{await $.setAIPrompt(y,"");const j=await $.getAIPrompts();t(j),r({intent:j.intent.current,context:j.context.current})}catch(j){l(j instanceof Error?j.message:"Revert failed")}finally{s(null)}}};return o.jsxs("details",{className:"card",style:{padding:"1.5rem",marginTop:"1rem"},onToggle:y=>{y.currentTarget.open&&m()},children:[o.jsx("summary",{style:{fontSize:"1rem",fontWeight:700,cursor:"pointer",listStyle:"revert",userSelect:"none"},children:"Advanced — AI assistant prompts"}),o.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",margin:"0.75rem 0 1rem 0",lineHeight:1.55},children:"These are the system prompts the AI assistant sees when helping you write Intent (per-authorization) or Context (your standing-orders brief). Edit with care — changes apply on the next chat turn."}),i&&o.jsx("div",{className:"alert alert-error",style:{marginBottom:"0.75rem"},children:i}),!p&&!i&&o.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.85rem"},children:"Loading prompts…"}),e&&o.jsxs(o.Fragment,{children:[o.jsx(Qc,{kind:"intent",label:"Intent — per-authorization",description:"Used on the Intent gate when creating a new authorization.",state:e.intent,draft:n.intent,onChange:y=>r(j=>({...j,intent:y})),onSave:()=>w("intent"),onRevert:()=>x("intent"),saving:a==="intent",justSaved:c==="intent"}),o.jsx(Qc,{kind:"context",label:"Context — standing-orders brief",description:"Used on the Brief page when refining your context.md.",state:e.context,draft:n.context,onChange:y=>r(j=>({...j,context:y})),onSave:()=>w("context"),onRevert:()=>x("context"),saving:a==="context",justSaved:c==="context"})]})]})}function Qc({kind:e,label:t,description:n,state:r,draft:a,onChange:s,onSave:i,onRevert:l,saving:c,justSaved:u}){const p=a!==r.current;return o.jsxs("section",{style:{marginBottom:"1.5rem"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"0.25rem",gap:"1rem",flexWrap:"wrap"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"0.9rem"},children:t}),o.jsx("div",{style:{fontSize:"0.78rem",color:"var(--text-secondary)"},children:n})]}),r.overridden&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--accent)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Custom"})]}),o.jsx("textarea",{className:"form-textarea",value:a,onChange:h=>s(h.target.value),rows:12,spellCheck:!1,style:{width:"100%",fontFamily:"'SF Mono', Monaco, 'Cascadia Code', monospace",fontSize:"0.82rem",lineHeight:1.55,resize:"vertical",minHeight:"14rem",marginTop:"0.5rem"},"aria-label":`${t} system prompt`}),o.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center",marginTop:"0.5rem",flexWrap:"wrap"},children:[o.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:i,disabled:c||!p,children:c?"Saving…":"Save"}),r.overridden&&o.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:l,disabled:c,title:"Discard the override and use the built-in default",children:"Revert to default"}),u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--success)"},children:"Saved"}),p&&!c&&!u&&o.jsx("span",{style:{fontSize:"0.78rem",color:"var(--text-muted)"},children:"Unsaved changes"})]}),o.jsxs("details",{style:{marginTop:"0.5rem"},children:[o.jsx("summary",{style:{fontSize:"0.78rem",color:"var(--text-muted)",cursor:"pointer"},children:"Show built-in default"}),o.jsx("pre",{style:{marginTop:"0.5rem",padding:"0.75rem 1rem",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.5rem",fontSize:"0.78rem",lineHeight:1.55,whiteSpace:"pre-wrap",maxHeight:"20rem",overflowY:"auto"},children:r.default})]}),o.jsx("span",{style:{display:"none"},children:e})]})}function by(e){return e.proposalId?"review":"automatic"}function Jc(e,t,n={}){const r=n.status??"pending",a=n.includeAutonomous??!1,s=[];for(const i of e)r==="pending"&&i.status!=="pending"||n.profile&&i.profileId!==n.profile||s.push({kind:"proposal",id:i.id,sortTimestamp:i.createdAt,commitmentMode:"review",profileId:i.profileId,proposal:i});if(r==="all")for(const i of t){const l=by(i);!a&&l==="automatic"||n.profile&&i.profileId!==n.profile||s.push({kind:"receipt",id:i.id,sortTimestamp:i.timestamp,commitmentMode:l,profileId:i.profileId,receipt:i})}return s.sort((i,l)=>l.sortTimestamp-i.sortTimestamp),typeof n.limit=="number"&&n.limit>0?s.slice(0,n.limit):s}function Kf(e,t){const n=e-Math.floor(t/1e3);if(n<=0)return{label:"expired",urgent:!1,expired:!0};const r=Math.floor(n/86400),a=Math.floor(n%86400/3600),s=Math.floor(n%3600/60);let i;return r>0?i=`expires in ${r}d ${a}h`:a>0?i=`expires in ${a}h ${s}m`:i=`expires in ${Math.max(1,s)}m`,{label:i,urgent:n<2*3600,expired:!1}}const Ny={pending:"Pending",committed:"Approved",executed:"Executed",rejected:"Rejected",expired:"Expired"},Ey={pending:"status-pending",committed:"status-active",executed:"status-active",rejected:"status-revoked",expired:"status-expired"};function zy(e){const t=Date.now()-e*1e3,n=t/36e5;return n<48?n<1?`${Math.max(1,Math.round(t/6e4))}m ago`:`${Math.round(n)}h ago`:new Date(e*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Iy(e){return e.split("__").pop()??e}function Py(e){const t=e.toLowerCase();return t.includes("delete")||t.includes("refund")||t.includes("cancel")||t.includes("revoke")}const Ty=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]),Ry=/^(image|img|photo|picture|thumbnail)(_?url)?$/i;function _y(e,t){return typeof t!="string"?!1:/^data:image\//i.test(t)?!0:Ry.test(e)?/^https?:\/\//.test(t):/^https?:\/\/.+\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i.test(t)}function yi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>yi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xc({item:e,onApprove:t,onReject:n,resolving:r}){const a=e.kind==="proposal",s=a?e.proposal.status:"executed",i=a?e.proposal.tool:e.receipt.action,l=Iy(i),c=Py(i),u=a?e.proposal.toolArgs:null,p=a?e.proposal.executionContext:e.receipt.executionContext,h=a?null:e.receipt.cumulativeState,m=u?Object.entries(u).filter(([x])=>!Ty.has(x)):[],w=Object.entries(p??{});return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.75rem",flexWrap:"wrap"},children:[o.jsx(Vf,{profileId:e.profileId}),o.jsx("code",{style:{fontSize:"0.85rem"},children:l}),e.commitmentMode==="automatic"&&o.jsx("span",{style:{fontSize:"0.7rem",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:"autonomous"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[a&&s==="pending"&&(()=>{const x=Kf(e.proposal.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:x.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:x.urgent?600:400,whiteSpace:"nowrap"},children:x.label})})(),o.jsx("span",{className:`status-badge ${Ey[s]}`,children:Ny[s]}),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:zy(e.sortTimestamp)})]})]}),c&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.4rem",fontSize:"0.8rem",color:"var(--warning)",background:"var(--bg-main)",border:"1px solid var(--border)",borderRadius:"0.375rem",padding:"0.4rem 0.6rem",marginBottom:"0.75rem"},children:[o.jsx("span",{children:"⚠"}),o.jsx("span",{children:"Irreversible action"})]}),a&&typeof(u==null?void 0:u._imagePreview)=="string"&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Preview"}),o.jsx("img",{src:u._imagePreview,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:"local image preview",style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"}})]}),a&&m.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.35rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:m.map(([x,y])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:x}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:_y(x,y)?o.jsx("img",{src:y,alt:typeof(u==null?void 0:u.altText)=="string"?u.altText:x,style:{display:"block",maxWidth:"100%",maxHeight:"240px",borderRadius:"0.375rem",border:"1px solid var(--border)"},onError:j=>{const g=j.currentTarget,f=g.parentElement;if(!f)return;g.style.display="none";const v=document.createElement("span");v.textContent=y,v.style.color="var(--text-tertiary)",f.appendChild(v)}}):yi(y)})]},x))})]}),w.length>0&&o.jsx("div",{style:{marginBottom:"0.75rem",fontSize:"0.8rem",color:"var(--text-secondary)"},children:w.map(([x,y])=>`${x}=${yi(y)}`).join(" · ")}),h&&o.jsxs("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:["After this action · today: ",h.daily.count," action",h.daily.count===1?"":"s",h.daily.amount>0?`, ${h.daily.amount}`:""," · ","this month: ",h.monthly.count,h.monthly.amount>0?`, ${h.monthly.amount}`:""]}),a&&s==="pending"&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:()=>t==null?void 0:t(e.id),disabled:r,children:r?"Approving…":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:()=>n==null?void 0:n(e.id),disabled:r,children:"Reject"})]}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:[a?"Proposal":"Receipt",": ",e.id]})]})}const Ay=new Set(["apiKey","api_key","accessToken","access_token","password","secret","signature","_imagePreview"]);function xi(e){if(e==null)return"—";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.map(t=>xi(t)).join(", ");try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $y(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Ly({proposal:e,currentUserId:t,onAction:n,onMessage:r}){const[a,s]=d.useState(!1),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,h]=d.useState(!1),[m,w]=d.useState(null),[x,y]=d.useState(!1),j=e.tool.split("__").pop()??e.tool,g=Object.entries(e.toolArgs).filter(([B])=>!Ay.has(B)),f=Object.entries(e.executionContext),v=e.pendingApprovers??[],S=e.approvedBy??{},E=Object.keys(S).length,z=v.filter(B=>!(B in S)).length,k=t in S,N=async()=>{if(c===null){h(!0),w(null);try{const B=await $.getAttestationIntent(e.authorizationId);if(!B){w("Intent not available or you are not an authorized approver.");return}const R=await $.decryptIntent({intentCiphertext:B.intentCiphertext,encryptedKey:B.encryptedKey,approverId:t});u(R)}catch(B){w(B instanceof Error?B.message:"Failed to decrypt intent")}finally{h(!1)}}},b=async()=>{x?y(!1):(y(!0),await N())},I=async()=>{s(!0),r("");try{await $.approveProposal(e.id);try{if(c===null){const B=await $.getAttestationIntent(e.authorizationId);if(B){const R=await $.decryptIntent({intentCiphertext:B.intentCiphertext,encryptedKey:B.encryptedKey,approverId:t});u(R),await $.storeApprovedIntent(e.authorizationId,R)}}else await $.storeApprovedIntent(e.authorizationId,c)}catch{}r(`Approved. ${z-1>0?`${z-1} more approver(s) still needed.`:"All approvers signed off — action is ready to execute."}`),n()}catch(B){r(B instanceof Error?B.message:"Approval failed")}finally{s(!1)}},H=async()=>{const B=prompt("Rejection reason (optional):");if(B!==null){l(!0),r("");try{await $.rejectProposal(e.id,B||void 0),r("Action rejected."),n()}catch(R){r(R instanceof Error?R.message:"Rejection failed")}finally{l(!1)}}},U=a||i;return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ie(e.profileId)}),o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"0.5rem"},children:[(()=>{const B=Kf(e.expiresAt,Date.now());return o.jsx("span",{style:{fontSize:"0.72rem",color:B.urgent?"var(--warning)":"var(--text-tertiary)",fontWeight:B.urgent?600:400,whiteSpace:"nowrap"},children:B.label})})(),o.jsx("span",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)"},children:$y(e.createdAt)})]})]}),o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[E," of ",v.length," approver",v.length===1?"":"s"," signed off",v.map(B=>{const R=B in S;return o.jsxs("span",{style:{marginLeft:"0.5rem",color:R?"var(--success, green)":"var(--text-tertiary)"},children:[R?"✓":"○"," ",B===t?"You":B]},B)})]}),o.jsxs("div",{style:{marginBottom:"0.5rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Proposed action"}),o.jsx("code",{style:{fontSize:"0.85rem"},children:j})]}),g.length>0&&o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsx("div",{style:{fontSize:"0.7rem",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:"0.25rem"},children:"Arguments"}),o.jsx("dl",{style:{display:"grid",gridTemplateColumns:"max-content 1fr",gap:"0.2rem 0.75rem",fontSize:"0.85rem",margin:0},children:g.map(([B,R])=>o.jsxs(d.Fragment,{children:[o.jsx("dt",{style:{color:"var(--text-tertiary)",whiteSpace:"nowrap",alignSelf:"start"},children:B}),o.jsx("dd",{style:{color:"var(--text-primary)",margin:0,wordBreak:"break-word",whiteSpace:"pre-wrap"},children:xi(R)})]},B))})]}),f.length>0&&o.jsx("div",{style:{fontSize:"0.8rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:f.map(([B,R])=>`${B}=${xi(R)}`).join(" · ")}),o.jsxs("div",{style:{marginBottom:"0.75rem"},children:[o.jsxs("button",{className:"btn btn-ghost btn-sm",style:{padding:"0.2rem 0",fontSize:"0.75rem"},onClick:b,disabled:p,children:[x?"▲ Hide intent":"▼ Show intent",p&&" (decrypting...)"]}),x&&o.jsx("div",{style:{marginTop:"0.5rem",padding:"0.75rem",background:"var(--bg-main)",borderRadius:"0.375rem",border:"1px solid var(--border)"},children:m?o.jsx("p",{style:{color:"var(--danger)",fontSize:"0.8rem",margin:0},children:m}):c!==null?o.jsx("p",{style:{fontSize:"0.85rem",margin:0,whiteSpace:"pre-wrap",color:"var(--text-primary)"},children:c}):o.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"0.8rem",margin:0},children:"No intent available for this authority."})})]}),!k&&o.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:"0.25rem"},children:[o.jsx("button",{className:"btn btn-primary",onClick:I,disabled:U,children:a?"Approving...":"Approve"}),o.jsx("button",{className:"btn btn-ghost",style:{color:"var(--danger)"},onClick:H,disabled:U,children:i?"Rejecting...":"Reject"})]}),k&&o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginTop:"0.25rem"},children:"You approved this action. Waiting on other approvers."}),o.jsxs("div",{style:{marginTop:"0.5rem",fontSize:"0.7rem",color:"var(--text-tertiary)"},children:["Proposal: ",e.id]})]})}function My(){const{domain:e,user:t}=Pe(),n=(t==null?void 0:t.id)??"",[r,a]=d.useState("awaiting-me"),[s,i]=d.useState([]),[l,c]=d.useState(!0),[u,p]=d.useState(""),h=d.useCallback(async()=>{try{const _=await $.getProposalsForApprover();i(_)}catch{}finally{c(!1)}},[]);he("proposal-added",h),he("proposal-approved",h),he("proposal-rejected",h),he("proposal-resolved",h),Ft(h,3e4);const[m,w]=d.useState([]),x=d.useCallback(async()=>{try{const _=await $.getProposals(e||"owner");w(_)}catch{}},[e]);he("proposal-added",x),he("proposal-approved",x),he("proposal-rejected",x),he("proposal-resolved",x),Ft(x,3e4,e);const y=d.useMemo(()=>m.filter(_=>{var V;return _.status==="pending"&&(((V=_.pendingApprovers)==null?void 0:V.length)??0)===0}),[m]),j=d.useMemo(()=>Jc(y,[],{status:"pending"}),[y]),[g,f]=d.useState([]),v=d.useCallback(async()=>{if(n)try{const V=(await $.getProposals(e||"owner")).filter(q=>q.status==="pending"&&q.pendingApprovers&&q.pendingApprovers.includes(n)&&q.approvedBy&&n in q.approvedBy);f(V)}catch{}},[n,e]);he("proposal-approved",v),he("proposal-rejected",v),Ft(v,3e4,`${n}:${e}`),d.useEffect(()=>{h(),x(),v()},[]);const[S,E]=d.useState([]),[z,k]=d.useState([]),[N,b]=d.useState(!0),[I,H]=d.useState(null),[U,B]=d.useState(""),[R,F]=d.useState("pending"),[ee,ie]=d.useState(null),[A,K]=d.useState(!1),T=d.useCallback(async()=>{try{const{proposals:_,receipts:V}=await $.getThread({domain:e,status:R,sinceDays:7});E(_),k(V)}catch{}finally{b(!1)}},[e,R]);Ft(T,3e4,`${e}:${R}`);const P=async(_,V)=>{H(_),B("");try{const q=e||"owner",Q=await $.resolveProposal(_,V,q);B(V==="commit"?`Action approved. Status: ${Q.status}`:"Action rejected."),await Promise.all([T(),x()])}catch(q){B(q instanceof Error?q.message:"Failed")}finally{H(null)}},O=d.useMemo(()=>{const _=new Set;for(const V of S)_.add(V.profileId);for(const V of z)_.add(V.profileId);return Array.from(_).sort()},[S,z]),X=d.useMemo(()=>Jc(S,z,{status:R,profile:ee??void 0,includeAutonomous:A}),[S,z,R,ee,A]),Y=d.useCallback(()=>{h(),v()},[h,v]),le=d.useMemo(()=>{const _=new Set,V=[];for(const q of g)_.has(q.id)||(_.add(q.id),V.push(q));return V.sort((q,Q)=>Q.createdAt-q.createdAt)},[g]),C=s.length+j.length,D=le.length;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Pending Approvals"}),o.jsx("p",{className:"page-subtitle",children:"Actions awaiting approval, plus recent activity from the last 7 days."})]}),o.jsxs("div",{className:"nav-tabs",style:{marginBottom:"1rem"},children:[o.jsxs("button",{className:`nav-tab${r==="awaiting-me"?" active":""}`,onClick:()=>a("awaiting-me"),children:["Awaiting me ",C>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--warning)",color:"var(--bg-elevated)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:C})]}),o.jsxs("button",{className:`nav-tab${r==="awaiting-others"?" active":""}`,onClick:()=>a("awaiting-others"),children:["Awaiting others ",D>0&&o.jsx("span",{style:{marginLeft:"0.4rem",background:"var(--border)",color:"var(--text-secondary)",borderRadius:"0.625rem",padding:"0 0.375rem",fontSize:"0.7rem",fontWeight:600},children:D})]}),o.jsx("button",{className:`nav-tab${r==="all"?" active":""}`,onClick:()=>{a("all"),T()},children:"All"})]}),r==="awaiting-me"&&o.jsx(o.Fragment,{children:l&&C===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):C===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions awaiting your approval."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Review-mode actions and above-cap actions you must approve will appear here."})]}):o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:[(u||U)&&o.jsx("div",{className:"alert alert-success",children:u||U}),j.map(_=>o.jsx(Xc,{item:_,onApprove:V=>P(V,"commit"),onReject:V=>P(V,"reject"),resolving:I===_.id},_.id)),s.map(_=>o.jsx(Ly,{proposal:_,currentUserId:n,onAction:Y,onMessage:p},_.id))]})}),r==="awaiting-others"&&o.jsx(o.Fragment,{children:le.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:"No actions waiting on others."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:"Actions you proposed or approved that are pending other approvers will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:le.map(_=>o.jsx(Oy,{proposal:_,currentUserId:n,onCancel:async()=>{try{await $.rejectProposal(_.id,"cancelled by creator"),v(),x()}catch(V){alert(V instanceof Error?V.message:"Cancel failed")}}},_.id))})}),r==="all"&&o.jsxs(o.Fragment,{children:[U&&o.jsx("div",{className:"alert alert-success",style:{marginBottom:"1rem"},children:U}),o.jsxs("div",{className:"filter-chips",style:{marginBottom:"1rem"},children:[o.jsx("button",{className:`filter-chip ${R==="pending"?"selected":""}`,onClick:()=>F("pending"),children:"Pending"}),o.jsx("button",{className:`filter-chip ${R==="all"?"selected":""}`,onClick:()=>F("all"),children:"All"}),O.length>0&&o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),O.map(_=>o.jsx("button",{className:`filter-chip ${ee===_?"selected":""}`,onClick:()=>ie(ee===_?null:_),children:Ie(_)},_)),R==="all"&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:1,background:"var(--border)",alignSelf:"stretch",margin:"0 0.25rem"}}),o.jsxs("button",{className:`filter-chip ${A?"selected":""}`,onClick:()=>K(!A),title:"Include actions executed without human review (automatic commitment mode)",children:[A?"✓ ":"","Autonomous actions"]})]})]}),N&&X.length===0?o.jsx("p",{style:{color:"var(--text-tertiary)"},children:"Loading..."}):X.length===0?o.jsxs("div",{className:"card",style:{textAlign:"center",padding:"2rem"},children:[o.jsx("p",{style:{color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:R==="pending"?"No actions awaiting your approval.":"Nothing here yet."}),o.jsx("p",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)"},children:R==="pending"?"Your agents are operating within their authorizations. Switch to All to see recent activity.":"When an agent calls a gated tool, activity will appear here."})]}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"1rem"},children:X.map(_=>o.jsx(Xc,{item:_,onApprove:V=>P(V,"commit"),onReject:V=>P(V,"reject"),resolving:I===_.id},_.id))})]})]})}function Fy(e){const t=Date.now()-e*1e3,n=Math.floor(t/6e4);if(n<60)return`${Math.max(1,n)}m ago`;const r=Math.floor(t/36e5);return r<48?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Oy({proposal:e,currentUserId:t,onCancel:n}){var u;const[r,a]=d.useState(!1),s=Object.keys(e.approvedBy??{}),i=(e.pendingApprovers??[]).filter(p=>!(p in(e.approvedBy??{}))),l=(((u=e.pendingApprovers)==null?void 0:u.length)??0)>0,c=async()=>{if(confirm("Cancel this action? All approvers will be notified.")){a(!0);try{await n()}finally{a(!1)}}};return o.jsxs("div",{className:"card",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.5rem",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:"0.9rem"},children:Ie(e.profileId)}),l&&o.jsx("span",{style:{fontSize:"0.65rem",padding:"0.15rem 0.4rem",borderRadius:"0.25rem",background:"var(--accent-subtle)",color:"var(--accent)",fontWeight:600},children:"Above cap"}),o.jsx("span",{style:{marginLeft:"auto",fontSize:"0.75rem",color:"var(--text-tertiary)"},children:Fy(e.createdAt)})]}),o.jsx("div",{style:{fontSize:"0.85rem",color:"var(--text-secondary)",marginBottom:"0.5rem"},children:o.jsx("code",{children:e.tool.split("__").pop()??e.tool})}),l&&o.jsxs("div",{style:{fontSize:"0.8rem",color:"var(--text-tertiary)",marginBottom:"0.5rem"},children:[s.map(p=>o.jsx("span",{style:{marginRight:"0.75rem",color:"var(--success, green)"},children:p===t?"You approved":`${p} approved`},p)),i.map(p=>o.jsxs("span",{style:{marginRight:"0.75rem",color:"var(--text-tertiary)"},children:["Waiting on ",p===t?"you":p]},p))]}),o.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.5rem",marginTop:"0.5rem"},children:o.jsx("button",{className:"btn btn-ghost btn-sm",style:{color:"var(--danger)"},onClick:c,disabled:r,children:r?"Cancelling...":"Cancel"})})]})}const By=`# Agent Brief
70
70
 
71
71
  You act on my behalf through Suveren — the gateway that gates every
72
72
  privileged tool call you make. Suveren implements the bounded-authority
@@ -102,4 +102,4 @@ executes. When you propose an action:
102
102
  next.
103
103
  - Never email anyone outside the company without asking first.
104
104
  - When drafting posts, prefer plain language over marketing copy.
105
- `;function Dy(){const[e,t]=d.useState(""),[n,r]=d.useState(""),[a,s]=d.useState(!0),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,m]=d.useState(!1),g=e!==n,w=new Blob([e]).size,x=16*1024;d.useEffect(()=>{if(!g)return;const f=S=>{S.preventDefault(),S.returnValue=""},v=S=>{var k,N;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const E=(N=(k=S.target)==null?void 0:k.closest)==null?void 0:N.call(k,"a");if(!E||!E.href)return;let z;try{z=new URL(E.href)}catch{return}z.origin===window.location.origin&&z.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",f),document.addEventListener("click",v,!0),()=>{window.removeEventListener("beforeunload",f),document.removeEventListener("click",v,!0)}},[g]),d.useEffect(()=>{let f=!1;return L.getAgentContext().then(v=>{f||(t(v),r(v))}).catch(v=>{f||u({kind:"error",text:v instanceof Error?v.message:"Failed to load context"})}).finally(()=>{f||s(!1)}),()=>{f=!0}},[]);const y=async()=>{l(!0),u(null);try{await L.saveAgentContext(e),r(e),u({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(f){u({kind:"error",text:f instanceof Error?f.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),u(null)},h=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(By)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Agent Brief"}),o.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!a&&o.jsx("button",{className:"btn btn-primary btn-sm",onClick:h,disabled:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&o.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),o.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[o.jsx("div",{className:"card intent-pane chat",children:o.jsx(yo,{target:{kind:"context"},currentText:e,onApply:f=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(f)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[o.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),o.jsxs("span",{style:{fontSize:"0.75rem",color:w>x?"var(--danger)":"var(--text-muted)"},children:[w.toLocaleString()," / ",x.toLocaleString()," bytes"]})]}),o.jsx("textarea",{className:"form-textarea",value:e,onChange:f=>t(f.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),o.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i||!g,children:"Revert"}),o.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:y,disabled:i||!g||w>x||a,children:i?"Saving…":"Save"})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>m(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),o.jsx(Bf,{open:p,onClose:()=>m(!1),ariaLabel:"Brief assistant",children:o.jsx(yo,{target:{kind:"context"},currentText:e,onApply:f=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(f),m(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Uy({children:e}){const{user:t,mode:n,domain:r}=Pe();return t?n==="team"&&!r?o.jsx(Jt,{to:"/onboarding",replace:!0}):o.jsx(o.Fragment,{children:e}):o.jsx(Jt,{to:"/login",replace:!0})}function Wy(){const{user:e}=Pe();return o.jsxs(wg,{children:[o.jsx(Ne,{path:"/login",element:e?o.jsx(Jt,{to:"/",replace:!0}):o.jsx(wv,{})}),o.jsx(Ne,{path:"/onboarding",element:e?o.jsx(Sv,{}):o.jsx(Jt,{to:"/login",replace:!0})}),o.jsxs(Ne,{element:o.jsx(Uy,{children:o.jsx(xv,{})}),children:[o.jsx(Ne,{path:"/",element:o.jsx(Nv,{})}),o.jsx(Ne,{path:"/agent/new",element:o.jsx(Jt,{to:"/authorizations?new=1",replace:!0})}),o.jsx(Ne,{path:"/agent/gate",element:o.jsx(Jv,{})}),o.jsx(Ne,{path:"/agent/review",element:o.jsx(ty,{})}),o.jsx(Ne,{path:"/integrations",element:o.jsx(ay,{})}),o.jsx(Ne,{path:"/groups",element:o.jsx(oy,{})}),o.jsx(Ne,{path:"/authorizations",element:o.jsx(yy,{})}),o.jsx(Ne,{path:"/audit",element:o.jsx(jy,{})}),o.jsx(Ne,{path:"/proposals",element:o.jsx(My,{})}),o.jsx(Ne,{path:"/agent-brief",element:o.jsx(Dy,{})}),o.jsx(Ne,{path:"/settings",element:o.jsx(ky,{})}),o.jsx(Ne,{path:"/settings/services",element:o.jsx(Jt,{to:"/settings",replace:!0})}),o.jsx(Ne,{path:"/deploy",element:o.jsx(Jt,{to:"/integrations",replace:!0})})]}),o.jsx(Ne,{path:"*",element:o.jsx(Jt,{to:"/",replace:!0})})]})}function Hy(){return o.jsx(Vg,{children:o.jsx(tv,{children:o.jsx(nv,{children:o.jsx(Wy,{})})})})}ff(document.getElementById("root")).render(o.jsx(d.StrictMode,{children:o.jsx(Hy,{})}));
105
+ `;function Dy(){const[e,t]=d.useState(""),[n,r]=d.useState(""),[a,s]=d.useState(!0),[i,l]=d.useState(!1),[c,u]=d.useState(null),[p,h]=d.useState(!1),m=e!==n,w=new Blob([e]).size,x=16*1024;d.useEffect(()=>{if(!m)return;const f=S=>{S.preventDefault(),S.returnValue=""},v=S=>{var k,N;if(S.defaultPrevented||S.button!==0||S.metaKey||S.ctrlKey||S.shiftKey||S.altKey)return;const E=(N=(k=S.target)==null?void 0:k.closest)==null?void 0:N.call(k,"a");if(!E||!E.href)return;let z;try{z=new URL(E.href)}catch{return}z.origin===window.location.origin&&z.pathname!==window.location.pathname&&(confirm("You have unsaved changes to your agent brief. Leave anyway?")||(S.preventDefault(),S.stopPropagation()))};return window.addEventListener("beforeunload",f),document.addEventListener("click",v,!0),()=>{window.removeEventListener("beforeunload",f),document.removeEventListener("click",v,!0)}},[m]),d.useEffect(()=>{let f=!1;return $.getAgentContext().then(v=>{f||(t(v),r(v))}).catch(v=>{f||u({kind:"error",text:v instanceof Error?v.message:"Failed to load context"})}).finally(()=>{f||s(!1)}),()=>{f=!0}},[]);const y=async()=>{l(!0),u(null);try{await $.saveAgentContext(e),r(e),u({kind:"ok",text:"Saved. New MCP sessions will pick this up on next connect."})}catch(f){u({kind:"error",text:f instanceof Error?f.message:"Save failed"})}finally{l(!1)}},j=()=>{t(n),u(null)},g=()=>{e.trim()&&!confirm("Replace current context with the starter template?")||t(By)};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"page-header",children:[o.jsx("h1",{className:"page-title",children:"Agent Brief"}),o.jsx("p",{className:"page-subtitle",children:"Standing orders for agents that connect via MCP. This text prepends every new session — keep it tight."}),!e.trim()&&!a&&o.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:i,title:"Insert a starter brief covering Suveren basics and example standing orders",style:{marginTop:"0.5rem"},children:"Insert starter template"})]}),c&&o.jsx("div",{className:c.kind==="ok"?"alert alert-success":"error-message",style:{marginBottom:"1rem"},children:c.text}),o.jsxs("div",{className:"intent-layout",style:{marginBottom:"1rem"},children:[o.jsx("div",{className:"card intent-pane chat",children:o.jsx(yo,{target:{kind:"context"},currentText:e,onApply:f=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||t(f)},greeting:"Tell me what your agent should know — I'll help shape your standing orders. Or ask me to draft a full brief and we'll iterate.",placeholder:"Ask for help with your brief…"})}),o.jsxs("div",{className:"card intent-pane document",children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"0.5rem",flexWrap:"wrap",marginBottom:"0.5rem"},children:[o.jsx("h3",{className:"card-title",style:{marginBottom:0},children:"context.md"}),o.jsxs("span",{style:{fontSize:"0.75rem",color:w>x?"var(--danger)":"var(--text-muted)"},children:[w.toLocaleString()," / ",x.toLocaleString()," bytes"]})]}),o.jsx("textarea",{className:"form-textarea",value:e,onChange:f=>t(f.target.value),placeholder:a?"Loading…":'Type your standing orders here, or click "Insert starter template" below.',disabled:a,rows:18,style:{fontFamily:"'SF Mono', Monaco, monospace",fontSize:"0.85rem",lineHeight:1.5,minHeight:"22rem"}}),o.jsxs("div",{className:"intent-footer",style:{marginTop:"0.75rem"},children:[o.jsx("button",{className:"btn btn-ghost",onClick:j,disabled:i||!m,children:"Revert"}),o.jsx("button",{className:"btn btn-primary",style:{flex:1},onClick:y,disabled:i||!m||w>x||a,children:i?"Saving…":"Save"})]})]}),o.jsx("button",{type:"button",className:"floating-help",onClick:()=>h(!0),"aria-label":"Open brief assistant",children:"Get help with brief"}),o.jsx(Bf,{open:p,onClose:()=>h(!1),ariaLabel:"Brief assistant",children:o.jsx(yo,{target:{kind:"context"},currentText:e,onApply:f=>{e.trim()&&!confirm("Replace the current context with the applied draft?")||(t(f),h(!1))},greeting:"Tell me what your agent should know — I'll help shape your standing orders.",placeholder:"Ask for help with your brief…"})})]})]})}function Uy({children:e}){const{user:t,mode:n,domain:r}=Pe();return t?n==="team"&&!r?o.jsx(Jt,{to:"/onboarding",replace:!0}):o.jsx(o.Fragment,{children:e}):o.jsx(Jt,{to:"/login",replace:!0})}function Wy(){const{user:e}=Pe();return o.jsxs(wg,{children:[o.jsx(Ne,{path:"/login",element:e?o.jsx(Jt,{to:"/",replace:!0}):o.jsx(wv,{})}),o.jsx(Ne,{path:"/onboarding",element:e?o.jsx(Sv,{}):o.jsx(Jt,{to:"/login",replace:!0})}),o.jsxs(Ne,{element:o.jsx(Uy,{children:o.jsx(xv,{})}),children:[o.jsx(Ne,{path:"/",element:o.jsx(Nv,{})}),o.jsx(Ne,{path:"/agent/new",element:o.jsx(Jt,{to:"/authorizations?new=1",replace:!0})}),o.jsx(Ne,{path:"/agent/gate",element:o.jsx(Jv,{})}),o.jsx(Ne,{path:"/agent/review",element:o.jsx(ty,{})}),o.jsx(Ne,{path:"/integrations",element:o.jsx(ay,{})}),o.jsx(Ne,{path:"/groups",element:o.jsx(oy,{})}),o.jsx(Ne,{path:"/authorizations",element:o.jsx(yy,{})}),o.jsx(Ne,{path:"/audit",element:o.jsx(jy,{})}),o.jsx(Ne,{path:"/proposals",element:o.jsx(My,{})}),o.jsx(Ne,{path:"/agent-brief",element:o.jsx(Dy,{})}),o.jsx(Ne,{path:"/settings",element:o.jsx(ky,{})}),o.jsx(Ne,{path:"/settings/services",element:o.jsx(Jt,{to:"/settings",replace:!0})}),o.jsx(Ne,{path:"/deploy",element:o.jsx(Jt,{to:"/integrations",replace:!0})})]}),o.jsx(Ne,{path:"*",element:o.jsx(Jt,{to:"/",replace:!0})})]})}function Hy(){return o.jsx(Vg,{children:o.jsx(tv,{children:o.jsx(nv,{children:o.jsx(Wy,{})})})})}ff(document.getElementById("root")).render(o.jsx(d.StrictMode,{children:o.jsx(Hy,{})}));