diff --git "a/backend/static/assets/index-CcTOklY6.js" "b/backend/static/assets/index-CcTOklY6.js" new file mode 100644--- /dev/null +++ "b/backend/static/assets/index-CcTOklY6.js" @@ -0,0 +1,44 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function Uc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Na={exports:{}},Tl={},_a={exports:{}},$={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var kr=Symbol.for("react.element"),Vc=Symbol.for("react.portal"),Bc=Symbol.for("react.fragment"),Wc=Symbol.for("react.strict_mode"),Hc=Symbol.for("react.profiler"),Qc=Symbol.for("react.provider"),Kc=Symbol.for("react.context"),Xc=Symbol.for("react.forward_ref"),Yc=Symbol.for("react.suspense"),Gc=Symbol.for("react.memo"),Jc=Symbol.for("react.lazy"),co=Symbol.iterator;function Zc(e){return e===null||typeof e!="object"?null:(e=co&&e[co]||e["@@iterator"],typeof e=="function"?e:null)}var Ca={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ea=Object.assign,Pa={};function Fn(e,t,n){this.props=e,this.context=t,this.refs=Pa,this.updater=n||Ca}Fn.prototype.isReactComponent={};Fn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Fn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Ta(){}Ta.prototype=Fn.prototype;function ci(e,t,n){this.props=e,this.context=t,this.refs=Pa,this.updater=n||Ca}var di=ci.prototype=new Ta;di.constructor=ci;Ea(di,Fn.prototype);di.isPureReactComponent=!0;var fo=Array.isArray,La=Object.prototype.hasOwnProperty,fi={current:null},Ra={key:!0,ref:!0,__self:!0,__source:!0};function za(e,t,n){var r,l={},s=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(s=""+t.key),t)La.call(t,r)&&!Ra.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,K=w[W];if(0>>1;Wl(lt,I))oel(Fe,lt)?(w[W]=Fe,w[oe]=I,W=oe):(w[W]=lt,w[Se]=I,W=Se);else if(oel(Fe,I))w[W]=Fe,w[oe]=I,W=oe;else break e}}return M}function l(w,M){var I=w.sortIndex-M.sortIndex;return I!==0?I:w.id-M.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var u=[],f=[],m=1,v=null,h=3,j=!1,N=!1,k=!1,D=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function d(w){for(var M=n(f);M!==null;){if(M.callback===null)r(f);else if(M.startTime<=w)r(f),M.sortIndex=M.expirationTime,t(u,M);else break;M=n(f)}}function g(w){if(k=!1,d(w),!N)if(n(u)!==null)N=!0,y(C);else{var M=n(f);M!==null&&U(g,M.startTime-w)}}function C(w,M){N=!1,k&&(k=!1,p(P),P=-1),j=!0;var I=h;try{for(d(M),v=n(u);v!==null&&(!(v.expirationTime>M)||w&&!O());){var W=v.callback;if(typeof W=="function"){v.callback=null,h=v.priorityLevel;var K=W(v.expirationTime<=M);M=e.unstable_now(),typeof K=="function"?v.callback=K:v===n(u)&&r(u),d(M)}else r(u);v=n(u)}if(v!==null)var Pe=!0;else{var Se=n(f);Se!==null&&U(g,Se.startTime-M),Pe=!1}return Pe}finally{v=null,h=I,j=!1}}var E=!1,T=null,P=-1,A=5,R=-1;function O(){return!(e.unstable_now()-Rw||125W?(w.sortIndex=I,t(f,w),n(u)===null&&w===n(f)&&(k?(p(P),P=-1):k=!0,U(g,I-W))):(w.sortIndex=K,t(u,w),N||j||(N=!0,y(C))),w},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(w){var M=h;return function(){var I=h;h=M;try{return w.apply(this,arguments)}finally{h=I}}}})(Oa);Da.exports=Oa;var ud=Da.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var cd=_,Ue=ud;function S(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ys=Object.prototype.hasOwnProperty,dd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,mo={},ho={};function fd(e){return ys.call(ho,e)?!0:ys.call(mo,e)?!1:dd.test(e)?ho[e]=!0:(mo[e]=!0,!1)}function pd(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function md(e,t,n,r){if(t===null||typeof t>"u"||pd(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ee(e,t,n,r,l,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var ve={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ve[e]=new Ee(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ve[t]=new Ee(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ve[e]=new Ee(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ve[e]=new Ee(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ve[e]=new Ee(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ve[e]=new Ee(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ve[e]=new Ee(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ve[e]=new Ee(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ve[e]=new Ee(e,5,!1,e.toLowerCase(),null,!1,!1)});var mi=/[\-:]([a-z])/g;function hi(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(mi,hi);ve[t]=new Ee(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(mi,hi);ve[t]=new Ee(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(mi,hi);ve[t]=new Ee(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ve[e]=new Ee(e,1,!1,e.toLowerCase(),null,!1,!1)});ve.xlinkHref=new Ee("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ve[e]=new Ee(e,1,!1,e.toLowerCase(),null,!0,!0)});function vi(e,t,n,r){var l=ve.hasOwnProperty(t)?ve[t]:null;(l!==null?l.type!==0:r||!(2a||l[o]!==s[a]){var u=` +`+l[o].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=o&&0<=a);break}}}finally{Xl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Xn(e):""}function hd(e){switch(e.tag){case 5:return Xn(e.type);case 16:return Xn("Lazy");case 13:return Xn("Suspense");case 19:return Xn("SuspenseList");case 0:case 2:case 15:return e=Yl(e.type,!1),e;case 11:return e=Yl(e.type.render,!1),e;case 1:return e=Yl(e.type,!0),e;default:return""}}function Ss(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 dn:return"Fragment";case cn:return"Portal";case xs:return"Profiler";case gi:return"StrictMode";case ws:return"Suspense";case js:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ua:return(e.displayName||"Context")+".Consumer";case $a:return(e._context.displayName||"Context")+".Provider";case yi:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case xi:return t=e.displayName||null,t!==null?t:Ss(e.type)||"Memo";case kt:t=e._payload,e=e._init;try{return Ss(e(t))}catch{}}return null}function vd(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 Ss(t);case 8:return t===gi?"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 Ot(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ba(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function gd(e){var t=Ba(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 l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Lr(e){e._valueTracker||(e._valueTracker=gd(e))}function Wa(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ba(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function sl(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 ks(e,t){var n=t.checked;return ne({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function go(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ot(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 Ha(e,t){t=t.checked,t!=null&&vi(e,"checked",t,!1)}function Ns(e,t){Ha(e,t);var n=Ot(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")?_s(e,t.type,n):t.hasOwnProperty("defaultValue")&&_s(e,t.type,Ot(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function yo(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 _s(e,t,n){(t!=="number"||sl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Yn=Array.isArray;function Sn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Rr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function or(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Zn={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},yd=["Webkit","ms","Moz","O"];Object.keys(Zn).forEach(function(e){yd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Zn[t]=Zn[e]})});function Ya(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Zn.hasOwnProperty(e)&&Zn[e]?(""+t).trim():t+"px"}function Ga(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Ya(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var xd=ne({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 Ps(e,t){if(t){if(xd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(S(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(S(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(S(61))}if(t.style!=null&&typeof t.style!="object")throw Error(S(62))}}function Ts(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 Ls=null;function wi(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Rs=null,kn=null,Nn=null;function jo(e){if(e=Cr(e)){if(typeof Rs!="function")throw Error(S(280));var t=e.stateNode;t&&(t=Il(t),Rs(e.stateNode,e.type,t))}}function Ja(e){kn?Nn?Nn.push(e):Nn=[e]:kn=e}function Za(){if(kn){var e=kn,t=Nn;if(Nn=kn=null,jo(e),t)for(e=0;e>>=0,e===0?32:31-(Ld(e)/Rd|0)|0}var zr=64,Mr=4194304;function Gn(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 ul(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~l;a!==0?r=Gn(a):(s&=o,s!==0&&(r=Gn(s)))}else o=n&~l,o!==0?r=Gn(o):s!==0&&(r=Gn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Nr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-tt(t),e[t]=n}function Fd(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=bn),Lo=" ",Ro=!1;function gu(e,t){switch(e){case"keyup":return cf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fn=!1;function ff(e,t){switch(e){case"compositionend":return yu(t);case"keypress":return t.which!==32?null:(Ro=!0,Lo);case"textInput":return e=t.data,e===Lo&&Ro?null:e;default:return null}}function pf(e,t){if(fn)return e==="compositionend"||!Pi&&gu(e,t)?(e=hu(),Jr=_i=Et=null,fn=!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)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=Fo(n)}}function Su(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Su(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ku(){for(var e=window,t=sl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=sl(e.document)}return t}function Ti(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 Sf(e){var t=ku(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Su(n.ownerDocument.documentElement,n)){if(r!==null&&Ti(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 l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=Do(n,s);var o=Do(n,r);l&&o&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.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=document.documentMode,pn=null,Os=null,tr=null,As=!1;function Oo(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;As||pn==null||pn!==sl(r)||(r=pn,"selectionStart"in r&&Ti(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}),tr&&pr(tr,r)||(tr=r,r=fl(Os,"onSelect"),0vn||(e.current=Hs[vn],Hs[vn]=null,vn--)}function X(e,t){vn++,Hs[vn]=e.current,e.current=t}var At={},je=Ut(At),ze=Ut(!1),Jt=At;function Tn(e,t){var n=e.type.contextTypes;if(!n)return At;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Me(e){return e=e.childContextTypes,e!=null}function ml(){Z(ze),Z(je)}function Ho(e,t,n){if(je.current!==At)throw Error(S(168));X(je,t),X(ze,n)}function zu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(S(108,vd(e)||"Unknown",l));return ne({},n,r)}function hl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||At,Jt=je.current,X(je,e),X(ze,ze.current),!0}function Qo(e,t,n){var r=e.stateNode;if(!r)throw Error(S(169));n?(e=zu(e,t,Jt),r.__reactInternalMemoizedMergedChildContext=e,Z(ze),Z(je),X(je,e)):Z(ze),X(ze,n)}var ft=null,Fl=!1,as=!1;function Mu(e){ft===null?ft=[e]:ft.push(e)}function If(e){Fl=!0,Mu(e)}function Vt(){if(!as&&ft!==null){as=!0;var e=0,t=H;try{var n=ft;for(H=1;e>=o,l-=o,pt=1<<32-tt(t)+l|n<P?(A=T,T=null):A=T.sibling;var R=h(p,T,d[P],g);if(R===null){T===null&&(T=A);break}e&&T&&R.alternate===null&&t(p,T),c=s(R,c,P),E===null?C=R:E.sibling=R,E=R,T=A}if(P===d.length)return n(p,T),b&&Wt(p,P),C;if(T===null){for(;PP?(A=T,T=null):A=T.sibling;var O=h(p,T,R.value,g);if(O===null){T===null&&(T=A);break}e&&T&&O.alternate===null&&t(p,T),c=s(O,c,P),E===null?C=O:E.sibling=O,E=O,T=A}if(R.done)return n(p,T),b&&Wt(p,P),C;if(T===null){for(;!R.done;P++,R=d.next())R=v(p,R.value,g),R!==null&&(c=s(R,c,P),E===null?C=R:E.sibling=R,E=R);return b&&Wt(p,P),C}for(T=r(p,T);!R.done;P++,R=d.next())R=j(T,p,P,R.value,g),R!==null&&(e&&R.alternate!==null&&T.delete(R.key===null?P:R.key),c=s(R,c,P),E===null?C=R:E.sibling=R,E=R);return e&&T.forEach(function(B){return t(p,B)}),b&&Wt(p,P),C}function D(p,c,d,g){if(typeof d=="object"&&d!==null&&d.type===dn&&d.key===null&&(d=d.props.children),typeof d=="object"&&d!==null){switch(d.$$typeof){case Tr:e:{for(var C=d.key,E=c;E!==null;){if(E.key===C){if(C=d.type,C===dn){if(E.tag===7){n(p,E.sibling),c=l(E,d.props.children),c.return=p,p=c;break e}}else if(E.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===kt&&Yo(C)===E.type){n(p,E.sibling),c=l(E,d.props),c.ref=Wn(p,E,d),c.return=p,p=c;break e}n(p,E);break}else t(p,E);E=E.sibling}d.type===dn?(c=Gt(d.props.children,p.mode,g,d.key),c.return=p,p=c):(g=ll(d.type,d.key,d.props,null,p.mode,g),g.ref=Wn(p,c,d),g.return=p,p=g)}return o(p);case cn:e:{for(E=d.key;c!==null;){if(c.key===E)if(c.tag===4&&c.stateNode.containerInfo===d.containerInfo&&c.stateNode.implementation===d.implementation){n(p,c.sibling),c=l(c,d.children||[]),c.return=p,p=c;break e}else{n(p,c);break}else t(p,c);c=c.sibling}c=vs(d,p.mode,g),c.return=p,p=c}return o(p);case kt:return E=d._init,D(p,c,E(d._payload),g)}if(Yn(d))return N(p,c,d,g);if(An(d))return k(p,c,d,g);Ur(p,d)}return typeof d=="string"&&d!==""||typeof d=="number"?(d=""+d,c!==null&&c.tag===6?(n(p,c.sibling),c=l(c,d),c.return=p,p=c):(n(p,c),c=hs(d,p.mode,g),c.return=p,p=c),o(p)):n(p,c)}return D}var Rn=Ou(!0),Au=Ou(!1),yl=Ut(null),xl=null,xn=null,Mi=null;function Ii(){Mi=xn=xl=null}function Fi(e){var t=yl.current;Z(yl),e._currentValue=t}function Xs(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 Cn(e,t){xl=e,Mi=xn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Re=!0),e.firstContext=null)}function Xe(e){var t=e._currentValue;if(Mi!==e)if(e={context:e,memoizedValue:t,next:null},xn===null){if(xl===null)throw Error(S(308));xn=e,xl.dependencies={lanes:0,firstContext:e}}else xn=xn.next=e;return t}var Kt=null;function Di(e){Kt===null?Kt=[e]:Kt.push(e)}function $u(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Di(t)):(n.next=l.next,l.next=n),t.interleaved=n,yt(e,r)}function yt(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 Nt=!1;function Oi(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Uu(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 ht(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Mt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,V&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,yt(e,n)}return l=r.interleaved,l===null?(t.next=t,Di(r)):(t.next=l.next,l.next=t),r.interleaved=t,yt(e,n)}function qr(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,Si(e,n)}}function Go(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,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 wl(e,t,n,r){var l=e.updateQueue;Nt=!1;var s=l.firstBaseUpdate,o=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,f=u.next;u.next=null,o===null?s=f:o.next=f,o=u;var m=e.alternate;m!==null&&(m=m.updateQueue,a=m.lastBaseUpdate,a!==o&&(a===null?m.firstBaseUpdate=f:a.next=f,m.lastBaseUpdate=u))}if(s!==null){var v=l.baseState;o=0,m=f=u=null,a=s;do{var h=a.lane,j=a.eventTime;if((r&h)===h){m!==null&&(m=m.next={eventTime:j,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var N=e,k=a;switch(h=t,j=n,k.tag){case 1:if(N=k.payload,typeof N=="function"){v=N.call(j,v,h);break e}v=N;break e;case 3:N.flags=N.flags&-65537|128;case 0:if(N=k.payload,h=typeof N=="function"?N.call(j,v,h):N,h==null)break e;v=ne({},v,h);break e;case 2:Nt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[a]:h.push(a))}else j={eventTime:j,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},m===null?(f=m=j,u=v):m=m.next=j,o|=h;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;h=a,a=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(m===null&&(u=v),l.baseState=u,l.firstBaseUpdate=f,l.lastBaseUpdate=m,t=l.shared.interleaved,t!==null){l=t;do o|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);bt|=o,e.lanes=o,e.memoizedState=v}}function Jo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=cs.transition;cs.transition={};try{e(!1),t()}finally{H=n,cs.transition=r}}function rc(){return Ye().memoizedState}function Af(e,t,n){var r=Ft(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},lc(e))sc(t,n);else if(n=$u(e,t,n,r),n!==null){var l=_e();nt(n,e,r,l),ic(n,t,r)}}function $f(e,t,n){var r=Ft(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(lc(e))sc(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,a=s(o,n);if(l.hasEagerState=!0,l.eagerState=a,rt(a,o)){var u=t.interleaved;u===null?(l.next=l,Di(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=$u(e,t,l,r),n!==null&&(l=_e(),nt(n,e,r,l),ic(n,t,r))}}function lc(e){var t=e.alternate;return e===te||t!==null&&t===te}function sc(e,t){nr=Sl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ic(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Si(e,n)}}var kl={readContext:Xe,useCallback:ye,useContext:ye,useEffect:ye,useImperativeHandle:ye,useInsertionEffect:ye,useLayoutEffect:ye,useMemo:ye,useReducer:ye,useRef:ye,useState:ye,useDebugValue:ye,useDeferredValue:ye,useTransition:ye,useMutableSource:ye,useSyncExternalStore:ye,useId:ye,unstable_isNewReconciler:!1},Uf={readContext:Xe,useCallback:function(e,t){return it().memoizedState=[e,t===void 0?null:t],e},useContext:Xe,useEffect:qo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,el(4194308,4,qu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return el(4194308,4,e,t)},useInsertionEffect:function(e,t){return el(4,2,e,t)},useMemo:function(e,t){var n=it();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=it();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=Af.bind(null,te,e),[r.memoizedState,e]},useRef:function(e){var t=it();return e={current:e},t.memoizedState=e},useState:Zo,useDebugValue:Qi,useDeferredValue:function(e){return it().memoizedState=e},useTransition:function(){var e=Zo(!1),t=e[0];return e=Of.bind(null,e[1]),it().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=te,l=it();if(b){if(n===void 0)throw Error(S(407));n=n()}else{if(n=t(),fe===null)throw Error(S(349));qt&30||Hu(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,qo(Ku.bind(null,r,s,e),[e]),r.flags|=2048,jr(9,Qu.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=it(),t=fe.identifierPrefix;if(b){var n=mt,r=pt;n=(r&~(1<<32-tt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=xr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[ot]=t,e[vr]=r,vc(e,t,!1,!1),t.stateNode=e;e:{switch(o=Ts(n,r),n){case"dialog":G("cancel",e),G("close",e),l=r;break;case"iframe":case"object":case"embed":G("load",e),l=r;break;case"video":case"audio":for(l=0;lIn&&(t.flags|=128,r=!0,Hn(s,!1),t.lanes=4194304)}else{if(!r)if(e=jl(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Hn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!b)return xe(t),null}else 2*le()-s.renderingStartTime>In&&n!==1073741824&&(t.flags|=128,r=!0,Hn(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(n=s.last,n!==null?n.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=le(),t.sibling=null,n=ee.current,X(ee,r?n&1|2:n&1),t):(xe(t),null);case 22:case 23:return Zi(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Oe&1073741824&&(xe(t),t.subtreeFlags&6&&(t.flags|=8192)):xe(t),null;case 24:return null;case 25:return null}throw Error(S(156,t.tag))}function Yf(e,t){switch(Ri(t),t.tag){case 1:return Me(t.type)&&ml(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zn(),Z(ze),Z(je),Ui(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return $i(t),null;case 13:if(Z(ee),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(S(340));Ln()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Z(ee),null;case 4:return zn(),null;case 10:return Fi(t.type._context),null;case 22:case 23:return Zi(),null;case 24:return null;default:return null}}var Br=!1,we=!1,Gf=typeof WeakSet=="function"?WeakSet:Set,L=null;function wn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){re(e,t,r)}else n.current=null}function ni(e,t,n){try{n()}catch(r){re(e,t,r)}}var ua=!1;function Jf(e,t){if($s=cl,e=ku(),Ti(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 l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,u=-1,f=0,m=0,v=e,h=null;t:for(;;){for(var j;v!==n||l!==0&&v.nodeType!==3||(a=o+l),v!==s||r!==0&&v.nodeType!==3||(u=o+r),v.nodeType===3&&(o+=v.nodeValue.length),(j=v.firstChild)!==null;)h=v,v=j;for(;;){if(v===e)break t;if(h===n&&++f===l&&(a=o),h===s&&++m===r&&(u=o),(j=v.nextSibling)!==null)break;v=h,h=v.parentNode}v=j}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Us={focusedElem:e,selectionRange:n},cl=!1,L=t;L!==null;)if(t=L,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,L=e;else for(;L!==null;){t=L;try{var N=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(N!==null){var k=N.memoizedProps,D=N.memoizedState,p=t.stateNode,c=p.getSnapshotBeforeUpdate(t.elementType===t.type?k:qe(t.type,k),D);p.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var d=t.stateNode.containerInfo;d.nodeType===1?d.textContent="":d.nodeType===9&&d.documentElement&&d.removeChild(d.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(S(163))}}catch(g){re(t,t.return,g)}if(e=t.sibling,e!==null){e.return=t.return,L=e;break}L=t.return}return N=ua,ua=!1,N}function rr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&ni(t,n,s)}l=l.next}while(l!==r)}}function Al(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 ri(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 xc(e){var t=e.alternate;t!==null&&(e.alternate=null,xc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ot],delete t[vr],delete t[Ws],delete t[zf],delete t[Mf])),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 wc(e){return e.tag===5||e.tag===3||e.tag===4}function ca(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||wc(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 li(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=pl));else if(r!==4&&(e=e.child,e!==null))for(li(e,t,n),e=e.sibling;e!==null;)li(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 me=null,be=!1;function St(e,t,n){for(n=n.child;n!==null;)jc(e,t,n),n=n.sibling}function jc(e,t,n){if(at&&typeof at.onCommitFiberUnmount=="function")try{at.onCommitFiberUnmount(Ll,n)}catch{}switch(n.tag){case 5:we||wn(n,t);case 6:var r=me,l=be;me=null,St(e,t,n),me=r,be=l,me!==null&&(be?(e=me,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):me.removeChild(n.stateNode));break;case 18:me!==null&&(be?(e=me,n=n.stateNode,e.nodeType===8?os(e.parentNode,n):e.nodeType===1&&os(e,n),dr(e)):os(me,n.stateNode));break;case 4:r=me,l=be,me=n.stateNode.containerInfo,be=!0,St(e,t,n),me=r,be=l;break;case 0:case 11:case 14:case 15:if(!we&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&ni(n,t,o),l=l.next}while(l!==r)}St(e,t,n);break;case 1:if(!we&&(wn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){re(n,t,a)}St(e,t,n);break;case 21:St(e,t,n);break;case 22:n.mode&1?(we=(r=we)||n.memoizedState!==null,St(e,t,n),we=r):St(e,t,n);break;default:St(e,t,n)}}function da(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Gf),t.forEach(function(r){var l=sp.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ge(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=o),r&=~s}if(r=l,r=le()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*qf(r/1960))-r,10e?16:e,Pt===null)var r=!1;else{if(e=Pt,Pt=null,Cl=0,V&6)throw Error(S(331));var l=V;for(V|=4,L=e.current;L!==null;){var s=L,o=s.child;if(L.flags&16){var a=s.deletions;if(a!==null){for(var u=0;ule()-Gi?Yt(e,0):Yi|=n),Ie(e,t)}function Tc(e,t){t===0&&(e.mode&1?(t=Mr,Mr<<=1,!(Mr&130023424)&&(Mr=4194304)):t=1);var n=_e();e=yt(e,t),e!==null&&(Nr(e,t,n),Ie(e,n))}function lp(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tc(e,n)}function sp(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(S(314))}r!==null&&r.delete(t),Tc(e,n)}var Lc;Lc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ze.current)Re=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Re=!1,Kf(e,t,n);Re=!!(e.flags&131072)}else Re=!1,b&&t.flags&1048576&&Iu(t,gl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;tl(e,t),e=t.pendingProps;var l=Tn(t,je.current);Cn(t,n),l=Bi(null,t,r,e,l,n);var s=Wi();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Me(r)?(s=!0,hl(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Oi(t),l.updater=Ol,t.stateNode=l,l._reactInternals=t,Gs(t,r,e,n),t=qs(null,t,r,!0,s,n)):(t.tag=0,b&&s&&Li(t),Ne(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(tl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=op(r),e=qe(r,e),l){case 0:t=Zs(null,t,r,e,n);break e;case 1:t=ia(null,t,r,e,n);break e;case 11:t=la(null,t,r,e,n);break e;case 14:t=sa(null,t,r,qe(r.type,e),n);break e}throw Error(S(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:qe(r,l),Zs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:qe(r,l),ia(e,t,r,l,n);case 3:e:{if(pc(t),e===null)throw Error(S(387));r=t.pendingProps,s=t.memoizedState,l=s.element,Uu(e,t),wl(t,r,null,n);var o=t.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=Mn(Error(S(423)),t),t=oa(e,t,r,n,l);break e}else if(r!==l){l=Mn(Error(S(424)),t),t=oa(e,t,r,n,l);break e}else for(Ae=zt(t.stateNode.containerInfo.firstChild),$e=t,b=!0,et=null,n=Au(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ln(),r===l){t=xt(e,t,n);break e}Ne(e,t,r,n)}t=t.child}return t;case 5:return Vu(t),e===null&&Ks(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,o=l.children,Vs(r,l)?o=null:s!==null&&Vs(r,s)&&(t.flags|=32),fc(e,t),Ne(e,t,o,n),t.child;case 6:return e===null&&Ks(t),null;case 13:return mc(e,t,n);case 4:return Ai(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rn(t,null,r,n):Ne(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:qe(r,l),la(e,t,r,l,n);case 7:return Ne(e,t,t.pendingProps,n),t.child;case 8:return Ne(e,t,t.pendingProps.children,n),t.child;case 12:return Ne(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,o=l.value,X(yl,r._currentValue),r._currentValue=o,s!==null)if(rt(s.value,o)){if(s.children===l.children&&!ze.current){t=xt(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=ht(-1,n&-n),u.tag=2;var f=s.updateQueue;if(f!==null){f=f.shared;var m=f.pending;m===null?u.next=u:(u.next=m.next,m.next=u),f.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Xs(s.return,n,t),a.lanes|=n;break}u=u.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(S(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),Xs(o,n,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}Ne(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Cn(t,n),l=Xe(l),r=r(l),t.flags|=1,Ne(e,t,r,n),t.child;case 14:return r=t.type,l=qe(r,t.pendingProps),l=qe(r.type,l),sa(e,t,r,l,n);case 15:return cc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:qe(r,l),tl(e,t),t.tag=1,Me(r)?(e=!0,hl(t)):e=!1,Cn(t,n),oc(t,r,l),Gs(t,r,l,n),qs(null,t,r,!0,e,n);case 19:return hc(e,t,n);case 22:return dc(e,t,n)}throw Error(S(156,t.tag))};function Rc(e,t){return lu(e,t)}function ip(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 Qe(e,t,n,r){return new ip(e,t,n,r)}function bi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function op(e){if(typeof e=="function")return bi(e)?1:0;if(e!=null){if(e=e.$$typeof,e===yi)return 11;if(e===xi)return 14}return 2}function Dt(e,t){var n=e.alternate;return n===null?(n=Qe(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 ll(e,t,n,r,l,s){var o=2;if(r=e,typeof e=="function")bi(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case dn:return Gt(n.children,l,s,t);case gi:o=8,l|=8;break;case xs:return e=Qe(12,n,t,l|2),e.elementType=xs,e.lanes=s,e;case ws:return e=Qe(13,n,t,l),e.elementType=ws,e.lanes=s,e;case js:return e=Qe(19,n,t,l),e.elementType=js,e.lanes=s,e;case Va:return Ul(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case $a:o=10;break e;case Ua:o=9;break e;case yi:o=11;break e;case xi:o=14;break e;case kt:o=16,r=null;break e}throw Error(S(130,e==null?e:typeof e,""))}return t=Qe(o,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Gt(e,t,n,r){return e=Qe(7,e,r,t),e.lanes=n,e}function Ul(e,t,n,r){return e=Qe(22,e,r,t),e.elementType=Va,e.lanes=n,e.stateNode={isHidden:!1},e}function hs(e,t,n){return e=Qe(6,e,null,t),e.lanes=n,e}function vs(e,t,n){return t=Qe(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ap(e,t,n,r,l){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=Jl(0),this.expirationTimes=Jl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function eo(e,t,n,r,l,s,o,a,u){return e=new ap(e,t,n,a,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Qe(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oi(s),e}function up(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Fc)}catch(e){console.error(e)}}Fc(),Fa.exports=Ve;var mp=Fa.exports,Dc,xa=mp;Dc=xa.createRoot,xa.hydrateRoot;async function se(e,t={}){const n=await fetch(e,t);if(!n.ok){let r=n.statusText;try{r=(await n.json()).detail||r}catch{}throw new Error(r)}return n.json()}const Bt=(e,t)=>({method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),J={health:()=>se("/api/health"),models:()=>se("/api/models"),languages:()=>se("/api/languages"),listProjects:()=>se("/api/projects"),createProject:e=>se("/api/projects",Bt("POST",e)),patchProject:(e,t)=>se(`/api/projects/${e}`,Bt("PATCH",t)),deleteProject:e=>fetch(`/api/projects/${e}`,{method:"DELETE"}),authMe:()=>se("/api/auth/me"),register:e=>se("/api/auth/register",Bt("POST",e)),login:e=>se("/api/auth/login",Bt("POST",e)),logout:()=>se("/api/auth/logout",{method:"POST"}),listCorpora:e=>se(`/api/projects/${e}/corpora`),uploadCorpus:(e,t)=>{const n=new FormData;return n.append("file",t),se(`/api/projects/${e}/corpora`,{method:"POST",body:n})},listConstructs:()=>se("/api/constructs"),createConstruct:e=>se("/api/constructs",Bt("POST",e)),generateConstructItems:e=>se("/api/constructs/generate-items",Bt("POST",e)),parseConstructFile:e=>{const t=new FormData;return t.append("file",e),se("/api/constructs/parse-file",{method:"POST",body:t})},createJob:e=>se("/api/jobs",Bt("POST",e)),listJobs:e=>se(`/api/jobs?project_id=${e}`),getJob:e=>se(`/api/jobs/${e}`),jobResults:e=>se(`/api/jobs/${e}/results`),exportUrl:e=>`/api/jobs/${e}/export`,metadataUrl:e=>`/api/jobs/${e}/metadata`,scriptUrl:e=>`/api/jobs/${e}/script`,scriptRequirementsUrl:e=>`/api/jobs/${e}/script-requirements`},gs=["external","lab","maintainer","pi"],on={external:"external user",lab:"lab member",maintainer:"maintainer",pi:"PI"};function Qr({k:e,v:t}){return i.jsxs("div",{className:"stat",children:[i.jsx("div",{className:"v",children:t}),i.jsx("div",{className:"k",children:e})]})}function an({title:e,hint:t,defaultOpen:n=!0,children:r}){const[l,s]=_.useState(n);return i.jsxs("div",{className:"card",children:[i.jsxs("h3",{onClick:()=>s(o=>!o),style:{cursor:"pointer",userSelect:"none",display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:".6rem",marginBottom:l?void 0:0},title:l?"Click to collapse":"Click to expand",children:[i.jsxs("span",{children:[e,!l&&t?i.jsxs("span",{className:"muted small",style:{fontWeight:400},children:[" · ",t]}):null]}),i.jsx("span",{className:"muted small",style:{fontWeight:400},children:l?"▾":"▸"})]}),l&&r]})}async function Ze(e,t={}){const n=await fetch(e,t);if(!n.ok){let r=n.statusText;try{r=(await n.json()).detail||r}catch{}throw new Error(r)}return n.status===204?null:n.json()}const un=(e,t)=>Ze(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t||{})});function hp({auth:e}){var ge;const[t,n]=_.useState(null),[r,l]=_.useState([]),[s,o]=_.useState([]),[a,u]=_.useState([]),[f,m]=_.useState([]),[v,h]=_.useState([]),[j,N]=_.useState(null),[k,D]=_.useState(!0),[p,c]=_.useState("lab"),[d,g]=_.useState(""),[C,E]=_.useState("lab"),[T,P]=_.useState(""),[A,R]=_.useState(""),O=(e==null?void 0:e.role)==="maintainer",B=_.useCallback(()=>{P(""),Ze("/api/admin/overview").then(n).catch(y=>P(y.message)),Ze("/api/admin/users").then(l).catch(()=>{}),Ze("/api/admin/jobs/failed").then(o).catch(()=>{}),Ze("/api/admin/role-assignments").then(m).catch(()=>{}),Ze("/api/admin/invites").then(h).catch(()=>{}),Ze("/api/admin/audit").then(N).catch(()=>N(null)),Ze("/api/admin/constructs"+(k?"?status=needs_verification":"")).then(u).catch(()=>{})},[k]);if(_.useEffect(()=>{B()},[B]),!(e!=null&&e.signed_in)||!(e!=null&&e.is_admin))return i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Admin"}),i.jsxs("p",{className:"hint",children:["This page requires an admin account."," ",i.jsx("a",{href:"/",children:"Back to the platform"}),"."]})]});async function Q(y){P(""),R("");try{await y(),B()}catch(U){P(U.message)}}async function Y(y){const U=`${window.location.origin}/?invite=${encodeURIComponent(y.token)}`;try{await navigator.clipboard.writeText(U),R(`Invite link copied (${on[y.role]}, expires ${y.expires_at}). Paste it in Slack.`)}catch{R(`Could not copy automatically - the link: ${U}`)}}return i.jsxs(i.Fragment,{children:[T&&i.jsx("div",{className:"error-banner",onClick:()=>P(""),children:T}),A&&i.jsx("div",{className:"card",style:{borderColor:"var(--brand)"},children:i.jsx("p",{style:{overflowWrap:"anywhere"},children:i.jsx("b",{children:A})})}),i.jsxs("div",{className:"project-header",children:[i.jsx("span",{className:"project-title",children:"Admin"}),i.jsx("a",{className:"ghost",href:"/",children:"← Back to dashboard"})]}),i.jsx(an,{title:"Overview",children:t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"stat-grid",children:[i.jsx(Qr,{k:"Accounts",v:t.users}),i.jsx(Qr,{k:"Runs total",v:t.runs_total}),i.jsx(Qr,{k:"Projects",v:t.projects}),i.jsx(Qr,{k:"Awaiting verification",v:t.constructs_unverified})]}),i.jsxs("p",{className:"small muted",style:{margin:"10px 0 0"},children:[gs.filter(y=>{var U;return(U=t.users_by_role)==null?void 0:U[y]}).map(y=>`${t.users_by_role[y]} ${on[y]}`).join(", ")||"no accounts yet"," ","· ",t.signups_last_7_days," sign-up",t.signups_last_7_days===1?"":"s"," and"," ",t.runs_last_7_days," run",t.runs_last_7_days===1?"":"s"," this week",(ge=t.runs_by_status)!=null&&ge.failed?` · ${t.runs_by_status.failed} failed run${t.runs_by_status.failed===1?"":"s"} total`:""," ","· ",t.anonymous_projects," anonymous project",t.anonymous_projects===1?"":"s"]})]}):i.jsx("p",{className:"hint",children:"Loading…"})}),i.jsx(an,{title:"Users",hint:`${r.length} account${r.length===1?"":"s"}`,children:i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Name"}),i.jsx("th",{children:"Role"}),i.jsx("th",{children:"Saved runs"}),i.jsx("th",{children:"Sign-in"}),i.jsx("th",{})]})}),i.jsxs("tbody",{children:[r.map(y=>i.jsxs("tr",{children:[i.jsxs("td",{children:[y.email,y.is_admin?" ★":""]}),i.jsx("td",{children:y.name}),i.jsx("td",{children:i.jsx("select",{value:y.role,onChange:U=>Q(()=>un(`/api/admin/users/${y.id}/role`,{role:U.target.value})),children:gs.map(U=>i.jsx("option",{value:U,children:on[U]},U))})}),i.jsx("td",{children:y.saved_runs}),i.jsx("td",{className:"muted small",children:y.google_only?"Google":"password"}),i.jsxs("td",{children:[!y.google_only&&i.jsx("button",{className:"linkish",onClick:()=>Q(async()=>{const U=await un(`/api/admin/users/${y.id}/reset-password`);R(`Temporary password for ${U.email}: ${U.temporary_password}`)}),children:"Reset password"})," ",!y.env_admin&&i.jsx("button",{className:"linkish danger",onClick:()=>{window.confirm(`Delete ${y.email} and ALL their data?`)&&Q(()=>Ze(`/api/admin/users/${y.id}`,{method:"DELETE"}))},children:"Delete"})]})]},y.id)),r.length===0&&i.jsx("tr",{children:i.jsx("td",{colSpan:6,className:"muted",children:"No accounts yet."})})]})]})})}),i.jsxs(an,{title:"Access before sign-in",children:[i.jsxs("p",{className:"hint",children:[i.jsx("b",{children:"Pre-assign a role to an email"})," (e.g. an external collaborator who should land with full credentials): whoever first signs in with that email - password or Google - gets the role automatically."]}),i.jsxs("form",{onSubmit:y=>{y.preventDefault(),d.trim()&&Q(async()=>{await un("/api/admin/role-assignments",{email:d.trim(),role:C}),g("")})},style:{display:"flex",gap:".5rem",flexWrap:"wrap",alignItems:"center"},children:[i.jsx("input",{type:"email",placeholder:"person@university.edu",value:d,onChange:y=>g(y.target.value),style:{minWidth:"16rem"}}),i.jsx("select",{value:C,onChange:y=>E(y.target.value),children:gs.map(y=>i.jsx("option",{value:y,children:on[y]},y))}),i.jsx("button",{type:"submit",className:"ghost",disabled:!d.trim(),children:"Pre-assign"})]}),f.length>0&&i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Email"}),i.jsx("th",{children:"Role"}),i.jsx("th",{children:"By"}),i.jsx("th",{children:"Status"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:f.map(y=>i.jsxs("tr",{children:[i.jsx("td",{children:y.email}),i.jsx("td",{children:on[y.role]||y.role}),i.jsx("td",{className:"muted small",children:y.assigned_by}),i.jsx("td",{className:"muted small",children:y.claimed_at?`claimed ${y.claimed_at.slice(0,10)}`:"pending"}),i.jsx("td",{children:!y.claimed_at&&i.jsx("button",{className:"linkish danger",onClick:()=>Q(()=>Ze(`/api/admin/role-assignments/${y.id}`,{method:"DELETE"})),children:"Remove"})})]},y.id))})]})}),(t==null?void 0:t.invites_enabled)&&i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"hint",style:{marginTop:"1rem"},children:[i.jsx("b",{children:"Or create an invite link"}),' (anyone with the link; lab member / external only - staff is granted per person above): paste it in Slack, it expires after a week. Revoking kills a link immediately; "used by" shows every account created through it.']}),i.jsxs("div",{style:{display:"flex",gap:".5rem",alignItems:"center"},children:[i.jsxs("select",{value:p,onChange:y=>c(y.target.value),children:[i.jsx("option",{value:"lab",children:"lab member"}),i.jsx("option",{value:"external",children:"external user"})]}),i.jsx("button",{className:"ghost",onClick:()=>Q(async()=>{const y=await un("/api/admin/invites",{role:p});await Y(y)}),children:"Create invite link"})]}),v.length>0&&i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Role"}),i.jsx("th",{children:"Created"}),i.jsx("th",{children:"Expires"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Used by"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:v.map(y=>i.jsxs("tr",{children:[i.jsx("td",{children:on[y.role]||y.role}),i.jsxs("td",{className:"muted small",children:[y.created_at.slice(0,10)," · ",y.created_by]}),i.jsx("td",{className:"muted small",children:y.expires_at}),i.jsx("td",{children:i.jsx("span",{className:`pill ${y.status==="active"?"completed":"queued"}`,children:y.status})}),i.jsx("td",{className:"small",children:y.redemptions.length===0?i.jsx("span",{className:"muted",children:"nobody yet"}):y.redemptions.map(U=>i.jsx("div",{title:U.at,children:U.email},U.email))}),i.jsx("td",{children:y.status==="active"&&i.jsxs(i.Fragment,{children:[i.jsx("button",{className:"linkish",onClick:()=>Q(()=>Y(y)),children:"Copy link"})," ",i.jsx("button",{className:"linkish danger",onClick:()=>{window.confirm("Revoke this invite link? It stops working immediately.")&&Q(()=>Ze(`/api/admin/invites/${y.id}`,{method:"DELETE"}))},children:"Revoke"})]})})]},y.id))})]})})]})]}),j!==null&&i.jsx(an,{title:"Audit trail",hint:`${j.length} recent entries`,defaultOpen:!1,children:j.length===0?i.jsx("p",{className:"hint",children:"No admin actions recorded yet."}):i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"When"}),i.jsx("th",{children:"Who"}),i.jsx("th",{children:"Action"}),i.jsx("th",{children:"Target"}),i.jsx("th",{children:"Detail"})]})}),i.jsx("tbody",{children:j.map((y,U)=>i.jsxs("tr",{children:[i.jsx("td",{className:"muted small",children:y.at.replace("T"," ").slice(0,16)}),i.jsx("td",{className:"small",children:y.actor}),i.jsx("td",{className:"small",children:y.action.replaceAll("_"," ")}),i.jsx("td",{className:"small",children:y.target}),i.jsx("td",{className:"muted small",children:y.detail})]},U))})]})})}),i.jsx(an,{title:"Failed runs",hint:s.length?`${s.length} to triage`:"none",children:s.length===0?i.jsx("p",{className:"hint",children:"None. 🎉"}):i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"When"}),i.jsx("th",{children:"Corpus"}),i.jsx("th",{children:"Model"}),i.jsx("th",{children:"Error"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:s.map(y=>i.jsxs("tr",{children:[i.jsx("td",{className:"muted",children:y.created_at.replace("T"," ").slice(0,16)}),i.jsx("td",{children:y.corpus_filename}),i.jsx("td",{className:"muted small",children:y.model_name}),i.jsx("td",{className:"small",title:y.error_tail,children:y.error_tail.slice(0,90)}),i.jsx("td",{children:y.corpus_file_available?i.jsx("button",{className:"linkish",onClick:()=>Q(()=>un(`/api/admin/jobs/${y.id}/requeue`)),children:"Requeue"}):i.jsx("span",{className:"muted small",children:"file expired"})})]},y.id))})]})})}),i.jsxs(an,{title:"Construct verification",hint:`${a.length} ${k?"awaiting":"listed"}`,defaultOpen:!1,children:[i.jsxs("p",{className:"hint",children:["The maintainer's workflow: mark a scale verified once its wording is checked against the original publication (cross-reference the verification checklist spreadsheet). Statuses set here are applied back to the library files before production.",!O&&" Your account has read access; verification actions are for maintainers."," ",i.jsx("button",{className:"linkish",onClick:()=>D(y=>!y),children:k?"Show all":"Show unverified only"})]}),i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Scale"}),i.jsx("th",{children:"Category"}),i.jsx("th",{children:"Items"}),i.jsx("th",{children:"Status"}),i.jsx("th",{})]})}),i.jsxs("tbody",{children:[a.map(y=>i.jsxs("tr",{children:[i.jsx("td",{title:y.reference,children:y.name}),i.jsx("td",{className:"muted small",children:y.category}),i.jsx("td",{children:y.n_items}),i.jsx("td",{children:i.jsx("span",{className:`pill ${y.verification_status==="verified"?"completed":"queued"}`,children:y.verification_status.replace("_"," ")})}),i.jsx("td",{children:O&&i.jsx("button",{className:"linkish",onClick:()=>Q(()=>un(`/api/admin/constructs/${y.id}/verification`,{status:y.verification_status==="verified"?"needs_verification":"verified"})),children:y.verification_status==="verified"?"Un-verify":"Mark verified"})})]},y.id)),a.length===0&&i.jsx("tr",{children:i.jsx("td",{colSpan:5,className:"muted",children:"Nothing awaiting verification. 🎉"})})]})]})})]})]})}const vp=[{n:"1",title:"Upload your texts",body:"A CSV or Excel file with one text per row - tweets, essays, open-ended survey answers, transcripts."},{n:"2",title:"Pick a validated scale",body:"Choose from the construct library (90+ published psychological scales) or paste your own questionnaire items."},{n:"3",title:"Get scores you can defend",body:"Every text is scored against every item, with distributions, per-item loadings, warnings, and a downloadable script that reproduces the numbers on any machine."}];function gp({onEnter:e}){return i.jsxs("div",{className:"welcome",children:[i.jsxs("section",{className:"welcome-hero card",children:[i.jsx("h2",{children:"Theory-Driven Psychological Text Analysis"}),i.jsxs("p",{children:[i.jsx("b",{children:"Contextualized Construct Representation (CCR)"})," offers a theory-driven way to measure psychological themes in text without relying on simple word counts. CCR uses validated questionnaire items (or prototypical statements) designed to assess psychological constructs such as individualism, moral values, depression, religiosity, or personality traits. A language model then compares the meaning of a passage with the meaning of each input sentence and produces a score indicating how strongly the passage reflects the construct of interest. CCR is free, open-source, publicly available, multilingual, adaptable to new language models, and highly flexible."]}),i.jsxs("div",{className:"welcome-cta",children:[i.jsx("button",{className:"primary",onClick:e,children:"Open the dashboard →"}),i.jsx("a",{className:"ghost-link",href:"/guide",children:"How to use it"})]})]}),i.jsx("section",{className:"welcome-steps",children:vp.map(t=>i.jsxs("div",{className:"card welcome-step",children:[i.jsx("div",{className:"step-n",children:t.n}),i.jsx("h3",{children:t.title}),i.jsx("p",{className:"hint",children:t.body})]},t.n))}),i.jsxs("section",{className:"card",children:[i.jsx("h3",{children:"Your data stays here"}),i.jsx("p",{className:"hint",children:"The embedding models run on this server - no text is ever sent to third-party AI APIs. Every run records the exact model version, scale wording, and package versions, so results are auditable and reproducible outside the platform."})]}),i.jsxs("section",{className:"card",children:[i.jsx("h3",{children:"Who runs this"}),i.jsxs("p",{className:"hint",children:["This interface is designed, built, and maintained by the"," ",i.jsx("a",{href:"https://websites.umass.edu/matari/",target:"_blank",rel:"noopener noreferrer",children:"Culture & Morality Lab"})," ","(PI:"," ",i.jsx("a",{href:"https://mohammadatari.com/",target:"_blank",rel:"noopener noreferrer",children:"Mohammad Atari"}),") at the University of Massachusetts Amherst. The CCR pipeline is built based on Atari et al. (2023), extended and validated by Chen et al. (2024), and features PsyEmbedding language models, which are fine-tuned open-source models for psychological text analysis (Atari et al., 2026). For suggestions, questions, bugs, and ideas, reach out to the maintainer at ",i.jsx("a",{href:"mailto:devaanand@umass.edu",children:"devaanand@umass.edu"}),"."]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h3",{children:"Open-source disclaimer"}),i.jsx("p",{className:"hint",children:'This is an open-source software: use at your own risk. This open-source software is provided "as is," without warranties or guarantees of accuracy, reliability, security, fitness for a particular purpose, or continued support. Users are responsible for validating outputs, protecting their data, and determining whether the software is appropriate for their intended use. The authors and contributors are not liable for losses or damages resulting from its use.'})]})]})}const Oc="ccr_recent_constructs",yp=5;function Ac(){try{return JSON.parse(localStorage.getItem(Oc)||"[]")}catch{return[]}}function xp(e){const t=[e,...Ac().filter(n=>n!==e)].slice(0,yp);try{localStorage.setItem(Oc,JSON.stringify(t))}catch{}}function wp({constructs:e,selectedIds:t,onToggle:n}){const[r,l]=_.useState(!1),[s,o]=_.useState(""),[a,u]=_.useState(0),f=_.useRef(null),m=_.useRef(null),v=_.useRef(null),h=new Set(t),j=_.useMemo(()=>{const c=s.trim().toLowerCase(),d=O=>!c||O.name.toLowerCase().includes(c)||(O.category||"").toLowerCase().includes(c),g=e.filter(d),C=[],E=new Set,P=Ac().map(O=>g.find(B=>B.id===O)).filter(Boolean);P.length&&(C.push(["Recently used",P]),P.forEach(O=>E.add(O.id)));const A=g.filter(O=>!O.is_seed&&!E.has(O.id));A.length&&(C.push(["My custom constructs",A]),A.forEach(O=>E.add(O.id)));const R=new Map;for(const O of g){if(E.has(O.id))continue;const B=O.category||"Other";R.has(B)||R.set(B,[]),R.get(B).push(O)}for(const O of[...R.keys()].sort((B,Q)=>B.localeCompare(Q)))C.push([O,R.get(O).sort((B,Q)=>B.name.localeCompare(Q.name))]);return C},[e,s]),N=_.useMemo(()=>j.flatMap(([,c])=>c),[j]);_.useEffect(()=>u(0),[s,r]),_.useEffect(()=>{if(!r)return;const c=d=>{f.current&&!f.current.contains(d.target)&&l(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[r]),_.useEffect(()=>{var d;const c=(d=v.current)==null?void 0:d.querySelector('[data-active="true"]');c==null||c.scrollIntoView({block:"nearest"})},[a,r]);function k(c){n(c.id),h.has(c.id)||xp(c.id),l(!1),o("")}function D(c){c.key==="ArrowDown"?(c.preventDefault(),u(d=>Math.min(d+1,N.length-1))):c.key==="ArrowUp"?(c.preventDefault(),u(d=>Math.max(d-1,0))):c.key==="Enter"?(c.preventDefault(),N[a]&&k(N[a])):c.key==="Escape"&&l(!1)}let p=-1;return i.jsx("div",{className:"picker",ref:f,children:r?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:m,type:"text",role:"combobox","aria-expanded":"true","aria-autocomplete":"list",className:"picker-search",placeholder:"Search by scale, construct, or category (e.g. empathy, GAD-7)",value:s,onChange:c=>o(c.target.value),onKeyDown:D}),i.jsxs("div",{className:"picker-panel",role:"listbox",ref:v,children:[N.length===0&&i.jsxs("p",{className:"small muted picker-empty",children:['No constructs match "',s,'". Try a scale abbreviation or use + Custom construct.']}),j.map(([c,d])=>i.jsxs("div",{children:[i.jsx("div",{className:"picker-group",children:c}),d.map(g=>{p+=1;const C=p===a,E=h.has(g.id);return i.jsxs("div",{role:"option","aria-selected":E,"data-active":C||void 0,className:"picker-option"+(C?" active":"")+(E?" selected":""),onMouseDown:T=>{T.preventDefault(),k(g)},children:[i.jsxs("span",{className:"picker-name",children:[E?"✓ ":"",g.name]}),i.jsxs("span",{className:"picker-meta",children:[g.category?`${g.category} · `:"",g.items.length," item",g.items.length===1?"":"s",g.ai_generated?" · AI-generated · not validated":g.verification_status!=="verified"?" · unverified":"",E?" · click to remove":""]})]},g.id)})]},c))]})]}):i.jsxs("button",{type:"button",className:"picker-display","aria-haspopup":"listbox","aria-expanded":"false",onClick:()=>{l(!0),setTimeout(()=>{var c;return(c=m.current)==null?void 0:c.focus()},0)},children:[h.size>0?i.jsxs("span",{children:["+ Add another construct (",h.size," selected)"]}):i.jsxs("span",{className:"muted",children:["Select one or more constructs (",e.length," in library)"]}),i.jsx("span",{className:"picker-caret","aria-hidden":"true",children:"▾"})]})})}function jp({jobId:e,onBack:t}){var f;const[n,r]=_.useState(null),[l,s]=_.useState("");if(_.useEffect(()=>{J.jobResults(e).then(r).catch(m=>s(m.message))},[e]),l)return i.jsxs("div",{className:"card",children:[i.jsx("div",{className:"error-banner",children:l}),i.jsx("button",{className:"ghost",onClick:t,children:"← Back"})]});if(!n)return i.jsx("div",{className:"card",children:"Loading results…"});const{summary:o,metadata:a}=n,u=Array.isArray(o.constructs);return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"results-toolbar",children:[i.jsx("button",{className:"ghost",onClick:t,children:"← Back to workspace"}),i.jsxs("div",{className:"row result-actions",children:[i.jsx("a",{href:J.exportUrl(e),children:i.jsx("button",{className:"primary",children:"Export results CSV"})}),i.jsx("a",{href:J.scriptUrl(e),children:i.jsx("button",{className:"ghost",children:"Python script"})}),i.jsx("a",{href:J.scriptRequirementsUrl(e),children:i.jsx("button",{className:"ghost",children:"requirements.txt"})}),i.jsx("a",{href:J.metadataUrl(e),children:i.jsx("button",{className:"ghost",children:"Run metadata (JSON)"})})]})]}),i.jsxs("div",{className:"card",children:[i.jsxs("h3",{children:[a.construct," × ",a.corpus_file]}),i.jsxs("p",{className:"hint",children:["CCR score = mean cosine similarity between each text and a construct's scale items. Higher = the text expresses the construct more strongly.",u&&" All constructs were scored on the same pass over the corpus, so scores are row-aligned and directly comparable."]}),[a.construct_snapshot,...(a.constructs||[]).map(m=>m.snapshot)].some(m=>(m==null?void 0:m.source_type)==="llm_generated")&&i.jsx("p",{className:"small muted",children:"⚠ This run uses a construct whose items were AI-generated and have not been psychometrically validated. Interpret scores with appropriate caution."}),i.jsxs("div",{className:"stat-grid",children:[i.jsx(Je,{k:"Texts scored",v:o.n_docs.toLocaleString()}),u?i.jsx(Je,{k:"Constructs",v:o.constructs.length}):i.jsxs(i.Fragment,{children:[i.jsx(Je,{k:"Mean score",v:o.score_mean.toFixed(3)}),i.jsx(Je,{k:"SD",v:o.score_sd.toFixed(3)}),i.jsx(Je,{k:"Min",v:o.score_min.toFixed(3)}),i.jsx(Je,{k:"Max",v:o.score_max.toFixed(3)})]}),o.n_dropped_empty>0&&i.jsx(Je,{k:"Empty rows dropped",v:o.n_dropped_empty})]}),((f=o.warnings)==null?void 0:f.length)>0&&i.jsxs("div",{className:"warnings mt",children:[i.jsx("strong",{className:"small",children:"Data-quality notes"}),i.jsx("ul",{className:"small",style:{margin:"4px 0 0",paddingLeft:20},children:o.warnings.map((m,v)=>i.jsx("li",{children:typeof m=="string"?m:i.jsxs(i.Fragment,{children:[i.jsx("code",{style:{fontSize:11},children:m.code})," - ",m.message]})},v))})]})]}),u&&i.jsx(Sp,{correlations:o.correlations}),u?o.constructs.map((m,v)=>i.jsxs("details",{className:"card construct-results",open:o.constructs.length<=2,children:[i.jsxs("summary",{children:[i.jsx("strong",{children:m.construct_name}),i.jsxs("span",{className:"picker-meta",children:[" ","mean ",m.score_mean.toFixed(3)," · SD ",m.score_sd.toFixed(3)," ·"," ",m.n_items," item",m.n_items===1?"":"s"," · CSV columns"," ",i.jsxs("code",{children:[m.column_prefix,"_*"]})]})]}),i.jsxs("div",{className:"stat-grid mt",children:[i.jsx(Je,{k:"Mean score",v:m.score_mean.toFixed(3)}),i.jsx(Je,{k:"SD",v:m.score_sd.toFixed(3)}),i.jsx(Je,{k:"Min",v:m.score_min.toFixed(3)}),i.jsx(Je,{k:"Max",v:m.score_max.toFixed(3)})]}),i.jsx("h4",{children:"Score distribution"}),i.jsx(ja,{histogram:m.histogram}),i.jsx("h4",{children:"Per-item mean loadings"}),i.jsx(wa,{itemMeans:m.item_means}),i.jsxs("div",{className:"row",children:[i.jsxs("div",{className:"grow",children:[i.jsx("h4",{children:"Highest-scoring texts"}),i.jsx(Kr,{docs:m.top_docs})]}),i.jsxs("div",{className:"grow",children:[i.jsx("h4",{children:"Lowest-scoring texts"}),i.jsx(Kr,{docs:m.bottom_docs})]})]})]},m.construct_id||v)):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Score distribution"}),i.jsx(ja,{histogram:o.histogram})]}),i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Per-item mean loadings"}),i.jsx("p",{className:"hint",children:"Mean similarity of the corpus to each scale item - a face-validity check on which items drive the construct signal."}),i.jsx(wa,{itemMeans:o.item_means})]}),i.jsxs("div",{className:"row",children:[i.jsxs("div",{className:"grow card",children:[i.jsx("h3",{children:"Highest-scoring texts"}),i.jsx(Kr,{docs:o.top_docs})]}),i.jsxs("div",{className:"grow card",children:[i.jsx("h3",{children:"Lowest-scoring texts"}),i.jsx(Kr,{docs:o.bottom_docs})]})]})]}),i.jsxs("div",{className:"meta-footer",children:[i.jsx("strong",{children:"Reproducibility record"})," - model: ",i.jsx("code",{children:a.model})," (dim"," ",a.embedding_dim,")",!u&&i.jsxs(i.Fragment,{children:[" ","· items hash: ",i.jsx("code",{children:a.items_sha256_16})]})," ","· text column: ",i.jsx("code",{children:a.text_column})," · run:"," ",a.started_at," → ",a.finished_at," (",a.duration_seconds,"s) · numpy ",a.numpy,a.sentence_transformers&&` · sentence-transformers ${a.sentence_transformers}`,u?i.jsx("div",{className:"mt small",children:a.constructs.map(m=>i.jsxs("div",{children:[m.name," — items hash ",i.jsx("code",{children:m.items_sha256_16}),m.reference?` · ${m.reference}`:""]},m.column_prefix))}):i.jsxs("div",{className:"mt small",children:["Construct reference: ",a.construct_reference||"-"]})]})]})}function Sp({correlations:e}){const{constructs:t,matrix:n,n_texts:r}=e;function l(s,o){if(o||s==null)return{color:"#98a2b3"};const a=Math.min(.85,Math.abs(s));return{background:s>=0?`rgba(38, 115, 111, ${a})`:`rgba(178, 96, 43, ${a})`,color:Math.abs(s)>.5?"#fff":void 0,textAlign:"center"}}return i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Construct interrelations"}),i.jsxs("p",{className:"hint",children:["Pearson correlation between per-text CCR scores (",r.toLocaleString()," texts). Positive r = the constructs rise and fall together in your corpus; negative r = texts high on one tend to be low on the other. The exported CSV contains every per-text score, so these are fully recomputable."]}),i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{}),t.map((s,o)=>i.jsx("th",{style:{textAlign:"center"},title:s,children:o+1},o))]})}),i.jsx("tbody",{children:t.map((s,o)=>i.jsxs("tr",{children:[i.jsxs("th",{style:{textAlign:"left",fontWeight:500},children:[o+1,". ",s]}),n[o].map((a,u)=>i.jsx("td",{style:l(a,o===u),children:o===u?"—":a==null?"n/a":a.toFixed(2)},u))]},o))})]})})]})}function Je({k:e,v:t}){return i.jsxs("div",{className:"stat",children:[i.jsx("div",{className:"v",children:t}),i.jsx("div",{className:"k",children:e})]})}function wa({itemMeans:e}){const t=Math.max(...e.map(n=>Math.abs(n.mean)),1e-9);return i.jsx(i.Fragment,{children:e.map((n,r)=>i.jsxs("div",{className:"item-bar-row",children:[i.jsx("span",{className:"item-bar-label",title:n.item,children:n.item.length>80?n.item.slice(0,80)+"…":n.item}),i.jsx("div",{className:"item-bar-track",children:i.jsx("div",{className:"item-bar-fill",style:{width:`${Math.max(2,Math.abs(n.mean)/t*100)}%`}})}),i.jsx("span",{className:"item-bar-val",children:n.mean.toFixed(3)})]},r))})}function Kr({docs:e}){return i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{style:{width:60},children:"Score"}),i.jsx("th",{children:"Text"})]})}),i.jsx("tbody",{children:e.map(t=>i.jsxs("tr",{children:[i.jsx("td",{className:"score",children:t.score.toFixed(3)}),i.jsx("td",{children:t.text})]},t.row))})]})})}function ja({histogram:e}){const{counts:t,edges:n}=e,r=640,l=180,s={top:10,right:10,bottom:26,left:34},o=r-s.left-s.right,a=l-s.top-s.bottom,u=Math.max(...t,1),f=o/t.length;return i.jsxs("svg",{viewBox:`0 0 ${r} ${l}`,style:{width:"100%",maxWidth:720},children:[[.25,.5,.75,1].map(m=>{const v=s.top+a-m*a;return i.jsxs("g",{children:[i.jsx("line",{x1:s.left,x2:r-s.right,y1:v,y2:v,stroke:"#eceef1"}),i.jsx("text",{x:s.left-6,y:v+4,fontSize:"10",fill:"#98a2b3",textAnchor:"end",children:Math.round(m*u)})]},m)}),t.map((m,v)=>{const h=m/u*a;return i.jsx("rect",{x:s.left+v*f+1.5,y:s.top+a-h,width:Math.max(1,f-3),height:h,rx:"2",fill:"#339b98",opacity:"0.85",children:i.jsxs("title",{children:[n[v].toFixed(3)," – ",n[v+1].toFixed(3),": ",m]})},v)}),[0,Math.floor(t.length/2),t.length].map(m=>i.jsx("text",{x:s.left+m*f,y:l-8,fontSize:"10",fill:"#98a2b3",textAnchor:"middle",children:n[m].toFixed(2)},m)),i.jsx("line",{x1:s.left,x2:r-s.right,y1:s.top+a,y2:s.top+a,stroke:"#d0d5dd"})]})}function kp({project:e,auth:t,onAuthRefresh:n,onProjectChanged:r,onProjectDeleted:l}){var ln,lo,so,io,oo,ao,uo;const[s,o]=_.useState([]),[a,u]=_.useState([]),[f,m]=_.useState([]),[v,h]=_.useState([]),[j,N]=_.useState(""),[k,D]=_.useState(""),[p,c]=_.useState([]),[d,g]=_.useState(""),[C,E]=_.useState(["en"]),[T,P]=_.useState("en"),[A,R]=_.useState(!1),[O,B]=_.useState(!1),[Q,Y]=_.useState(""),[ge,y]=_.useState(null),[U,w]=_.useState(null),[M,I]=_.useState(!1),[W,K]=_.useState(""),Pe=_.useRef(null);async function Se(){try{await J.patchProject(e.id,{archived:!e.archived}),r==null||r()}catch(x){Y(x.message)}}async function lt(){try{await J.deleteProject(e.id),I(!1),l==null||l()}catch(x){Y(x.message)}}const oe=_.useCallback(()=>J.listJobs(e.id).then(h).catch(()=>{}),[e.id]);_.useEffect(()=>{J.listCorpora(e.id).then(o).catch(x=>Y(x.message)),J.listConstructs().then(u).catch(x=>Y(x.message)),J.models().then(x=>{m(x);const q=x.find(ct=>ct.default)||x[0];q&&g(q.id)}).catch(x=>Y(x.message)),J.languages().then(E).catch(()=>{}),oe()},[e.id,oe]);const Fe=v.some(x=>x.status==="queued"||x.status==="running");_.useEffect(()=>{if(!Fe)return;const x=setInterval(oe,1200);return()=>clearInterval(x)},[Fe,oe]);const z=s.find(x=>x.id===j)||null,ke=p.map(x=>a.find(q=>q.id===x)).filter(Boolean),ce=10;function rn(x){c(q=>q.includes(x)?q.filter(ct=>ct!==x):q.length>=ce?(Y(`At most ${ce} constructs per run.`),q):[...q,x])}async function F(x){var ct;const q=(ct=x.target.files)==null?void 0:ct[0];if(q){R(!0),Y("");try{const jt=await J.uploadCorpus(e.id,q),$c=await J.listCorpora(e.id);o($c),N(jt.id),D(jt.suggested_text_column||jt.columns[0])}catch(jt){Y(jt.message)}finally{R(!1),Pe.current&&(Pe.current.value="")}}}async function pe(){B(!0),Y("");try{await J.createJob({project_id:e.id,corpus_id:j,construct_ids:p,text_column:k,model_name:d,language:T}),await oe(),n==null||n()}catch(x){Y(x.message)}finally{B(!1)}}if(U)return i.jsx(jp,{jobId:U,onBack:()=>{w(null),oe()}});const Te=z&&z.file_available===!1,De=j&&k&&p.length>0&&d&&!O&&!Te;return i.jsxs(i.Fragment,{children:[Q&&i.jsx("div",{className:"error-banner",onClick:()=>Y(""),children:Q}),i.jsxs("div",{className:"project-header",children:[i.jsxs("div",{children:[i.jsx("span",{className:"project-title",children:e.name}),e.archived&&i.jsx("span",{className:"pill queued",children:"archived"})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"ghost",onClick:Se,children:e.archived?"Unarchive":"Archive"}),i.jsx("button",{className:"ghost danger",onClick:()=>I(!0),children:"Delete"})]})]}),M&&i.jsx("div",{className:"modal-backdrop",onClick:()=>I(!1),children:i.jsxs("div",{className:"modal",onClick:x=>x.stopPropagation(),children:[i.jsxs("h3",{children:['Delete "',e.name,'"?']}),i.jsxs("p",{className:"hint",children:["This permanently deletes ",s.length," dataset",s.length===1?"":"s",","," ",v.length," run",v.length===1?"":"s",", and all uploaded and result files. This cannot be undone. If you might need it later, use Archive instead."]}),i.jsxs("label",{className:"field",children:["Type the project name to confirm",i.jsx("input",{type:"text",autoFocus:!0,value:W,onChange:x=>K(x.target.value),placeholder:e.name})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary danger-solid",disabled:W!==e.name,onClick:lt,children:"Delete permanently"}),i.jsx("button",{className:"ghost",onClick:()=>{I(!1),K("")},children:"Cancel"})]})]})}),i.jsxs("div",{className:"card",children:[i.jsxs("h3",{children:[i.jsx("span",{className:"step-badge",children:"1"}),"Corpus"]}),i.jsxs("p",{className:"hint",children:["Upload a CSV or XLSX file, then choose the column containing the text to analyze.",t&&!t.signed_in&&((ln=t.limits)==null?void 0:ln.max_rows)&&i.jsxs(i.Fragment,{children:[" ","Anonymous limit: ",Math.round(t.limits.max_bytes/1048576)," MB /"," ",t.limits.max_rows.toLocaleString()," rows per file; uploads are deleted after analysis. Sign in (top right) for larger uploads and to keep your data."]}),t&&t.signed_in&&((lo=t.limits)==null?void 0:lo.max_rows)&&i.jsxs(i.Fragment,{children:[" ","Limit: ",Math.round(t.limits.max_bytes/1048576)," MB /"," ",t.limits.max_rows.toLocaleString()," rows per file."]})]}),i.jsxs("div",{className:"row",children:[i.jsxs("div",{className:"grow",children:[i.jsxs("label",{className:"field",children:["Upload file",i.jsx("input",{ref:Pe,type:"file",accept:".csv,.xlsx,.xls",onChange:F,disabled:A})]}),A&&i.jsx("span",{className:"small muted",children:"Uploading…"})]}),i.jsx("div",{className:"grow",children:i.jsxs("label",{className:"field",children:["Corpus",i.jsxs("select",{value:j,onChange:x=>N(x.target.value),children:[i.jsx("option",{value:"",children:"- select -"}),s.map(x=>i.jsxs("option",{value:x.id,children:[x.filename," (",x.n_rows.toLocaleString()," rows)",x.file_available===!1?" - re-upload to run":""]},x.id))]})]})}),i.jsx("div",{className:"grow",children:i.jsxs("label",{className:"field",children:["Text column",i.jsxs("select",{value:k,onChange:x=>D(x.target.value),disabled:!z,children:[i.jsx("option",{value:"",children:"- select -"}),z==null?void 0:z.columns.map(x=>i.jsxs("option",{value:x,children:[x,x===z.suggested_text_column?" (suggested)":""]},x))]})]})})]}),((so=z==null?void 0:z.parse_info)==null?void 0:so.note)&&i.jsxs("p",{className:"small muted",children:["⚠ ",z.parse_info.note]}),z&&z.file_available===!1&&i.jsx("p",{className:"small muted",children:"⚠ This dataset's file is no longer on the server (the instance restarted). Your past results for it are safe, but to run a new analysis, upload the file again above."})]}),i.jsxs("div",{className:"card",children:[i.jsxs("h3",{children:[i.jsx("span",{className:"step-badge",children:"2"}),"Construct"]}),i.jsx("p",{className:"hint",children:"Three ways to add a construct: pick validated scales from the library, add your own items (typed or uploaded), or draft items with AI when no validated scale exists. Selecting several runs them together in one pass (up to 10) and shows how they correlate in your texts."}),i.jsxs("div",{className:"construct-row",children:[i.jsx("div",{className:"grow",children:i.jsx(wp,{constructs:a,selectedIds:p,onToggle:rn})}),i.jsx("button",{className:"ghost",onClick:()=>y(x=>x?null:"type"),children:ge?"✕ Close":"+ New construct"})]}),ke.map(x=>i.jsxs("details",{className:"construct-selected",open:ke.length===1,children:[i.jsxs("summary",{children:[i.jsx("span",{className:"construct-selected-name",children:x.name}),i.jsxs("span",{className:"picker-meta",children:[" ",x.items.length," item",x.items.length===1?"":"s",x.ai_generated?" · AI-generated · not validated":x.verification_status!=="verified"?" · unverified":""]}),i.jsx("button",{type:"button",className:"linkish construct-remove",onClick:q=>{q.preventDefault(),rn(x.id)},children:"remove"})]}),i.jsx("ul",{className:"construct-items",children:x.items.map((q,ct)=>{var jt;return i.jsxs("li",{children:[q,(jt=x.reverse_scored)!=null&&jt[ct]?" (reverse-scored)":""]},ct)})}),x.reference&&i.jsxs("p",{className:"small muted mt",children:["Reference: ",x.reference]}),x.ai_generated?i.jsx("p",{className:"small muted",children:"⚠ This construct's items were AI-generated and have not been psychometrically validated. Interpret scores with appropriate caution."}):x.verification_status!=="verified"&&i.jsxs("p",{className:"small muted",children:["⚠ Item wording not yet verified verbatim against the original publication (status: ",x.verification_status.replace("_"," "),")."]})]},x.id)),ge&&i.jsx(Np,{auth:t,constructs:a,source:ge,onSourceChange:y,onCreated:async x=>{const q=await J.listConstructs();u(q),rn(x.id),y(null)},onError:Y})]}),i.jsxs("div",{className:"card",children:[i.jsxs("h3",{children:[i.jsx("span",{className:"step-badge",children:"3"}),"Language, model & run"]}),i.jsx("p",{className:"hint",children:"Embeddings run locally via sentence-transformers; model and language are recorded in the run metadata. If the corpus doesn't match the selected language or the model doesn't support it, you'll get a warning - never a silent result."}),i.jsxs("div",{className:"run-settings",children:[i.jsxs("label",{className:"field language-control",children:["Text language",i.jsx("select",{value:T,onChange:x=>P(x.target.value),children:C.map(x=>i.jsx("option",{value:x,children:x},x))})]}),i.jsxs("label",{className:"field model-control",children:["Embedding model",i.jsx("select",{value:d,onChange:x=>g(x.target.value),children:f.map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]}),i.jsx("button",{className:"primary run-button",disabled:!De,onClick:pe,children:O?"Starting…":p.length>1?`Run CCR analysis (${p.length} constructs)`:"Run CCR analysis"})]}),!De&&!O&&!Te&&i.jsxs("p",{className:"small muted",children:["To run, still needed:"," ",[!j&&"a dataset (Step 1)",j&&!k&&"a text column (Step 1)",p.length===0&&"at least one construct (Step 2)"].filter(Boolean).join(", "),"."]}),t&&!t.signed_in&&((io=t.usage)==null?void 0:io.max_runs_per_day)!=null&&i.jsxs("p",{className:"small muted",children:[Math.min(t.usage.runs_used_today,t.usage.max_runs_per_day)," of"," ",t.usage.max_runs_per_day," free runs used today",t.usage.runs_used_today>=t.usage.max_runs_per_day?" - sign in (top right) to keep running.":"."]}),(t==null?void 0:t.signed_in)&&((oo=t.usage)==null?void 0:oo.max_saved_runs)!=null&&i.jsxs("p",{className:"small muted",children:[t.usage.saved_runs," of ",t.usage.max_saved_runs," saved runs used."]}),(uo=(ao=f.find(x=>x.id===d))==null?void 0:ao.warnings)==null?void 0:uo.map((x,q)=>i.jsxs("p",{className:"small muted",children:["⚠ ",x]},q))]}),v.length>0&&i.jsxs("div",{className:"card",children:[i.jsx("h3",{children:"Runs"}),i.jsx("div",{className:"table-wrap",children:i.jsxs("table",{className:"docs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Started"}),i.jsx("th",{children:"Corpus"}),i.jsx("th",{children:"Construct"}),i.jsx("th",{children:"Model"}),i.jsx("th",{children:"Lang"}),i.jsx("th",{style:{width:"20%"},children:"Status"}),i.jsx("th",{})]})}),i.jsx("tbody",{children:v.map(x=>{var q;return i.jsxs("tr",{children:[i.jsx("td",{className:"muted",children:(x.started_at||x.created_at).replace("T"," ").slice(0,16)}),i.jsx("td",{children:x.corpus_filename}),i.jsx("td",{children:((q=x.construct_names)!=null&&q.length?x.construct_names:[x.construct_name]).join(" + ")}),i.jsx("td",{className:"muted small",children:x.model_name}),i.jsx("td",{className:"muted small",children:x.language}),i.jsxs("td",{children:[x.status==="running"?i.jsx("div",{className:"progress-track",title:`${Math.round(x.progress*100)}%`,children:i.jsx("div",{className:"progress-fill",style:{width:`${Math.max(3,x.progress*100)}%`}})}):i.jsx("span",{className:`pill ${x.status}`,children:x.status}),x.status==="failed"&&i.jsx("div",{className:"small muted",title:x.error,children:x.error.split(` +`).pop()})]}),i.jsx("td",{children:x.status==="completed"&&i.jsx("button",{className:"linkish",onClick:()=>w(x.id),children:"View results"})})]},x.id)})})]})})]})]})}const Sa=/\s*\((r|rev|reversed)\)\s*$/i;function Np({auth:e,constructs:t,source:n,onSourceChange:r,onCreated:l,onError:s}){var rn;const[o,a]=_.useState(""),[u,f]=_.useState(""),[m,v]=_.useState(""),[h,j]=_.useState(""),[N,k]=_.useState(!1),[D,p]=_.useState(!1),[c,d]=_.useState([]),[g,C]=_.useState(10),[E,T]=_.useState(!1),[P,A]=_.useState(null),[R,O]=_.useState(""),[B,Q]=_.useState(null),Y=_.useRef(null),ge=_.useRef(null),y=r,U=B||(((rn=e==null?void 0:e.usage)==null?void 0:rn.max_generations_per_day)!=null?{used:e.usage.generations_used_today,max:e.usage.max_generations_per_day}:null),w=e==null?void 0:e.generation,M=w!=null&&w.available?w.model_label||w.model:null,I=M?`AI item drafting uses ${M}${w.provider_label?` (${w.provider_label})`:""}, prompt version ${w.prompt_version}. Positively-keyed items only, ${w.n_items_min} to ${w.n_items_max} per draft, ${w.max_generations_per_day} drafts per day. Not a validated scale; the model, version, and date are recorded in each run's metadata.`:"AI item drafting uses a hosted language model. Not a validated scale; the model, version, and date are recorded in each run's metadata.",W=o.trim().toLowerCase(),K=W.length>=3?(t||[]).find(F=>F.is_seed&&(F.name.toLowerCase().includes(W)||W.includes(F.name.toLowerCase()))):null;async function Pe(){if(!o.trim()||!m.trim()){s("AI drafting needs the construct's name and a few sentences explaining what it means (the Description field).");return}T(!0),O("");try{const F=await J.generateConstructItems({name:o.trim(),description:m.trim(),n_items:g});j(F.items.join(` +`)),A({...F.generation,n:F.items.length}),O(F.notes||""),Q({used:F.generations_used_today,max:F.max_generations_per_day}),setTimeout(()=>{var pe,Te;(pe=ge.current)==null||pe.scrollIntoView({behavior:"smooth",block:"center"}),(Te=ge.current)==null||Te.focus({preventScroll:!0})},50)}catch(F){s(F.message)}finally{T(!1)}}function Se(){return h.split(` +`).map(F=>F.trim()).filter(Boolean).map(F=>({text:F.replace(Sa,"").trim(),reverse:Sa.test(F)}))}async function lt(F){var Te;const pe=(Te=F.target.files)==null?void 0:Te[0];if(pe){p(!0),d([]);try{const De=await J.parseConstructFile(pe);j(De.items.map(ln=>ln.reverse_scored?`${ln.text} (R)`:ln.text).join(` +`)),A(null),O(""),!o.trim()&&De.suggested_name&&a(De.suggested_name),d(De.warnings||[])}catch(De){s(De.message)}finally{p(!1),Y.current&&(Y.current.value="")}}}async function oe(F){F.preventDefault();const pe=Se();if(!o.trim()||pe.length===0){s("A custom construct needs a name and at least one item (one per line).");return}k(!0);try{const Te=await J.createConstruct({name:o.trim(),reference:u,description:m.trim(),items:pe.map(De=>De.text),reverse_scored:pe.map(De=>De.reverse),generation:P?{model:P.model,prompt_version:P.prompt_version,generated_at:P.generated_at,items:P.items}:void 0});l(Te)}catch(Te){s(Te.message)}finally{k(!1)}}const Fe=Se().filter(F=>F.reverse).length,z=Se().length>0,ke=n!=="ai"||!!(h.trim()||P),ce=[["type","Type or paste","Enter a scale's items yourself, one per line"],["upload","Upload a file","CSV/XLSX with an item column - review, then save"],...e!=null&&e.generation_available?[["ai","Draft with AI","From a name + description, when no validated scale exists"]]:[]];return i.jsxs("form",{onSubmit:oe,className:"new-construct mt",children:[i.jsxs("div",{className:"new-construct-head",children:[i.jsx("strong",{children:"New construct"}),i.jsx("button",{type:"button",className:"linkish",onClick:()=>y(null),children:"✕ Close"})]}),i.jsx("div",{className:"source-cards",role:"tablist","aria-label":"How to add items",children:ce.map(([F,pe,Te])=>i.jsxs("button",{type:"button",role:"tab","aria-selected":n===F,className:"source-card"+(n===F?" active":""),onClick:()=>y(F),children:[i.jsxs("b",{children:[n===F?"● ":"○ ",pe]}),i.jsx("span",{children:Te})]},F))}),n==="ai"&&!(e!=null&&e.signed_in)?i.jsx("p",{className:"small muted",children:"Sign in (top right) to draft items with AI - accounts are free."}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row",children:[i.jsx("div",{className:"grow",children:i.jsxs("label",{className:"field",children:["Name",i.jsx("input",{type:"text",value:o,onChange:F=>a(F.target.value)})]})}),n!=="ai"&&i.jsx("div",{className:"grow",children:i.jsxs("label",{className:"field",children:["Reference (publication, optional)",i.jsx("input",{type:"text",value:u,onChange:F=>f(F.target.value)})]})})]}),n==="ai"&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"ai-modeline",children:[i.jsxs("span",{className:"small muted",children:["Drafted by"," ",i.jsx("b",{children:M||"a hosted AI language model"})]}),i.jsxs("span",{className:"infotip",tabIndex:0,role:"note","aria-label":I,title:I,children:[i.jsx("span",{className:"infotip-icon","aria-hidden":"true",children:"i"}),i.jsxs("span",{className:"infotip-pop","aria-hidden":"true",children:[i.jsx("b",{children:"How AI drafting works"}),i.jsxs("ul",{children:[i.jsxs("li",{children:["Model: ",M||"hosted language model",w!=null&&w.provider_label?` (${w.provider_label})`:""]}),i.jsxs("li",{children:["Prompt version: v",(w==null?void 0:w.prompt_version)??"1"]}),i.jsxs("li",{children:["Positively-keyed items only,"," ",w?`${w.n_items_min}-${w.n_items_max}`:"5-20"," per draft"]}),i.jsxs("li",{children:["Limit: ",(w==null?void 0:w.max_generations_per_day)??20," drafts per day"]}),i.jsx("li",{children:"Not a validated scale. The model, prompt version, and date are recorded in every run's metadata and reproduction script."})]}),i.jsx("a",{href:"/guide#ai",target:"_blank",rel:"noopener noreferrer",tabIndex:-1,children:"More in the guide"})]})]})]}),i.jsxs("label",{className:"field",children:["Description - a few sentences on what this construct means (the AI drafts from this)",i.jsx("textarea",{rows:2,value:m,onChange:F=>v(F.target.value)})]}),K&&i.jsxs("p",{className:"small muted",children:["⚠ The library already has “",K.name,"” (",K.items.length," validated items). Prefer the library scale unless you specifically need custom items."]}),i.jsxs("div",{className:"field-row",children:[i.jsxs("label",{className:"field",children:["Number of items",i.jsx("select",{value:g,onChange:F=>C(Number(F.target.value)),children:Array.from({length:16},(F,pe)=>pe+5).map(F=>i.jsx("option",{value:F,children:F},F))})]}),i.jsx("button",{type:"button",className:"primary",onClick:Pe,disabled:E||N||D||!o.trim()||!m.trim(),children:E?"Drafting…":"Draft items"}),U&&i.jsxs("span",{className:"small muted",children:[U.used," of ",U.max," used today"]})]}),(!o.trim()||!m.trim())&&i.jsxs("p",{className:"small muted",children:["To draft, fill in",o.trim()?"":" the Name",!o.trim()&&!m.trim()?" and":"",m.trim()?"":" the Description"," above."]}),i.jsx("p",{className:"small muted",children:"These items are drafted by an AI language model. They are a starting point, not a validated questionnaire. Review every item, edit or remove weak ones, and prefer a validated scale whenever one exists."}),P&&i.jsxs("p",{className:"small",children:["✓ ",i.jsxs("b",{children:[P.n," items drafted - review them below."]})," Edit or remove weak ones, then Save. The saved construct will be labeled “AI-generated · not validated” (model: ",P.model,")."]}),R&&i.jsxs("p",{className:"small muted",children:["Model notes: ",R]})]}),n==="upload"&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"field",children:['CSV/XLSX with an "item" column, or one item per row; reverse-scored via a "reverse" column or a trailing (R)',i.jsx("input",{ref:Y,type:"file",accept:".csv,.xlsx,.xls",onChange:lt,disabled:D})]}),D&&i.jsx("p",{className:"small muted",children:"Parsing…"}),c.map((F,pe)=>i.jsxs("p",{className:"small muted",children:["⚠ ",F]},pe))]}),ke&&i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"field",children:["Items - one per line",n==="type"?" (or paste a whole scale)":"","; append (R) to mark a reverse-scored item",i.jsx("textarea",{ref:ge,rows:6,value:h,onChange:F=>j(F.target.value)})]}),Fe>0&&i.jsxs("p",{className:"small muted",children:[Fe," item(s) marked reverse-scored."]}),i.jsx("button",{className:"primary",type:"submit",disabled:N||D||!o.trim()||!z,children:N?"Saving…":"Save construct"}),(!o.trim()||!z)&&i.jsxs("p",{className:"small muted",children:["To save, this construct still needs",o.trim()?"":" a name",!o.trim()&&!z?" and":"",z?"":" at least one item","."]})]})]})]})}const Kn=window.location.pathname==="/admin",ka="ccr_welcome_seen",_p=window.location.pathname==="/welcome";function Cp(e){if(!e)return"";const t=new Date(e.endsWith("Z")||e.includes("+")?e:e+"Z"),n=Math.max(0,Math.floor((Date.now()-t.getTime())/6e4));if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const l=Math.floor(r/24);return l<7?`${l}d ago`:t.toISOString().slice(0,10)}function Ep(e){const t=Date.now(),n=864e5,r={Today:[],"This week":[],Earlier:[],Archived:[]};for(const l of e){if(l.archived){r.Archived.push(l);continue}const s=l.last_activity_at||l.created_at,o=new Date(s.endsWith("Z")||s.includes("+")?s:s+"Z").getTime(),a=t-o;al.length>0)}function Pp(){var oe,Fe;const[e,t]=_.useState([]),[n,r]=_.useState(null),[l,s]=_.useState(!1),[o,a]=_.useState(""),[u,f]=_.useState(""),[m,v]=_.useState(""),[h,j]=_.useState(null),[N,k]=_.useState(!1),[D,p]=_.useState("signin"),[c,d]=_.useState(""),[g,C]=_.useState(""),[E,T]=_.useState(""),[P,A]=_.useState(""),[R,O]=_.useState(!1),[B,Q]=_.useState(""),[Y,ge]=_.useState(_p||!Kn&&!localStorage.getItem(ka));function y(){localStorage.setItem(ka,"1"),window.location.pathname!=="/"&&window.history.replaceState({},"","/"),ge(!1)}const U=(()=>{if(!B)return null;try{const z=JSON.parse(atob(B.split(".")[0].replace(/-/g,"+").replace(/_/g,"/")));return{lab:"lab member",external:"external user"}[z.invite]||null}catch{return null}})(),w=()=>J.listProjects().then(t).catch(z=>v(z.message)),M=()=>J.authMe().then(j).catch(()=>{});_.useEffect(()=>{w(),M();const z=new URLSearchParams(window.location.search),ke=z.get("auth_error");ke&&(v(`Sign-in problem: ${ke.replaceAll("-"," ")}.`),window.history.replaceState({},"","/"));const ce=z.get("invite");ce&&(Q(ce),p("register"),k(!0),ge(!1))},[]);async function I(z){z.preventDefault(),A(""),O(!0);try{D==="register"?(await J.register({email:c.trim(),password:g,name:E.trim(),...B?{invite_token:B}:{}}),B&&(Q(""),window.history.replaceState({},"","/"))):await J.login({email:c.trim(),password:g}),k(!1),d(""),C(""),T(""),await Promise.all([M(),w()])}catch(ke){A(ke.message)}finally{O(!1)}}async function W(){try{await J.logout(),await Promise.all([M(),w()])}catch(z){v(z.message)}}_.useEffect(()=>{if(e.length===0){r(null);return}(!n||!e.some(z=>z.id===n))&&r(e[0].id)},[e,n]);async function K(z){if(z.preventDefault(),!!o.trim())try{const ke=await J.createProject({name:o.trim()});a(""),s(!1),await w(),r(ke.id)}catch(ke){v(ke.message)}}const Pe=e.find(z=>z.id===n)||null,Se=u.trim().toLowerCase(),lt=e.filter(z=>z.name.toLowerCase().includes(Se));return i.jsxs("div",{className:"app",children:[i.jsxs("header",{className:"header",children:[i.jsx("a",{className:"brand",href:"/",onClick:z=>{Kn||(z.preventDefault(),y())},children:i.jsx("img",{className:"brand-logo",src:"/ccr-logo-white.svg",alt:"CCR Platform"})}),i.jsx("span",{className:"sub",children:"Psychological Text Analysis with Contextualized Construct Representation"}),i.jsxs("nav",{className:"header-nav",children:[Kn?i.jsx("a",{className:"header-link",href:"/welcome",children:"About"}):i.jsx("button",{className:"header-link"+(Y?" current":""),onClick:()=>ge(!0),children:"About"}),i.jsx("a",{className:"header-link",href:"/guide",children:"Guide"}),["lab","maintainer","pi"].includes(h==null?void 0:h.role)&&i.jsxs(i.Fragment,{children:[i.jsx("a",{className:"header-link",href:"/testing",children:"Testing"}),i.jsx("a",{className:"header-link",href:"/product",children:"How it works"})]}),h!=null&&h.signed_in?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"small",children:["Hi, ",h.name]}),h.is_admin&&!Kn&&i.jsx("a",{className:"header-btn",href:"/admin",children:"Admin"}),i.jsx("button",{className:"header-btn",onClick:W,children:"Sign out"})]}):i.jsx("button",{className:"header-btn",onClick:()=>k(!0),children:"Sign in"})]})]}),N&&i.jsx("div",{className:"modal-backdrop",onClick:()=>k(!1),children:i.jsxs("div",{className:"modal",onClick:z=>z.stopPropagation(),children:[i.jsx("h3",{children:D==="register"?"Create an account":"Sign in"}),B&&D==="register"&&i.jsxs("p",{className:"hint",style:{fontWeight:600},children:["🎟 You've been invited",U?` as a ${U}`:""," - create your account below and the access comes with it."]}),i.jsxs("p",{className:"hint",children:["Accounts are free. Signing in lifts the anonymous limits",(oe=h==null?void 0:h.limits)!=null&&oe.max_rows?` (${Math.round(h.limits.max_bytes/1048576)} MB / ${h.limits.max_rows.toLocaleString()} rows per file, ${((Fe=h==null?void 0:h.usage)==null?void 0:Fe.max_runs_per_day)??3} runs/day)`:""," ","and keeps your datasets and runs instead of deleting them after analysis."]}),P&&i.jsx("p",{className:"small",style:{color:"var(--danger, #b3261e)"},children:P}),(h==null?void 0:h.google_available)&&i.jsxs(i.Fragment,{children:[i.jsx("a",{className:"primary google-btn",href:"/api/auth/google/login",children:"Continue with Google"}),i.jsx("p",{className:"small muted",style:{textAlign:"center",margin:"8px 0"},children:"or use email and password"})]}),i.jsxs("form",{onSubmit:I,className:"mt",children:[D==="register"&&i.jsxs("label",{className:"field",children:["Name",i.jsx("input",{type:"text",autoFocus:!0,value:E,onChange:z=>T(z.target.value),placeholder:"e.g. Mohammad"})]}),i.jsxs("label",{className:"field",children:["Email",i.jsx("input",{type:"email",autoFocus:D==="signin",value:c,onChange:z=>d(z.target.value),placeholder:"you@example.com"})]}),i.jsxs("label",{className:"field",children:["Password",D==="register"&&i.jsx("span",{className:"field-hint",children:" at least 8 characters"}),i.jsx("input",{type:"password",value:g,onChange:z=>C(z.target.value)})]}),i.jsxs("div",{className:"row",children:[i.jsx("button",{className:"primary",type:"submit",disabled:R||!c.trim()||!g||D==="register"&&!E.trim(),children:R?"…":D==="register"?"Create account":"Sign in"}),i.jsx("button",{className:"ghost",type:"button",onClick:()=>k(!1),children:"Cancel"})]})]}),i.jsxs("p",{className:"small muted mt",children:[D==="register"?i.jsxs(i.Fragment,{children:["Already have an account?"," ",i.jsx("button",{className:"linkish",onClick:()=>{p("signin"),A("")},children:"Sign in"})]}):i.jsxs(i.Fragment,{children:["New here?"," ",i.jsx("button",{className:"linkish",onClick:()=>{p("register"),A("")},children:"Create a free account"})]}),h!=null&&h.google_available?" · Forgot your password? Contact the lab admin, or use Google.":" · Google sign-in arrives with lab accounts. Forgot your password? Contact the lab admin."]})]})}),Kn?i.jsx("main",{className:"main",style:{maxWidth:1100,margin:"0 auto",padding:"0 1rem"},children:i.jsx(hp,{auth:h})}):Y?i.jsx("main",{className:"main",style:{maxWidth:920,margin:"0 auto",padding:"0 1rem"},children:i.jsx(gp,{onEnter:y})}):i.jsxs("div",{className:"layout",children:[i.jsxs("aside",{className:"sidebar",children:[i.jsxs("h2",{children:["Projects",e.length>0&&i.jsx("span",{className:"count",children:e.length})]}),i.jsx("input",{type:"text",className:"sidebar-filter",placeholder:"Search projects...",value:u,onChange:z=>f(z.target.value)}),i.jsxs("div",{className:"project-list",children:[Ep(lt).map(([z,ke])=>i.jsxs("div",{children:[i.jsx("div",{className:"group-label",children:z}),ke.map(ce=>i.jsxs("button",{className:"project-item"+(ce.id===n?" active":""),onClick:()=>r(ce.id),title:ce.name,children:[i.jsx("span",{className:"project-name",children:ce.name}),i.jsxs("span",{className:"date",children:[ce.n_runs>0?`${ce.n_runs} run${ce.n_runs===1?"":"s"} · `:"",Cp(ce.last_activity_at||ce.created_at)]})]},ce.id))]},z)),u&<.length===0&&i.jsxs("p",{className:"small muted",children:['No projects match "',u,'".']})]}),i.jsx("div",{className:"project-create",children:l?i.jsxs("form",{onSubmit:K,children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:"Project name",value:o,onChange:z=>a(z.target.value)}),i.jsxs("div",{className:"row mt",children:[i.jsx("button",{className:"primary",type:"submit",children:"Create"}),i.jsx("button",{className:"ghost",type:"button",onClick:()=>s(!1),children:"Cancel"})]})]}):i.jsx("button",{className:"ghost",onClick:()=>s(!0),children:"+ New project"})})]}),i.jsxs("main",{className:"main",children:[m&&i.jsx("div",{className:"error-banner",onClick:()=>v(""),children:m}),Pe?i.jsx(kp,{project:Pe,auth:h,onAuthRefresh:M,onProjectChanged:w,onProjectDeleted:()=>{r(null),w()}},Pe.id):i.jsxs("div",{className:"card empty-state",children:[i.jsx("h3",{children:"Create your first project"}),i.jsx("p",{className:"hint",children:"A project holds your datasets and runs. Upload a corpus (CSV/XLSX), choose a validated construct, and run a CCR analysis - results include per-item loadings, score distributions, and a reproducibility record for every run."}),i.jsxs("div",{className:"empty-actions",children:[i.jsx("button",{className:"primary",onClick:()=>s(!0),children:"+ New project"}),i.jsx("a",{className:"ghost-link",href:"/guide",children:"Read the 5-minute guide"})]}),i.jsx("p",{className:"small muted",children:"Self-contained by design: embeddings run on this server itself - no third-party AI APIs. Please don't upload sensitive or identifiable data on this dev instance."})]})]})]}),i.jsxs("footer",{className:"site-footer",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"CCR Platform"})," - Contextualized Construct Representation analysis for psychology research, operated by the"," ",i.jsx("a",{href:"https://websites.umass.edu/matari/",target:"_blank",rel:"noopener noreferrer",children:"Culture and Morality Lab"})," ","at the University of Massachusetts Amherst. Principal investigator: Dr. Mohammad Atari."]}),i.jsxs("p",{children:["Contact ",i.jsx("a",{href:"mailto:devaanand@umass.edu",children:"devaanand@umass.edu"})," · ",i.jsx("a",{href:"https://github.com/Culture-and-Morality-Lab/ccr-platform",target:"_blank",rel:"noopener noreferrer",children:"Source code"})," · ",i.jsx("a",{href:"/guide",children:"How this tool works"})]})]})]})}Dc(document.getElementById("root")).render(i.jsx(nd.StrictMode,{children:i.jsx(Pp,{})}));